public interface

StateTracker

sun.java2d.StateTracker
Known Indirect Subclasses

Class Overview

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.

Summary

Fields
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.
Public Methods
abstract 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.

Fields

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.

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.

Public Methods

public abstract 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.

See Also