Package net.sf.basedb.util.jep
Class FunctionSafeJep
- java.lang.Object
-
- org.nfunk.jep.JEP
-
- net.sf.basedb.util.jep.FunctionSafeJep
-
public class FunctionSafeJep extends JEP
Extension to the JEP parser that provides better error handling for unknown functions. The normal error message when JEP encounters an unknown function is: Syntax Error (implicit multiplication not enabled). This is not very informative so this class improves the error handling by giving a message: Unknown function foo() instead.- Since:
- 2.15
- Author:
- Nicklas
- Last modified
- $Date $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
FunctionSafeJep.SafeFunctionTable
Function table implementation that pretends that all possible functions exists, but sends an error message if someone tries to use a function that doesn't really exists.(package private) static class
FunctionSafeJep.UnknownFunction
Represents an unknown function that appears in an expression.
-
Field Summary
-
Fields inherited from class org.nfunk.jep.JEP
allowAssignment, allowUndeclared, errorList, ev, funTab, implicitMul, numberFactory, opSet, parser, symTab
-
-
Constructor Summary
Constructors Constructor Description FunctionSafeJep()
Create a new function-safe JEP parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addError(String error)
Adds an error message to the "real" JEP parser.Object
getValueAsObject()
Override the superclass method so that exceptions are passed on instead of swallowed.void
initFunTab()
Overrides the regular function lookup table by replacing it with a function table that pretends that all functions has been registered, but then generates an error message if it doesn't exists.-
Methods inherited from class org.nfunk.jep.JEP
addComplex, addConstant, addFunction, addStandardConstants, addStandardFunctions, addVariable, addVariable, addVariable, evaluate, getAllowAssignment, getAllowUndeclared, getComplexValue, getErrorInfo, getEvaluatorVisitor, getFunctionTable, getImplicitMul, getNumberFactory, getOperatorSet, getParser, getSymbolTable, getTopNode, getTraverse, getValue, getVar, getVarValue, hasError, initSymTab, parse, parseExpression, removeFunction, removeVariable, setAllowAssignment, setAllowUndeclared, setImplicitMul, setTraverse, setVarValue
-
-
-
-
Method Detail
-
initFunTab
public void initFunTab()
Overrides the regular function lookup table by replacing it with a function table that pretends that all functions has been registered, but then generates an error message if it doesn't exists.- Overrides:
initFunTab
in classJEP
-
addError
void addError(String error)
Adds an error message to the "real" JEP parser.
-
getValueAsObject
public Object getValueAsObject()
Override the superclass method so that exceptions are passed on instead of swallowed.- Overrides:
getValueAsObject
in classJEP
- Since:
- 3.0
-
-