org.objectweb.medor.filter.lib
Class BasicOperand

java.lang.Object
  |
  +--org.objectweb.medor.filter.lib.BasicOperand
All Implemented Interfaces:
Cloneable, java.lang.Cloneable, Expression, Operand
Direct Known Subclasses:
BasicVariableOperand, CollectionOperand

public class BasicOperand
extends java.lang.Object
implements Operand

Author:
Sebastien Chassande-Barrioz

Field Summary
protected  double doubleValue
           
protected  boolean isDefined
           
protected  long longValue
           
protected  java.lang.Object objectValue
           
protected  PType type
           
 
Constructor Summary
  BasicOperand(java.lang.Object p, PType type)
           
protected BasicOperand(PType p)
           
 
Method Summary
 java.lang.Object clone()
           
 void compileExpression()
          Checks the semantic integrity of an expression.
 void evaluate(ParameterOperand[] pos, Tuple t)
          It evaluates the expression tree and puts the result into the operand result.
 java.math.BigDecimal getBigDecimal()
          evalute the expression result and return a string value
 boolean getBoolean()
          get the operand result as a boolean value
 byte getByte()
          get the operand result as a byte value
 byte[] getByteArray()
          get the operand result as a byte[] value
 char getChar()
          get the operand result as a char value
 char[] getCharArray()
          get the operand result as a char[] value
 java.util.Date getDate()
          get the operand result a java.util.Date value
 double getDouble()
          get the operand result as a double value
 float getFloat()
          get the operand result as a float value
 int getInt()
          get the operand result as a byte value
 long getLong()
          get the operand result as a long value
 java.lang.Object getObject()
          get the operand result as a java.lang.Object value
 Operand getResult()
          Gets the operand in wich the result will be put in
 short getShort()
          get the operand result as a short value
 java.lang.String getString()
          evalute the expression result and return a string value
 java.sql.Time getTime()
          get the operand result a java.sql.Time value
 java.sql.Timestamp getTimestamp()
          get the operand result a java.sql.Timestamp value
 Tuple getTuple()
          get the operand result as a Tuple value
 TupleCollection getTupleCollection()
          get the operand result as a TupleCollection value
 PType getType()
          It gets the result type of this expression
 java.lang.String getValueAsString()
          It retrieves the value of the operand as a String.
 boolean isCompiled()
          Gets wether this expression is compiled or not
 boolean isDefined()
          Indicates if the operand has been defined, ie is the value returned if pertinent
 void setIsDefined(boolean isdefined)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

longValue

protected long longValue

doubleValue

protected double doubleValue

objectValue

protected java.lang.Object objectValue

type

protected PType type

isDefined

protected boolean isDefined
Constructor Detail

BasicOperand

protected BasicOperand(PType p)

BasicOperand

public BasicOperand(java.lang.Object p,
                    PType type)
Method Detail

getValueAsString

public java.lang.String getValueAsString()
It retrieves the value of the operand as a String.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException

evaluate

public void evaluate(ParameterOperand[] pos,
                     Tuple t)
              throws MedorException
Description copied from interface: Expression
It evaluates the expression tree and puts the result into the operand result.

Specified by:
evaluate in interface Expression
Parameters:
pos - a list of ParameterOperand
t - Tuple
Throws:
MedorException - if evaluation error

getType

public PType getType()
Description copied from interface: Expression
It gets the result type of this expression

Specified by:
getType in interface Expression
Returns:
a PType object

isDefined

public boolean isDefined()
Description copied from interface: Operand
Indicates if the operand has been defined, ie is the value returned if pertinent

Specified by:
isDefined in interface Operand

setIsDefined

public void setIsDefined(boolean isdefined)
Specified by:
setIsDefined in interface Operand

getBoolean

public boolean getBoolean()
                   throws TypingException
Description copied from interface: Operand
get the operand result as a boolean value

Specified by:
getBoolean in interface Operand
Returns:
a boolean value
Throws:
TypingException - if it is impossible to return a boolean value

getInt

public int getInt()
           throws TypingException
Description copied from interface: Operand
get the operand result as a byte value

Specified by:
getInt in interface Operand
Returns:
an int value
Throws:
TypingException - if it is impossible to return an int value

getByte

public byte getByte()
             throws TypingException
Description copied from interface: Operand
get the operand result as a byte value

