org.teiid.query.sql.lang
Class Select

java.lang.Object
  extended by org.teiid.query.sql.lang.Select
All Implemented Interfaces:
java.lang.Cloneable, LanguageObject

public class Select
extends java.lang.Object
implements LanguageObject

This class represents the SELECT clause of a query, which defines what elements or expressions are returned from the query.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
 
Constructor Summary
Select()
          Constructs a default instance of this class.
Select(java.util.List<? extends SelectSymbol> symbols)
          Constructs an instance of this class from an ordered set of symbols.
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 void addSymbol(SelectSymbol symbol)
          Adds a new symbol to the list of symbols.
 void addSymbols(java.util.Collection<? extends SelectSymbol> toAdd)
          Adds a new collection of symbols to the list of symbols.
 void clearSymbols()
          Remove all current symbols
 java.lang.Object clone()
          Return a deep copy of this Select.
 boolean containsSymbol(SelectSymbol symbol)
          Checks if a symbol is in the Select.
 boolean equals(java.lang.Object obj)
          Compare two Selects for equality.
 int getCount()
          Returns the number of symbols in select.
 java.util.List<SingleElementSymbol> getProjectedSymbols()
          Get the ordered list of all elements returned by this select.
 SelectSymbol getSymbol(int index)
          Returns the select symbol at the specified index.
 java.util.List<SelectSymbol> getSymbols()
          Returns an ordered list of the symbols in the select.
 int hashCode()
          Get hashcode for Select.
 boolean isDistinct()
          Checks whether the select is distinct
 boolean isStar()
          Checks for a Select * clause
 void setDistinct(boolean isDistinct)
          Set whether select is distinct.
 void setSymbols(java.util.List<? extends SelectSymbol> symbols)
          Sets an ordered list of the symbols in the select.
 java.lang.String toString()
          Returns a string representation of an instance of this class.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Select

public Select()
Constructs a default instance of this class.


Select

public Select(java.util.List<? extends SelectSymbol> symbols)
Constructs an instance of this class from an ordered set of symbols.

Parameters:
symbols - The ordered list of symbols
Method Detail

getCount

public int getCount()
Returns the number of symbols in select.

Returns:
Get count of number of symbols in select

isStar

public boolean isStar()
Checks for a Select * clause

Returns:
True if Select * is used

getSymbols

public java.util.List<SelectSymbol> getSymbols()
Returns an ordered list of the symbols in the select.

Parameters:
Get - list of SelectSymbol in SELECT

setSymbols

public void setSymbols(java.util.List<? extends SelectSymbol> symbols)
Sets an ordered list of the symbols in the select.

Parameters:
symbols - list of SelectSymbol in SELECT

getSymbol

public SelectSymbol getSymbol(int index)
Returns the select symbol at the specified index.

Parameters:
index - Index to get
Returns:
The variable identifier at the index

addSymbol

public void addSymbol(SelectSymbol symbol)
Adds a new symbol to the list of symbols.

Parameters:
symbol - New symbol

addSymbols

public void addSymbols(java.util.Collection<? extends SelectSymbol> toAdd)
Adds a new collection of symbols to the list of symbols.

Parameters:
symbols - Collection of SelectSymbols

clearSymbols

public void clearSymbols()
Remove all current symbols


containsSymbol

public boolean containsSymbol(SelectSymbol symbol)
Checks if a symbol is in the Select.

Parameters:
symbol - Symbol to check for
Returns:
True if the Select contains the symbol

setDistinct

public void setDistinct(boolean isDistinct)
Set whether select is distinct.

Parameters:
isDistinct - True if SELECT is distinct

isDistinct

public boolean isDistinct()
Checks whether the select is distinct

Returns:
True if select is distinct

acceptVisitor

public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface: LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.

Specified by:
acceptVisitor in interface LanguageObject
Parameters:
visitor - Visitor being used

getProjectedSymbols

public java.util.List<SingleElementSymbol> getProjectedSymbols()
Get the ordered list of all elements returned by this select. These elements may be ElementSymbols or ExpressionSymbols but in all cases each represents a single column.

Returns:
Ordered list of SingleElementSymbol

clone

public java.lang.Object clone()
Return a deep copy of this Select.

Specified by:
clone in interface LanguageObject
Overrides:
clone in class java.lang.Object
Returns:
Deep clone

equals

public boolean equals(java.lang.Object obj)
Compare two Selects for equality. Order is important in the select (for determining the order of the returned columns), so this is a compare with order, not just a set comparison.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Other object
Returns:
True if equal

hashCode

public int hashCode()
Get hashcode for Select. WARNING: The hash code relies on the variables in the select, so changing the variables will change the hash code, causing a select to be lost in a hash structure. Do not hash a Select if you plan to change it.

Overrides:
hashCode in class java.lang.Object
Returns:
Hash code

toString

public java.lang.String toString()
Returns a string representation of an instance of this class.

Overrides:
toString in class java.lang.Object
Returns:
String representation of object


Copyright © 2011. All Rights Reserved.