Package net.sf.okapi.common.observer
Interface IObservable
-
- All Known Implementing Classes:
BaseObservable,Pipeline,WeakReferenceObservable,XPipeline
public interface IObservableThis interface is intended to provide more flexibility to complex object models when multiple inheritance is needed.By providing Observable as an interface, instead of the JDK'a
Observableclass, client classes have the option to mimic multiple inheritance by means of a delegate pattern which uses an inner private class which implements this interface.This class is based on the work done by Martin Fischer, with only minor changes. See references below.
- Author:
- Martin Fischer (original author), Richard Gomes
- See Also:
- Martin Fischer: Observer and Observable interfaces, Improved Observer/Observable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddObserver(IObserver observer)Attaches a observer to the Observable.intcountObservers()Counts how many Observers were attached to this class.voiddeleteObserver(IObserver observer)Detaches a previously attached observer to the observable.voiddeleteObservers()Detaches all previously attached observer to the observable.List<IObserver>getObservers()Returns list of observers registered with the Observable.voidnotifyObservers()Notifies all attached observers about changes in the observable.voidnotifyObservers(Object arg)Notifies all attached observers about changes in the observable.
-
-
-
Method Detail
-
addObserver
void addObserver(IObserver observer)
Attaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.- Parameters:
observer- The observer to attach to the observable
-
countObservers
int countObservers()
Counts how many Observers were attached to this class.- Returns:
- the number of Observers
- See Also:
IObserver
-
getObservers
List<IObserver> getObservers()
Returns list of observers registered with the Observable. List returned is unmodifiable list.- Returns:
- list of observers
-
deleteObserver
void deleteObserver(IObserver observer)
Detaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.- Parameters:
observer- The observer to detach from the observable
-
deleteObservers
void deleteObservers()
Detaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.
-
notifyObservers
void notifyObservers()
Notifies all attached observers about changes in the observable.
-
notifyObservers
void notifyObservers(Object arg)
Notifies all attached observers about changes in the observable.- Parameters:
arg- an arbitrary Object to be passed to the Observer
-
-