OGS Java API Spec

ogs.support
Class Object

java.lang.Object
  |
  +--ogs.support.Object
All Implemented Interfaces:
EventListener
Direct Known Subclasses:
Ability, CClass, Character, Defense, Entity, Feature, Modifier, Modifiers, Spell

public abstract class Object
extends Object
implements EventListener

An object with a notifier, handler, and listeners of events. This class follows the Observer design pattern. It encapsulates both roles of Subject and Observer in one class by reusing the existing Java event handling classes. Subclasses should extend this class if event handling may potentially be needed.


Field Summary
protected  EventListenerList listeners
          List of event listeners.
 
Constructor Summary
Object()
           
 
Method Summary
 void addListener(EventListener listener)
          Add an event listener.
protected  void handleEvent(EventObject event)
          Handle an event.
protected  void notifyListeners(EventObject event)
          Notify all listeners of an event.
 void removeListener(EventListener listener)
          Remove an event listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected EventListenerList listeners
List of event listeners. This list is created only when needed; that is, when the first listener is added.

Constructor Detail

Object

public Object()
Method Detail

addListener

public void addListener(EventListener listener)
Add an event listener. For efficiency, the list of event listeners is created only when needed; that is, when the very first listener is added to the object.

Parameters:
listener - An event listener.

removeListener

public void removeListener(EventListener listener)
Remove an event listener.

Parameters:
listener - An event listener.

notifyListeners

protected void notifyListeners(EventObject event)
Notify all listeners of an event. Subclasses may expose this method to allow any other class to control when listeners are notified. Otherwise, subclasses control when listeners are notified of events.

Parameters:
event - Event that occurred.

handleEvent

protected void handleEvent(EventObject event)
Handle an event. The implementation of this method does nothing by default. Subclasses must override this method to handle events appropriately.

Parameters:
event - Event that occured.

OGS Java API Spec