Package org.apache.openjpa.util
Class AbstractLRSProxyCollection
- java.lang.Object
-
- org.apache.openjpa.util.AbstractLRSProxyCollection
-
- All Implemented Interfaces:
java.lang.Iterable,java.util.Collection,java.util.function.Predicate,java.util.Set,ChangeTracker,CollectionChangeTracker,LRSProxy,Proxy
- Direct Known Subclasses:
LRSProxyCollection
public abstract class AbstractLRSProxyCollection extends java.lang.Object implements java.util.Set, LRSProxy, java.util.function.Predicate, CollectionChangeTracker
A collection proxy designed for collections backed by extremely large result sets in which each call toiterator()may perform a database query. Changes to the collection are tracked through aChangeTracker. This collection has the following limitations:- The
sizemethod may returnInteger.MAX_VALUE. - The collection cannot contain duplicate elements.
- Author:
- Abe White
-
-
Constructor Summary
Constructors Constructor Description AbstractLRSProxyCollection(java.lang.Class elementType, boolean ordered)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object o)booleanaddAll(java.util.Collection all)voidadded(java.lang.Object val)Record that the given element was added.voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection all)java.lang.Objectcopy(java.lang.Object orig)Return an unproxied copy of the given instance.protected abstract intcount()Return the number of elements in the collection, orInteger.MAX_VALUE.java.util.CollectiongetAdded()Return the collection of values that need to be added to the managed container.java.util.CollectiongetChanged()Return the set of elements that have changed.ChangeTrackergetChangeTracker()Return the change tracker for this proxy, or null if none.intgetNextSequence()The next element sequence value for this proxy at load time.OpenJPAStateManagergetOwner()Return the owning object.intgetOwnerField()Return the owning field index.java.util.CollectiongetRemoved()Return the set of values that need to be removed from the managed container.protected abstract booleanhas(java.lang.Object o)Return whether the collection contains the given element.booleanisEmpty()booleanisTracking()Return true if this tracker has an up-to-date view of all the changes to the container it is managing.java.util.Iteratoriterator()protected abstract java.util.Iteratoritr()Implement this method to return an iterator over the contents of the collection.booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection all)voidremoved(java.lang.Object val)Record that the given element was removed.booleanretainAll(java.util.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()voidstartTracking()Reset the state of the change tracker, and turn change tracking back on if it has been disabled.voidstopTracking()Tell the tracker to stop tracking changes for its container.booleantest(java.lang.Object o)java.lang.Object[]toArray()java.lang.Object[]toArray(java.lang.Object[] a)protected java.lang.ObjectwriteReplace()
-
-
-
Method Detail
-
setOwner
public void setOwner(OpenJPAStateManager sm, int field)
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
public OpenJPAStateManager 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
public ChangeTracker getChangeTracker()
Description copied from interface:ProxyReturn the change tracker for this proxy, or null if none.- Specified by:
getChangeTrackerin interfaceProxy
-
copy
public java.lang.Object copy(java.lang.Object orig)
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
public boolean add(java.lang.Object o)
- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.Set
-
addAll
public boolean addAll(java.util.Collection all)
- Specified by:
addAllin interfacejava.util.Collection- Specified by:
addAllin interfacejava.util.Set
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.Set
-
removeAll
public boolean removeAll(java.util.Collection all)
- Specified by:
removeAllin interfacejava.util.Collection- Specified by:
removeAllin interfacejava.util.Set
-
retainAll
public boolean retainAll(java.util.Collection all)
- Specified by:
retainAllin interfacejava.util.Collection- Specified by:
retainAllin interfacejava.util.Set
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection- Specified by:
clearin interfacejava.util.Set
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection- Specified by:
containsin interfacejava.util.Set
-
containsAll
public boolean containsAll(java.util.Collection all)
- Specified by:
containsAllin interfacejava.util.Collection- Specified by:
containsAllin interfacejava.util.Set
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.Set
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.Set
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection- Specified by:
sizein interfacejava.util.Set
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection- Specified by:
isEmptyin interfacejava.util.Set
-
iterator
public java.util.Iterator iterator()
- Specified by:
iteratorin interfacejava.util.Collection- Specified by:
iteratorin interfacejava.lang.Iterable- Specified by:
iteratorin interfacejava.util.Set
-
writeReplace
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException- Throws:
java.io.ObjectStreamException
-
itr
protected abstract java.util.Iterator 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
protected abstract boolean has(java.lang.Object o)
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
public boolean test(java.lang.Object o)
- Specified by:
testin interfacejava.util.function.Predicate
-
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
public java.util.Collection getAdded()
Description copied from interface:ChangeTrackerReturn the collection of values that need to be added to the managed container.- Specified by:
getAddedin interfaceChangeTracker
-
getRemoved
public java.util.Collection getRemoved()
Description copied from interface:ChangeTrackerReturn the set of values that need to be removed from the managed container.- Specified by:
getRemovedin interfaceChangeTracker
-
getChanged
public java.util.Collection 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
public void added(java.lang.Object val)
Description copied from interface:CollectionChangeTrackerRecord that the given element was added.- Specified by:
addedin interfaceCollectionChangeTracker
-
removed
public void removed(java.lang.Object val)
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
-
-