Package org.apache.openjpa.util
Class AbstractLRSProxyCollection
java.lang.Object
org.apache.openjpa.util.AbstractLRSProxyCollection
- All Implemented Interfaces:
Iterable,Collection,Predicate,Set,ChangeTracker,CollectionChangeTracker,LRSProxy,Proxy
- Direct Known Subclasses:
LRSProxyCollection
public abstract class AbstractLRSProxyCollection
extends Object
implements Set, LRSProxy, Predicate, CollectionChangeTracker
A collection proxy designed for collections backed by extremely large
result sets in which each call to
iterator() may perform a database
query. Changes to the collection are tracked through a
ChangeTracker. This collection has the following limitations:
- The
sizemethod may returnInteger.MAX_VALUE. - The collection cannot contain duplicate elements.
- Author:
- Abe White
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection all) voidRecord that the given element was added.voidclear()booleanbooleancontainsAll(Collection all) Return an unproxied copy of the given instance.protected abstract intcount()Return the number of elements in the collection, orInteger.MAX_VALUE.getAdded()Return the collection of values that need to be added to the managed container.Return the set of elements that have changed.Return the change tracker for this proxy, or null if none.intThe next element sequence value for this proxy at load time.getOwner()Return the owning object.intReturn the owning field index.Return the set of values that need to be removed from the managed container.protected abstract booleanReturn whether the collection contains the given element.booleanisEmpty()booleanReturn true if this tracker has an up-to-date view of all the changes to the container it is managing.iterator()protected abstract Iteratoritr()Implement this method to return an iterator over the contents of the collection.booleanbooleanremoveAll(Collection all) voidRecord that the given element was removed.booleanretainAll(Collection all) voidsetNextSequence(int seq) The maximum element sequence value for this proxy at load time.voidsetOwner(OpenJPAStateManager sm, int field) Reset the state of the proxy, and set the owning instance of the proxy and the name of the field it is assigned to.intsize()voidReset the state of the change tracker, and turn change tracking back on if it has been disabled.voidTell the tracker to stop tracking changes for its container.booleanObject[]toArray()Object[]protected ObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
AbstractLRSProxyCollection
Constructor.- Parameters:
elementType- the allowed type of elements, or null for no restrictionsordered- true if this collection is ordered
-
-
Method Details
-
setOwner
Description copied from interface:ProxyReset the state of the proxy, and set the owning instance of the proxy and the name of the field it is assigned to. Set to null to indicate that the proxy is no longer managed. -
getOwner
Description copied from interface:ProxyReturn the owning object. -
getOwnerField
public int getOwnerField()Description copied from interface:ProxyReturn the owning field index.- Specified by:
getOwnerFieldin interfaceProxy
-
getChangeTracker
Description copied from interface:ProxyReturn the change tracker for this proxy, or null if none.- Specified by:
getChangeTrackerin interfaceProxy
-
copy
Description copied from interface:ProxyReturn an unproxied copy of the given instance. This method is used by proxy managers to create backup values for use in rollback. -
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceSet
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceSet
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceSet
-
iterator
-
writeReplace
- Throws:
ObjectStreamException
-
itr
Implement this method to return an iterator over the contents of the collection. This method may be invoked multiple times. The returned iterator does not have to support theIterator.remove()method, and may implementCloseable. -
has
Return whether the collection contains the given element. -
count
protected abstract int count()Return the number of elements in the collection, orInteger.MAX_VALUE. -
test
-
isTracking
public boolean isTracking()Description copied from interface:ChangeTrackerReturn true if this tracker has an up-to-date view of all the changes to the container it is managing.- Specified by:
isTrackingin interfaceChangeTracker
-
startTracking
public void startTracking()Description copied from interface:ChangeTrackerReset the state of the change tracker, and turn change tracking back on if it has been disabled.- Specified by:
startTrackingin interfaceChangeTracker
-
stopTracking
public void stopTracking()Description copied from interface:ChangeTrackerTell the tracker to stop tracking changes for its container.- Specified by:
stopTrackingin interfaceChangeTracker
-
getAdded
Description copied from interface:ChangeTrackerReturn the collection of values that need to be added to the managed container.- Specified by:
getAddedin interfaceChangeTracker
-
getRemoved
Description copied from interface:ChangeTrackerReturn the set of values that need to be removed from the managed container.- Specified by:
getRemovedin interfaceChangeTracker
-
getChanged
Description copied from interface:ChangeTrackerReturn the set of elements that have changed. In maps, this marks a possible change in value for a key. In collections, this marks an element that has been removed and re-added.- Specified by:
getChangedin interfaceChangeTracker
-
added
Description copied from interface:CollectionChangeTrackerRecord that the given element was added.- Specified by:
addedin interfaceCollectionChangeTracker
-
removed
Description copied from interface:CollectionChangeTrackerRecord that the given element was removed.- Specified by:
removedin interfaceCollectionChangeTracker
-
getNextSequence
public int getNextSequence()Description copied from interface:ChangeTrackerThe next element sequence value for this proxy at load time. If the data store keeps this proxy's data in sequence order but allows holes for removed objects, the implementation can set the next sequence at load time, then retrieve it and start from there for added objects at flush time. This value is set back to 0 if the proxy stops tracking changes. For ordered proxies, it is set to the proxy's size when the proxy starts tracking changes again.- Specified by:
getNextSequencein interfaceChangeTracker
-
setNextSequence
public void setNextSequence(int seq) Description copied from interface:ChangeTrackerThe maximum element sequence value for this proxy at load time. If the data store keeps this proxy's data in sequence order but allows holes for removed objects, the implementation can set the next sequence at load time, then retrieve it and start from there for added objects at flush time. This value is set back to 0 if the proxy stops tracking changes. For ordered proxies, it is set to the proxy's size when the proxy starts tracking changes again.- Specified by:
setNextSequencein interfaceChangeTracker
-