UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.satin.watch
Interface Watchable

All Superinterfaces:
Cloneable, Serializable
All Known Subinterfaces:
GraphicalObject, GraphicalObjectGroup, Patch
All Known Implementing Classes:
GraphicalObjectGroupImpl, GraphicalObjectImpl, Sheet, WatchableImpl

public interface Watchable
extends Serializable, Cloneable

This interface is a replacement for Observable, because Observable is a class instead of an interface. A Watchable object is essentially a set with no duplicates.

 Revisions:  - SATIN-v1.0-1.0.0, Mar 08 1999, JH
               Created class
             - SATIN-v2.1-1.0.0, Aug 11 2000, JH
               Touched for SATIN release
 

Since:
JDK 1.2
Version:
SATIN-v2.1-1.0.0, Aug 11 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )

Method Summary
 Watcher addWatcher(Watcher w)
          Add a watcher to this object.
 void clearWatchers()
          Delete all watchers on this object.
 Object clone()
          Make a clone of this Watchable object.
 int countWatchers()
          Count the number of watchers watching this object.
 void disableNotify()
          Turn off ability to notify others.
 void enableNotify()
          Turn on ability to notify others.
 boolean hasNotifyEnabled()
          Check current ability to notify others.
 void notifyWatchers()
          Notify the watchers.
 void notifyWatchers(Object arg)
          Notify the watchers.
 void notifyWatchersDelete()
          Notify the watchers that this object has been deleted.
 void notifyWatchersUpdate(Object arg)
          Notify the watchers that the object has been changed and the change needs to be handled by the watchers.
 void notifyWatchersUpdate(String strProperty, Object oldVal, Object newVal)
          Notify the watchers that some value has been changed.
 Watcher removeWatcher(Watcher w)
          Delete a watcher on this object.
 

Method Detail

addWatcher

public Watcher addWatcher(Watcher w)
Add a watcher to this object.
Parameters:
w - is the Watcher to add.
Returns:
a reference to the added Watcher.

countWatchers

public int countWatchers()
Count the number of watchers watching this object.

removeWatcher

public Watcher removeWatcher(Watcher w)
Delete a watcher on this object.
Returns:
a reference to the removed Watcher.

clearWatchers

public void clearWatchers()
Delete all watchers on this object.

disableNotify

public void disableNotify()
Turn off ability to notify others. This works like a counting semaphore. Every time you call this method, the enabled value is incremented by 1. The watch is enabled if and only if the value is 0.

enableNotify

public void enableNotify()
Turn on ability to notify others.
See Also:
disableNotify()

hasNotifyEnabled

public boolean hasNotifyEnabled()
Check current ability to notify others.
See Also:
disableNotify(), enableNotify()

notifyWatchers

public void notifyWatchers()
Notify the watchers. This is just a generic method, should not be generally used.

notifyWatchers

public void notifyWatchers(Object arg)
Notify the watchers. This is just a generic method, should not be generally used.

notifyWatchersUpdate

public void notifyWatchersUpdate(Object arg)
Notify the watchers that the object has been changed and the change needs to be handled by the watchers.
Parameters:
arg - is the argument to send to all Watchers.

notifyWatchersUpdate

public void notifyWatchersUpdate(String strProperty,
                                 Object oldVal,
                                 Object newVal)
Notify the watchers that some value has been changed. Modifying the parameters should have no effect on this Watchable object. See SatinConstants for a list of predefined property names.
Parameters:
strProperty - is some agreed upon name for the property.
oldVal - is the old value.
newVal - is the new value. It should be a clone, not a reference to the actual value, unless it is prohibitively expensive to clone. Whether this is a copy or a reference should be defined in the SatinConstants file.
See Also:
SatinConstants

notifyWatchersDelete

public void notifyWatchersDelete()
Notify the watchers that this object has been deleted. Notifications are error-prone, as you may accidentally modify the iterator. Be sure to clone first.

clone

public Object clone()
Make a clone of this Watchable object.
Overrides:
clone in class Object

Copyright Information