org.objectweb.medor.expression.lib
Class BasicOperand

java.lang.Object
  extended byorg.objectweb.medor.clone.lib.BasicCloneable
      extended byorg.objectweb.medor.expression.lib.BasicExpression
          extended byorg.objectweb.medor.expression.lib.BasicOperand
All Implemented Interfaces:
org.objectweb.medor.clone.api.Cloneable, java.lang.Cloneable, Expression, Operand, java.io.Serializable
Direct Known Subclasses:
BasicVariableOperand

public class BasicOperand
extends BasicExpression
implements Operand

Author:
Sebastien Chassande-Barrioz
See Also:
Serialized Form

Field Summary
protected  double doubleValue
           
protected  boolean isDefined
           
protected  long longValue
           
protected  java.lang.Object objectValue
           
 
Fields inherited from class org.objectweb.medor.expression.lib.BasicExpression
logger, type
 
Constructor Summary
  BasicOperand()
           
  BasicOperand(BasicOperand bo)
           
  BasicOperand(boolean p)
           
  BasicOperand(byte p)
           
  BasicOperand(byte[] p)
           
  BasicOperand(char p)
           
  BasicOperand(char[] p)
           
  BasicOperand(java.util.Date p)
           
  BasicOperand(double p)
           
  BasicOperand(float p)
           
  BasicOperand(int p)
           
  BasicOperand(long p)
           
  BasicOperand(java.lang.Object p, org.objectweb.jorm.type.api.PType type)
           
protected BasicOperand(org.objectweb.jorm.type.api.PType p)
           
  BasicOperand(short p)
           
  BasicOperand(java.lang.String p)
           
 
Method Summary
 java.lang.Object clone(java.lang.Object clone, java.util.Map obj2clone)
          Clone the current object.
 Operand compileExpression()
          Checks the semantic integrity of an expression.
 Operand evaluate(ParameterOperand[] pos, java.lang.Object o)
          It evaluates the expression tree and puts the result into the operand result.
 java.math.BigDecimal getBigDecimal()
          evalute the expression result and return a BigDecimal value
 java.math.BigInteger getBigInteger()
          evalute the expression result and return a BigInteger 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
 short getShort()
          get the operand result as a short value
 java.lang.String getString()
          evalute the expression result and return a string value
 org.objectweb.jorm.type.api.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 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 org.objectweb.medor.clone.lib.BasicCloneable
clone, clone, getClone
 
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

isDefined

protected boolean isDefined
Constructor Detail

BasicOperand

public BasicOperand()

BasicOperand

public BasicOperand(BasicOperand bo)

BasicOperand

protected BasicOperand(org.objectweb.jorm.type.api.PType p)

BasicOperand

public BasicOperand(boolean p)

BasicOperand

public BasicOperand(char p)

BasicOperand

public BasicOperand(char[] p)

BasicOperand

public BasicOperand(byte p)

BasicOperand

public BasicOperand(byte[] p)

BasicOperand

public BasicOperand(short p)

BasicOperand

public BasicOperand(int p)

BasicOperand

public BasicOperand(long p)

BasicOperand

public BasicOperand(float p)

BasicOperand

public BasicOperand(double p)

BasicOperand

public BasicOperand(java.lang.String p)

BasicOperand

public BasicOperand(java.util.Date p)

BasicOperand

public BasicOperand(java.lang.Object p,
                    org.objectweb.jorm.type.api.PType type)
Method Detail

clone

public java.lang.Object clone(java.lang.Object clone,
                              java.util.Map obj2clone)
                       throws java.lang.CloneNotSupportedException
Description copied from interface: org.objectweb.medor.clone.api.Cloneable
Clone the current object.

Specified by:
clone in interface org.objectweb.medor.clone.api.Cloneable
Overrides:
clone in class BasicExpression
Throws:
java.lang.CloneNotSupportedException

getValueAsString

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


toString

public java.lang.String toString()

evaluate

public Operand evaluate(ParameterOperand[] pos,
                        java.lang.Object o)
                 throws ExpressionException
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
o - the input Object from which values are taken for the evaluation
Returns:
an Operand containing the result of the evaluation
Throws:
ExpressionException

getType

public org.objectweb.jorm.type.api.PType getType()
Description copied from interface: Expression
It gets the result type of this expression

Specified by:
getType in interface Expression
Overrides:
getType in class BasicExpression

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 BigDecimal value

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

getBigInteger

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

Specified by:
getBigInteger in interface Operand
Returns:
BigInteger 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

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 Operand 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