com.metamatrix.query.sql.lang
Class GroupBy

java.lang.Object
  extended by com.metamatrix.query.sql.lang.GroupBy
All Implemented Interfaces:
LanguageObject, java.io.Serializable, java.lang.Cloneable

public class GroupBy
extends java.lang.Object
implements LanguageObject

This class represents the GROUP BY clause of a query, which defines the expressions that should be used for grouping the results of the query. The groups produced in the query are grouped on all symbols listed contained in the GROUP BY clause. The GROUP BY clause may not contain aliased elements, expressions, or constants.

See Also:
Serialized Form

Constructor Summary
GroupBy()
          Constructs a default instance of this class.
GroupBy(java.util.List 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(Expression symbol)
          Adds a new symbol to the list of symbols.
 java.lang.Object clone()
          Return a deep copy of this object
 boolean equals(java.lang.Object obj)
          Compare two GroupBys for equality.
 int getCount()
          Returns the number of symbols in the GROUP BY
 java.util.List getSymbols()
          Returns an ordered list of the symbols in the GROUP BY
 int hashCode()
          Get hashcode for GroupBy.
 void replaceSymbols(java.util.Collection symbols)
          Replaces the existing set of symbols with a new collection of symbols
 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

GroupBy

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


GroupBy

public GroupBy(java.util.List symbols)
Constructs an instance of this class from an ordered set of symbols.

Parameters:
symbols - The ordered list of ElementSymbols
Method Detail

getCount

public int getCount()
Returns the number of symbols in the GROUP BY

Returns:
Count of the number of symbols in GROUP BY

getSymbols

public java.util.List getSymbols()
Returns an ordered list of the symbols in the GROUP BY

Returns:
List of ElementSymbols

addSymbol

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

Parameters:
symbol - Symbol to add to GROUP BY

replaceSymbols

public void replaceSymbols(java.util.Collection symbols)
Replaces the existing set of symbols with a new collection of symbols

Parameters:
symbols - Collection of ElementSymbols to replace current symbols with

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

clone

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

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

equals

public boolean equals(java.lang.Object obj)
Compare two GroupBys for equality. Order is important in the comparison.

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

hashCode

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

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

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 © 2009. All Rights Reserved.