Package org.ofbiz.core.entity
Class EntityListIterator
java.lang.Object
org.ofbiz.core.entity.EntityListIterator
- All Implemented Interfaces:
Iterator<GenericValue>,ListIterator<GenericValue>
Generic Entity Cursor List Iterator for Handling Cursored DB Results
Note that you should *not* rely on this for streaming large datasets, as the backing ResultSet will pull the entire dataset into memory anyway. For more information, see PSA: OfBizListIterator is not good enough Created July 12, 2002
- Author:
- David E. Jones
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected GenericDelegatorprotected booleanprotected ModelEntityprotected ModelFieldTypeReaderprotected ResultSetprotected List<ModelField>protected SQLProcessor -
Constructor Summary
ConstructorsConstructorDescriptionEntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader) -
Method Summary
Modifier and TypeMethodDescriptionbooleanabsolute(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()voidadd(GenericValue obj) voidSets the cursor position to just after the last result so that previous() will return the last resultvoidSets the cursor position to just before the first result so that next() will return the first resultvoidclose()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 twiceintbooleanfirst()Sets the cursor position to last result; if result set is empty returns falsegetPartialList(int start, int number) Gets a partial list of results starting at start and containing at most number elements.booleanhasNext()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 nullbooleanPLEASE 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 nullbooleanisCaseSensitive(String entityFieldName) Detect whether or not the column data is case sensitive.booleanlast()Sets the cursor position to last result; if result set is empty returns falsenext()Moves the cursor to the next position and returns the GenericValue object for that position; if there is no next, returns nullintReturns the index of the next result, but does not guarantee that there will be a next resultprevious()Moves the cursor to the previous position and returns the GenericValue object for that position; if there is no previous, returns nullintReturns the index of the previous result, but does not guarantee that there will be a previous resultvoidremove()voidset(GenericValue obj) voidsetDelegator(GenericDelegator delegator) voidsetFetchSize(int rows) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
sqlp
-
resultSet
-
modelEntity
-
selectFields
-
modelFieldTypeReader
-
closed
protected boolean closed -
haveMadeValue
protected boolean haveMadeValue -
delegator
-
-
Constructor Details
-
EntityListIterator
public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader)
-
-
Method Details
-
setDelegator
-
isCaseSensitive
Detect whether or not the column data is case sensitive.- Parameters:
entityFieldName- the field to check.- Returns:
- true if the field is case sensitive or false otherwise.
- Throws:
GenericEntityException- if the information could not be found.
-
afterLast
Sets the cursor position to just after the last result so that previous() will return the last result- Throws:
GenericEntityException
-
beforeFirst
Sets the cursor position to just before the first result so that next() will return the first result- Throws:
GenericEntityException
-
last
Sets the cursor position to last result; if result set is empty returns false- Throws:
GenericEntityException
-
first
Sets the cursor position to last result; if result set is empty returns false- Throws:
GenericEntityException
-
close
- Throws:
GenericEntityException
-
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- Throws:
GenericEntityException
-
currentIndex
- Throws:
GenericEntityException
-
absolute
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
-
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- Specified by:
hasNextin interfaceIterator<GenericValue>- Specified by:
hasNextin interfaceListIterator<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:
hasPreviousin interfaceListIterator<GenericValue>
-
next
Moves the cursor to the next position and returns the GenericValue object for that position; if there is no next, returns null- Specified by:
nextin interfaceIterator<GenericValue>- Specified by:
nextin interfaceListIterator<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:
nextIndexin interfaceListIterator<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:
previousin interfaceListIterator<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:
previousIndexin interfaceListIterator<GenericValue>
-
setFetchSize
- Throws:
GenericEntityException
-
getCompleteList
- Throws:
GenericEntityException
-
getPartialList
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
-
add
- Specified by:
addin interfaceListIterator<GenericValue>
-
remove
public void remove()- Specified by:
removein interfaceIterator<GenericValue>- Specified by:
removein interfaceListIterator<GenericValue>
-
set
- Specified by:
setin interfaceListIterator<GenericValue>
-