0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d;
0N/A
0N/A/**
0N/A * This interface is used to track changes to the complex data of an
0N/A * object that implements the StateTrackable interface.
0N/A * <p>
0N/A * The usage pattern for code accessing the trackable data is as follows:
0N/A * <pre>
0N/A * StateTrackable trackedobject;
0N/A * MyInfo cacheddata;
0N/A * StateTracker cachetracker;
0N/A * public synchronized MyInfo getInfoAbout(StateTrackable obj) {
0N/A * if (trackedobject != obj || !cachetracker.isCurrent()) {
0N/A * // Note: Always call getStateTracker() before
0N/A * // caching any data about the objct...
0N/A * cachetracker = obj.getStateTracker();
0N/A * cacheddata = calculateInfoFrom(obj);
0N/A * trackedobject = obj;
0N/A * }
0N/A * return cacheddata;
0N/A * }
0N/A * </pre>
0N/A * Note that the sample code above works correctly regardless of the
0N/A * {@link StateTrackable.State State} of the complex data of the object,
0N/A * but it may be inefficient to store precalculated information about
0N/A * an object whose current {@link StateTrackable.State State} is
0N/A * {@link StateTrackable.State#UNTRACKABLE UNTRACKABLE}
0N/A * and it is unnecessary to perform the {@link #isCurrent} test for
0N/A * data whose current {@link StateTrackable.State State} is
0N/A * {@link StateTrackable.State#IMMUTABLE IMMUTABLE}.
0N/A * Optimizations to the sample code for either or both of those terminal
0N/A * States may be of benefit for some use cases, but is left out of the
0N/A * example to reduce its complexity.
0N/A *
0N/A * @see StateTrackable.State
0N/A * @since 1.7
0N/A */
0N/Apublic interface StateTracker {
0N/A /**
0N/A * An implementation of the StateTracker interface which
0N/A * always returns true.
0N/A * This implementation is useful for objects whose current
0N/A * {@link StateTrackable.State State} is
0N/A * {@link StateTrackable.State#IMMUTABLE IMMUTABLE}.
0N/A * @since 1.7
0N/A */
0N/A public StateTracker ALWAYS_CURRENT = new StateTracker() {
0N/A public boolean isCurrent() {
0N/A return true;
0N/A }
0N/A };
0N/A
0N/A /**
0N/A * An implementation of the StateTracker interface which
0N/A * always returns false.
0N/A * This implementation is useful for objects whose current
0N/A * {@link StateTrackable.State State} is
0N/A * {@link StateTrackable.State#UNTRACKABLE UNTRACKABLE}.
0N/A * This implementation may also be useful for some objects
0N/A * whose current {@link StateTrackable.State State} is
0N/A * {@link StateTrackable.State#DYNAMIC DYNAMIC}.
0N/A * @since 1.7
0N/A */
0N/A public StateTracker NEVER_CURRENT = new StateTracker() {
0N/A public boolean isCurrent() {
0N/A return false;
0N/A }
0N/A };
0N/A
0N/A /**
0N/A * Returns true iff the contents of the complex data of the
0N/A * associated StateTrackable object have not changed since
0N/A * the time that this StateTracker was returned from its
0N/A * getStateTracker() method.
0N/A * @see StateTrackable
0N/A * @since 1.7
0N/A */
0N/A public boolean isCurrent();
0N/A}