info.javelot.functionalj
Class InstanceFunction

java.lang.Object
  extended byinfo.javelot.functionalj.Function
      extended byinfo.javelot.functionalj.ReflectionFunction
          extended byinfo.javelot.functionalj.MethodFunction
              extended byinfo.javelot.functionalj.InstanceFunction
All Implemented Interfaces:
Serializable

public class InstanceFunction
extends MethodFunction

Represents a function that targets an instance method. See MethodFunction for information on how method names are matched.

Author:
Copyright © 2006 Frederic Daoud
See Also:
Serialized Form

Field Summary
 
Fields inherited from class info.javelot.functionalj.Function
m_class, m_name, m_object, m_parameters, m_targets
 
Constructor Summary
InstanceFunction(Class p_class, String p_name)
          Creates a function that targets the instance methods of the given class which match the given name.
InstanceFunction(Class p_class, String p_name, Object p_object)
          Creates a function that targets the instance methods of the given class which match the given name, to be invoked on the given object.
InstanceFunction(Class p_class, String p_name, Object[] p_parameters)
          Creates a function that targets the instance methods of the given class which match the given name, with the given parameters.
InstanceFunction(Class p_class, String p_name, Object p_object, Object[] p_parameters)
          Creates a function that targets the instance methods of the given class which match the given name, to be invoked on the given object, with the supplied parameters; this is the constructor that is ultimately called by all other constructors.
InstanceFunction(Object p_object, String p_name)
          Convenience constructor that accepts the given object on which to invoke the method of the specified name, determining the target class from the target object and using the InstanceFunction(Class,String,Object) constructor.
InstanceFunction(Object p_object, String p_name, Object[] p_parameters)
          Convenience constructor that accepts the given object on which to invoke the method of the specified name, with the supplied parameters, determining the target class from the target object and using the InstanceFunction(Class,String,Object,Object[]) constructor.
 
Method Summary
 boolean isObjectRequired()
          Returns true since an object is required to invoke the method.
protected  Function newInstance(Class p_class, Object[] p_parameters)
          Creates a new InstanceFunction object using the specified target class and parameters, and using the object on which to invoke the target, if one was previously supplied.
 Function object(Object p_object)
          Supplies the object on which to invoke the method, and returns a new InstanceFunction which includes this object.
 
Methods inherited from class info.javelot.functionalj.MethodFunction
getAllTargets, getInsertIndex, getParameterTypes, invoke
 
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, objectOrParameter, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InstanceFunction

public InstanceFunction(Class p_class,
                        String p_name)
Creates a function that targets the instance methods of the given class which match the given name. See InstanceFunction(Class,String,Object,Object[]) for more details.

See Also:
InstanceFunction(Class,String,Object,Object[])

InstanceFunction

public InstanceFunction(Class p_class,
                        String p_name,
                        Object p_object)
                 throws FunctionException
Creates a function that targets the instance methods of the given class which match the given name, to be invoked on the given object. See InstanceFunction(Class,String,Object,Object[]) for more details.

See Also:
InstanceFunction(Class,String,Object,Object[])

InstanceFunction

public InstanceFunction(Class p_class,
                        String p_name,
                        Object[] p_parameters)
Creates a function that targets the instance methods of the given class which match the given name, with the given parameters. See InstanceFunction(Class,String,Object,Object[]) for more details.

See Also:
InstanceFunction(Class,String,Object,Object[])

InstanceFunction

public InstanceFunction(Class p_class,
                        String p_name,
                        Object p_object,
                        Object[] p_parameters)
Creates a function that targets the instance methods of the given class which match the given name, to be invoked on the given object, with the supplied parameters; this is the constructor that is ultimately called by all other constructors.

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_object - the object on which to invoke the method.
p_parameters - the parameters to be supplied to the method.
Throws:
FunctionException - thrown if no methods of the target class match the given name.

InstanceFunction

public InstanceFunction(Object p_object,
                        String p_name)
Convenience constructor that accepts the given object on which to invoke the method of the specified name, determining the target class from the target object and using the InstanceFunction(Class,String,Object) constructor.

Thanks to Jean Safar for suggesting this.

See Also:
InstanceFunction(Class,String,Object).

InstanceFunction

public InstanceFunction(Object p_object,
                        String p_name,
                        Object[] p_parameters)
Convenience constructor that accepts the given object on which to invoke the method of the specified name, with the supplied parameters, determining the target class from the target object and using the InstanceFunction(Class,String,Object,Object[]) constructor.

Thanks to Jean Safar for suggesting this.

See Also:
InstanceFunction(Class,String,Object,Object[]).
Method Detail

isObjectRequired

public boolean isObjectRequired()
Returns true since an object is required to invoke the method.

Specified by:
isObjectRequired in class Function
Returns:
true.

newInstance

protected Function newInstance(Class p_class,
                               Object[] p_parameters)
Creates a new InstanceFunction object using the specified target class and parameters, and using the object on which to invoke the target, if one was previously supplied.

Specified by:
newInstance in class Function
Parameters:
p_class - the class of the target.
p_parameters - the supplied parameters.
Returns:
a new InstanceFunction object of the target class, containing the supplied parameters.

object

public Function object(Object p_object)
                throws FunctionException
Supplies the object on which to invoke the method, and returns a new InstanceFunction which includes this object.

Specified by:
object in class Function
Parameters:
p_object - the object on which to invoke the method.
Returns:
a new InstanceFunction which includes the supplied object on which to invoke the method.
Throws:
FunctionException - thrown if another object was already previously supplied, or if the class of supplied object is not compatible with the class of the target of the function.