APIdia Launch Partner
Top Description Fields Methods
sun.java2d

public Interface StateTracker

Known Direct Implementers
sun.java2d.SurfaceDataProxy.CountdownTracker

This interface is used to track changes to the complex data of an object that implements the StateTrackable interface.

The usage pattern for code accessing the trackable data is as follows:

    StateTrackable trackedobject;
    MyInfo cacheddata;
    StateTracker cachetracker;
    public synchronized MyInfo getInfoAbout(StateTrackable obj) {
        if (trackedobject != obj || !cachetracker.isCurrent()) {
            // Note: Always call getStateTracker() before
            // caching any data about the objct...
            cachetracker = obj.getStateTracker();
            cacheddata = calculateInfoFrom(obj);
            trackedobject = obj;
        }
        return cacheddata;
    }
Note that the sample code above works correctly regardless of the State of the complex data of the object, but it may be inefficient to store precalculated information about an object whose current State is UNTRACKABLE and it is unnecessary to perform the isCurrent test for data whose current State is IMMUTABLE. Optimizations to the sample code for either or both of those terminal States may be of benefit for some use cases, but is left out of the example to reduce its complexity.
Since
1.7
See Also
StateTrackable.State

Field Summary

Modifier and TypeField and Description
public static final StateTracker
ALWAYS_CURRENT

An implementation of the StateTracker interface which always returns true.

public static final StateTracker
NEVER_CURRENT

An implementation of the StateTracker interface which always returns false.

Method Summary

Modifier and TypeMethod and Description
public boolean
isCurrent()

Returns true iff the contents of the complex data of the associated StateTrackable object have not changed since the time that this StateTracker was returned from its getStateTracker() method.

Field Detail

ALWAYS_CURRENTback to summary
public static final StateTracker ALWAYS_CURRENT

An implementation of the StateTracker interface which always returns true. This implementation is useful for objects whose current State is IMMUTABLE.

Since
1.7
NEVER_CURRENTback to summary
public static final StateTracker NEVER_CURRENT

An implementation of the StateTracker interface which always returns false. This implementation is useful for objects whose current State is UNTRACKABLE. This implementation may also be useful for some objects whose current State is DYNAMIC.

Since
1.7

Method Detail

isCurrentback to summary
public boolean isCurrent()

Returns true iff the contents of the complex data of the associated StateTrackable object have not changed since the time that this StateTracker was returned from its getStateTracker() method.

Since
1.7
See Also
StateTrackable