|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.std.util.ObservableEvent
public class ObservableEvent
This class represents an object which is observable. Other objects may
register their intent to be notified when this object changes; and when
this object does change, it will trigger the update
method
of each observer.
Note that the notifyObservers()
method of this class is
unrelated to the notify()
of Object.
Observable
Field Summary | |
---|---|
(package private) static long |
serialVersionUID
|
Constructor Summary | |
---|---|
ObservableEvent(java.lang.Class<?>... args)
instantiates a new Event to be invoked using the specified arguments |
Method Summary | |
---|---|
boolean |
addObserverMethod(java.lang.Object o,
java.lang.String method)
registers an instance method to be called when this event is invoked |
boolean |
addStaticObserverMethod(java.lang.Class<?> c,
java.lang.String method)
registers a static method to be called when this event is invoked |
void |
clearChanged()
Reset this ObservableEvent's state to unchanged. |
int |
countObservers()
Returns the number of observers for this object. |
boolean |
deleteObserverMethod(java.lang.Object o,
java.lang.String method)
removes an instance method from registration |
void |
deleteObservers()
Deletes all observer methods of this ObservableEvent. |
boolean |
deleteStaticObserverMethod(java.lang.Class<?> c,
java.lang.String method)
removes a static method from registration |
boolean |
hasChanged()
True if setChanged has been called more recently than
clearChanged . |
void |
notifyObserverMethods(java.lang.Object... args)
invoke all the Observers Note that though the order of notification is unspecified in subclasses, in ObservableEvent it is in the order of registration. |
void |
setChanged()
Marks this Observable as having changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
Constructor Detail |
---|
public ObservableEvent(java.lang.Class<?>... args)
args
- the classes and order of the arguments to be passedMethod Detail |
---|
public boolean addObserverMethod(java.lang.Object o,
java.lang.String method)
o
- instance the method should be called onmethod
- name of the method to be called
java.lang.IllegalArgumentException
- if the method
doesn't exist on the specified instancepublic boolean addStaticObserverMethod(java.lang.Class<?> c,
java.lang.String method)
c
- class the method should be called onmethod
- name of the method to be called
java.lang.NoSuchMethodException
- if the method
doesn't exist on the specified classpublic void clearChanged()
notifyObservers
once all observer methods have been notified.
#notifyObserverMethods(Object ... args)
public int countObservers()
public boolean deleteObserverMethod(java.lang.Object o,
java.lang.String method)
o
- instance of the method that should be removedmethod
- name of the method to be removed
java.lang.NoSuchMethodException
- if the method
doesn't exist on the specified instancepublic void deleteObservers()
public boolean deleteStaticObserverMethod(java.lang.Class<?> c,
java.lang.String method)
c
- class of the method that should be removedmethod
- name of the method to be removed
java.lang.NoSuchMethodException
- if the method
doesn't exist on the specified classpublic boolean hasChanged()
setChanged
has been called more recently than
clearChanged
.
public void notifyObserverMethods(java.lang.Object... args)
args
- arguments to be passed
to the registered methodspublic void setChanged()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |