org.ofbiz.entity.util
Class EntityListIterator

java.lang.Object
  extended by org.ofbiz.entity.util.EntityListIterator
All Implemented Interfaces:
java.util.Iterator<GenericValue>, java.util.ListIterator<GenericValue>

public class EntityListIterator
extends java.lang.Object
implements java.util.ListIterator<GenericValue>

Generic Entity Cursor List Iterator for Handling Cursored DB Results


Field Summary
protected  boolean closed
           
protected  GenericDelegator delegator
           
protected  boolean haveMadeValue
           
protected  ModelEntity modelEntity
           
protected  ModelFieldTypeReader modelFieldTypeReader
           
static java.lang.String module
          Module Name Used for debugging
protected  java.sql.ResultSet resultSet
           
protected  java.util.List<ModelField> selectFields
           
protected  SQLProcessor sqlp
           
 
Constructor Summary
EntityListIterator(java.sql.ResultSet resultSet, ModelEntity modelEntity, java.util.List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader)
           
EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, java.util.List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader)
           
 
Method Summary
 boolean absolute(int rowNum)
          performs the same function as the ResultSet.absolute method; if rowNum is positive, goes to that position relative to the beginning of the list; if rowNum is negative, goes to that position relative to the end of the list; a rowNum of 1 is the same as first(); a rowNum of -1 is the same as last()
 void add(GenericValue obj)
           
 void afterLast()
          Sets the cursor position to just after the last result so that previous() will return the last result
 void beforeFirst()
          Sets the cursor position to just before the first result so that next() will return the first result
 void close()
           
 GenericValue currentGenericValue()
          NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice
 int currentIndex()
           
