org.objectweb.medor.expression.api
Interface Expression
- java.lang.Cloneable, Serializable, org.objectweb.medor.clone.api.Cloneable
- BinaryArithmeticOperator, BinaryLogicalOperator, BinaryOperator, CalculatedParameterOperand, Comparator, Operand, Operator, ParameterOperand, UnaryArithmeticOperator, UnaryLogicalOperator, UnaryOperator, VariableOperand
- Abs, And, BasicBinaryArithmeticOperator, BasicBinaryLogicalOperator, BasicBinaryOperator, BasicComparator, BasicExpression, BasicOperand, BasicOperator, BasicParameterOperand, BasicUnaryArithmeticOperator, BasicUnaryLogicalOperator, BasicUnaryOperator, BasicVariableOperand, Bitwize, Concat, ConditionalAnd, ConditionalOr, DivideBy, Equal, FirstLocate, Greater, GreaterEqual, IndexedLocate, Length, Like, Lower, LowerEqual, Minus, Mod, Mult, Not, NotEqual, Or, Plus, Sqrt, StringLower, StringUpper, Substring, TypeConverter, UMinus
public interface Expression
extends Serializable, org.objectweb.medor.clone.api.Cloneable
This interface represents an arithmetic and/or a
boolean expression.
It represents operations over operands. It is
represented by a tree where nodes represents operations and leafs operands.
An expression have two states:
Not compiled in wich case it can be modified.
Compiled, this state is possible after compilation method
CompileExpression().
Then it will be evaluable and its structure cannot be further modified.
Here is a simple example:
Expression exp = ...
exp.CompileExpression();
Operand op = exp.getResult();
exp.evaluate(......);
System.out.println("the result = "+ op.getInt());
compileExpression
public Operand compileExpression()
throws ExpressionException,
MalformedExpressionException
Checks the semantic integrity of an expression.
It checks that all types are compatible and prepare the expression to be
evaluable.It also creates buffers where stores the result. Notes that
when evaluating there is no creation of new objects. This method change
the state of this expression object, it will be evaluable and not
modifiable.
MalformedExpressionException
- if syntax error
evaluate
public Operand evaluate(ParameterOperand values,
Object o)
throws ExpressionException
It evaluates the expression tree and puts the result into the operand
result.
values
- a list of ParameterOperando
- the input Object from which values are taken for the
evaluation
- an Operand containing the result of the evaluation
getType
public PType getType()
It gets the result type of this expression
- a PType object