pmlib
Class PMLEventHandler

java.lang.Object
  extended by pmlib.PMLEventHandler

public class PMLEventHandler
extends java.lang.Object

PMLEventHandler Class

The PMLEventHandler object permits the routing of PMLEvent and PMLFloat objects to user specified methods using reflection.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.


Constructor Summary
PMLEventHandler()
          Create a new object instance
 
Method Summary
 boolean add(java.lang.String tag, java.lang.Object mobj, java.lang.String mstr, char[] args)
          Add an object method to the event handler
 void clear()
          Clear all object methods
 void debug()
          Print the contents of this object to the output
 int remove(java.lang.Object mobj, java.lang.String mstr, char[] args)
          Remove all object methods matching that specified
 int remove(java.lang.String tag)
          Remove all object methods with the specified tag
 void route(PMLEvent evnt)
          Route the event variables of the specified object to any attached methods with matching tag
 void route(PMLEvent[] evnt)
          Route the event variables of the specified objects to any methods with matching tags
 void route(PMLFloat flt)
          Route the value of the specified object to any attached methods with matching tags
 void route(PMLFloat[] flt)
          Route the values of the specified objects to any attached methods with matching tags
 int size()
          Return the number of attached methods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PMLEventHandler

public PMLEventHandler()
Create a new object instance

Method Detail

add

public boolean add(java.lang.String tag,
                   java.lang.Object mobj,
                   java.lang.String mstr,
                   char[] args)
Add an object method to the event handler

Object methods should be public with no return value. Currently only methods with int, float and String arguments are supported. This limitation is based on the assertion that other data types are unnecessary within the context of the PMLib library.

Method arguments should be specified by an array of characters with 'i', 'f' and 's' denoting int, float and String respectively. For example, a method with the arguments (int, String, float, float) should be specified with { 'i', 's', 'f', 'f' }.

Parameters:
tag - tag
mobj - method object
mstr - method string
args - method arguments
Returns:
true if the method was successfully added

remove

public int remove(java.lang.String tag)
Remove all object methods with the specified tag

Parameters:
tag - tag
Returns:
the total methods removed

remove

public int remove(java.lang.Object mobj,
                  java.lang.String mstr,
                  char[] args)
Remove all object methods matching that specified

Parameters:
mobj - method object
mstr - method string
args - method arguments
Returns:
the total methods removed

clear

public void clear()
Clear all object methods


debug

public void debug()
Print the contents of this object to the output


route

public void route(PMLFloat flt)
Route the value of the specified object to any attached methods with matching tags

Parameters:
flt - tagged float

route

public void route(PMLFloat[] flt)
Route the values of the specified objects to any attached methods with matching tags

Parameters:
flt - tagged float array

route

public void route(PMLEvent evnt)
Route the event variables of the specified object to any attached methods with matching tag

Parameters:
evnt - tagged event

route

public void route(PMLEvent[] evnt)
Route the event variables of the specified objects to any methods with matching tags

Parameters:
evnt - event

size

public int size()
Return the number of attached methods

Returns:
the number of attached methods