public class ParsedEquation extends java.lang.Object implements Expression, Equation
STRUCT_ARRAY, STRUCT_SCALAR, STRUCT_STRUCTURE, TYPE_BOOL, TYPE_DYNAMIC, TYPE_FLOAT, TYPE_INTEGER, TYPE_NUMERIC, TYPE_STRING, TYPE_UNDEF| Constructor and Description |
|---|
ParsedEquation() |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptUndefinedVariables(boolean acceptUndefVars) |
void |
addVariable(Variable var) |
java.lang.Object |
clone() |
Constant |
createBooleanConstant(boolean value) |
Constant |
createConstant(java.lang.String expr) |
Constant |
createPIConstant(double value) |
void |
endParsing() |
java.lang.Object |
eval()
Evaluate the expression.
|
boolean |
evalAsBoolean()
Evaluate the expression as a boolean.
|
float |
evalAsFloat()
Evaluate the expression as a float.
|
int |
evalAsInt()
Evaluate the expression as an int.
|
Variable |
getDollarVariable(java.lang.String dollarName) |
Expression |
getExpression()
Return the associated expression.
|
java.lang.String |
getExpressionName()
Return the expression name.
|
java.util.Map<java.lang.String,LocalVariable> |
getLocalVariables()
Return the local variables used by this expression.
|
CodeBlock |
getParentBlock()
Return the parent expression block if the expression is one of several expressions separated by commas.
|
short |
getResultStructure()
Return the structure of the result for the expression.
|
short |
getResultType()
Return the type of the result for the expression.
|
Expression |
getRoot()
Return the root expression.
|
Variable |
getVariable(java.lang.String varName)
Return a variable declared by the expression.
|
Variable |
getVariable(java.lang.String varName,
boolean createIfAbsent)
Return a variable declared by the expression.
|
java.util.Map<java.lang.String,Variable> |
getVariables()
Return the variables used by this expression.
|
java.util.Map<java.lang.String,Variable> |
getVariables(boolean includeLocals)
Return the variables used by this expression, possibly including local variables.
|
boolean |
hasVariable(java.lang.String varName,
boolean includeLocals)
Return true if there is a variable with a specified name.
|
void |
setExpression(Expression expr) |
void |
setParentBlock(CodeBlock block)
Set the parent expression block.
|
void |
setValue(java.lang.String varName,
java.lang.Object value)
Set the value of a variable.
|
void |
setVariables(java.util.List<Variable> varsList) |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLocalVariable, hasVariable, removeVariablepublic java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface Expressionclone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic void setParentBlock(CodeBlock block)
ExpressionsetParentBlock in interface Expressionblock - the parent expression blockpublic CodeBlock getParentBlock()
Expressionb=a+2; return b, the two "b=a+2" and "return b" have "b=a+2; return b" as their
parent block.getParentBlock in interface Expressionpublic java.lang.String getExpressionName()
ExpressiongetExpressionName in interface Expressionpublic void acceptUndefinedVariables(boolean acceptUndefVars)
public void endParsing()
public void setExpression(Expression expr)
public java.util.Map<java.lang.String,Variable> getVariables()
int c=a+b, only "a" and "b" will be returned.getVariables in interface Expressionpublic java.util.Map<java.lang.String,Variable> getVariables(boolean includeLocals)
getVariables in interface ExpressionincludeLocals - true if local variables should be includedpublic java.util.Map<java.lang.String,LocalVariable> getLocalVariables()
getLocalVariables in interface Expressionpublic Expression getExpression()
ExpressiongetExpression in interface EquationgetExpression in interface Expressionpublic Expression getRoot()
getRoot in interface Expressionpublic short getResultType()
ExpressionExpressionType.TYPE_INTEGER: integerExpressionType.TYPE_FLOAT: floatExpressionType.TYPE_NUMERIC: integer or float value. The runtime actual type may depend on the expression argumentsExpressionType.TYPE_STRING: stringExpressionType.TYPE_DYNAMIC: dynamic type. The runtime actual type may depend on the expression argumentsExpressionType.TYPE_UNDEF: undefined type. The default type, characteristic of an error if entountered.getResultType in interface Expressionpublic short getResultStructure()
ExpressionExpressionType.STRUCT_SCALAR: a scalar valueExpressionType.STRUCT_ARRAY: an array valuegetResultStructure in interface Expressionpublic void addVariable(Variable var)
public void setVariables(java.util.List<Variable> varsList)
public Variable getDollarVariable(java.lang.String dollarName) throws ParseException
ParseExceptionpublic Variable getVariable(java.lang.String varName)
ExpressiongetVariable in interface ExpressionvarName - the variable namepublic boolean hasVariable(java.lang.String varName,
boolean includeLocals)
hasVariable in interface ExpressionvarName - the variable nameincludeLocals - true if local variables should be includedpublic Variable getVariable(java.lang.String varName, boolean createIfAbsent)
getVariable in interface ExpressionvarName - the variable namecreateIfAbsent - true if the variabel should be created if absentpublic Constant createPIConstant(double value)
public Constant createBooleanConstant(boolean value)
public Constant createConstant(java.lang.String expr)
public void setValue(java.lang.String varName,
java.lang.Object value)
Equationpublic int evalAsInt()
throws java.lang.ArithmeticException
ExpressionExpression.eval(), but the evaluation
engine will be able to optimize the computation by knwoing that the result is an int (primitive valeus are cached internally).evalAsInt in interface Expressionjava.lang.ArithmeticExceptionpublic float evalAsFloat()
throws java.lang.ArithmeticException
ExpressionExpression.eval(), but the evaluation
engine will be able to optimize the computation by knwoing that the result is a float (primitive valeus are cached internally).evalAsFloat in interface Expressionjava.lang.ArithmeticExceptionpublic boolean evalAsBoolean()
throws java.lang.ArithmeticException
ExpressionExpression.eval(), but the evaluation
engine will be able to optimize the computation by knwoing that the result is a boolean (primitive valeus are cached internally).evalAsBoolean in interface Expressionjava.lang.ArithmeticExceptionpublic java.lang.Object eval()
throws java.lang.ArithmeticException
Expressioneval in interface Expressionjava.lang.ArithmeticExceptionCopyright © 2018 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence