com.taursys.xml
Class Component

java.lang.Object
  extended bycom.taursys.xml.Component
All Implemented Interfaces:
MapperComponent
Direct Known Subclasses:
Container, Parameter, Trigger

public abstract class Component
extends java.lang.Object
implements MapperComponent

This is the foundation object for MapperXML components. All components share this base abstract class. It provides common attributes and basic event dispatching methods with limited implementation.

This object defines the following properties:

This object is designed to respond to 5 types of events. The following are the events this component is designed to respond to:

In order to be notified of these events, this component must register with each of the appropriate dispatchers. This is done by adding/removing the types of events you wish to be notified of to the eventTypeList. This is done by invoking the addEventType or removeEventType method with the fully qualified class name of the desired event. The eventTypeList is used by the addNotify and removeNotify methods which are invoked by the Container during the add and remove Container methods.

This component contains a 2 general purpose methods modeled after AWT and Swing: dispatchEvent and processEvent. These 2 methods simply call the specific processXXXEvent method based on the event type.

For each of the specific event types, there are a set of 3 related methods.


Constructor Summary
Component()
          Constructs a component
 
Method Summary
protected  void addEventType(java.lang.String eventType)
          Adds the given eventType to the event type list.
 void addInputListener(InputListener l)
          Adds given listener to notification list for InputEvents
 void addNotify()
          Registers this component with dispatcher to be notified of ParameterEvents This method invokes the lazyAddNotify method to perform the work
 void addParameterListener(ParameterListener l)
          Adds given listener to notification list for ParameterEvents
 void addRecycleListener(RecycleListener l)
          Adds given listener to notification list for RecycleEvents
 void addRenderListener(RenderListener l)
          Adds given listener to notification list for RenderEvents
 void addTriggerListener(TriggerListener l)
          Adds given listener to notification list for TriggerEvents
 void dispatchEvent(java.util.EventObject e)
          Dispatches an event to this component or one of its subcomponents.
protected  void fireActionPerformed(TriggerEvent e)
          Notifies all registered listeners of a given TriggerEvent
protected  void fireInputReceived(InputEvent e)
          Notifies all registered listeners of a given InputEvent
protected  void fireParameterReceived(ParameterEvent e)
          Notifies all registered listeners of a given ParameterEvent
protected  void fireRecycle(RecycleEvent e)
          Notifies all registered listeners of a given RecycleEvent
protected  void fireRender(RenderEvent e)
          Notifies all registered listeners of a given RenderEvent
protected  java.util.ArrayList getEventTypeList()
          Returns the list of event types that this component responds to
 Container getParent()
          Returns the parent container of this component else null.
protected  boolean isNotifySet()
          Gets indicator of whether or not notification has been setup.
 boolean isVisible()
          Get the indicator whether or not this component should be rendered visible.
protected  void lazyAddNotify()
          Conditionally registers this component with dispatchers for the event types contained in the eventTypeList.
protected  void lazyRemoveNotify()
          Conditionally un-registers this component from dispatcher for the event types contained in the eventTypeList.
protected  void processEvent(java.util.EventObject e)
          Processes given event by invoking the appropriate processX__Event method.
protected  void processInputEvent(InputEvent e)
          Processes a given InputEvent.
protected  void processParameterEvent(ParameterEvent e)
          Processes a given ParameterEvent.
 void processRecycleEvent(RecycleEvent e)
          Processes a given RecycleEvent.
 void processRenderEvent(RenderEvent e)
          Processes a given RenderEvent.
protected  void processTriggerEvent(TriggerEvent e)
          Processes a given TriggerEvent.
protected  void removeEventType(java.lang.String eventType)
          Removes the given eventType from the event type list.
 void removeInputListener(InputListener l)
          Removes given listener from notification list for InputEvents
 void removeNotify()
          Un-Registers this component with dispatcher.
 void removeParameterListener(ParameterListener l)
          Removes given listener from notification list for ParameterEvents
 void removeRecycleListener(RecycleListener l)
          Removes given listener from notification list for RecycleEvents
 void removeRenderListener(RenderListener l)
          Removes given listener from notification list for RenderEvents
 void removeTriggerListener(TriggerListener l)
          Removes given listener from notification list for TriggerEvents
 void setVisible(boolean visible)
          Set the indicator whether or not this component should be rendered visible.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Component

public Component()
Constructs a component

Method Detail

getParent

public Container getParent()
Returns the parent container of this component else null.


setVisible

public void setVisible(boolean visible)
Set the indicator whether or not this component should be rendered visible. This indicator is only meaningful for components which are in the Document.

Parameters:
visible - the indicator whether or not this component should be rendered visible.

isVisible

public boolean isVisible()
Get the indicator whether or not this component should be rendered visible. This indicator is only meaningful for components which are in the Document.

Returns:
indicator whether or not this component should be rendered visible.

getEventTypeList

protected java.util.ArrayList getEventTypeList()
Returns the list of event types that this component responds to

Returns:
the list of event types that this component responds to

removeEventType

protected void removeEventType(java.lang.String eventType)
Removes the given eventType from the event type list. The event type list is used by addNotify and removeNotify methods to register/un-register with Dispatchers for events. The eventType is the fully qualified class name of the event. This method does not re-register with Dispatchers. You must invoke the addNotify and removeNotify methods to register with Dispatchers.

Parameters:
eventType - fully qualified class name of the Event

addEventType

protected void addEventType(java.lang.String eventType)
Adds the given eventType to the event type list. The event type list is used by addNotify and removeNotify methods to register/un-register with Dispatchers for events. The eventType is the fully qualified class name of the event. This method does not re-register with Dispatchers. You must invoke the addNotify and removeNotify methods to register with Dispatchers.

Parameters:
eventType - fully qualified class name of the Event

addNotify

public void addNotify()
Registers this component with dispatcher to be notified of ParameterEvents This method invokes the lazyAddNotify method to perform the work


removeNotify

public void removeNotify()
Un-Registers this component with dispatcher. This method invokes the lazyRemoveNotify method to perform the work


lazyAddNotify

protected void lazyAddNotify()
Conditionally registers this component with dispatchers for the event types contained in the eventTypeList. In order to be notified, this component must have a parent and the notifySet flag must be false.


lazyRemoveNotify

protected void lazyRemoveNotify()
Conditionally un-registers this component from dispatcher for the event types contained in the eventTypeList. Only un-registers if it WAS registered and parent is not null.


isNotifySet

protected boolean isNotifySet()
Gets indicator of whether or not notification has been setup. This flag is set to true after addNotify has successfully registered, and set to false after removeNotify has successfully un-registered.

Returns:
indicator if notification has been setup.

dispatchEvent

public void dispatchEvent(java.util.EventObject e)
                   throws java.lang.Exception
Dispatches an event to this component or one of its subcomponents. This method invokes processEvent before returning.

Throws:
java.lang.Exception

processEvent

protected void processEvent(java.util.EventObject e)
                     throws java.lang.Exception
Processes given event by invoking the appropriate processX__Event method. The appropriate event type is determined by the class of the given EventObject.

Throws:
java.lang.Exception

processParameterEvent

protected void processParameterEvent(ParameterEvent e)
                              throws java.lang.Exception
Processes a given ParameterEvent. This implementation simply propagates the ParameterEvent to registered listeners. Components who need to respond to ParameterEvents should override this method.

Throws:
java.lang.Exception

removeParameterListener

public void removeParameterListener(ParameterListener l)
Removes given listener from notification list for ParameterEvents


addParameterListener

public void addParameterListener(ParameterListener l)
Adds given listener to notification list for ParameterEvents


fireParameterReceived

protected void fireParameterReceived(ParameterEvent e)
                              throws java.lang.Exception
Notifies all registered listeners of a given ParameterEvent

Throws:
java.lang.Exception

processInputEvent

protected void processInputEvent(InputEvent e)
                          throws java.lang.Exception
Processes a given InputEvent. This implementation simply propagates the InputEvent to registered listeners. Components who need to respond to InputEvents should override this method.

Throws:
java.lang.Exception

removeInputListener

public void removeInputListener(InputListener l)
Removes given listener from notification list for InputEvents


addInputListener

public void addInputListener(InputListener l)
Adds given listener to notification list for InputEvents


fireInputReceived

protected void fireInputReceived(InputEvent e)
                          throws java.lang.Exception
Notifies all registered listeners of a given InputEvent

Throws:
java.lang.Exception

processRenderEvent

public void processRenderEvent(RenderEvent e)
                        throws RenderException
Processes a given RenderEvent. This implementation simply propagates the RenderEvent to registered listeners. Components who need to respond to RenderEvents should override this method.

Parameters:
e - the RenderEvent to process
Throws:
RenderException - for any problems during rendering

removeRenderListener

public void removeRenderListener(RenderListener l)
Removes given listener from notification list for RenderEvents


addRenderListener

public void addRenderListener(RenderListener l)
Adds given listener to notification list for RenderEvents


fireRender

protected void fireRender(RenderEvent e)
                   throws RenderException
Notifies all registered listeners of a given RenderEvent

Throws:
RenderException

processTriggerEvent

protected void processTriggerEvent(TriggerEvent e)
                            throws java.lang.Exception
Processes a given TriggerEvent. This implementation simply propagates the TriggerEvent to registered listeners. Components who need to respond to TriggerEvents should override this method.

Throws:
java.lang.Exception

removeTriggerListener

public void removeTriggerListener(TriggerListener l)
Removes given listener from notification list for TriggerEvents


addTriggerListener

public void addTriggerListener(TriggerListener l)
Adds given listener to notification list for TriggerEvents


fireActionPerformed

protected void fireActionPerformed(TriggerEvent e)
                            throws java.lang.Exception
Notifies all registered listeners of a given TriggerEvent

Throws:
java.lang.Exception

processRecycleEvent

public void processRecycleEvent(RecycleEvent e)
                         throws RecycleException
Processes a given RecycleEvent. This implementation simply propagates the RecycleEvent to registered listeners. Components who need to respond to RecycleEvents should override this method.

Parameters:
e - the RecycleEvent to process
Throws:
RecycleException - for any problems during recycleing

removeRecycleListener

public void removeRecycleListener(RecycleListener l)
Removes given listener from notification list for RecycleEvents


addRecycleListener

public void addRecycleListener(RecycleListener l)
Adds given listener to notification list for RecycleEvents


fireRecycle

protected void fireRecycle(RecycleEvent e)
                    throws RecycleException
Notifies all registered listeners of a given RecycleEvent

Throws:
RecycleException

toString

public java.lang.String toString()
Returns a string representation of this object. This contains the object identity and state information.

Returns:
a string representation of this object


Copyright © 2007 Martin T Phelan. All Rights Reserved.