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
Modifier and TypeFieldDescriptionprotected Collection
Collection of added items.protected Collection
Collection of changed items.protected Collection
Collection of removed items. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Mark the given value as added.protected void
Notify the tracker that the given object was added.protected abstract void
Mark the given value as changed.protected void
Notify the tracker that the given object was changed.getAdded()
Return the collection of values that need to be added to the managed container.boolean
Whether to automatically stop tracking when the number of changes exceeds the container size.Return the set of elements that have changed.int
The 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 int
Return the initial sequence value for this proxy.boolean
Return true if this tracker has an up-to-date view of all the changes to the container it is managing.protected Set
newSet()
Create a new set for storing adds/removes/changes.protected abstract void
Mark the given value as removed.protected void
Notify the tracker that the given object was removed.protected void
reset()
Reset the state of the tracker.void
setAutoOff
(boolean autoOff) Whether to automatically stop tracking when the number of changes exceeds the container size.void
setNextSequence
(int seq) The maximum element sequence value for this proxy at load time.void
Reset the state of the change tracker, and turn change tracking back on if it has been disabled.void
Tell 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:ChangeTracker
Return true if this tracker has an up-to-date view of all the changes to the container it is managing.- Specified by:
isTracking
in interfaceChangeTracker
-
startTracking
public void startTracking()Description copied from interface:ChangeTracker
Reset the state of the change tracker, and turn change tracking back on if it has been disabled.- Specified by:
startTracking
in 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:ChangeTracker
Tell the tracker to stop tracking changes for its container.- Specified by:
stopTracking
in interfaceChangeTracker
-
reset
protected void reset()Reset the state of the tracker. -
getAdded
Description copied from interface:ChangeTracker
Return the collection of values that need to be added to the managed container.- Specified by:
getAdded
in interfaceChangeTracker
-
getRemoved
Description copied from interface:ChangeTracker
Return the set of values that need to be removed from the managed container.- Specified by:
getRemoved
in interfaceChangeTracker
-
getChanged
Description copied from interface:ChangeTracker
Return 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:
getChanged
in 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:ChangeTracker
The 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:
getNextSequence
in interfaceChangeTracker
-
setNextSequence
public void setNextSequence(int seq) Description copied from interface:ChangeTracker
The 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:
setNextSequence
in 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.
-