public interface Expression extends ExpressionType, java.lang.Cloneable
AryExpression
: an expression with two predicates, as for example ANDUnaryExpression
: an expression with one predicate, as for example NOTVariable
: a VariableConstant
: a ConstantSTRUCT_ARRAY, STRUCT_SCALAR, STRUCT_STRUCTURE, TYPE_BOOL, TYPE_DYNAMIC, TYPE_FLOAT, TYPE_INTEGER, TYPE_NUMERIC, TYPE_STRING, TYPE_UNDEF
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
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.
|
default Expression |
getExpression()
Return the associated expression.
|
java.lang.String |
getExpressionName()
Return the expression name.
|
default LocalVariable |
getLocalVariable(java.lang.String varName)
Return the local variable of a specified name.
|
default 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.
|
default Variable |
getVariable(java.lang.String varName)
Return a variable declared by the expression.
|
default Variable |
getVariable(java.lang.String varName,
boolean includeLocals)
Return a variable declared by the expression.
|
java.util.Map<java.lang.String,Variable> |
getVariables()
Return the variables used by this expression.
|
default java.util.Map<java.lang.String,Variable> |
getVariables(boolean includeLocals)
Return the variables used by this expression, possibly including local variables.
|
default boolean |
hasVariable(java.lang.String varName)
Return true if there is a variable with a specified name.
|
default boolean |
hasVariable(java.lang.String varName,
boolean includeLocals)
Return true if there is a variable with a specified name.
|
default Variable |
removeVariable(java.lang.String varName)
Remove a variable from the expression.
|
void |
setParentBlock(CodeBlock block)
Set the parent expression block.
|
default Expression getExpression()
Expression getRoot()
java.lang.Object clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
void setParentBlock(CodeBlock block)
block
- the parent expression blockCodeBlock getParentBlock()
b=a+2; return b
, the two "b=a+2" and "return b" have "b=a+2; return b" as their
parent block.int evalAsInt()
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).float evalAsFloat()
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).boolean evalAsBoolean()
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).java.lang.Object eval()
short getResultType()
ExpressionType.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.short getResultStructure()
ExpressionType.STRUCT_SCALAR
: a scalar valueExpressionType.STRUCT_ARRAY
: an array valuejava.lang.String getExpressionName()
java.util.Map<java.lang.String,Variable> getVariables()
int c=a+b
, only "a" and "b" will be returned.default Variable removeVariable(java.lang.String varName)
varName
- the variable namedefault java.util.Map<java.lang.String,Variable> getVariables(boolean includeLocals)
includeLocals
- true if local variables should be includeddefault java.util.Map<java.lang.String,LocalVariable> getLocalVariables()
default LocalVariable getLocalVariable(java.lang.String varName)
varName
- the variable namedefault Variable getVariable(java.lang.String varName)
varName
- the variable namedefault boolean hasVariable(java.lang.String varName)
varName
- the variable namedefault Variable getVariable(java.lang.String varName, boolean includeLocals)
getVariable(java.lang.String)
.varName
- the variable nameincludeLocals
- true if local variables should be includeddefault boolean hasVariable(java.lang.String varName, boolean includeLocals)
varName
- the variable nameincludeLocals
- true if local variables should be includedCopyright © 2018 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence