org.josql.expressions
Class ConstantExpression

java.lang.Object
  extended by org.josql.expressions.Expression
      extended by org.josql.expressions.ValueExpression
          extended by org.josql.expressions.ConstantExpression

public class ConstantExpression
extends ValueExpression

This class represents a constant String or number. ALL numbers in JoSQL are represented by double.


Constructor Summary
ConstantExpression()
           
 
Method Summary
 Object evaluate(Object o, Query q)
          Get the value of this constant.
 Class getExpectedReturnType(Query q)
          Get the expected return type.
 Object getValue(Object o, Query q)
          Get the value of this constant.
 boolean hasFixedResult(Query q)
          Always returns true, well duh!
 void init(Query q)
          Inits the expression, in reality does nothing here, can't init a constant!
 boolean isTrue(Object o, Query q)
          Returns whether the value of this constant represents a true value.
 void setValue(Object v)
           
 String toString()
          Returns a string representation of this constant.
 
Methods inherited from class org.josql.expressions.Expression
isBracketed, setBracketed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantExpression

public ConstantExpression()
Method Detail

getExpectedReturnType

public Class getExpectedReturnType(Query q)
Get the expected return type. Will be either: java.lang.String.class or: java.lang.Double.class.

Specified by:
getExpectedReturnType in class Expression
Parameters:
q - The Query object.
Returns:
The expected class.

init

public void init(Query q)
Inits the expression, in reality does nothing here, can't init a constant!

Specified by:
init in class Expression
Parameters:
q - The Query object.

setValue

public void setValue(Object v)

isTrue

public boolean isTrue(Object o,
                      Query q)
Returns whether the value of this constant represents a true value. See: ArithmeticExpression.isTrue(Object,Query) for details of how the return value is determined.

Specified by:
isTrue in class Expression
Parameters:
o - The current object. Not used in this method.
q - The Query object.
Returns:
true if the constant evaluates to true.

getValue

public Object getValue(Object o,
                       Query q)
Get the value of this constant.

Overrides:
getValue in class ValueExpression
Parameters:
o - The current object, not used in this method.
q - The Query object, not used in this method.
Returns:
The constant value.

evaluate

public Object evaluate(Object o,
                       Query q)
Get the value of this constant.

Specified by:
evaluate in class ValueExpression
Parameters:
o - The current object, not used in this method.
q - The Query object, not used in this method.
Returns:
The constant value.

hasFixedResult

public boolean hasFixedResult(Query q)
Always returns true, well duh!

Specified by:
hasFixedResult in class Expression
Parameters:
q - The Query object.
Returns:
true always.

toString

public String toString()
Returns a string representation of this constant. If the constant is a String then it should be noted that the original quoting character is not kept in this class and the output of this method will contain the character "'" instead. If the constant is a number then "toString" is called on it, so any "," or other number formatting will have been lost.

Specified by:
toString in class Expression
Returns:
A string representation of this constant.


  Copyright © 2008 Gary Bentley. All Rights Reserved.