sun.java2d.StateTracker |
![]() |
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.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ALWAYS_CURRENT | An implementation of the StateTracker interface which always returns true. | ||||||||||
NEVER_CURRENT | An implementation of the StateTracker interface which always returns false. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
|
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
.
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.