| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.perfectjpattern.core.behavioral.observer.Subject<E>
E - Type of event data this ISubject 
 notifies with.public class Subject<E>
Base core implementation of ISubject interface.
 
ISubject|  |  | 
| Field Summary | |
|---|---|
| protected static IObserver[] | EMPTY_ARRAYReusable empty array of IObserverso it does not need
 to be recreated each time there is a call tonotifyObservers | 
| Constructor Summary | |
|---|---|
| Subject() | |
| Method Summary | |
|---|---|
|  void | attach(IObserver<E>... anObservers)Attaches a variable list of IObserverinstances to theISubjectinstance. | 
|  void | clear()Detaches all registered IObserverinstances from thisISubject | 
|  void | detach(IObserver<E>... anObservers)Detaches a variable list of IObserverinstances from theISubjectinstance. | 
| protected  Collection<IObserver<E>> | getObservers()Returns the Observer instances | 
|  void | notifyObservers(E anEventData)Notifies the attached IObserverinstances that a change 
 has occurred. | 
|  int | size()Returns the number of attached IObserverinstances | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected static final IObserver[] EMPTY_ARRAY
IObserver so it does not need
 to be recreated each time there is a call to 
 notifyObservers
| Constructor Detail | 
|---|
public Subject()
| Method Detail | 
|---|
public void attach(IObserver<E>... anObservers)
IObserver instances to the 
 ISubject instance.
attach in interface ISubject<E>anObservers - IObserver instances to be attached.public void clear()
IObserver instances from this
 ISubject
clear in interface ISubject<E>public void detach(IObserver<E>... anObservers)
IObserver instances from the 
 ISubject instance.
detach in interface ISubject<E>anObservers - IObserver instances to be detached.public void notifyObservers(E anEventData)
IObserver instances that a change 
 has occurred. It is compulsory to provide a non null parameter 
 anEventData. For situations where passing information is 
 not required use instead NullEventData singleton instance.
notifyObservers in interface ISubject<E>anEventData - Event data pushed to IObserver 
        instances.public int size()
IObserver instances
size in interface ISubject<E>IObserver instances.protected Collection<IObserver<E>> getObservers()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||