org.objectweb.medor.expression.lib
Class TypeConverter

java.lang.Object
  extended byorg.objectweb.medor.clone.lib.BasicCloneable
      extended byorg.objectweb.medor.expression.lib.BasicExpression
          extended byorg.objectweb.medor.expression.lib.BasicOperator
              extended byorg.objectweb.medor.expression.lib.BasicUnaryOperator
                  extended byorg.objectweb.medor.expression.lib.TypeConverter
All Implemented Interfaces:
org.objectweb.medor.clone.api.Cloneable, java.lang.Cloneable, Expression, Operator, java.io.Serializable, UnaryOperator

public class TypeConverter
extends BasicUnaryOperator

This unary operator permit to change the type of an expression to another. It is a kind of cast operation.

Author:
S.Chassande-Barrioz
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.medor.expression.lib.BasicOperator
expressions, result, verified
 
Fields inherited from class org.objectweb.medor.expression.lib.BasicExpression
logger, type
 
Fields inherited from interface org.objectweb.medor.expression.api.Operator
ABS, AND, AVG, BITWIZE, CONCAT, CONDAND, CONDOR, COUNT, DIV, EQUAL, FIRSTLOCATE, GREATER, GREATEREQUAL, IN, INDEXEDLOCATE, LENGTH, LOWER, LOWEREQUAL, MAX, MEMBEROF, MIN, MINUS, MOD, MULT, NAV, NOT, NOTEQUAL, NOTMEMBEROF, OR, PLUS, SQRT, STRING_LOWER, STRING_UPPER, SUBSTRING, SUM, UMINUS
 
Constructor Summary
TypeConverter(Expression operand, org.objectweb.jorm.type.api.PType newType)
          Builds a TypeConverter.
TypeConverter(org.objectweb.jorm.type.api.PType newType)
          Builds a TypeConverter.
 
Method Summary
 Operand compileExpression()
          Checks the semantic integrity of an expression.
 Operand evaluate(ParameterOperand[] values, java.lang.Object o)
          It evaluates the expression tree and puts the result into the operand result.
 java.lang.String getOperatorString()
          Returns the String representing the operator in Java
 
Methods inherited from class org.objectweb.medor.expression.lib.BasicUnaryOperator
getExpression, getExpression, getOperandNumber, setExpression, setExpression
 
Methods inherited from class org.objectweb.medor.expression.lib.BasicOperator
clone
 
Methods inherited from class org.objectweb.medor.expression.lib.BasicExpression
getType
 
Methods inherited from class org.objectweb.medor.clone.lib.BasicCloneable
clone, clone, getClone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.medor.expression.api.Expression
getType
 
Methods inherited from interface org.objectweb.medor.clone.api.Cloneable
clone
 

Constructor Detail

TypeConverter

public TypeConverter(org.objectweb.jorm.type.api.PType newType)
              throws MalformedExpressionException
Builds a TypeConverter.

Parameters:
newType - is the new PType of the expression. (cannot be null).

TypeConverter

public TypeConverter(Expression operand,
                     org.objectweb.jorm.type.api.PType newType)
              throws MalformedExpressionException
Builds a TypeConverter.

Parameters:
operand - is the sub expression which the type must be converted.
newType - is the new PType of the expression. (cannot be null).
Method Detail

getOperatorString

public java.lang.String getOperatorString()
Description copied from interface: Operator
Returns the String representing the operator in Java

Returns:
the String representing the operator in Java

evaluate

public Operand evaluate(ParameterOperand[] values,
                        java.lang.Object o)
                 throws ExpressionException
Description copied from interface: Expression
It evaluates the expression tree and puts the result into the operand result.

Parameters:
values - a list of ParameterOperand
o - the input Object from which values are taken for the evaluation
Returns:
an Operand containing the result of the evaluation
Throws:
ExpressionException

compileExpression

public Operand compileExpression()
                          throws ExpressionException,
                                 MalformedExpressionException
Description copied from interface: Expression
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:
MalformedExpressionException - if syntax error
ExpressionException