public class Selector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<?>[] |
_argumentTypes
argument classes
|
protected java.lang.String |
_methodName
name of the method
|
Constructor and Description |
---|
Selector(java.lang.String methodName,
java.lang.Class<?>... argumentTypes)
Constructor for a method that takes multiple arguments
|
Modifier and Type | Method and Description |
---|---|
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
|
<TargetType> |
invokesStaticOn(java.lang.Class<TargetType> targetClass)
Test if the target will respond to the selector
|
<TargetType> |
invokeStatic(java.lang.Class<TargetType> targetClass)
Invoke the appropriate static method on the specified class
|
<TargetType> |
invokeStatic(java.lang.Class<TargetType> targetClass,
java.lang.Object argument)
Invoke the appropriate static method on the specified class
|
<TargetType> |
invokeStatic(java.lang.Class<TargetType> targetClass,
java.lang.Object[] arguments)
Invoke the appropriate static method on the specified class
|
static <TargetType> |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class<?>[] argumentTypes,
java.lang.Class<TargetType> targetClass,
java.lang.Object[] arguments)
Invoke the static method with the specified arguments on the specified target class
|
static <TargetType> |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class<?> argumentType,
java.lang.Class<TargetType> targetClass,
java.lang.Object argument)
Invoke the static method with the specified arguments on the specified target class
|
static <TargetType> |
invokeStaticMethod(java.lang.String methodName,
java.lang.Class<TargetType> targetClass)
Invoke the static method with the specified arguments on the specified target class
|
<TargetType> |
methodForClass(java.lang.Class<TargetType> 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
|
protected java.lang.String _methodName
protected java.lang.Class<?>[] _argumentTypes
public Selector(java.lang.String methodName, java.lang.Class<?>... argumentTypes)
public java.lang.String methodName()
public boolean invokesOn(java.lang.Object target)
public <TargetType> boolean invokesStaticOn(java.lang.Class<TargetType> 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 <TargetType> java.lang.Object invokeStatic(java.lang.Class<TargetType> targetClass) throws java.lang.IllegalArgumentException, Selector.AccessException, Selector.InvocationException, Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public <TargetType> java.lang.Object invokeStatic(java.lang.Class<TargetType> 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 <TargetType> java.lang.Object invokeStatic(java.lang.Class<TargetType> 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 <TargetType> java.lang.Object invokeStaticMethod(java.lang.String methodName, java.lang.Class<?>[] argumentTypes, java.lang.Class<TargetType> 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 <TargetType> java.lang.Object invokeStaticMethod(java.lang.String methodName, java.lang.Class<?> argumentType, java.lang.Class<TargetType> 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 <TargetType> java.lang.Object invokeStaticMethod(java.lang.String methodName, java.lang.Class<TargetType> targetClass) throws java.lang.IllegalArgumentException, Selector.AccessException, Selector.InvocationException, Selector.MethodNotFoundException
java.lang.IllegalArgumentException
Selector.AccessException
Selector.InvocationException
Selector.MethodNotFoundException
public <TargetType> java.lang.reflect.Method methodForClass(java.lang.Class<TargetType> 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