|
||||||||||
| 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_ARRAY
Reusable empty array of IObserver so it does not need
to be recreated each time there is a call to
notifyObservers |
| Constructor Summary | |
|---|---|
Subject()
|
|
| Method Summary | |
|---|---|
void |
attach(IObserver<E>... anObservers)
Attaches a variable list of IObserver instances to the
ISubject instance. |
void |
clear()
Detaches all registered IObserver instances from this
ISubject |
void |
detach(IObserver<E>... anObservers)
Detaches a variable list of IObserver instances from the
ISubject instance. |
protected Collection<IObserver<E>> |
getObservers()
Returns the Observer instances |
void |
notifyObservers(E anEventData)
Notifies the attached IObserver instances that a change
has occurred. |
int |
size()
Returns the number of attached IObserver instances |
| 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 | |||||||||