|
||||||||||
| 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
info.javelot.functionalj.MethodFunction
Represents a function that targets a method by name, either a static method
(StaticFunction) or an instance method (InstanceFunction). In the
latter case, an object is required on which to invoke the method.
Name matching:
Method names are matched either exactly or by interpreting the name as a
property and matching on the corresponding getter and setter methods. Thus, for
the name "person", besides exact matches, the methods named
"getPerson", "isPerson" and "setPerson"
will also be considered matches. Exact matches have priority in the list of
possible targets.
| Field Summary |
| Fields inherited from class info.javelot.functionalj.Function |
m_class, m_name, m_object, m_parameters, m_targets |
| Constructor Summary | |
protected |
MethodFunction()
Default constructor which is only used by ComposedFunction. |
protected |
MethodFunction(Class p_class,
String p_name)
Creates a function that targets the methods of the given class which match the given name. |
protected |
MethodFunction(Class p_class,
String p_name,
Object[] p_parameters)
Creates a function that targets the methods of the given class which match the given name and parameters. |
protected |
MethodFunction(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
Creates a function that targets the methods of the given class which match the given name and parameters, to be invoked on the given object. |
| Method Summary | |
protected Object[] |
getAllTargets(Class p_class)
Returns the methods of the target class and its superclasses. |
protected int |
getInsertIndex(Object p_target)
Determines if the given method's name matches the target name, and returns the index at which to insert the method accordingly. |
protected Class[] |
getParameterTypes(Object p_target)
Returns the types of the parameters accepted by the method. |
protected Object |
invoke(Object p_target,
Object p_object,
Object[] p_parameters)
Invokes the Method.invoke(Object,Object[]) method
using the supplied object, which may be null in the case of a
static method, and the supplied parameters. |
| Methods inherited from class info.javelot.functionalj.ReflectionFunction |
call |
| 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 MethodFunction()
ComposedFunction.
protected MethodFunction(Class p_class,
String p_name)
throws FunctionException
p_class - the class of the target.p_name - the name to match, either exactly or by interpreting the name as
a property and matching on the corresponding getter and setter methods.
FunctionException - thrown if no methods of the target class match
the given name.
protected MethodFunction(Class p_class,
String p_name,
Object[] p_parameters)
p_class - the class of the target.p_name - the name to match, either exactly or by interpreting the name as
a property and matching on the corresponding getter and setter methods.p_parameters - the parameters to be supplied to the method.
FunctionException - thrown if no methods of the target class match
the given name and parameters.
protected MethodFunction(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
InstanceFunction only.
p_class - the class of the target.p_name - the name to match, either exactly or by interpreting the name as
a property and matching on the corresponding getter and setter methods.p_parameters - the parameters to be supplied to the method.
FunctionException - thrown if no methods of the target class match
the given name and parameters.| Method Detail |
protected Object[] getAllTargets(Class p_class)
getAllTargets in class ReflectionFunctionp_class - the target class.
protected Class[] getParameterTypes(Object p_target)
getParameterTypes in class ReflectionFunctionp_target - the target method for which to determine the types of the
parameters.
protected int getInsertIndex(Object p_target)
getInsertIndex in class ReflectionFunctionp_target - the method for which to obtain the index.
0 in the case of an exact match; the end of the list in the case
of a match on a getter or setter; or -1 if the method's name does
not match the target name.
protected Object invoke(Object p_target,
Object p_object,
Object[] p_parameters)
throws FunctionException
Method.invoke(Object,Object[]) method
using the supplied object, which may be null in the case of a
static method, and the supplied parameters.
invoke in class ReflectionFunctionp_target - the target method to invoke.p_object - the object on which to invoke the method, or null
if the target method is static.p_parameters - the parameters to pass to the method.
FunctionException - thrown if an exception occurs when invoking the
method.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||