|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.javelot.functionalj.Function
Base class for working with functions, which target constructors, static methods and instance methods.
| Field Summary | |
protected Class |
m_class
The class of the target of this function. |
protected String |
m_name
The name of the target, if applicable. |
protected Object |
m_object
The object on which to invoke the target, if applicable. |
protected Object[] |
m_parameters
The list of supplied parameters. |
protected List |
m_targets
The list of possible targets. |
| Constructor Summary | |
protected |
Function()
Default constructor. |
protected |
Function(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
Constructor which accepts the target class, function name, target object, and parameters of the function. |
| Method Summary | |
Function |
addParameter(Object p_parameter)
Convenience method that calls addParameters(Object[]), creating an
array containing the specified parameter. |
Function |
addParameters(List p_parameters)
Creates a new function object that contains the previously added parameters, if any, and the given parameters appended to the list, by converting the list to an array and calling addParameters(Object[]). |
Function |
addParameters(Object[] p_parameters)
Creates a new function object that contains the previously added parameters, if any, and the given parameters appended to the list. |
Function |
addParameters(Object p_parameter1,
Object p_parameter2)
Convenience method that calls addParameters(Object[]), creating an
array containing the specified parameters. |
Function |
addParameters(Object p_parameter1,
Object p_parameter2,
Object p_parameter3)
Convenience method that calls addParameters(Object[]), creating an
array containing the specified parameters. |
Function |
addParameters(Object p_parameter1,
Object p_parameter2,
Object p_parameter3,
Object p_parameter4)
Convenience method that calls addParameters(Object[]), creating an
array containing the specified parameters. |
abstract Object |
call()
Calls the function by invoking the target using the parameters that have been previously supplied (if any) and returns the result. |
String |
getName()
Returns the name of the target of this function. |
Object |
getObject()
Returns the object on which to invoke the target of this function. |
Object[] |
getParameters()
Returns the list of parameters that have been supplied, if any. |
Class |
getTargetClass()
Returns the class of the target of this function. |
List |
getTargets()
Returns the list of possible targets of this function. |
boolean |
isObjectPresent()
Indicates if an object has been supplied to the function. |
abstract boolean |
isObjectRequired()
Indicates whether or not an object is required to invoke the target. |
protected abstract Function |
newInstance(Class p_class,
Object[] p_parameters)
Used to ask subclasses to create an appropriate new instance. |
abstract Function |
object(Object p_object)
Supplies the object to use for instance methods. |
Function |
objectOrParameter(Object p_object)
Accepts the specified object and uses it as the object on which to invoke the target, if one is required and has not yet been specified; otherwise, the object is used as a parameter supplied to the function. |
String |
toString()
Returns a String representation of this Function object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Class m_class
protected String m_name
protected Object m_object
protected Object[] m_parameters
protected List m_targets
| Constructor Detail |
protected Function()
protected Function(Class p_class,
String p_name,
Object p_object,
Object[] p_parameters)
throws FunctionException
p_class - the class of the target of this function.p_name - the name of the target. When the target is a method, this name
is required. When the target is a constructor, this name is null.p_object - if the target is an instance method, this is the object on
which to invoke the method.p_parameters - the parameters, if any, to use when invoking the target.
FunctionException - thrown if the class parameter is null, or if no
possibly matching targets are found.| Method Detail |
public abstract boolean isObjectRequired()
true if an object is required to invoke the target,
false otherwise.
protected abstract Function newInstance(Class p_class,
Object[] p_parameters)
p_class - the class of the target.p_parameters - the parameters that have been supplied.
public abstract Function object(Object p_object)
throws FunctionException
InstanceFunction class. For other subclasses, a FunctionException is
thrown.
FunctionException
public Function addParameter(Object p_parameter)
throws FunctionException
addParameters(Object[]), creating an
array containing the specified parameter.
FunctionExceptionaddParameters(Object[]).
public Function addParameters(Object p_parameter1,
Object p_parameter2)
throws FunctionException
addParameters(Object[]), creating an
array containing the specified parameters.
FunctionExceptionaddParameters(Object[]).
public Function addParameters(Object p_parameter1,
Object p_parameter2,
Object p_parameter3)
throws FunctionException
addParameters(Object[]), creating an
array containing the specified parameters.
FunctionExceptionaddParameters(Object[]).
public Function addParameters(Object p_parameter1,
Object p_parameter2,
Object p_parameter3,
Object p_parameter4)
throws FunctionException
addParameters(Object[]), creating an
array containing the specified parameters.
FunctionExceptionaddParameters(Object[]).
public Function addParameters(Object[] p_parameters)
throws FunctionException
p_parameters - the parameters to be added to the list of parameters that
are supplied to the function.
FunctionException - thrown if the additional parameters cause the
list of supplied parameters not to match any of the possible targets.
public Function addParameters(List p_parameters)
throws FunctionException
addParameters(Object[]). Note that to add a
single parameter of type List, addParameter(Object)
should be used.
FunctionExceptionaddParameters(Object[]).
public abstract Object call()
throws FunctionException
FunctionException.
FunctionException - 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.public Class getTargetClass()
public String getName()
null if not
applicable.public Object getObject()
null if not applicable.public Object[] getParameters()
null.public List getTargets()
Function object cannot exist without
at least one possible target.public boolean isObjectPresent()
InstanceFunction only.
true if this function requires an object on which to
invoke the target and that object has been supplied, false
otherwise.public Function objectOrParameter(Object p_object)
p_object - the object to be used as an object on which to invoke the
target or as a parameter.
Function that results from adding the specified
object.public String toString()
Function object.
Function object,
containing all pertinent information (class, name, object, parameters, and
list of possible targets).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||