org.josql.expressions
Class AliasedExpression

java.lang.Object
  extended by org.josql.expressions.Expression
      extended by org.josql.expressions.AliasedExpression
Direct Known Subclasses:
AliasedFunction

public class AliasedExpression
extends Expression

Represents an expression that also has an alias. SELECT columns may have aliases as may the functions in the "EXECUTE ON" clause.


Field Summary
protected  Expression exp
           
 
Constructor Summary
AliasedExpression()
           
 
Method Summary
 String getAlias()
          Get the alias for the expression.
 Class getExpectedReturnType(Query q)
          Get the expected return type for the expression.
 Expression getExpression()
          Get the expression being aliased.
 Object getValue(Object o, Query q)
          Get the value for this expression.
 boolean hasFixedResult(Query q)
          Return whether this expression has a fixed result.
 void init(Query q)
          Init this expression.
 boolean isTrue(Object o, Query q)
          Indicate whether the expression evaluates to true.
 void setAlias(String a)
           
 void setExpression(Expression exp)
           
 String toString()
          Return a string representation of the aliased expression.
 
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
 

Field Detail

exp

protected Expression exp
Constructor Detail

AliasedExpression

public AliasedExpression()
Method Detail

hasFixedResult

public boolean hasFixedResult(Query q)
Return whether this expression has a fixed result. See: Expression.hasFixedResult(Query) for more details.

Specified by:
hasFixedResult in class Expression
Parameters:
q - The Query object.
Returns:
true if the expression returns a fixed result, false otherwise.

getExpectedReturnType

public Class getExpectedReturnType(Query q)
                            throws QueryParseException
Get the expected return type for the expression.

Specified by:
getExpectedReturnType in class Expression
Parameters:
q - The Query object.
Returns:
The class of the return type.
Throws:
QueryParseException - If an error occurs whilst trying to determine the return type.

init

public void init(Query q)
          throws QueryParseException
Init this expression. All that occurs here is that the aliased expression is inited via: Expression.init(Query).

Specified by:
init in class Expression
Parameters:
q - The Query object.
Throws:
QueryParseException - If an error occurs during the initialisation of the expression.

getAlias

public String getAlias()
Get the alias for the expression.

Returns:
The alias.

setAlias

public void setAlias(String a)

getExpression

public Expression getExpression()
Get the expression being aliased.

Returns:
The expression.

setExpression

public void setExpression(Expression exp)

isTrue

public boolean isTrue(Object o,
                      Query q)
               throws QueryExecutionException
Indicate whether the expression evaluates to true.

Specified by:
isTrue in class Expression
Parameters:
o - The object to perform the expression on.
q - The Query object.
Returns:
true if the expression evaulates to true, false otherwise.
Throws:
QueryExecutionException - If something goes wrong during execution of the: Expression.isTrue(Object,Query) method.
See Also:
Expression.isTrue(Object,Query)

getValue

public Object getValue(Object o,
                       Query q)
                throws QueryExecutionException
Get the value for this expression.

Specified by:
getValue in class Expression
Parameters:
o - The object to perform the expression on.
q - The Query object.
Returns:
The result of calling: Expression.getValue(Object,Query).
Throws:
QueryExecutionException - If something goes wrong with the execution of the expression.

toString

public String toString()
Return a string representation of the aliased expression. Returns in the form: Expression AS Alias.

Specified by:
toString in class Expression
Returns:
The result of calling: Expression.toString() + AS + getAlias().


  Copyright © 2008 Gary Bentley. All Rights Reserved.