|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.sns.tools.reflect.Selector
Selector is a convenience class that makes much of the Method class easier to use. Unlike Method, a Selector instance is not associated with a particular class. Binding happens upon invocation so the same selector can be used with many classes that do not necessarily share the same interface or superclasses. Also, Selector has convenience methods that allow fewer lines to be invoked. All exceptions are Runtime exceptions thus freeing the developer from having to deal with exceptions during rapid development. This class is intended to be used to handle group actions from a node perspective rather than a channel perspective. It can also be useful in creating powerful GUIs that allow users to script XAL.
| Nested Class Summary | |
class |
Selector.AccessException
Exception thrown when an attempt is made to invoke a method on a target such that the method is inaccessible on that target. |
class |
Selector.InvocationException
Exception that wraps an exception thrown during invocation. |
class |
Selector.MethodNotFoundException
Exception thrown when no method could be found matching a target to the method name and argument types. |
| Field Summary | |
protected java.lang.Class[] |
_argumentTypes
name of the method |
protected java.lang.String |
_methodName
|
| Constructor Summary | |
Selector(java.lang.String methodName)
Constructor for a method that takes no arguments |
|
Selector(java.lang.String methodName,
java.lang.Class argumentType)
Constructor for a method that takes a single argument |
|
Selector(java.lang.String methodName,
java.lang.Class[] argumentTypes)
Constructor for a method that takes multiple arguments |
|
| Method Summary | |
java.lang.Object |
invoke(java.lang.Object target)
Invoke a no argument method on the target |
java.lang.Object |
invoke(java.lang.Object target,
java.lang.Object argument)
Invoke a single argument method on the target. |
java.lang.Object |
invoke(java.lang.Object target,
java.lang.Object[] arguments)
Invoke a mulit-argument method on the target. |
static java.lang.Object |
invokeMethod(java.lang.String methodName,
java.lang.Class[] argumentTypes,
java.lang.Object target,
java.lang.Object[] arguments)
Invoke a multi-argument method on the target. |
static java.lang.Object |
invokeMethod(java.lang.String methodName,
java.lang.Class argumentType,
java.lang.Object target,
java.lang.Object argument)
Invoke a single argument method on the target. |
static java.lang.Object |
invokeMethod(java.lang.String methodName,
java.lang.Object target)
Invoke a no argument method on the target. |
boolean |
invokesOn(java.lang.Object target)
Test if the target will respond to the selector |
boolean |
invokesStaticOn(java.lang.Class targetClass)
Test if the target will respond to the selector |
java.lang.Object |
invokeStatic(java.lang.Class targetClass)
Invoke the appropriate static method on the specified class |
java.lang.Object |
invokeStatic(java.lang.Class targetClass,
java.lang.Object argument)
Invoke the appropriate static method on the specified class |
java.lang.Object |
invokeStatic(java.lang.Class targetClass,
java.lang.Object[] arguments)
Invoke the appropriate static method on the specified class |
static java.lang.Object |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class targetClass)
Invoke the static method with the specified arguments on the specified target class |
static java.lang.Object |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class[] argumentTypes,
java.lang.Class targetClass,
java.lang.Object[] arguments)
Invoke the static method with the specified arguments on the specified target class |
static java.lang.Object |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class argumentType,
java.lang.Class targetClass,
java.lang.Object argument)
Invoke the static method with the specified arguments on the specified target class |
java.lang.reflect.Method |
methodForClass(java.lang.Class targetClass)
Return a Method instance that binds the selector to a target class. |
java.lang.reflect.Method |
methodForObject(java.lang.Object target)
Return a Method instance that binds the selector to a target object. |
java.lang.String |
methodName()
Return the base name of the method |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.String _methodName
protected java.lang.Class[] _argumentTypes
| Constructor Detail |
public Selector(java.lang.String methodName)
public Selector(java.lang.String methodName,
java.lang.Class argumentType)
public Selector(java.lang.String methodName,
java.lang.Class[] argumentTypes)
| Method Detail |
public java.lang.String methodName()
public boolean invokesOn(java.lang.Object target)
public boolean invokesStaticOn(java.lang.Class targetClass)
public java.lang.Object invoke(java.lang.Object target)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.Object invoke(java.lang.Object target,
java.lang.Object argument)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.Object invoke(java.lang.Object target,
java.lang.Object[] arguments)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.Object invokeStatic(java.lang.Class targetClass)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.Object invokeStatic(java.lang.Class targetClass,
java.lang.Object argument)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.Object invokeStatic(java.lang.Class targetClass,
java.lang.Object[] arguments)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeMethod(java.lang.String methodName,
java.lang.Object target)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeMethod(java.lang.String methodName,
java.lang.Class argumentType,
java.lang.Object target,
java.lang.Object argument)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeMethod(java.lang.String methodName,
java.lang.Class[] argumentTypes,
java.lang.Object target,
java.lang.Object[] arguments)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeStaticMethod(java.lang.String methodName,
java.lang.Class[] argumentTypes,
java.lang.Class targetClass,
java.lang.Object[] arguments)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeStaticMethod(java.lang.String methodName,
java.lang.Class argumentType,
java.lang.Class targetClass,
java.lang.Object argument)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public static java.lang.Object invokeStaticMethod(java.lang.String methodName,
java.lang.Class targetClass)
throws java.lang.IllegalArgumentException,
Selector.AccessException,
Selector.InvocationException,
Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public java.lang.reflect.Method methodForClass(java.lang.Class targetClass)
throws Selector.MethodNotFoundException,
java.lang.SecurityException
Selector.MethodNotFoundException
java.lang.SecurityException
public java.lang.reflect.Method methodForObject(java.lang.Object target)
throws Selector.MethodNotFoundException,
java.lang.SecurityException
Selector.MethodNotFoundException
java.lang.SecurityException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||