System
Class Event<T extends EventArgs>

java.lang.Object
  extended by System.Event<T>
Type Parameters:
T - The EventArgs instance or subclass to use with this event.

public class Event<T extends EventArgs>
extends java.lang.Object

Base class for all events in JavaXNA.

Author:
Halofreak1990

Constructor Summary
Event()
          Creates a new instance of this Object.
 
Method Summary
 void addHandler(EventHandler<T> handler)
          Adds a handler for this event
 java.util.List<EventHandler<T>> getHandlers()
          Gets a list of handlers that are attached to this event.
 void raise(java.lang.Object sender, T e)
          Raises the event.
 void removeHandler(EventHandler<T> handler)
          Removes the specified handler for this event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Event

public Event()
Creates a new instance of this Object.

Method Detail

getHandlers

public java.util.List<EventHandler<T>> getHandlers()
Gets a list of handlers that are attached to this event. Use this to determine whether you can actually raise the event, since if the list is empty, you'll get an InvalidOperationException.


addHandler

public void addHandler(EventHandler<T> handler)
Adds a handler for this event

Parameters:
handler - The handler to add to this event.

removeHandler

public void removeHandler(EventHandler<T> handler)
Removes the specified handler for this event

Parameters:
handler -
Throws:
InvalidOperationException - Thrown when no event handlers have previously been assigned.

raise

public void raise(java.lang.Object sender,
                  T e)
Raises the event.

Parameters:
sender - The Object that raised the event.
e - An instance of System.EventArgs that provides information about the event.
Throws:
InvalidOperationException - Thrown when the event is raised with no event handlers assigned.