2.17.2: 2011-06-17

net.sf.basedb.util.jep.convert
Class ASTFunNodeConverter

java.lang.Object
  extended by net.sf.basedb.util.jep.convert.AbstractJepConversionFunction<ASTFunNode>
      extended by net.sf.basedb.util.jep.convert.ASTFunNodeConverter
All Implemented Interfaces:
JepConversionFunction<ASTFunNode>

public class ASTFunNodeConverter
extends AbstractJepConversionFunction<ASTFunNode>

Converts a function node to an expression or restriction. Function nodes are used by JEP to represent both operators (+, -, *, ==, !=, etc.) and built-in or extended functions (ln, exp, sqrt, etc.).

Version:
2.4
Author:
nicklas
Last modified
$Date: 2010-04-20 10:02:16 +0200 (Tue, 20 Apr 2010) $

Constructor Summary
ASTFunNodeConverter()
           
 
Method Summary
private  JepConversionFunction getConverter(org.nfunk.jep.function.PostfixMathCommandI function, Operator operator)
          Get a converter by first checking the if one exists for the given function, and then for the given operator symbol.
 Expression toExpression(ASTFunNode node)
          Get the PostfixMathCommandI object from the function node and delegate conversion to JepExpressionFunction if that interface is implemented.
 Restriction toRestriction(ASTFunNode node)
          Get the PostfixMathCommandI object from the function node and delegate conversion to JepRestrictionFunction if that interface is implemented.
 
Methods inherited from class net.sf.basedb.util.jep.convert.AbstractJepConversionFunction
getDescription, getName, isFunction, isOperator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASTFunNodeConverter

public ASTFunNodeConverter()
Method Detail

toExpression

public Expression toExpression(ASTFunNode node)
Get the PostfixMathCommandI object from the function node and delegate conversion to JepExpressionFunction if that interface is implemented. Otherwise check the ConverterFactory for a registered converter and use it.

Specified by:
toExpression in interface JepConversionFunction<ASTFunNode>
Overrides:
toExpression in class AbstractJepConversionFunction<ASTFunNode>
Parameters:
node - The object to convert
Returns:
An expression or null
Throws:
BaseException - If the node can't be converted

toRestriction

public Restriction toRestriction(ASTFunNode node)
Get the PostfixMathCommandI object from the function node and delegate conversion to JepRestrictionFunction if that interface is implemented. Otherwise check the ConverterFactory for a registered converter and use it. Get the Operator object from the function node and check the ConverterFactory for a registered converter and use it.

Specified by:
toRestriction in interface JepConversionFunction<ASTFunNode>
Overrides:
toRestriction in class AbstractJepConversionFunction<ASTFunNode>
Parameters:
node - The object to convert
Returns:
A restriction or null
Throws:
BaseException - If the node can't be converted

getConverter

private JepConversionFunction getConverter(org.nfunk.jep.function.PostfixMathCommandI function,
                                           Operator operator)
Get a converter by first checking the if one exists for the given function, and then for the given operator symbol.

Returns:
The converter or null if none is found

2.17.2: 2011-06-17