protected  void finalize()
           
 boolean first()
          Sets the cursor position to last result; if result set is empty returns false
 java.util.List<GenericValue> getCompleteList()
           
 java.util.List<GenericValue> getPartialList(int start, int number)
          Gets a partial list of results starting at start and containing at most number elements.
 int getResultsSizeAfterPartialList()
           
 boolean hasNext()
          PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use next() until it returns null For example, you could use the following to iterate through the results in an EntityListIterator: GenericValue nextValue = null; while ((nextValue = (GenericValue) this.next()) != null) { ...
 boolean hasPrevious()
          PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use previous() until it returns null
 boolean last()
          Sets the cursor position to last result; if result set is empty returns false
 GenericValue next()
          Moves the cursor to the next position and returns the GenericValue object for that position; if there is no next, returns null For example, you could use the following to iterate through the results in an EntityListIterator: GenericValue nextValue = null; while ((nextValue = (GenericValue) this.next()) != null) { ...
 int nextIndex()
          Returns the index of the next result, but does not guarantee that there will be a next result
 GenericValue previous()
          Moves the cursor to the previous position and returns the GenericValue object for that position; if there is no previous, returns null
 int previousIndex()
          Returns the index of the previous result, but does not guarantee that there will be a previous result
 boolean relative(int rows)
          performs the same function as the ResultSet.relative method; if rows is positive, goes forward relative to the current position; if rows is negative, goes backward relative to the current position;
 void remove()
           
 void set(GenericValue obj)
           
 void setDelegator(GenericDelegator delegator)
           
 void setFetchSize(int rows)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module
Module Name Used for debugging


sqlp

protected SQLProcessor sqlp

resultSet

protected java.sql.ResultSet resultSet

modelEntity

protected ModelEntity modelEntity

selectFields

protected java.util.List<ModelField> selectFields

modelFieldTypeReader

protected ModelFieldTypeReader modelFieldTypeReader

closed

protected boolean closed

haveMadeValue

protected boolean haveMadeValue

delegator

protected GenericDelegator delegator
Constructor Detail

EntityListIterator

public EntityListIterator(SQLProcessor sqlp,
                          ModelEntity modelEntity,
                          java.util.List<ModelField> selectFields,
                          ModelFieldTypeReader modelFieldTypeReader)

EntityListIterator

public EntityListIterator(java.sql.ResultSet resultSet,
                          ModelEntity modelEntity,
                          java.util.List<ModelField> selectFields,
                          ModelFieldTypeReader modelFieldTypeReader)
Method Detail

setDelegator

public void setDelegator(GenericDelegator delegator)

afterLast

public void afterLast()
               throws GenericEntityException
Sets the cursor position to just after the last result so that previous() will return the last result

Throws:
GenericEntityException

beforeFirst

public void beforeFirst()
                 throws GenericEntityException
Sets the cursor position to just before the first result so that next() will return the first result

Throws:
GenericEntityException

last

public boolean last()
             throws GenericEntityException
Sets the cursor position to last result; if result set is empty returns false

Throws:
GenericEntityException

first

public boolean first()
              throws GenericEntityException
Sets the cursor position to last result; if result set is empty returns false

Throws:
GenericEntityException

close

public void close()
           throws GenericEntityException
Throws:
GenericEntityException

currentGenericValue

public GenericValue currentGenericValue()
                                 throws GenericEntityException
NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice

Throws:
GenericEntityException

currentIndex

public int currentIndex()
                 throws GenericEntityException
Throws:
GenericEntityException

absolute

public boolean absolute(int rowNum)
                 throws GenericEntityException
performs the same function as the ResultSet.absolute method; if rowNum is positive, goes to that position relative to the beginning of the list; if rowNum is negative, goes to that position relative to the end of the list; a rowNum of 1 is the same as first(); a rowNum of -1 is the same as last()

Throws:
GenericEntityException

relative

public boolean relative(int rows)
                 throws GenericEntityException
performs the same function as the ResultSet.relative method; if rows is positive, goes forward relative to the current position; if rows is negative, goes backward relative to the current position;

Throws:
GenericEntityException

hasNext

public boolean hasNext()
PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use next() until it returns null For example, you could use the following to iterate through the results in an EntityListIterator: GenericValue nextValue = null; while ((nextValue = (GenericValue) this.next()) != null) { ... }

Specified by:
hasNext in interface java.util.Iterator<GenericValue>
Specified by:
hasNext in interface java.util.ListIterator<GenericValue>

hasPrevious

public boolean hasPrevious()
PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use previous() until it returns null

Specified by:
hasPrevious in interface java.util.ListIterator<GenericValue>

next

public GenericValue next()
Moves the cursor to the next position and returns the GenericValue object for that position; if there is no next, returns null For example, you could use the following to iterate through the results in an EntityListIterator: GenericValue nextValue = null; while ((nextValue = (GenericValue) this.next()) != null) { ... }

Specified by:
next in interface java.util.Iterator<GenericValue>
Specified by:
next in interface java.util.ListIterator<GenericValue>

nextIndex

public int nextIndex()
Returns the index of the next result, but does not guarantee that there will be a next result

Specified by:
nextIndex in interface java.util.ListIterator<GenericValue>

previous

public GenericValue previous()
Moves the cursor to the previous position and returns the GenericValue object for that position; if there is no previous, returns null

Specified by:
previous in interface java.util.ListIterator<GenericValue>

previousIndex

public int previousIndex()
Returns the index of the previous result, but does not guarantee that there will be a previous result

Specified by:
previousIndex in interface java.util.ListIterator<GenericValue>

setFetchSize

public void setFetchSize(int rows)
                  throws GenericEntityException
Throws:
GenericEntityException

getCompleteList

public java.util.List<GenericValue> getCompleteList()
                                             throws GenericEntityException
Throws:
GenericEntityException

getPartialList

public java.util.List<GenericValue> getPartialList(int start,
                                                   int number)
                                            throws GenericEntityException
Gets a partial list of results starting at start and containing at most number elements. Start is a one based value, ie 1 is the first element.

Throws:
GenericEntityException

getResultsSizeAfterPartialList

public int getResultsSizeAfterPartialList()
                                   throws GenericEntityException
Throws:
GenericEntityException

add

public void add(GenericValue obj)
Specified by:
add in interface java.util.ListIterator<GenericValue>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<GenericValue>
Specified by:
remove in interface java.util.ListIterator<GenericValue>

set

public void set(GenericValue obj)
Specified by:
set in interface java.util.ListIterator<GenericValue>

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable