org.opengts.util
Class MethodAction

java.lang.Object
  extended by org.opengts.util.MethodAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.lang.Runnable, java.util.EventListener

public class MethodAction
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable


Field Summary
static java.lang.String CONSTRUCTOR
           
 
Constructor Summary
MethodAction(java.lang.Object targ)
          Constructor
MethodAction(java.lang.Object targ, java.lang.Class... argClass)
          Constructor
MethodAction(java.lang.Object targ, java.lang.Class[] argClass, java.lang.Object[] args)
          Constructor
MethodAction(java.lang.Object targ, java.lang.String methName)
          Constructor
MethodAction(java.lang.Object targ, java.lang.String methName, java.lang.Class... argClass)
          Constructor
MethodAction(java.lang.Object targ, java.lang.String methName, java.lang.Class[] argClass, java.lang.Object[] args)
          Constructor
 
Method Summary
protected static java.lang.String _beanMethodName(java.lang.String prefix, java.lang.String fieldName)
          Returns the bean method name for the specified field
 void actionPerformed(java.awt.event.ActionEvent ae)
          ActionListener interface execution
 java.lang.Object[] getArgs()
          Returns an array of currently defined arguments
 java.lang.Object getReturnValue()
          Gets the returned value from the last MethodAction invocation
 java.lang.Object getTarget()
          Returns the MethodAction target (may be a Class or Object instance)
static MethodAction GetterMethod(java.lang.Object targ, java.lang.String fieldName)
          Returns a MethodAction instance which represents a bean field 'getter' method.
static java.lang.String getterMethodName(java.lang.String fieldName)
          Returns the bean 'getter' method name for the specified field
 java.lang.Object invoke()
          Invokes this MethodAction with the currently specified array/list of arguments
 java.lang.Object invoke(java.lang.Object... args)
          Invokes this MethodAction with the specified array/list of arguments
 void invokeAndWait()
          Queues the invocation of this MethodAction on the EventQueue, and waits for the EventQueue
static void invokeAndWait(java.lang.Runnable r)
          Queues the invocation of the specified Runnable on the EventQueue, and waits for the EventQueue thread to complete execution of the specified Runnable.
 void invokeDelayed(int delayMillis)
          Place this MethodAction object in the current EventQueue execution stack to be executed after the specified initial delay.
static void invokeDelayed(int delayMillis, java.lang.Runnable r)
          Place the Runnable object in the current EventQueue execution stack to be executed after the specified initial delay.
static java.lang.Object InvokeGetter(java.lang.Object targ, java.lang.String fieldName)
          Invokes a 'getter' method on the specified target for the specified field name
 void invokeLater()
          Queues the invocation of this MethodAction on the EventQueue
static void invokeLater(java.awt.event.ActionListener al, java.awt.event.ActionEvent ae)
          Queues the invocation of the specified ActionListener on the EventQueue
static void invokeLater(java.lang.Runnable r)
          Queues the invocation of the specified Runnable on the EventQueue
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, boolean value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, java.lang.Class valClass, java.lang.Object value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, double value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, float value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, int value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, long value)
          Invokes a 'setter' method on the specified target for the specified field name
static void InvokeSetter(java.lang.Object targ, java.lang.String fieldName, java.lang.String value)
          Invokes a 'setter' method on the specified target for the specified field name
static boolean isDispatchThread()
          Returns true if the calling Thread is the event dispatch thread
static void main(java.lang.String[] argv)
          Command-line test/debug
static java.lang.Object newInstance(java.lang.String className)
          Create a new instance of the specified class name
 void run()
          Runs this MethodAction now
 void setArgs(java.lang.Object... args)
          Sets the actual arguments to pass to the method at the time of invocation
static MethodAction SetterMethod(java.lang.Object targ, java.lang.String fieldName, java.lang.Class... argType)
          Returns a MethodAction instance which represents a bean field 'setter' method.
