Package org.apache.cayenne.access
Class IncrementalFaultList<E>
java.lang.Object
org.apache.cayenne.access.IncrementalFaultList<E>
- All Implemented Interfaces:
- Serializable,- Iterable<E>,- Collection<E>,- List<E>
public class IncrementalFaultList<E> extends Object implements List<E>, Serializable
A synchronized list that serves as a container of DataObjects. It is returned
 when a paged query is performed by DataContext. On creation, only the first
 "page" is fully resolved, for the rest of the objects only their ObjectIds
 are read. Pages following the first page are resolved on demand only. On
 access to an element, the list would ensure that this element as well as all
 its siblings on the same page are fully resolved.
 
The list can hold DataRows or DataObjects. Attempts to add any other object types will result in an exception.
 Performance note: certain operations like toArray would trigger
 full list fetch.
 
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected DataContextdataContextprotected Listelementsprotected intidWidthStores a hint allowing to distinguish data rows from unfetched ids when the query fetches data rows.protected SelectQuery<?>internalQueryprotected intmaxFetchSizeDefines the upper limit on the size of fetches.protected intpageSizeprotected ObjEntityrootEntityprotected intunfetchedObjects
- 
Constructor SummaryConstructors Constructor Description IncrementalFaultList(DataContext dataContext, Query query, int maxFetchSize)Creates a new IncrementalFaultList using a given DataContext and query.
- 
Method SummaryModifier and Type Method Description voidadd(int index, Object element)booleanadd(Object o)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)protected voidfillIn(Query query, List<Object> elementsList)Performs initialization of the list of objects.Eget(int index)DataContextgetDataContext()Returns the dataContext.intgetMaxFetchSize()Get the upper bound on the number of records to resolve in one round trip to the database.intgetPageSize()Returns the pageSize.intgetUnfetchedObjects()Returns a total number of objects that are not resolved yet.intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()Return an iterator for this list.intlastIndexOf(Object o)ListIterator<E>listIterator()Returns a list iterator for this list.ListIterator<E>listIterator(int index)Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.intpageIndex(int elementIndex)Returns zero-based index of the virtual "page" for a given array element index.Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)voidresolveAll()Will resolve all unread objects.protected voidresolveInterval(int fromIndex, int toIndex)Resolves a sublist of objects starting atfromIndexup to but not includingtoIndex.booleanretainAll(Collection<?> c)Eset(int index, Object element)voidsetMaxFetchSize(int fetchSize)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Listequals, hashCode, replaceAll, sort, spliterator
- 
Field Details- 
pageSizeprotected int pageSize
- 
elements
- 
dataContext
- 
rootEntity
- 
internalQuery
- 
unfetchedObjectsprotected int unfetchedObjects
- 
idWidthprotected int idWidthStores a hint allowing to distinguish data rows from unfetched ids when the query fetches data rows.
- 
maxFetchSizeprotected int maxFetchSizeDefines the upper limit on the size of fetches. This is needed to avoid where clause size limitations.
 
- 
- 
Constructor Details- 
IncrementalFaultListCreates a new IncrementalFaultList using a given DataContext and query.- Parameters:
- dataContext- DataContext used by IncrementalFaultList to fill itself with objects.
- query- Main query used to retrieve data. Must have "pageSize" property set to a value greater than zero.
- maxFetchSize- maximum number of fetches in one query
 
 
- 
- 
Method Details- 
fillInPerforms initialization of the list of objects. Only the first page is fully resolved. For the rest of the list, only ObjectIds are read.- Since:
- 3.0
 
- 
resolveAllpublic void resolveAll()Will resolve all unread objects.
- 
resolveIntervalprotected void resolveInterval(int fromIndex, int toIndex)Resolves a sublist of objects starting atfromIndexup to but not includingtoIndex. Internally performs bound checking and trims indexes accordingly.
- 
pageIndexpublic int pageIndex(int elementIndex)Returns zero-based index of the virtual "page" for a given array element index.
- 
getMaxFetchSizepublic int getMaxFetchSize()Get the upper bound on the number of records to resolve in one round trip to the database. This setting governs the size/complexity of the where clause generated to retrieve the next page of records. If the fetch size is less than the page size, then multiple fetches will be made to resolve a page.
- 
setMaxFetchSizepublic void setMaxFetchSize(int fetchSize)
- 
getDataContextReturns the dataContext.- Returns:
- DataContext
 
- 
getPageSizepublic int getPageSize()Returns the pageSize.- Returns:
- int
 
- 
listIteratorReturns a list iterator for this list. DataObjects are resolved a page (according to getPageSize()) at a time as necessary - when retrieved with next() or previous().- Specified by:
- listIteratorin interface- List<E>
 
- 
listIteratorReturns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one. DataObjects are resolved a page at a time (according to getPageSize()) as necessary - when retrieved with next() or previous().- Specified by:
- listIteratorin interface- List<E>
 
- 
iteratorReturn an iterator for this list. DataObjects are resolved a page (according to getPageSize()) at a time as necessary - when retrieved with next().
- 
add- Specified by:
- addin interface- List<E>
- See Also:
- List.add(int, Object)
 
- 
add- Specified by:
- addin interface- Collection<E>
- Specified by:
- addin interface- List<E>
- See Also:
- Collection.add(Object)
 
- 
addAll- Specified by:
- addAllin interface- Collection<E>
- Specified by:
- addAllin interface- List<E>
- See Also:
- Collection.addAll(Collection)
 
- 
addAll- Specified by:
- addAllin interface- List<E>
- See Also:
- List.addAll(int, Collection)
 
- 
clearpublic void clear()- Specified by:
- clearin interface- Collection<E>
- Specified by:
- clearin interface- List<E>
- See Also:
- Collection.clear()
 
- 
contains- Specified by:
- containsin interface- Collection<E>
- Specified by:
- containsin interface- List<E>
- See Also:
- Collection.contains(Object)
 
- 
containsAll- Specified by:
- containsAllin interface- Collection<E>
- Specified by:
- containsAllin interface- List<E>
- See Also:
- Collection.containsAll(Collection)
 
- 
get
- 
indexOf- Specified by:
- indexOfin interface- List<E>
- See Also:
- List.indexOf(Object)
 
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Collection<E>
- Specified by:
- isEmptyin interface- List<E>
- See Also:
- Collection.isEmpty()
 
- 
lastIndexOf- Specified by:
- lastIndexOfin interface- List<E>
 
- 
remove
- 
remove
- 
removeAll
- 
retainAll
- 
set- Specified by:
- setin interface- List<E>
- See Also:
- List.set(int, Object)
 
- 
sizepublic int size()- Specified by:
- sizein interface- Collection<E>
- Specified by:
- sizein interface- List<E>
- See Also:
- Collection.size()
 
- 
subList
- 
toArray
- 
toArraypublic <T> T[] toArray(T[] a)
- 
getUnfetchedObjectspublic int getUnfetchedObjects()Returns a total number of objects that are not resolved yet.
 
-