E
- the type of elements returned by this iteratorpublic class ERXFetchSpecificationBatchIterator<E> extends Object implements Iterator<E>, Enumeration<E>
Modifier and Type | Field and Description |
---|---|
protected int |
batchSize
holds the selected batch size
|
protected NSMutableArray<E> |
cachedBatch
holds array of fetched but not-yet-returned objects; used by the Iterator and Enumeration interfaces
|
protected int |
currentObjectFetchCount
holds the number of objects fetched
|
static int |
DefaultBatchSize
holds the default batch size, any bigger than this an Oracle has a fit
|
protected com.webobjects.eocontrol.EOEditingContext |
editingContext
holds a reference to the selected editing context
|
protected com.webobjects.eocontrol.EOFetchSpecification |
fetchSpecification
holds a reference to the fetch spec to iterate over
|
protected String |
primaryKeyAttributeName
holds the name of the primary key attribute corresponding to the entity being iterated over
|
protected NSArray |
primaryKeys
holds an array of primary key values to iterate through
|
protected boolean |
shouldFilterBatches
determines whether we should re-apply the original qualifier to each batch of objects fetched
|
Constructor and Description |
---|
ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification)
Constructs a fetch specification iterator for a given fetch
specification with the default batch size.
|
ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification,
com.webobjects.eocontrol.EOEditingContext ec)
Constructs a fetch specification iterator for a given fetch
specification with the default batch size.
|
ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification,
com.webobjects.eocontrol.EOEditingContext ec,
int batchSize)
Constructs a fetch specification iterator for a given fetch
specification and a batch size.
|
ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification,
NSArray pkeys,
com.webobjects.eocontrol.EOEditingContext ec,
int batchSize)
Constructs a fetch specification iterator for a fetch specification,
an optional set of pre-fetched primary keys
and a batch size.
|
Modifier and Type | Method and Description |
---|---|
protected NSArray<E> |
_fetchNextBatch()
Fetches the next batch unconditionally.
|
protected boolean |
_hasMoreToFetch() |
int |
batchCount()
Gets the number of batches for a given iterator.
|
protected com.webobjects.eocontrol.EOFetchSpecification |
batchFetchSpecificationForQualifier(com.webobjects.eocontrol.EOQualifier qualifier) |
int |
batchSize()
Gets the batch size.
|
NSArray<E> |
batchWithIndex(int index)
Returns the batch corresponding to the given index, that is, the
batch beginning at
batchSize() * index. |
NSArray<E> |
batchWithRange(com.webobjects.foundation.NSRange requestedRange)
Returns the batch corresponding to the given range.
|
int |
count()
Gets the number of objects.
|
int |
currentBatchIndex()
Gets the current batch index.
|
int |
currentObjectFetchCount()
Gets the current number of objects
fetched thus far.
|
com.webobjects.eocontrol.EOEditingContext |
editingContext()
Gets the currently set editing context.
|
boolean |
filtersBatches()
If true, each batch will be filtered based on the original qualifier.
|
boolean |
hasMoreElements()
Implementation of the Enumeration interface
|
boolean |
hasNext()
Implementation of the Iterator interface
|
boolean |
hasNextBatch()
Determines if the iterator has another batch.
|
E |
next()
Implementation of the Iterator interface
|
NSArray<E> |
nextBatch()
Gets the next batch of enterprise objects for the
given fetch specification.
|
E |
nextElement()
Implementation of the Enumeration interface
|
protected NSArray |
primaryKeys()
Method used to fetch the primary keys of the objects
for the given fetch specification.
|
void |
remove()
Implementation of the Iterator interface
|
void |
reset()
Resets the batch iterator so it will refetch its primary keys again.
|
void |
setBatchSize(int batchSize)
Sets the batch size.
|
void |
setEditingContext(com.webobjects.eocontrol.EOEditingContext ec)
Sets the editing context used to fetch objects
against.
|
void |
setFiltersBatches(boolean newValue)
If set to true, each batch fetched will be filtered based on the qualifier attached
to the original fetch specification.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEachRemaining
public static final int DefaultBatchSize
protected int batchSize
protected com.webobjects.eocontrol.EOEditingContext editingContext
protected com.webobjects.eocontrol.EOFetchSpecification fetchSpecification
protected String primaryKeyAttributeName
protected NSArray primaryKeys
protected NSMutableArray<E> cachedBatch
protected int currentObjectFetchCount
protected boolean shouldFilterBatches
public ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification)
fetchSpecification
- to iterate throughpublic ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, com.webobjects.eocontrol.EOEditingContext ec)
fetchSpecification
- to iterate throughec
- editing context to fetch againstpublic ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, com.webobjects.eocontrol.EOEditingContext ec, int batchSize)
fetchSpecification
- to iterate throughec
- editing context to fetch againstbatchSize
- number of objects to fetch in a given batchpublic ERXFetchSpecificationBatchIterator(com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, NSArray pkeys, com.webobjects.eocontrol.EOEditingContext ec, int batchSize)
Note: if no ec is supplied a new one is initialized.
fetchSpecification
- to iterate throughpkeys
- primary keys to iterate throughec
- editing context to fetch againstbatchSize
- number of objects to fetch in a given batchpublic int batchSize()
public int currentBatchIndex()
public int batchCount()
public int count()
public int currentObjectFetchCount()
public void setBatchSize(int batchSize)
batchSize
- to be set.public boolean filtersBatches()
setFiltersBatches(boolean)
public void setFiltersBatches(boolean newValue)
nextBatch()
, and null may be returned
from next()
and nextElement()
.
Note that not all qualifiers can be applied in-memory, so this should not bet set
to true if such a qualifier is being used.
Defaults to false.newValue
- whether batches should be re-filteredpublic com.webobjects.eocontrol.EOEditingContext editingContext()
public void setEditingContext(com.webobjects.eocontrol.EOEditingContext ec)
ec
- editing context used to fetch againstpublic boolean hasNextBatch()
nextBatch()
protected boolean _hasMoreToFetch()
public NSArray<E> nextBatch()
next()
or nextElement()
,
this method may return a partial batch of already-cached
objects, in the editing context which was in place at the
time they were fetched.)protected NSArray<E> _fetchNextBatch()
nextBatch()
, to get
automatic support for the Iterator and Enumeration interfaces.public NSArray<E> batchWithIndex(int index)
batchSize()
* index.
Note that if the batch size has been changed after fetching, the
batches return by nextBatch()
may not line up with the
batches returned by this method.
Calling this method does not affect the position of the iterator.index
- index of batch to retrievepublic NSArray<E> batchWithRange(com.webobjects.foundation.NSRange requestedRange)
requestedRange
- range of batch to retrieveprotected com.webobjects.eocontrol.EOFetchSpecification batchFetchSpecificationForQualifier(com.webobjects.eocontrol.EOQualifier qualifier)
protected NSArray primaryKeys()
public void reset()
public boolean hasNext()
public E next()
public void remove()
public boolean hasMoreElements()
hasMoreElements
in interface Enumeration<E>
public E nextElement()
nextElement
in interface Enumeration<E>
Copyright © 2002 – 2020 Project Wonder.