org.objectweb.medor.filter.api
Interface Expression

All Superinterfaces:
java.lang.Cloneable, Cloneable
All Known Subinterfaces:
AggregateOperator, BelongOperator, BinaryArithmeticOperator, BinaryLogicalOperator, BinaryOperator, CalculatedParameterOperand, Comparator, FieldOperand, Operand, Operator, ParameterOperand, RdbFieldOperand, ThreeArgsOperator, UnaryArithmeticOperator, UnaryLogicalOperator, UnaryOperator, VariableOperand
All Known Implementing Classes:
Abs, BasicAggregateOperator, BasicBelongOperator, BasicBinaryArithmeticOperator, BasicBinaryLogicalOperator, BasicBinaryOperator, BasicComparator, BasicFieldOperand, BasicOperand, BasicParameterOperand, BasicRdbFieldOperand, BasicThreeArgsOperator, BasicUnaryArithmeticOperator, BasicUnaryLogicalOperator, BasicUnaryOperator, BasicVariableOperand, CompositePName, Concat, EncodePName, FirstLocate, IndexedLocate, IsEmpty, IsNull, IsNullPName, Length, Like, MemberOf, Sqrt, Substring

public interface Expression
extends 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());


Method Summary
 void compileExpression()
          Checks the semantic integrity of an expression.
 void evaluate(ParameterOperand[] values, Tuple t)
          It evaluates the expression tree and puts the result into the operand result.
 Operand getResult()
          Gets the operand in wich the result will be put in
 PType getType()
          It gets the result type of this expression
 boolean isCompiled()
          Gets wether this expression is compiled or not
 
Methods inherited from interface org.objectweb.medor.api.Cloneable
clone
 

Method Detail

getType

public PType getType()
It gets the result type of this expression

Returns:
a PType object

isCompiled

public boolean isCompiled()
Gets wether this expression is compiled or not

Returns:
true if the expression is compiled and false if it is not

compileExpression

public void compileExpression()
                       throws TypingException,
                              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.

Throws:
TypingException - when incompatible types error occures.
MalformedExpressionException - if syntax error

getResult

public Operand getResult()
                  throws java.lang.IllegalStateException
Gets the operand in wich the result will be put in

Returns:
an Operand Object
Throws:
java.lang.IllegalStateException - if this expression is not compiled.

evaluate

public void evaluate(ParameterOperand[] values,
                     Tuple t)
              throws MedorException,
                     java.lang.IllegalStateException
It evaluates the expression tree and puts the result into the operand result.

Parameters:
values - a list of ParameterOperand
t - Tuple
Throws:
MedorException - if evaluation error
java.lang.IllegalStateException - if this expression is not compiled.