org.mmbase.util.functions
Class NodeFunction

java.lang.Object
  extended byorg.mmbase.util.functions.AbstractFunction
      extended byorg.mmbase.util.functions.NodeFunction
All Implemented Interfaces:
Comparable, Function, Serializable
Direct Known Subclasses:
PatternNodeFunctionProvider.PatternNodeFunction

public abstract class NodeFunction
extends AbstractFunction

A NodeFunction represents a function on a node instances of this builder. This means that it always has one implicit node argument. This node-argument needs not be mentioned in the Parameter array of the constructor.

Since:
MMBase-1.8
Version:
$Id: NodeFunction.java,v 1.21 2006/03/02 17:25:13 michiel Exp $
Author:
Michiel Meeuwissen
See Also:
MMObjectBuilder.executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List), Node.getFunctionValue(java.lang.String, java.util.List), BeanFunction, Serialized Form

Field Summary
 
Fields inherited from class org.mmbase.util.functions.AbstractFunction
name, returnType
 
Constructor Summary
NodeFunction(String name, Parameter[] def, ReturnType returnType)
           
 
Method Summary
protected  MMObjectNode getCoreNode(MMObjectBuilder builder, Node node)
          Utility method to convert a Node to a a MMObjectNode.
static String getFunctionNameAndFillArgs(String function, List args)
           
protected  Object getFunctionValue(MMObjectNode coreNode, Parameters parameters)
          Implements the function on a certain node.
protected abstract  Object getFunctionValue(Node node, Parameters parameters)
           
static FieldValue getFunctionValue(Node node, String function)
          Utility function, for easy call of function on node by one string.
 Object getFunctionValue(Parameters parameters)
          To implement a NodeFunction, you must override getFunctionValue(Node, Parameters).
protected  Node getNode(Parameters parameters)
           
protected static Parameter[] getNodeParameterDef(Parameter[] def)
           
 Function newInstance(MMObjectNode node)
          Returns a new instance of NodeInstanceFunction, which represents an actual Function.
 
Methods inherited from class org.mmbase.util.functions.AbstractFunction
compareTo, createParameters, equals, getDescription, getFunctionValueWithList, getName, getParameterDefinition, getReturnType, hashCode, setDescription, setParameterDefinition, setReturnType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeFunction

public NodeFunction(String name,
                    Parameter[] def,
                    ReturnType returnType)
Method Detail

getFunctionValue

public static FieldValue getFunctionValue(Node node,
                                          String function)
Utility function, for easy call of function on node by one string.


getFunctionNameAndFillArgs

public static String getFunctionNameAndFillArgs(String function,
                                                List args)

getNodeParameterDef

protected static Parameter[] getNodeParameterDef(Parameter[] def)

newInstance

public final Function newInstance(MMObjectNode node)
Returns a new instance of NodeInstanceFunction, which represents an actual Function.


getFunctionValue

protected final Object getFunctionValue(MMObjectNode coreNode,
                                        Parameters parameters)
Implements the function on a certain node. Override this method or it's bridge counter-part getFunctionValue(org.mmbase.bridge.Node, Parameters). Overriding the bridge version has two advantages. It's easier, and mmbase security will be honoured. That last thing is of course not necesary if you are not going to use other nodes. XXX: made final because it does not work well if you don't implement a bridge version


getCoreNode

protected final MMObjectNode getCoreNode(MMObjectBuilder builder,
                                         Node node)
Utility method to convert a Node to a a MMObjectNode.


getFunctionValue

protected abstract Object getFunctionValue(Node node,
                                           Parameters parameters)

getNode

protected Node getNode(Parameters parameters)

getFunctionValue

public Object getFunctionValue(Parameters parameters)
To implement a NodeFunction, you must override getFunctionValue(Node, Parameters). This one can be overriden if the same function must also be a builder function.

Specified by:
getFunctionValue in interface Function
Specified by:
getFunctionValue in class AbstractFunction
Parameters:
parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID. Implementors are encouraged to support null too.
Returns:
The function value, which can be of any type compatible to AbstractFunction.getReturnType()
See Also:
AbstractFunction.createParameters()


MMBase build 1.8.1.20060716