dk.eobjects.metamodel.query
Class SelectItem

Package class diagram package SelectItem
java.lang.Object
  extended by dk.eobjects.metamodel.query.SelectItem
All Implemented Interfaces:
IQueryItem, java.io.Serializable, java.lang.Cloneable

public class SelectItem
extends java.lang.Object
implements IQueryItem, java.lang.Cloneable

Represents a SELECT item. SelectItems can take different forms:

See Also:
SelectClause, Serialized Form

Constructor Summary
SelectItem(Column column)
          Creates a simple SelectItem that selects from a column
SelectItem(FunctionType function, Column column)
          Creates a SelectItem that uses a function on a column, for example SUM(price) or MAX(age)
SelectItem(FunctionType function, java.lang.String expression, java.lang.String alias)
          Creates a SelectItem based on a function and an expression.
SelectItem(SelectItem subQuerySelectItem, FromItem subQueryFromItem)
          Creates a SelectItem that
SelectItem(java.lang.String expression, java.lang.String alias)
          Creates a SelectItem based on an expression.
 
Method Summary
protected  SelectItem clone()
           
 boolean equals(java.lang.Object obj)
           
 boolean equalsIgnoreAlias(SelectItem that)
           
 java.lang.String getAlias()
           
 Column getColumn()
           
static SelectItem getCountAllItem()
          Generates a COUNT(*) select item
 java.lang.String getExpression()
           
 FunctionType getFunction()
           
 Query getQuery()
           
 java.lang.String getSameQueryAlias()
           
 FromItem getSubQueryFromItem()
           
 SelectItem getSubQuerySelectItem()
           
 java.lang.String getSuperQueryAlias()
           
 java.lang.String getSuperQueryAlias(boolean includeQuotes)
           
 int hashCode()
           
static boolean isCountAllItem(SelectItem item)
           
 boolean isReferenced(Column column)
          Investigates whether or not this SelectItem references a particular column.
 SelectItem setAlias(java.lang.String alias)
           
 SelectItem setColumn(Column column)
           
 SelectItem setExpression(java.lang.String expression)
           
 SelectItem setFunction(FunctionType function)
           
 SelectItem setQuery(Query query)
           
 SelectItem setSubQueryFromItem(FromItem subQueryFromItem)
           
 SelectItem setSubQuerySelectItem(SelectItem subQuerySelectItem)
           
 java.lang.String toString()
           
 java.lang.StringBuilder toStringNoAlias()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectItem

public SelectItem(Column column)
Creates a simple SelectItem that selects from a column

Parameters:
column -

SelectItem

public SelectItem(FunctionType function,
                  Column column)
Creates a SelectItem that uses a function on a column, for example SUM(price) or MAX(age)

Parameters:
function -
column -

SelectItem

public SelectItem(java.lang.String expression,
                  java.lang.String alias)
Creates a SelectItem based on an expression. All expression-based SelectItems must have aliases.

Parameters:
expression -
alias -

SelectItem

public SelectItem(FunctionType function,
                  java.lang.String expression,
                  java.lang.String alias)
Creates a SelectItem based on a function and an expression. All expression-based SelectItems must have aliases.

Parameters:
function -
expression -
alias -

SelectItem

public SelectItem(SelectItem subQuerySelectItem,
                  FromItem subQueryFromItem)
Creates a SelectItem that

Parameters:
subQuerySelectItem -
subQueryFromItem - the FromItem that holds the sub-query
Method Detail

getCountAllItem

public static SelectItem getCountAllItem()
Generates a COUNT(*) select item


isCountAllItem

public static boolean isCountAllItem(SelectItem item)

getAlias

public java.lang.String getAlias()

setAlias

public SelectItem setAlias(java.lang.String alias)

getFunction

public FunctionType getFunction()

setFunction

public SelectItem setFunction(FunctionType function)

getColumn

public Column getColumn()

setColumn

public SelectItem setColumn(Column column)

getExpression

public java.lang.String getExpression()

setExpression

public SelectItem setExpression(java.lang.String expression)

setQuery

public SelectItem setQuery(Query query)
Specified by:
setQuery in interface IQueryItem

getQuery

public Query getQuery()
Specified by:
getQuery in interface IQueryItem

getSubQuerySelectItem

public SelectItem getSubQuerySelectItem()

setSubQuerySelectItem

public SelectItem setSubQuerySelectItem(SelectItem subQuerySelectItem)

getSubQueryFromItem

public FromItem getSubQueryFromItem()

setSubQueryFromItem

public SelectItem setSubQueryFromItem(FromItem subQueryFromItem)

getSuperQueryAlias

public java.lang.String getSuperQueryAlias()
Returns:
the name that this SelectItem can be referenced with, if referenced from a super-query. This will usually be the alias, but if there is no alias, then the column name will be used.

getSuperQueryAlias

public java.lang.String getSuperQueryAlias(boolean includeQuotes)
Parameters:
includeQuotes - indicates whether or not the output should include quotes, if the select item's column has quotes associated (typically true, but false if used for presentation)
Returns:
the name that this SelectItem can be referenced with, if referenced from a super-query. This will usually be the alias, but if there is no alias, then the column name will be used.

getSameQueryAlias

public java.lang.String getSameQueryAlias()
Returns:
an alias that can be used in WHERE, GROUP BY and ORDER BY clauses in the same query

toString

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

toStringNoAlias

public java.lang.StringBuilder toStringNoAlias()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

equalsIgnoreAlias

public boolean equalsIgnoreAlias(SelectItem that)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

protected SelectItem clone()
Overrides:
clone in class java.lang.Object

isReferenced

public boolean isReferenced(Column column)
Investigates whether or not this SelectItem references a particular column. This will search for direct references and indirect references via subqueries.

Parameters:
column -
Returns:
a boolean that is true if the specified column is referenced by this SelectItem and false otherwise.


Copyright © 2007-2010. All Rights Reserved.