org.graffiti.plugin.view.interactive
Class Observable<T>

java.lang.Object
  extended by org.graffiti.plugin.view.interactive.Observable<T>
Type Parameters:
T - The type of the encapsulated property.

public class Observable<T>
extends Object

Class that encapsulates a property and manages a list of Observers, which will be informed when that property changes.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Constructor Summary
Observable()
          Constructs a Observable.
Observable(T value)
          Constructs a Observable and initializes the encapsulated property with the specified value.
 
Method Summary
 void addObserver(Observer<T> observer)
          Adds an Observer to the list of observers that will be notified when the encapsulated property is assigned a new value.
 void clearObservers()
          Clears the list of observers.
 T get()
          Returns the value of the encapsulated property.
 void set(T value)
          Sets the encapsulated variable to the specified value and notifies all Observers about the change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Observable

public Observable(T value)
Constructs a Observable and initializes the encapsulated property with the specified value.

Parameters:
value - the initial value of the encapsulated property.

Observable

public Observable()
Constructs a Observable.

Method Detail

get

public T get()
Returns the value of the encapsulated property.

Returns:
the value of the encapsulated property.

set

public void set(T value)
Sets the encapsulated variable to the specified value and notifies all Observers about the change.

Parameters:
value - the new value assigned to the encapsulated property.

addObserver

public void addObserver(Observer<T> observer)
Adds an Observer to the list of observers that will be notified when the encapsulated property is assigned a new value. If an observer is added to this list multiple times, it will be notified accordingly multiple times in response to each single change of the encapsulated property.

Parameters:
observer - the observer to be added to the list of observers monitoring the encapsulated property.

clearObservers

public void clearObservers()
Clears the list of observers.



Generated at 2012-05-30 11:00:36 PM CEST