public class BaseWeakReferencingObservable extends java.lang.Object implements ComplexWeakReferencingObservable, java.lang.Cloneable
Constructor and Description |
---|
BaseWeakReferencingObservable() |
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer observer)
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.
|
void |
addObserver(java.lang.ref.Reference ref) |
void |
addObservers(BaseWeakReferencingObservable observable) |
void |
beginComplexNotification()
Sets the Observable in complex notification mode.
|
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.
|
java.lang.Object |
clone() |
int |
countObservers()
Returns the number of observers of this object.
|
void |
deleteObserver(Observer observer)
Deletes an observer from the set of observers of this object.
|
void |
deleteObserver(java.lang.ref.Reference ref) |
void |
deleteObservers()
Clears the observer list so that this object no longer has any observers.
|
void |
disableNotifications()
Disable the notification of events to registered Observers.
|
void |
enableNotifications()
Enable (default) the notification of events to registered Observers.
|
void |
endComplexNotification()
Ends the complex notification mode.
|
protected boolean |
hasChanged()
Tests if this object has changed.
|
boolean |
inComplex() |
boolean |
isEnabledNotifications() |
protected void |
notify(WeakReferencingObservable observable,
java.lang.Object notification) |
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(java.lang.Object 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 DefaultObservable object as having been changed; the
hasChanged method will now return true.
|
public void addObserver(Observer observer)
addObserver
in interface Observable
observer
- an observer to be added.java.lang.NullPointerException
- if the parameter o is null.public void addObserver(java.lang.ref.Reference ref)
public void addObservers(BaseWeakReferencingObservable observable)
public void deleteObserver(Observer observer)
null
to this method will have no effect.deleteObserver
in interface Observable
observer
- the observer to be deleted.public void deleteObserver(java.lang.ref.Reference ref)
public void notifyObservers()
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)
Observable.clearChanged()
,
Observable.hasChanged()
,
Observer.update(java.util.Observable, java.lang.Object)
public void notifyObservers(java.lang.Object arg)
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. public void visit(Object obj)
throws VisitCanceledException, BaseException {
// TODO Auto-generated method stub
}
arg
- any object.Observable.clearChanged()
,
Observable.hasChanged()
,
Observer.update(java.util.Observable, java.lang.Object)
public void deleteObservers()
deleteObservers
in interface Observable
public int countObservers()
public void enableNotifications()
ComplexObservable
enableNotifications
in interface ComplexObservable
public void disableNotifications()
ComplexObservable
disableNotifications
in interface ComplexObservable
public boolean isEnabledNotifications()
public boolean inComplex()
public void beginComplexNotification()
ComplexObservable
beginComplexNotification
in interface ComplexObservable
public void endComplexNotification()
ComplexObservable
If a observer is a ComplexObserver
, it will be notified with a
single DefaultComplexNotification
instead of each of the notifications.
Some important notes to take into account when calling this method.
Observer
is processing a notification another Observer
is
registered to the source Observable
, it won't get any of the
notifications currently being notified, but future ones.endComplexNotification
in interface ComplexObservable
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
protected void notify(WeakReferencingObservable observable, java.lang.Object notification)
protected boolean hasChanged()
true
if and only if the setChanged
method has been called more recently than the
clearChanged
method on this object;
false
otherwise.Observable.clearChanged()
,
Observable.setChanged()
protected void setChanged()
protected void clearChanged()
notifyObservers
methods.Observable.notifyObservers()
,
Observable.notifyObservers(java.lang.Object)