Methods Summary |
---|
public synchronized void | addObserver(RemoteObserver ob)Adds a RemoteObserver to the list of objects observing this
object.
if( !observers.contains(ob) ) {
observers.addElement(ob);
}
|
protected synchronized void | clearChanged()Marks the observable as unchanged.
changed = false;
|
public synchronized int | countObservers()
return observers.size();
|
public synchronized void | deleteObserver(RemoteObserver ob)Removes the specified RemoteObserver from the list of
objects being observed.
if( observers.contains(ob) ) {
observers.removeElement(ob);
}
|
public synchronized void | deleteObservers()Clears out the entire observer list.
observers = new Vector();
|
public synchronized boolean | hasChanged()
return changed;
|
public void | notifyObservers(java.rmi.Remote r)Notifies observers of a change with the specified remote
reference as an argument.
performNotify(r);
|
public void | notifyObservers(java.io.Serializable s)Notifies observers of a change with the specified serializable
object as an argument.
performNotify(s);
|
public void | notifyObservers()Assuming the object has been changed called, this method
will notify its observers with null as an argument.
performNotify(null);
|
public void | performNotify(java.lang.Object arg)
RemoteObserver[] obs;
int count;
synchronized (this) {
if( !hasChanged() ) {
return;
}
count = observers.size();
obs = new RemoteObserver[count];
observers.copyInto(obs);
clearChanged();
}
for(int i=0; i<count; i++) {
if( obs[i] != null ) {
try {
obs[i].update(this, arg);
}
catch( RemoteException e ) {
e.printStackTrace();
}
}
}
|
protected synchronized void | setChanged()Marks the observable as changed.
changed = true;
|