at.ac.tuwien.infosys.sm4all.copal.api.util
Class BaseObservable<E extends java.lang.Enum<?>,T,O extends Observer<E,T>>

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.util.BaseObservable<E,T,O>
Type Parameters:
E - the type of change represented as an Enum.
T - the type of changed object.
O - the type of Observer that can attach and detach to this BaseObservable.
All Implemented Interfaces:
Observable<E,T,O>
Direct Known Subclasses:
BaseRegistry, ConcreteObservable, ContextQuery, ContextQueryFactoryImpl

public abstract class BaseObservable<E extends java.lang.Enum<?>,T,O extends Observer<E,T>>
extends java.lang.Object
implements Observable<E,T,O>

The class which represents an object that can be observed.

Author:
sanjin

Constructor Summary
BaseObservable()
           
 
Method Summary
 void attach(O observer)
          Attaches specified Observer so it will in future receive notifications on changes.
 void detach(O observer)
          Detach specified Observer so it will not receive any future notifications on changes.
protected  void detachAll()
          Detaches all attached Observers.
protected  java.util.Collection<O> getObservers()
          Returns all attached Observers.
protected  void notifyAll(E change, T object)
          Notifies all attached Observers that specified change happened on specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseObservable

public BaseObservable()
Method Detail

attach

public void attach(O observer)
Attaches specified Observer so it will in future receive notifications on changes.

Specified by:
attach in interface Observable<E extends java.lang.Enum<?>,T,O extends Observer<E,T>>
Parameters:
observer - the Observer.
Throws:
java.lang.NullPointerException - if specified observer is null.

detach

public void detach(O observer)
Detach specified Observer so it will not receive any future notifications on changes.

Specified by:
detach in interface Observable<E extends java.lang.Enum<?>,T,O extends Observer<E,T>>
Parameters:
observer - the QueryObserver.
Throws:
java.lang.NullPointerException - if specified observer is null.

notifyAll

protected void notifyAll(E change,
                         T object)
Notifies all attached Observers that specified change happened on specified object.

Parameters:
change - the change.
object - the changed object.
Throws:
java.lang.NullPointerException - if specified change is null.

detachAll

protected void detachAll()
Detaches all attached Observers.


getObservers

protected java.util.Collection<O> getObservers()
Returns all attached Observers.

Returns:
all attached Observers.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.