|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.javelot.functionalj.Function
info.javelot.functionalj.ReflectionFunction
Represents a function that uses reflection. If you do not want to use reflection,
you can implement the IFunctionN interface and use FunctionN to
create a function object that uses your implementation.
| Field Summary |
| Fields inherited from class info.javelot.functionalj.Function |
m_class, m_name, m_object, m_parameters, m_targets |
| Constructor Summary | |
protected |
ReflectionFunction()
Default constructor. |
protected |
ReflectionFunction(Class p_class)
Constructor used by ConstructorFunction, since no name is required. |
protected |
ReflectionFunction(Class p_class,
Object[] p_parameters)
Constructor used by ConstructorFunction, since no name is required. |
protected |
ReflectionFunction(Class p_class,
String p_name)
Constructor used by MethodFunction, since a name is required. |
protected |
ReflectionFunction(Class p_class,
String p_name,
Object[] p_parameters)
Constructor used by MethodFunction, since a name is required. |
protected |
ReflectionFunction(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
Creates a function that uses reflection to target the method of the name and class, to be invoked on the given object (if applicable), with the specified parameters. |
| Method Summary | |
Object |
call()
Calls the function by invoking the target using the parameters that have been previously supplied (if any) and returns the result. |
protected abstract Object[] |
getAllTargets(Class p_class)
Method for subclasses to specify the targets of the class, which are constructors or methods. |
protected abstract int |
getInsertIndex(Object p_target)
Method for subclasses to specify the index at which to insert the target into the list of possible targets, according to priority. |
protected abstract Class[] |
getParameterTypes(Object p_target)
Method for subclasses to specify the parameter types of the target, which can be a constructor or a method. |
protected abstract Object |
invoke(Object p_target,
Object p_object,
Object[] p_parameters)
Method to indicate to subclasses to invoke the given target, on the given object (if applicable), and with the given parameters. |
| Methods inherited from class info.javelot.functionalj.Function |
addParameter, addParameters, addParameters, addParameters, addParameters, addParameters, getName, getObject, getParameters, getTargetClass, getTargets, isObjectPresent, isObjectRequired, newInstance, object, objectOrParameter, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected ReflectionFunction()
protected ReflectionFunction(Class p_class)
throws FunctionException
ConstructorFunction, since no name is required.
See {#ReflectionFunction(Class,String,Object,Object[]) for more information.
ReflectionFunction(Class,String,Object,Object[]).
protected ReflectionFunction(Class p_class,
Object[] p_parameters)
throws FunctionException
ConstructorFunction, since no name is required.
See {#ReflectionFunction(Class,String,Object,Object[]) for more information.
ReflectionFunction(Class,String,Object,Object[]).
protected ReflectionFunction(Class p_class,
String p_name)
throws FunctionException
MethodFunction, since a name is required.
See {#ReflectionFunction(Class,String,Object,Object[]) for more information.
ReflectionFunction(Class,String,Object,Object[]).
protected ReflectionFunction(Class p_class,
String p_name,
Object[] p_parameters)
throws FunctionException
MethodFunction, since a name is required.
See {#ReflectionFunction(Class,String,Object,Object[]) for more information.
ReflectionFunction(Class,String,Object,Object[]).
protected ReflectionFunction(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
throws FunctionException
p_class - the target class of the function.p_name - the name of the method to be invoked on the target class.p_object - the object on which to invoke the method, in the case of an
InstanceFunction.p_parameters - the method parameters.
FunctionException - thrown if no possible target methods satisfying
the given conditions were found.| Method Detail |
protected abstract int getInsertIndex(Object p_target)
p_target - the constructor or method for which to obtain the index.
-1 if the target is not to be inserted into the list.protected abstract Object[] getAllTargets(Class p_class)
p_class - the class for which to specify the targets.protected abstract Class[] getParameterTypes(Object p_target)
Constructor and
Method have a getParameterTypes()
method, but this method is not present in their common parent, AccessibleObject.
p_target - the constructor or method for which to obtain the parameter
types.
protected abstract Object invoke(Object p_target,
Object p_object,
Object[] p_parameters)
throws FunctionException
p_target - the target to invoke.p_object - the object on which to invoke the target, if applicable.p_parameters - the parameters to use when invoking the target.
FunctionException - thrown if an exception occurs when invoking the
target.
public Object call()
throws FunctionException
FunctionException.
call in class FunctionFunctionException - thrown if an exception occurs when invoking the
target, if an object on which to invoke the target is required but none has
been supplied, or if all of the potential targets expect more parameters than
have been supplied.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||