Package org.apache.openjpa.util
Class AbstractChangeTracker
java.lang.Object
org.apache.openjpa.util.AbstractChangeTracker
- All Implemented Interfaces:
ChangeTracker
- Direct Known Subclasses:
CollectionChangeTrackerImpl,MapChangeTrackerImpl
Base class that provides utilities to change trackers.
- Author:
- Abe White
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CollectionCollection of added items.protected CollectionCollection of changed items.protected CollectionCollection of removed items. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidMark the given value as added.protected voidNotify the tracker that the given object was added.protected abstract voidMark the given value as changed.protected voidNotify the tracker that the given object was changed.getAdded()Return the collection of values that need to be added to the managed container.booleanWhether to automatically stop tracking when the number of changes exceeds the container size.Return the set of elements that have changed.intThe next element sequence value for this proxy at load time.Return the set of values that need to be removed from the managed container.protected intReturn the initial sequence value for this proxy.booleanReturn true if this tracker has an up-to-date view of all the changes to the container it is managing.protected SetnewSet()Create a new set for storing adds/removes/changes.protected abstract voidMark the given value as removed.protected voidNotify 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.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.
-
Field Details
-
add
Collection of added items. May be null. -
rem
Collection of removed items. May be null. -
change
Collection of changed items. May be null.
-
-
Constructor Details
-
AbstractChangeTracker
public AbstractChangeTracker()Constructor; supply configuration.
-
-
Method Details
-
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
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
Notify the tracker that the given object was added. -
add
Mark the given value as added. -
removed
Notify the tracker that the given object was removed. -
remove
Mark the given value as removed. -
changed
Notify the tracker that the given object was changed. -
change
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
Create a new set for storing adds/removes/changes. Takes into account whether we need to use an identity set or standard set.
-