static java.lang.String setterMethodName(java.lang.String fieldName)
          Returns the bean 'setter' method name for the specified field
static int test(java.lang.String m, int x)
          Command-line test method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTOR

public static final java.lang.String CONSTRUCTOR
See Also:
Constant Field Values
Constructor Detail

MethodAction

public MethodAction(java.lang.Object targ)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException

MethodAction

public MethodAction(java.lang.Object targ,
                    java.lang.String methName)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
methName - A method name
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException

MethodAction

public MethodAction(java.lang.Object targ,
                    java.lang.Class... argClass)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
argClass - An array/list of argument class types
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException

MethodAction

public MethodAction(java.lang.Object targ,
                    java.lang.String methName,
                    java.lang.Class... argClass)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
methName - A method name
argClass - An array/list of argument class types
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException

MethodAction

public MethodAction(java.lang.Object targ,
                    java.lang.Class[] argClass,
                    java.lang.Object[] args)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
argClass - An array/list of argument class types
args - An array of the actual method arguments
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException

MethodAction

public MethodAction(java.lang.Object targ,
                    java.lang.String methName,
                    java.lang.Class[] argClass,
                    java.lang.Object[] args)
             throws java.lang.NoSuchMethodException,
                    java.lang.ClassNotFoundException
Constructor

Parameters:
targ - The Object target (a class instance for static methods)
methName - A method name
argClass - An array/list of argument class types
args - An array of the actual method arguments
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
Method Detail

_beanMethodName

protected static java.lang.String _beanMethodName(java.lang.String prefix,
                                                  java.lang.String fieldName)
Returns the bean method name for the specified field

Parameters:
prefix - Either "get" or "set"
fieldName - The field name
Returns:
The 'getter'/'setter' method name

getterMethodName

public static java.lang.String getterMethodName(java.lang.String fieldName)
Returns the bean 'getter' method name for the specified field

Parameters:
fieldName - The field name
Returns:
The 'getter' method name

setterMethodName

public static java.lang.String setterMethodName(java.lang.String fieldName)
Returns the bean 'setter' method name for the specified field

Parameters:
fieldName - The field name
Returns:
The 'setter' method name

GetterMethod

public static MethodAction GetterMethod(java.lang.Object targ,
                                        java.lang.String fieldName)
                                 throws java.lang.NoSuchMethodException,
                                        java.lang.ClassNotFoundException
Returns a MethodAction instance which represents a bean field 'getter' method.

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
Returns:
The MethodAction instance
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException

InvokeGetter

public static java.lang.Object InvokeGetter(java.lang.Object targ,
                                            java.lang.String fieldName)
                                     throws java.lang.NoSuchMethodException,
                                            java.lang.ClassNotFoundException,
                                            java.lang.Throwable
Invokes a 'getter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
Returns:
The returned Object for the 'getter' method
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

SetterMethod

public static MethodAction SetterMethod(java.lang.Object targ,
                                        java.lang.String fieldName,
                                        java.lang.Class... argType)
                                 throws java.lang.NoSuchMethodException,
                                        java.lang.ClassNotFoundException
Returns a MethodAction instance which represents a bean field 'setter' method.

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
Returns:
The MethodAction instance
Throws:
java.lang.NoSuchMethodException - if the 'setter' method does not exist
java.lang.ClassNotFoundException

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                java.lang.Class valClass,
                                java.lang.Object value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                java.lang.String value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                boolean value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                int value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                long value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                float value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

InvokeSetter

public static void InvokeSetter(java.lang.Object targ,
                                java.lang.String fieldName,
                                double value)
                         throws java.lang.NoSuchMethodException,
                                java.lang.ClassNotFoundException,
                                java.lang.Throwable
Invokes a 'setter' method on the specified target for the specified field name

Parameters:
targ - The Object target
fieldName - The field name for which the 'getter' is returned
value - The value to 'set'.
Throws:
java.lang.NoSuchMethodException - if the 'getter' method does not exist
java.lang.ClassNotFoundException
java.lang.Throwable

getTarget

public java.lang.Object getTarget()
Returns the MethodAction target (may be a Class or Object instance)

Returns:
A class or Object instance

setArgs

public void setArgs(java.lang.Object... args)
Sets the actual arguments to pass to the method at the time of invocation

Parameters:
args - An array/list of method arguments

getArgs

public java.lang.Object[] getArgs()
Returns an array of currently defined arguments

Returns:
An array of currently defined arguments

invoke

public java.lang.Object invoke(java.lang.Object... args)
                        throws java.lang.Throwable
Invokes this MethodAction with the specified array/list of arguments

Parameters:
args - An array/list of arguments
Returns:
The returned Object
Throws:
java.lang.Throwable

invoke

public java.lang.Object invoke()
                        throws java.lang.Throwable
Invokes this MethodAction with the currently specified array/list of arguments

Returns:
The return Object
Throws:
java.lang.Throwable

getReturnValue

public java.lang.Object getReturnValue()
Gets the returned value from the last MethodAction invocation

Returns:
The returned Object

invokeDelayed

public static void invokeDelayed(int delayMillis,
                                 java.lang.Runnable r)
Place the Runnable object in the current EventQueue execution stack to be executed after the specified initial delay.

Parameters:
delayMillis - The number of milliseconds to wait befor executing the specified Runnable. This method will still return immediately.
r - The Runnable instance to execute (ie. call the "run()" method)

invokeDelayed

public void invokeDelayed(int delayMillis)
Place this MethodAction object in the current EventQueue execution stack to be executed after the specified initial delay.

Parameters:
delayMillis - The number of milliseconds to wait befor executing this MethodAction. This method will still return immediately.

invokeLater

public static void invokeLater(java.awt.event.ActionListener al,
                               java.awt.event.ActionEvent ae)
Queues the invocation of the specified ActionListener on the EventQueue

Parameters:
al - The ActionListener to execute
ae - The ActionEvent to pass to the ActionListener

invokeLater

public static void invokeLater(java.lang.Runnable r)
Queues the invocation of the specified Runnable on the EventQueue

Parameters:
r - The Runnable to execute

invokeAndWait

public static void invokeAndWait(java.lang.Runnable r)
                          throws java.lang.InterruptedException,
                                 java.lang.reflect.InvocationTargetException
Queues the invocation of the specified Runnable on the EventQueue, and waits for the EventQueue thread to complete execution of the specified Runnable.

Parameters:
r - The Runnable to execute
Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

invokeLater

public void invokeLater()
Queues the invocation of this MethodAction on the EventQueue


invokeAndWait

public void invokeAndWait()
                   throws java.lang.InterruptedException,
                          java.lang.reflect.InvocationTargetException
Queues the invocation of this MethodAction on the EventQueue, and waits for the EventQueue

Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

run

public void run()
Runs this MethodAction now

Specified by:
run in interface java.lang.Runnable

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
ActionListener interface execution

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ae - The ActionEvent

isDispatchThread

public static boolean isDispatchThread()
Returns true if the calling Thread is the event dispatch thread

Returns:
True if the calling Thread is the event dispatch thread

newInstance

public static java.lang.Object newInstance(java.lang.String className)
                                    throws java.lang.NoSuchMethodException,
                                           java.lang.ClassNotFoundException,
                                           java.lang.InstantiationException,
                                           java.lang.IllegalAccessException
Create a new instance of the specified class name

Parameters:
className - The class name to instantiate
Returns:
The new instance of the specified class name
Throws:
java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

test

public static int test(java.lang.String m,
                       int x)
Command-line test method

Parameters:
m - A String
x - An int
Returns:
An int

main

public static void main(java.lang.String[] argv)
Command-line test/debug

Parameters:
argv - The command-line args