|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.functions.AbstractFunction
An abstract representation of a piece of functionality (a 'function'). A function has a name, a
return type, and a parameter-definition (which is a Parameter array).
The goal of a Function object is to call its getFunctionValue(Parameters) method, which
executes it, given the specified parameters.
Parameter,
Parameters,
Serialized Form| Field Summary | |
protected String |
name
|
protected ReturnType |
returnType
|
| Constructor Summary | |
AbstractFunction(String name,
Parameter[] def,
ReturnType returnType)
Constructor for Function objects. |
|
| Method Summary | |
int |
compareTo(Object o)
|
Parameters |
createParameters()
Creates an empty 'Parameters' object for you, which you have to fill and feed back to getFunctionValue |
boolean |
equals(Object o)
|
String |
getDescription()
|
abstract Object |
getFunctionValue(Parameters parameters)
Executes the defined function supplying the given arguments. |
Object |
getFunctionValueWithList(List parameters)
Executes the defined function supplying the given List of arguments. |
String |
getName()
A function must have a name. |
Parameter[] |
getParameterDefinition()
|
ReturnType |
getReturnType()
|
int |
hashCode()
|
void |
setDescription(String description)
For documentational purposes a function object needs a description too. |
void |
setParameterDefinition(Parameter[] params)
A function object is of no use, as long as it lacks a definition. |
void |
setReturnType(ReturnType type)
Sets the ReturnType for this function if not set already. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected String name
protected ReturnType returnType
| Constructor Detail |
public AbstractFunction(String name,
Parameter[] def,
ReturnType returnType)
name - Every function must have a namedef - Every function must have a parameter definition. It can be left null and then filled later by setParameterDefinition(org.mmbase.util.functions.Parameter[])returnType - Every function must also specify its return type. It can be left null and then filled later by setReturnType(org.mmbase.util.functions.ReturnType)| Method Detail |
public Parameters createParameters()
createParameters in interface FunctiongetFunctionValue(Parameters)public abstract Object getFunctionValue(Parameters parameters)
getFunctionValue in interface Functionparameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.
Implementors are encouraged to support null too.
getReturnType()createParameters()public final Object getFunctionValueWithList(List parameters)
getFunctionValue(Parameters).
getFunctionValueWithList in interface Functionparameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.
getReturnType()public void setDescription(String description)
setDescription in interface Functionpublic String getDescription()
getDescription in interface FunctionsetDescription(String)public String getName()
getName in interface Functionnullpublic Parameter[] getParameterDefinition()
getParameterDefinition in interface Functionnull if not set already.public void setParameterDefinition(Parameter[] params)
setParameterDefinition in interface Functionparams - An array of Parameter objects.
IllegalStateException - if there was already set a parameter defintion for this function object.public ReturnType getReturnType()
getReturnType in interface Functionnull if not set already.public void setReturnType(ReturnType type)
setReturnType in interface Functiontype - A ReturnType object. For void functions that could be ReturnType.VOID.
IllegalStateException - if there was already set a return type for this function object.public int compareTo(Object o)
compareTo in interface Comparablepublic boolean equals(Object o)
public int hashCode()
Object.hashCode()public String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||