Specified by:
getByte in interface Operand
Returns:
a byte value
Throws:
TypingException - if it is impossible to return an int value

getByteArray

public byte[] getByteArray()
                    throws TypingException
Description copied from interface: Operand
get the operand result as a byte[] value

Specified by:
getByteArray in interface Operand
Returns:
a byte[] value
Throws:
TypingException - if it is impossible to return an int value

getShort

public short getShort()
               throws TypingException
Description copied from interface: Operand
get the operand result as a short value

Specified by:
getShort in interface Operand
Returns:
a short value
Throws:
TypingException - if it is impossible to return a short value

getLong

public long getLong()
             throws TypingException
Description copied from interface: Operand
get the operand result as a long value

Specified by:
getLong in interface Operand
Returns:
a long value
Throws:
TypingException - if it is impossible to return a long value

getFloat

public float getFloat()
               throws TypingException
Description copied from interface: Operand
get the operand result as a float value

Specified by:
getFloat in interface Operand
Returns:
a float value
Throws:
TypingException - if it is impossible to return a float value;

getDouble

public double getDouble()
                 throws TypingException
Description copied from interface: Operand
get the operand result as a double value

Specified by:
getDouble in interface Operand
Returns:
a double value
Throws:
TypingException - if it is impossible to return a double value

getChar

public char getChar()
             throws TypingException
Description copied from interface: Operand
get the operand result as a char value

Specified by:
getChar in interface Operand
Returns:
a char value
Throws:
TypingException - if it is impossible to return a char value;

getCharArray

public char[] getCharArray()
                    throws TypingException
Description copied from interface: Operand
get the operand result as a char[] value

Specified by:
getCharArray in interface Operand
Returns:
a char[] value
Throws:
TypingException - if it is impossible to return a char value;

getString

public java.lang.String getString()
                           throws TypingException
Description copied from interface: Operand
evalute the expression result and return a string value

Specified by:
getString in interface Operand
Returns:
string result
Throws:
TypingException - if it is impossible to return a string value

getBigDecimal

public java.math.BigDecimal getBigDecimal()
                                   throws TypingException
Description copied from interface: Operand
evalute the expression result and return a string value

Specified by:
getBigDecimal in interface Operand
Returns:
string result
Throws:
TypingException - if it is impossible to return a string value

getDate

public java.util.Date getDate()
                       throws TypingException
Description copied from interface: Operand
get the operand result a java.util.Date value

Specified by:
getDate in interface Operand
Returns:
a date value
Throws:
TypingException - if it is impossible to return java.util.Date

getTime

public java.sql.Time getTime()
                      throws TypingException
Description copied from interface: Operand
get the operand result a java.sql.Time value

Specified by:
getTime in interface Operand
Returns:
a Time value
Throws:
TypingException - if it is impossible to return java.sql.Time

getTimestamp

public java.sql.Timestamp getTimestamp()
                                throws TypingException
Description copied from interface: Operand
get the operand result a java.sql.Timestamp value

Specified by:
getTimestamp in interface Operand
Returns:
a Timestamp value
Throws:
TypingException - if it is impossible to return java.sql.Timestamp

getTuple

public Tuple getTuple()
               throws TypingException
Description copied from interface: Operand
get the operand result as a Tuple value

Specified by:
getTuple in interface Operand
Returns:
a Tuple value
Throws:
TypingException - if it is impossible to return a Tuple

getTupleCollection

public TupleCollection getTupleCollection()
                                   throws TypingException
Description copied from interface: Operand
get the operand result as a TupleCollection value

Specified by:
getTupleCollection in interface Operand
Returns:
a TupleCollection value
Throws:
TypingException - if it is impossible to return a TupleCollection

getObject

public java.lang.Object getObject()
Description copied from interface: Operand
get the operand result as a java.lang.Object value

Specified by:
getObject in interface Operand
Returns:
an object

compileExpression

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

Specified by:
compileExpression in interface Expression

isCompiled

public boolean isCompiled()
Description copied from interface: Expression
Gets wether this expression is compiled or not

Specified by:
isCompiled in interface Expression
Returns:
true if the expression is compiled and false if it is not

getResult

public Operand getResult()
Description copied from interface: Expression
Gets the operand in wich the result will be put in

Specified by:
getResult in interface Expression
Returns:
an Operand Object