|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.functions.AbstractFunction<Object>
org.mmbase.util.functions.BeanFunction
public class BeanFunction
One or more functions based on a Java-bean. Every setter method of the bean corresponds with one
parameter. The default value of the parameter can be defined with the getter method (which will
be called immediately after instantiation of such a Class). So the setters/getters define Parameters. More specific DataTypes can be attributes to such
parameters using the Type annotation.
All other methods (with no arguments) of the class correspond to the functions. So, you can implement more bean-functions in the same class, as long as they have the same parameters.
A BeanFunction can be aquired via FunctionFactory.getFunction(Class, String) (which
delegates to a static method in this class).
MethodFunction,
FunctionFactory,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
BeanFunction.Producer
A producer can instantiate beans |
| Field Summary | |
|---|---|
static Pattern |
NCName
|
| Fields inherited from class org.mmbase.util.functions.AbstractFunction |
|---|
autoReturnType, name, returnType |
| Constructor Summary | |
|---|---|
BeanFunction(Object bean,
String name)
|
|
| Method Summary | ||
|---|---|---|
static Class |
getClass(Class claz,
String name)
Utility function, searches an inner class of a given class. |
|
static DataType |
getDataType(String value,
BasicDataType base)
Given a string and a 'base' datatype, produces a new DataType. |
|
static BeanFunction |
getFunction(Class claz,
String name)
This defaulting version of getFunction(Class, String, Producer) uses a producer that uses Class.newInstance(). |
|
static BeanFunction |
getFunction(Class claz,
String name,
BeanFunction.Producer producer)
Gives back a Function object based on the 'bean' concept. |
|
Object |
getFunctionValue(Parameters parameters)
Executes the defined function supplying the given arguments. |
|
static
|
getInstance(Class<C> claz,
Object constructorArgument)
Utitily function to create an instance of a certain class. |
|
static Parameter<?>[] |
getParameterDefinition(Object sampleInstance,
List<Method> setMethods)
|
|
BeanFunction.Producer |
getProducer()
|
|
static void |
main(String[] argv)
|
|
static void |
setParameters(Object b,
Parameters parameters,
List<Method> setMethods)
|
|
| Methods inherited from class org.mmbase.util.functions.AbstractFunction |
|---|
compareTo, createParameters, equals, getDescription, getFunctionValueWithArgs, getFunctionValueWithList, getName, getParameterDefinition, getReturnType, hashCode, setDescription, setParameterDefinition, setReturnType, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Pattern NCName
| Constructor Detail |
|---|
public BeanFunction(Object bean,
String name)
throws IllegalAccessException,
InstantiationException,
InvocationTargetException,
DependencyException
IllegalAccessException
InstantiationException
InvocationTargetException
DependencyException| Method Detail |
|---|
public static Class getClass(Class claz,
String name)
claz - The class to be consideredname - The name of the inner class
IllegalArgumentException - if claz has no inner class with that name
public static BeanFunction getFunction(Class claz,
String name,
BeanFunction.Producer producer)
throws IllegalAccessException,
InstantiationException,
InvocationTargetException,
DependencyException
claz - The class which must be considered a 'bean' functionname - The name of the function (the name of a Method in the given class)producer - An object that can produce in instance of the class
claz. Defaults to a producer that simply calls Class.newInstance().
IllegalAccessException
InstantiationException
InvocationTargetException
DependencyException
public static BeanFunction getFunction(Class claz,
String name)
throws IllegalAccessException,
InstantiationException,
InvocationTargetException,
DependencyException
getFunction(Class, String, Producer) uses a producer that uses Class.newInstance().
Called from FunctionFactory
IllegalAccessException
InstantiationException
InvocationTargetException
DependencyException
public static <C> C getInstance(Class<C> claz,
Object constructorArgument)
throws IllegalAccessException,
InstantiationException,
InvocationTargetException
IllegalAccessException
InstantiationException
InvocationTargetException
public static Parameter<?>[] getParameterDefinition(Object sampleInstance,
List<Method> setMethods)
throws IllegalAccessException,
InvocationTargetException,
DependencyException
IllegalAccessException
InvocationTargetException
DependencyException
public static void setParameters(Object b,
Parameters parameters,
List<Method> setMethods)
throws IllegalAccessException,
InvocationTargetException
b - The 'bean' on which the setter methods must be invokedparameters - The object containing the parameter valuessetMethods - The setter methods
IllegalAccessException
InvocationTargetException
public static DataType getDataType(String value,
BasicDataType base)
throws DependencyException
DataType. If the string matches
NCName then the datatype is looked up in the MMBase DataType repository at DataTypes.getDataType(java.lang.String). Otherwise the String is interpreted as a piece
of XML.
DependencyExceptionpublic BeanFunction.Producer getProducer()
public Object getFunctionValue(Parameters parameters)
getFunctionValue in interface Function<Object>getFunctionValue in class AbstractFunction<Object>parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.
Implementors are encouraged to support null too.
AbstractFunction.getReturnType()AbstractFunction.createParameters()
public static void main(String[] argv)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||