org.deegree.filter.expression
Class Function

java.lang.Object
  extended by org.deegree.filter.expression.Function
All Implemented Interfaces:
Expression

public class Function
extends Object
implements Expression

Generic Function implementation that can be used to represent an arbitrary function, but that doesn't offer any evaluation capabilities (this is added by subclassing).

Version:
$Revision: $, $Date: $
Author:
Markus Schneider, last edited by: $Author: schneider $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.deegree.filter.Expression
Expression.Type
 
Constructor Summary
Function(String name, List<Expression> params)
          Creates a new Function instance.
 
Method Summary
 TypedObjectNode[] evaluate(List<TypedObjectNode[]> args)
          Evaluates the function for the given arguments (without a context object).
protected
<T> TypedObjectNode[]
evaluate(T obj, List<TypedObjectNode[]> args)
          Evaluates the function for the given arguments and context.
<T> TypedObjectNode[]
evaluate(T obj, XPathEvaluator<T> xpathEvaluator)
          Determines the values of the expression for the given context object.
 String getName()
          Returns the name of the function.
 List<Expression> getParameters()
          Returns the parameters of the function.
 Expression[] getParams()
          Returns the expression's paramters.
 Expression.Type getType()
          Always returns Expression.Type#FUNCTION.
 String toString(String indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Function

public Function(String name,
                List<Expression> params)
Creates a new Function instance.

Parameters:
name - name of the function, must not be null
params - parameters of the function, may be empty, but never null
Method Detail

getName

public String getName()
Returns the name of the function.

Returns:
the name of the function, never null

getType

public Expression.Type getType()
Always returns Expression.Type#FUNCTION.

Specified by:
getType in interface Expression
Returns:
Expression.Type#FUNCTION

getParameters

public List<Expression> getParameters()
Returns the parameters of the function.

Returns:
the parameters of the function, may be empty, but never null

evaluate

public TypedObjectNode[] evaluate(List<TypedObjectNode[]> args)
                           throws FilterEvaluationException
Evaluates the function for the given arguments (without a context object).

The double-dimension of input arguments is due to the fact that input arguments usually stem from XPath-evaluation performed on a TypedObjectNode (e.g. a Feature). Therefore, multiple values per input may occur. The outer list contains one entry per parameter, the inner array contain the values for each parameter. Depending on the type of function it may return multiple outputs as well.

Parameters:
args - input arguments, must match the parameter signature, can be empty, but never null
Returns:
output values, can be empty, but never null
Throws:
FilterEvaluationException

evaluate

protected <T> TypedObjectNode[] evaluate(T obj,
                                         List<TypedObjectNode[]> args)
                              throws FilterEvaluationException
Evaluates the function for the given arguments and context.

If the function requires information from the context object for performing the computation, this method must be overridden.

Parameters:
obj - context object, must not be null
args - input arguments, must match the parameter signature, can be empty, but never null
Returns:
output values, can be empty, but never null
Throws:
FilterEvaluationException

evaluate

public <T> TypedObjectNode[] evaluate(T obj,
                                      XPathEvaluator<T> xpathEvaluator)
                           throws FilterEvaluationException
Description copied from interface: Expression
Determines the values of the expression for the given context object.

Note that this returns an TypedObjectNode[], as an expression may evaluate to multiple values, e.g. a ValueReference that targets a multi property of a feature.

Specified by:
evaluate in interface Expression
Type Parameters:
T - type of the context object
Parameters:
obj - object that the expression is evaluated upon, must not be null
xpathEvaluator - used for evaluation of XPath expressions, must not be null
Returns:
the values of the expression, may be empty (and even contain null values), but never null
Throws:
FilterEvaluationException

toString

public String toString(String indent)
Specified by:
toString in interface Expression

getParams

public Expression[] getParams()
Description copied from interface: Expression
Returns the expression's paramters.

Specified by:
getParams in interface Expression
Returns:
the parameters of the expression


Copyright © 2011. All Rights Reserved.