Package org.apache.openjpa.util
Class AbstractChangeTracker
- java.lang.Object
-
- org.apache.openjpa.util.AbstractChangeTracker
-
- All Implemented Interfaces:
ChangeTracker
- Direct Known Subclasses:
CollectionChangeTrackerImpl,MapChangeTrackerImpl
public abstract class AbstractChangeTracker extends java.lang.Object implements ChangeTracker
Base class that provides utilities to change trackers.- Author:
- Abe White
-
-
Constructor Summary
Constructors Constructor Description AbstractChangeTracker()Constructor; supply configuration.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidadd(java.lang.Object val)Mark the given value as added.protected voidadded(java.lang.Object val)Notify the tracker that the given object was added.protected abstract voidchange(java.lang.Object val)Mark the given value as changed.protected voidchanged(java.lang.Object val)Notify the tracker that the given object was changed.java.util.CollectiongetAdded()Return the collection of values that need to be added to the managed container.booleangetAutoOff()Whether to automatically stop tracking when the number of changes exceeds the container size.java.util.CollectiongetChanged()Return the set of elements that have changed.intgetNextSequence()The next element sequence value for this proxy at load time.java.util.CollectiongetRemoved()Return the set of values that need to be removed from the managed container.protected intinitialSequence()Return the initial sequence value for this proxy.booleanisTracking()Return true if this tracker has an up-to-date view of all the changes to the container it is managing.protected java.util.SetnewSet()Create a new set for storing adds/removes/changes.protected abstract voidremove(java.lang.Object val)Mark the given value as removed.protected voidremoved(java.lang.Object val)Notify the tracker that the given object was removed.protected voidreset()Reset the state of the tracker.voidsetAutoOff(boolean autoOff)Whether to automatically stop tracking when the number of changes exceeds the container size.voidsetNextSequence(int seq)The maximum element sequence value for this proxy at load time.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.
-
-
-
Method Detail
-
getAutoOff
public boolean getAutoOff()
Whether to automatically stop tracking when the number of changes exceeds the container size. Defaults to true.
-
setAutoOff
public void setAutoOff(boolean autoOff)
Whether to automatically stop tracking when the number of changes exceeds the container size. Defaults to true.
-
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
-
initialSequence
protected int initialSequence()
Return the initial sequence value for this proxy. Typically this is the container size. Assumes an unordered collection by default, returning 0.
-
stopTracking
public void stopTracking()
Description copied from interface:ChangeTrackerTell the tracker to stop tracking changes for its container.- Specified by:
stopTrackingin interfaceChangeTracker
-
reset
protected void reset()
Reset the state of the tracker.
-
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
protected void added(java.lang.Object val)
Notify the tracker that the given object was added.
-
add
protected abstract void add(java.lang.Object val)
Mark the given value as added.
-
removed
protected void removed(java.lang.Object val)
Notify the tracker that the given object was removed.
-
remove
protected abstract void remove(java.lang.Object val)
Mark the given value as removed.
-
changed
protected void changed(java.lang.Object val)
Notify the tracker that the given object was changed.
-
change
protected abstract void change(java.lang.Object val)
Mark the given value as changed.
-
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
-
newSet
protected java.util.Set newSet()
Create a new set for storing adds/removes/changes. Takes into account whether we need to use an identity set or standard set.
-
-