net.sourceforge.rpgee.utility
Class BaseObservable<T>

java.lang.Object
  extended by net.sourceforge.rpgee.utility.BaseObservable<T>
All Implemented Interfaces:
Identified<java.lang.String>, MutableIdentified<java.lang.String>, Named, Observable<T>
Direct Known Subclasses:
Client, ClientNetworkMessageTransporter, DefaultRpgMessageHandler, NetworkMessageHub, ObserverObservingThread, ServerNetworkMessageTransporter

public class BaseObservable<T>
extends java.lang.Object
implements Observable<T>, Identified<java.lang.String>, MutableIdentified<java.lang.String>, Named


Field Summary
 
Fields inherited from interface net.sourceforge.rpgee.Identified
ID
 
Fields inherited from interface net.sourceforge.rpgee.Named
NAME
 
Constructor Summary
BaseObservable()
          Construct an BaseObservable with zero Observers.
BaseObservable(java.lang.String _id)
           
 
Method Summary
 void addObserver(Observer o)
          Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.
protected  void clearChanged()
          Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that the hasChanged method will now return false.
 int countObservers()
          Returns the number of observers of this BaseObservable object.
 void deleteObserver(Observer o)
          Deletes an observer from the set of observers of this object.
 void deleteObservers()
          Clears the observer list so that this object no longer has any observers.
 java.lang.String getId()
           
 java.lang.String getIdAsString()
           
 java.lang.String getName()
           
 boolean hasChanged()
          Tests if this object has changed.
 void notifyObservers()
          If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.
 void notifyObservers(T arg)
          If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.
protected  void setChanged()
          Marks this BaseObservable object as having been changed; the hasChanged method will now return true.
 void setId(java.lang.String _id)
           
protected  void setName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseObservable

public BaseObservable()
Construct an BaseObservable with zero Observers.


BaseObservable

public BaseObservable(java.lang.String _id)
Method Detail

addObserver

public void addObserver(Observer o)
Description copied from interface: Observable
Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.

Specified by:
addObserver in interface Observable<T>
Parameters:
o - an observer to be added.

deleteObserver

public void deleteObserver(Observer o)
Description copied from interface: Observable
Deletes an observer from the set of observers of this object. Passing null to this method will have no effect.

Specified by:
deleteObserver in interface Observable<T>
Parameters:
o - the observer to be deleted.

notifyObservers

public void notifyObservers()
                     throws java.lang.Exception
Description copied from interface: Observable
If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.

Each observer has its update method called with two arguments: this observable object and null. In other words, this method is equivalent to:

notifyObservers(null)

Specified by:
notifyObservers in interface Observable<T>
Throws:
java.lang.Exception
See Also:
Observable.clearChanged(), Observable.hasChanged(), Observer.update(java.util.Observable, java.lang.Object)

notifyObservers

public void notifyObservers(T arg)
                     throws java.lang.Exception
Description copied from interface: Observable
If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed.

Each observer has its update method called with two arguments: this observable object and the arg argument.

Specified by:
notifyObservers in interface Observable<T>
Parameters:
arg - any object.
Throws:
java.lang.Exception
See Also:
Observable.clearChanged(), Observable.hasChanged(), Observer.update(java.util.Observable, java.lang.Object)

deleteObservers

public void deleteObservers()
Description copied from interface: Observable
Clears the observer list so that this object no longer has any observers.

Specified by:
deleteObservers in interface Observable<T>

setChanged

protected void setChanged()
Marks this BaseObservable object as having been changed; the hasChanged method will now return true.


clearChanged

protected void clearChanged()
Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that the hasChanged method will now return false. This method is called automatically by the notifyObservers methods.

See Also:
Observable.notifyObservers(), Observable.notifyObservers(java.lang.Object)

hasChanged

public boolean hasChanged()
Description copied from interface: Observable
Tests if this object has changed.

Specified by:
hasChanged in interface Observable<T>
Returns:
true if and only if the setChanged method has been called more recently than the clearChanged method on this object; false otherwise.
See Also:
Observable.clearChanged(), Observable.setChanged()

countObservers

public int countObservers()
Description copied from interface: Observable
Returns the number of observers of this BaseObservable object.

Specified by:
countObservers in interface Observable<T>
Returns:
the number of observers of this object.

getId

public java.lang.String getId()
Specified by:
getId in interface Identified<java.lang.String>

getIdAsString

public java.lang.String getIdAsString()
Specified by:
getIdAsString in interface Identified<java.lang.String>

setId

public void setId(java.lang.String _id)
           throws IdentityException
Specified by:
setId in interface MutableIdentified<java.lang.String>
Throws:
IdentityException

getName

public java.lang.String getName()
Specified by:
getName in interface Named

setName

protected void setName(java.lang.String name)


Copyright © 2006 An Infinite Number of Monkeys. All Rights Reserved.