info.javelot.functionalj
Class FunctionN

java.lang.Object
  extended byinfo.javelot.functionalj.Function
      extended byinfo.javelot.functionalj.FunctionN
All Implemented Interfaces:
Serializable

public class FunctionN
extends Function

Represents a function of N parameters, which is constructed by specifying an implementation of the IFunctionN interface. This is useful to specify a function directly rather than using reflection. If, on the other hand, you want to create a function without having to implement an interface, use a subclass of ReflectionFunction instead.

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
FunctionN(IFunctionN p_iFunctionN)
          Creates a function of N parameters which uses the specified implementation of the function interface.
FunctionN(IFunctionN p_iFunctionN, Object[] p_parameters)
          Creates a function of N parameters which uses the specified implementation of the function interface and the given 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.
 boolean isObjectRequired()
          Returns false since an object is not required to invoke the method.
protected  Function newInstance(Class p_class, Object[] p_parameters)
          Creates a new FunctionN object using the specified parameters.
 Function object(Object p_object)
          Throws a FunctionException, since no object is required to invoke a method that is wrapped using an interface.
 
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

FunctionN

public FunctionN(IFunctionN p_iFunctionN)
Creates a function of N parameters which uses the specified implementation of the function interface. After using this constructor the function does not yet have any parameters.

Parameters:
p_iFunctionN - the implementation of IFunctionN which defines the function.

FunctionN

public FunctionN(IFunctionN p_iFunctionN,
                 Object[] p_parameters)
Creates a function of N parameters which uses the specified implementation of the function interface and the given parameters.

Parameters:
p_iFunctionN - the implementation of IFunctionN which defines the function.
p_parameters - the parameters to the function.
Method Detail

isObjectRequired

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

Specified by:
isObjectRequired in class Function
Returns:
false.

newInstance

protected Function newInstance(Class p_class,
                               Object[] p_parameters)
Creates a new FunctionN object using the specified parameters. In this case the target class is not used.

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

object

public Function object(Object p_object)
                throws FunctionException
Throws a FunctionException, since no object is required to invoke a method that is wrapped using an interface.

Specified by:
object in class Function
Throws:
FunctionException - always thrown since invoking this method is not applicable to instances of the FunctionN class.

call

public Object call()
            throws FunctionException
Calls the function by invoking the target using the parameters that have been previously supplied (if any) and returns the result. If an exception is thrown by the target call, it is wrapped into a FunctionException.

Specified by:
call in class Function
Throws:
FunctionException - thrown if an exception occurs when invoking the target.