|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.proteios.util.jep.Jep
public class Jep
Utility class for parsing mathematical expressions. This class uses the Java Mathematical Expression Parser package from Singular Systems to parse mathematical expressions.
Create a new JEP expression with the newJep(String, JepFunction[])
method. If the expression contains variables set values for those with the
JEP.setVarValue(String, Object) method. Then, evaluate the expression
using the JEP.getValue() method.
You can also convert the expression to a Query API Expression
object with the jepToExpression(JEP) method. The conversion
doesn't support all methods since the Query API doesn't have support for
them.
See the JEP homepage for more
information about JEP and all supported functions/operators.
See jepToExpression(JEP) and jepToRestriction(JEP)
for functions/operators supported by the conversion methods.
| Constructor Summary | |
|---|---|
Jep()
|
|
| Method Summary | |
|---|---|
static Expression |
formulaToExpression(String formula,
JepFunction... functions)
Convert JEP expression to a Query API Expression. |
static Restriction |
formulaToRestriction(String formula,
JepFunction... functions)
Convert JEP expression to a Query API Restriction. |
static Expression |
jepToExpression(JEP jep)
Convert a JEP expression to a Query API Expression. |
static Restriction |
jepToRestriction(JEP jep)
Convert a JEP expression to a Query API Restriction. |
static JEP |
newJep(String formula,
JepFunction... functions)
Create a new JEP expression. |
static Expression |
nodeToExpression(Node node)
Convert a node with it's children to an expression. |
static int |
nodeToInt(Node node)
Convert a node to an integer value. |
static String |
nodeToString(Node node)
Convert a node to a string value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Jep()
| Method Detail |
|---|
public static JEP newJep(String formula,
JepFunction... functions)
throws BaseException
JEP.getValue() method. Set values for variables
with the JEP.setVarValue(String, Object).
formula - The expression to parsefunctions - Extra functions that are required to parse the
expression
JEP object
BaseException - If the expression couldn't be parsed
public static Expression jepToExpression(JEP jep)
throws BaseException
Expression. The Query API
only supports a subset of the functions/operators that JEP supports.
Supported functions/operators are:
+= This is a optional function that must be registered when creating the JEP object.Expressions.add(Expression, Expression)-Expressions.subtract(Expression, Expression)Expressions.multiply(Expression, Expression)/Expressions.divide(Expression, Expression)-Expressions.negate(Expression)log10Expressions.log10(Expression)log2Expressions.log2(Expression)lnExpressions.ln(Expression)sqrtExpressions.sqrt(Expression)numberExpressions.integer(int)orExpressions.aFloat(float)stringExpressions.parameter(String, Object)variableExpressions.parameter(String)
jep - The JEP object
Expression object
BaseException - If the JEP expression can't be convertednewJep(String, JepFunction[])
public static Expression formulaToExpression(String formula,
JepFunction... functions)
throws BaseException
Expression. This method
is equivalent to: jepToExpression(newJep(formula, functions)).
BaseExceptionjepToExpression(JEP)
public static Restriction jepToRestriction(JEP jep)
throws BaseException
Restriction. The
Query API only supports a subset of the functions/operators that
JEP supports.
Supported functions/operators are:
=== This is a optional function that must be registered when creating the JEP object.Restrictions.eq(Expression, Expression)!=Restrictions.neq(Expression, Expression)>Restrictions.gt(Expression, Expression)>=Restrictions.gteq(Expression, Expression)<Restrictions.lt(Expression, Expression)<=Restrictions.lteq(Expression, Expression)>Restrictions.gt(Expression, Expression)&&Restrictions.and(Restriction[])||Restrictions.or(Restriction[])!Restrictions.not(Restriction)
All operators supported by the jepToExpression(JEP) are of
course also supported in the appropriate places.
jep - The JEP object
Restriction object
BaseException - If the JEP expression can't be convertednewJep(String, JepFunction[])
public static Restriction formulaToRestriction(String formula,
JepFunction... functions)
throws BaseException
Restriction. This method
is equivalent to: jepToRestriction(newJep(formula, functions)).
BaseExceptionjepToRestriction(JEP)
public static Expression nodeToExpression(Node node)
throws BaseException
BaseException
public static String nodeToString(Node node)
throws BaseException
BaseException
public static int nodeToInt(Node node)
throws BaseException
BaseException
|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||