2.17.2: 2011-06-17

net.sf.basedb.core.query
Class ExpressionSelect

java.lang.Object
  extended by net.sf.basedb.core.query.ExpressionSelect
All Implemented Interfaces:
QueryElement, Select

public class ExpressionSelect
extends Object
implements Select

A selection query element that selects an expression, optionally giving it an alias.

SELECT <expression> AS <alias>
FROM ...

Version:
2.0
Author:
Nicklas
See Also:
Selects.expression(Expression, String)
Last modified
$Date: 2010-04-21 11:48:29 +0200 (Wed, 21 Apr 2010) $

Field Summary
private  String alias
           
private  Expression e1
           
private  boolean useInDistinctCount
           
 
Constructor Summary
ExpressionSelect(Expression e1, String alias, boolean useInDistinctCount)
           
 
Method Summary
 boolean equals(Object other)
          This expression is equal to another ExpressionSelect if their child expressions and aliases are equal.
 String getAlias()
          Get the alias of the selected expression.
 Collection<? extends QueryElement> getChildren()
          Get the children of this query element or null if it has no children.
 Expression getExpression()
          Get the expression object representing the selected expression.
 int hashCode()
           
 String toQl(Query query, DbControl dc)
          Create a query language string of the query element.
 String toString()
           
 boolean useInDistinctCount()
          If this expression should be use in count distinct queries or not.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

e1

private final Expression e1

alias

private final String alias

useInDistinctCount

private final boolean useInDistinctCount
Constructor Detail

ExpressionSelect

ExpressionSelect(Expression e1,
                 String alias,
                 boolean useInDistinctCount)
Method Detail

toQl

public String toQl(Query query,
                   DbControl dc)
            throws BaseException
Description copied from interface: QueryElement
Create a query language string of the query element. Use the Query.getQueryType() method to find out which query language is wanted in case the element requires different syntax for different languages.

Specified by:
toQl in interface QueryElement
Parameters:
query - The query that is about to be executed
dc - The DbControl object used to execute the query
Throws:
BaseException - If there is any other error

getChildren

public Collection<? extends QueryElement> getChildren()
Description copied from interface: QueryElement
Get the children of this query element or null if it has no children. For example the AddExpression has two children, the expression beeing added.

Specified by:
getChildren in interface QueryElement
Returns:
The expressions to select

getAlias

public String getAlias()
Description copied from interface: Select
Get the alias of the selected expression.

Specified by:
getAlias in interface Select
Returns:
The alias, or null if no alias has been specified

getExpression

public Expression getExpression()
Description copied from interface: Select
Get the expression object representing the selected expression.

Specified by:
getExpression in interface Select
Returns:
An expression object

useInDistinctCount

public boolean useInDistinctCount()
Description copied from interface: Select
If this expression should be use in count distinct queries or not.
SELECT COUNT(DISTINCT expression)

Specified by:
useInDistinctCount in interface Select
Returns:
TRUE or FALSE

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object other)
This expression is equal to another ExpressionSelect if their child expressions and aliases are equal.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

2.17.2: 2011-06-17