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

edu.berkeley.guir.lib.satin.watch
Class WatchableImpl

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.watch.WatchableImpl
All Implemented Interfaces:
Cloneable, Serializable, Watchable
Direct Known Subclasses:
CommandSubsystem

public class WatchableImpl
extends Object
implements Watchable

This is a sample implementation of Watchable. It is designed to be used as a delegate class. That is, if you want to implement the Watchable interface but don't want to implement the methods, you can have a WatchableImpl object contained within and just delegate the Watchable methods to this object.

This class is intended to be a delegate, and is not really intended to be subclassed. Calling any of the normal notify methods causes RuntimeExceptions to be thrown, just to let you know you shouldn't be using this class this way.

 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 )
See Also:
Serialized Form

Constructor Summary
WatchableImpl()
           
 
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()
          Throws an exception.
 void notifyWatchers(Object arg)
          Throws an exception.
 void notifyWatchers(Watchable watchable)
           
 void notifyWatchers(Watchable watchable, Object arg)
          This is a convenience method if this class is used in a delegation fashion.
 void notifyWatchersDelete()
          Throws an exception.
 void notifyWatchersDelete(Watchable watchable)
          This is a convenience method if this class is used in a delegation fashion.
 void notifyWatchersUpdate(Object arg)
          Throws an exception.
 void notifyWatchersUpdate(String strProperty, Object oldVal, Object newVal)
          Throws an exception.
 void notifyWatchersUpdate(Watchable watchable)
          This is a convenience method if this class is used in a delegation fashion.
 void notifyWatchersUpdate(Watchable watchable, Object arg)
          This is a convenience method if this class is used in a delegation fashion.
 void notifyWatchersUpdate(Watchable watchable, String strProperty, Object oldVal, Object newVal)
          This is a convenience method if this class is used in a delegation fashion.
 Watcher removeWatcher(Watcher w)
          Delete a watcher on this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WatchableImpl

public WatchableImpl()
Method Detail

addWatcher

public Watcher addWatcher(Watcher w)
Description copied from interface: Watchable
Add a watcher to this object.
Specified by:
addWatcher in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
Parameters:
w - is the Watcher to add.
Returns:
a reference to the added Watcher.

countWatchers

public int countWatchers()
Description copied from interface: Watchable
Count the number of watchers watching this object.
Specified by:
countWatchers in interface Watchable

removeWatcher

public Watcher removeWatcher(Watcher w)
Description copied from interface: Watchable
Delete a watcher on this object.
Specified by:
removeWatcher in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
Returns:
a reference to the removed Watcher.

clearWatchers

public void clearWatchers()
Description copied from interface: Watchable
Delete all watchers on this object.
Specified by:
clearWatchers in interface Watchable

disableNotify

public void disableNotify()
Description copied from interface: Watchable
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.
Specified by:
disableNotify in interface Watchable

enableNotify

public void enableNotify()
Description copied from interface: Watchable
Turn on ability to notify others.
Specified by:
enableNotify in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
See Also:
Watchable.disableNotify()

hasNotifyEnabled

public boolean hasNotifyEnabled()
Description copied from interface: Watchable
Check current ability to notify others.
Specified by:
hasNotifyEnabled in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
See Also:
Watchable.disableNotify(), Watchable.enableNotify()

notifyWatchers

public void notifyWatchers()
Throws an exception. This method should not be called. Use one of the other notifyWatchers() methods, specifying the object using this implementation as the Watchable.
Specified by:
notifyWatchers in interface Watchable

notifyWatchers

public void notifyWatchers(Object arg)
Throws an exception. This method should not be called. Use one of the other notifyWatchers() methods, specifying the object using this implementation as the Watchable.
Specified by:
notifyWatchers in interface Watchable

notifyWatchers

public void notifyWatchers(Watchable watchable)

notifyWatchers

public void notifyWatchers(Watchable watchable,
                           Object arg)
This is a convenience method if this class is used in a delegation fashion. This lets you set who the Watchable object really is.
Parameters:
watchable - is the Watchable object that will be passed to the Watcher on the callback.
arg - is the generic argument.
See Also:
Watchable.notifyWatchers()

notifyWatchersUpdate

public void notifyWatchersUpdate(Object arg)
Throws an exception. This method should not be called. Use one of the other notifyWatchers() methods, specifying the object using this implementation as the Watchable.
Specified by:
notifyWatchersUpdate in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
Parameters:
arg - is the argument to send to all Watchers.

notifyWatchersUpdate

public void notifyWatchersUpdate(String strProperty,
                                 Object oldVal,
                                 Object newVal)
Throws an exception. This method should not be called. Use one of the other notifyWatchers() methods, specifying the object using this implementation as the Watchable.
Specified by:
notifyWatchersUpdate in interface Watchable
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watchable
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

notifyWatchersUpdate

public void notifyWatchersUpdate(Watchable watchable)
This is a convenience method if this class is used in a delegation fashion. This lets you set who the Watchable object really is. Sends a null argument.
Parameters:
watchable - is the Watchable object that will be passed to the Watcher on the callback.
See Also:
Watchable.notifyWatchersUpdate(Object)

notifyWatchersUpdate

public void notifyWatchersUpdate(Watchable watchable,
                                 Object arg)
This is a convenience method if this class is used in a delegation fashion. This lets you set who the Watchable object really is.
Parameters:
watchable - is the Watchable object that will be passed to the Watcher on the callback.
arg - is the argument to send.

notifyWatchersUpdate

public void notifyWatchersUpdate(Watchable watchable,
                                 String strProperty,
                                 Object oldVal,
                                 Object newVal)
This is a convenience method if this class is used in a delegation fashion. This lets you set who the Watchable object really is.
Parameters:
watchable - is the Watchable object that will be passed to the Watcher on the callback.
strProperty - is the agreed-upon name of the property.
oldVal - is the old value of the property.
newVal - is the new value of the property.
See Also:
Watchable.notifyWatchersUpdate(String, Object, Object)

notifyWatchersDelete

public void notifyWatchersDelete()
Throws an exception. This method should not be called. Use one of the other notifyWatchers() methods, specifying the object using this implementation as the Watchable.
Specified by:
notifyWatchersDelete in interface Watchable

notifyWatchersDelete

public void notifyWatchersDelete(Watchable watchable)
This is a convenience method if this class is used in a delegation fashion. This lets you set who the Watchable object really is.
Parameters:
watchable - is the Watchable object that will be passed to the Watcher on the callback.
See Also:
Watchable.notifyWatchersDelete()

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Description copied from interface: Watchable
Make a clone of this Watchable object.
Specified by:
clone in interface Watchable
Overrides:
clone in class Object

Copyright Information