org.geotools.filter
Class FunctionImpl

Object
  extended by ExpressionAbstract
      extended by FunctionImpl
All Implemented Interfaces:
Expression, Function
Direct Known Subclasses:
ConcatenateFunction, InternalVolatileFunction, StringInFunction

public class FunctionImpl
extends ExpressionAbstract
implements Function

Default implementation of a Function; you may extend this class to implement specific functionality.

Author:
Cory Horner, Refractions Research

Field Summary
protected  FunctionName functionName
          FunctionName description for FilterCapabilities, may be provided by subclass in constructor, or will be lazily created based on name and number of arguments.
 
Fields inherited from interface Expression
NIL
 
Constructor Summary
FunctionImpl()
           
 
Method Summary
 Object accept(ExpressionVisitor visitor, Object extraData)
          Accepts a visitor.
protected  LinkedHashMap<String,Object> dispatchArguments(Object obj)
          Gathers up and groups the parameters to the function based on the declared parameters.
 Object evaluate(Object object)
          Default implementation simply returns the fallbackValue.
protected static FunctionName functionName(String name, String ret, String... args)
          Convenience method for creating a function name from a set of strings describing the return and argument parameters of the function.
 Literal getFallbackValue()
          The value of the fallbackValue attribute is used as a default value, if the SE implementation does not support the function.
 FunctionName getFunctionName()
          Access to the FunctionName description as used in a FilterCapabilities document.
 String getName()
          Gets the name of this function.
 List<Expression> getParameters()
          Returns the function parameters.
 void setFallbackValue(Literal fallbackValue)
           
 void setName(String name)
          Sets the name of the function.
 void setParameters(List<Expression> params)
          Sets the function parameters.
 
Methods inherited from class ExpressionAbstract
eval, eval, evaluate
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Expression
evaluate
 

Field Detail

functionName

protected FunctionName functionName
FunctionName description for FilterCapabilities, may be provided by subclass in constructor, or will be lazily created based on name and number of arguments.

Constructor Detail

FunctionImpl

public FunctionImpl()
Method Detail

getName

public String getName()
Gets the name of this function.

Specified by:
getName in interface Function
Returns:
the name of the function.

getFunctionName

public FunctionName getFunctionName()
Description copied from interface: Function
Access to the FunctionName description as used in a FilterCapabilities document.

Specified by:
getFunctionName in interface Function
Returns:
FunctionName description, if available.

setName

public void setName(String name)
Sets the name of the function.


getParameters

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

Specified by:
getParameters in interface Function

evaluate

public Object evaluate(Object object)
Default implementation simply returns the fallbackValue.

Please override this method to produce a value based on the provided arguments.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class ExpressionAbstract
Parameters:
object - Object being evaluated; often a Feature
Returns:
value for the provided object

setParameters

public void setParameters(List<Expression> params)
Sets the function parameters.


setFallbackValue

public void setFallbackValue(Literal fallbackValue)

getFallbackValue

public Literal getFallbackValue()
Description copied from interface: Function
The value of the fallbackValue attribute is used as a default value, if the SE implementation does not support the function. If the implementation supports the function, then the result value is determined by executing the function.

Specified by:
getFallbackValue in interface Function
Returns:
Optional literal to use if an implementation for this function is not available.

accept

public Object accept(ExpressionVisitor visitor,
                     Object extraData)
Description copied from interface: Expression
Accepts a visitor. Subclasses must implement with a method whose content is the following:
return visitor.visit(this, extraData);

Specified by:
accept in interface Expression

dispatchArguments

protected LinkedHashMap<String,Object> dispatchArguments(Object obj)
Gathers up and groups the parameters to the function based on the declared parameters.

This method calls validateArguments() which enforces java style argument conventions for multi valued parameters. Basically enforcing that only teh last argument in a function can be variable.


functionName

protected static FunctionName functionName(String name,
                                           String ret,
                                           String... args)
Convenience method for creating a function name from a set of strings describing the return and argument parameters of the function.

The value of ret and each value of args is a string of the following structure:

  name[:type[:min,max]]
 
Where: Examples: The type parameter may be specified relative to the following well known packages: Otherwise it must be specified as a full qualified class name.

Parameters:
name - The name of the function
ret - The parameter specification of the return of the function
args - The argument specifications of the function arguments


Copyright © 1996-2014 Geotools. All Rights Reserved.