Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 Object
implements ChangeTracker

Base class that provides utilities to change trackers.

Author:
  Abe White

Field Summary
`protected Collection` | `add` Collection of added items.
`protected Collection` | `change` Collection of changed items.
`protected Collection` | `rem` Collection of removed items.

Constructor Summary
`AbstractChangeTracker()` Constructor; supply configuration.

Method Summary
`protected abstract void` | `add(Object val)` Mark the given value as added.
`protected void` | `added(Object val)` Notify the tracker that the given object was added.
`protected abstract void` | `change(Object val)` Mark the given value as changed.
`protected void` | `changed(Object val)` Notify the tracker that the given object was changed.
`Collection` | `getAdded()` Return the collection of values that need to be added to the managed container.
`boolean` | `getAutoOff()` Whether to automatically stop tracking when the number of changes exceeds the container size.
`Collection` | `getChanged()` Return the set of elements that have changed.
`int` | `getNextSequence()` The next element sequence value for this proxy at load time.
`Collection` | `getRemoved()` Return the set of values that need to be removed from the managed container.
`protected int` | `initialSequence()` Return the initial sequence value for this proxy.
`boolean` | `isTracking()` 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` | `remove(Object val)` Mark the given value as removed.
`protected void` | `removed(Object val)` 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` | `startTracking()` Reset the state of the change tracker, and turn change tracking back on if it has been disabled.
`void` | `stopTracking()` Tell the tracker to stop tracking changes for its container.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### add

    protected Collection add

  Collection of added items. May be null.

### rem

    protected Collection rem

  Collection of removed items. May be null.

### change

    protected Collection change

  Collection of changed items. May be null.

Constructor Detail

### AbstractChangeTracker

    public AbstractChangeTracker()

  Constructor; supply configuration.

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: `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 interface `ChangeTracker`

### 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 interface `ChangeTracker`

### 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 interface `ChangeTracker`

### reset

    protected void reset()

  Reset the state of the tracker.

### getAdded

    public Collection getAdded()

  Description copied from interface: `ChangeTracker`
  Return the collection of values that need to be added to the managed container.

  Specified by:
    `getAdded` in interface `ChangeTracker`

### getRemoved

    public Collection getRemoved()

  Description copied from interface: `ChangeTracker`
  Return the set of values that need to be removed from the managed container.

  Specified by:
    `getRemoved` in interface `ChangeTracker`

### getChanged

    public Collection 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 interface `ChangeTracker`

### added

    protected void added(Object val)

  Notify the tracker that the given object was added.

### add

    protected abstract void add(Object val)

  Mark the given value as added.

### removed

    protected void removed(Object val)

  Notify the tracker that the given object was removed.

### remove

    protected abstract void remove(Object val)

  Mark the given value as removed.

### changed

    protected void changed(Object val)

  Notify the tracker that the given object was changed.

### change

    protected abstract void change(Object val)

  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 interface `ChangeTracker`

### 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 interface `ChangeTracker`

### newSet

    protected 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 Apache Software Foundation. All Rights Reserved.