|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.electrotank.electroserver5.client.events.EventDispatcher<I,E>
I - The enumeration that will identify specific events.E - The type of event that this dispatcher will handle.public class EventDispatcher<I extends Enum,E extends Event>
Provides a developer friendly method of handling event dispatching, similar to the way it is done in ActionScript 3. Using this class and it's semantics for event dispatching instead of traditional Java EventHandlers allows the developer to avoid casting events, allows multiple identifiers for a single event type to be handled by one dispatcher and adds support for event priority. This type of event dispatching also uses methods as targets for events instead of interfaces, so no anonymous inner classes or adapters are needed.
| Constructor Summary | |
|---|---|
EventDispatcher()
|
|
| Method Summary | ||
|---|---|---|
protected void |
addEventListener(I eventIdentifier,
Object target,
Method method)
|
|
protected void |
addEventListener(I eventIdentifier,
Object target,
Method method,
int priority)
|
|
void |
addEventListener(I eventIdentifier,
Object target,
String method)
|
|
void |
addEventListener(I eventIdentifier,
Object target,
String method,
Class methodArgType)
|
|
void |
addEventListener(I eventIdentifier,
Object target,
String method,
Class methodArgType,
int priority)
Adds an event listener that will be notified on event dispatches. |
|
void |
addEventListener(I eventIdentifier,
Object target,
String method,
int priority)
|
|
void |
dispatchEvent(E event)
|
|
static Class<?> |
getClass(Type type)
Get the underlying class for a type, or null if the type is a variable type. |
|
static
|
getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a generic base class. |
|
void |
removeEventListener(I eventIdentifier,
Object target,
String method)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EventDispatcher()
| Method Detail |
|---|
public void addEventListener(I eventIdentifier,
Object target,
String method,
Class methodArgType,
int priority)
eventIdentifier - Events with this type will be dispatched to this listener.target - The Object that will receive the event.method - The name of a method on target that will receive the event.methodArgType - The type of event that is expected to be received. Supplying this allows the developer to avoid a cast on the listener.priority - Notification priority. Higher priorities are notified before lower.
public void addEventListener(I eventIdentifier,
Object target,
String method,
Class methodArgType)
public void addEventListener(I eventIdentifier,
Object target,
String method,
int priority)
public void addEventListener(I eventIdentifier,
Object target,
String method)
protected void addEventListener(I eventIdentifier,
Object target,
Method method)
protected void addEventListener(I eventIdentifier,
Object target,
Method method,
int priority)
public void removeEventListener(I eventIdentifier,
Object target,
String method)
public void dispatchEvent(E event)
public static Class<?> getClass(Type type)
type - the type
public static <T> List<Class<?>> getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
baseClass - the base classchildClass - the child class
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||