Package org.teiid.query.sql.lang
Class Select
- java.lang.Object
-
- org.teiid.query.sql.lang.Select
-
- All Implemented Interfaces:
Cloneable
,LanguageObject
public class Select extends 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
Constructors Constructor Description Select()
Constructs a default instance of this class.Select(List<? extends Expression> symbols)
Constructs an instance of this class from an ordered set of symbols.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.void
addSymbol(Expression symbol)
void
addSymbols(Collection<? extends Expression> toAdd)
void
clearSymbols()
Remove all current symbolsSelect
clone()
Return a deep copy of this Select.boolean
containsSymbol(Expression symbol)
Checks if a symbol is in the Select.boolean
equals(Object obj)
Compare two Selects for equality.int
getCount()
Returns the number of symbols in select.List<Expression>
getProjectedSymbols()
Get the ordered list of all elements returned by this select.Expression
getSymbol(int index)
Returns the select symbol at the specified index.List<Expression>
getSymbols()
Returns an ordered list of the symbols in the select.int
hashCode()
Get hashcode for Select.boolean
isDistinct()
Checks whether the select is distinctboolean
isStar()
Checks for a Select * clausevoid
setDistinct(boolean isDistinct)
Set whether select is distinct.void
setSymbols(Collection<? extends Expression> symbols)
Sets an ordered list of the symbols in the select.String
toString()
Returns a string representation of an instance of this class.
-
-
-
Constructor Detail
-
Select
public Select()
Constructs a default instance of this class.
-
Select
public Select(List<? extends Expression> 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 List<Expression> getSymbols()
Returns an ordered list of the symbols in the select.
-
setSymbols
public void setSymbols(Collection<? extends Expression> symbols)
Sets an ordered list of the symbols in the select. Reuses the current symbol list.- Parameters:
symbols
- list of SelectSymbol in SELECT
-
getSymbol
public Expression 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(Expression symbol)
- Parameters:
symbol
- New symbol
-
addSymbols
public void addSymbols(Collection<? extends Expression> toAdd)
-
clearSymbols
public void clearSymbols()
Remove all current symbols
-
containsSymbol
public boolean containsSymbol(Expression 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 interfaceLanguageObject
- Parameters:
visitor
- Visitor being used
-
getProjectedSymbols
public List<Expression> 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 Select clone()
Return a deep copy of this Select.- Specified by:
clone
in interfaceLanguageObject
- Overrides:
clone
in classObject
- Returns:
- Deep clone
-
equals
public boolean equals(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.
-
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.
-
-