|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectcz.cuni.amis.pogamut.base.communication.worldview.react.ObjectEventReact<OBJECT,EVENT>
EVENT - public abstract class ObjectEventReact<OBJECT extends IWorldObject,EVENT extends IWorldObjectEvent<OBJECT>>
This abstract class allows you to easily hook a specific event-handling behavior. It automatically
register a listener for a specified IWorldObjectEvent for you and calls react(IWorldObjectEvent)
method automatically.
If you need to react only once to the event, use ObjectEventReactOnce.
Use enable() and disable() to enable react / disable react. The reaction is enabled
as default.
WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to listeners and if you do not save pointer to the object, it will be gc()ed!
| Field Summary | |
|---|---|
protected static int |
LEVEL_B_EVENT
|
protected static int |
LEVEL_C_EVENT
|
protected static int |
LEVEL_D_EVENT
|
protected static int |
LEVEL_E_EVENT
|
protected Class |
reactEventClass
|
protected IWorldObjectEventListener<OBJECT,EVENT> |
reactListener
|
protected Class |
reactObjectClass
|
protected int |
reactObjectEventType
|
protected WorldObjectId |
reactObjectId
|
protected IWorldView |
reactWorldView
|
| Constructor Summary | |
|---|---|
ObjectEventReact(Class<?> objectClass,
Class<?> eventClass,
IWorldView worldView)
|
|
ObjectEventReact(Class<?> objectClass,
IWorldView worldView)
|
|
ObjectEventReact(WorldObjectId objectId,
Class<?> eventClass,
IWorldView worldView)
|
|
ObjectEventReact(WorldObjectId objectId,
IWorldView worldView)
|
|
| Method Summary | |
|---|---|
void |
disable()
Disables the reaction. |
void |
enable()
Enables the reaction. |
protected void |
postReact(EVENT event)
post- ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work after the react method. |
protected void |
preReact(EVENT event)
pre- ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work before the react method. |
protected abstract void |
react(EVENT event)
React upon event notification. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int LEVEL_B_EVENT
protected static final int LEVEL_C_EVENT
protected static final int LEVEL_D_EVENT
protected static final int LEVEL_E_EVENT
protected IWorldObjectEventListener<OBJECT extends IWorldObject,EVENT extends IWorldObjectEvent<OBJECT>> reactListener
protected IWorldView reactWorldView
protected Class reactEventClass
protected Class reactObjectClass
protected WorldObjectId reactObjectId
protected final int reactObjectEventType
| Constructor Detail |
|---|
public ObjectEventReact(Class<?> objectClass,
IWorldView worldView)
public ObjectEventReact(Class<?> objectClass,
Class<?> eventClass,
IWorldView worldView)
public ObjectEventReact(WorldObjectId objectId,
IWorldView worldView)
public ObjectEventReact(WorldObjectId objectId,
Class<?> eventClass,
IWorldView worldView)
| Method Detail |
|---|
public void disable()
public void enable()
protected void preReact(EVENT event)
ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work before the react method.
event - protected abstract void react(EVENT event)
event - protected void postReact(EVENT event)
ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work after the react method.
event -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||