com.endeca.navigation.analytics
Class GroupBy

java.lang.Object
  extended by com.endeca.navigation.analytics.GroupBy
All Implemented Interfaces:
QueryNode

public class GroupBy
extends Object
implements QueryNode

A GroupBy defines a single dimension of record grouping for a containing Statement operation. Basically, a GroupBy represents an Endeca property or dimension by which records will be grouped. Input records for the containing Statement operation are grouped together by common assignment from the GroupBy property or dimension. GroupBy instances are encapsulated in a GroupByList, which in turn is set in the Statement object.


Constructor Summary
GroupBy(String groupingKey)
          Constructs a new GroupBy which will request aggregation of records into groups based on the Endeca property or dimension named groupingKey.
GroupBy(String groupingKey, int depth)
          Constructs a new GroupBy which will request aggregation of records into groups based on the Endeca property or dimension named groupingKey.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether this GroupBy has an equivalence to a reference GroupBy specified by obj.
 int getDepth()
          Gets the dimension depth for the aggregates defined by this GroupBy.
 String getFieldName()
          Gets the name of the grouping property or dimension for this GroupBy.
 void setDepth(int depth)
          Sets the dimension depth for the aggregates defined by this GroupBy.
 void setFieldName(String key)
          Sets the name of the grouping property or dimension for this GroupBy.
 String toString()
          Returns the string form of this GroupBy.
 String toWire()
          Returns the wire format of this GroupBy.
 void validateSyntax()
          Validates the syntax of this GroupBy.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GroupBy

public GroupBy(String groupingKey)
Constructs a new GroupBy which will request aggregation of records into groups based on the Endeca property or dimension named groupingKey. For example, this code:
GroupByList g = new GroupByList();
g.add(new GroupBy("Year"));
performs a leaf-level grouping of records based on the Endeca dimension named Year.

Parameters:
groupingKey - the name of the Endeca property or dimension by which the records will be aggregated.

GroupBy

public GroupBy(String groupingKey,
               int depth)
Constructs a new GroupBy which will request aggregation of records into groups based on the Endeca property or dimension named groupingKey.

For dimensions, the grouping will depend on the value's ancestor at depth from the root of the dimension's hierarchy. For example, if a Region dimension contains a hierarchy of Country, State, and City, and the grouping was desired at the State level (one level below the root of the dimension hierarchy), the constructor code would be:

GroupByList g = new GroupByList();
g.add(new GroupBy("Region",1));
Note that a depth of zero does not indicate grouping at the root of the hierarchy, but rather it denotes that depth will not be taken into account at all, so grouping will be performed based on the values encountered.

Parameters:
groupingKey - the name of the Endeca property or dimension by which the records will be aggregated.
depth - the level of a dimension hierarchy at which the grouping will be performed.
Method Detail

setFieldName

public void setFieldName(String key)
Sets the name of the grouping property or dimension for this GroupBy.

Parameters:
key - the name of the Endeca property or dimension by which the records will be grouped.

getFieldName

public String getFieldName()
Gets the name of the grouping property or dimension for this GroupBy.

Returns:
The name of the Endeca property or dimension by which the records will be grouped.

setDepth

public void setDepth(int depth)
Sets the dimension depth for the aggregates defined by this GroupBy.

Parameters:
depth - the level of a dimension hierarchy at which the grouping will be performed.

getDepth

public int getDepth()
Gets the dimension depth for the aggregates defined by this GroupBy.

Returns:
an integer representing the level of a dimension hierarchy at which the grouping is performed.

equals

public boolean equals(Object obj)
Indicates whether this GroupBy has an equivalence to a reference GroupBy specified by obj. The method returns one of these results: Note that the the depth settings of the two GroupBy objects are not compared.

Overrides:
equals in class Object
Parameters:
obj - the reference GroupBy with which to compare.
Returns:
true if this GroupBy is the same as the obj argument; false otherwise.

toString

public String toString()
Returns the string form of this GroupBy. These are of the format: "grouping-key-name" or "grouping-key-name:3". For example, the string:
Region:2
is returned if the grouping key is a dimension named Region with a grouping level of 2 (that is, two levels below the root of the dimension hierarchy).

Specified by:
toString in interface QueryNode
Overrides:
toString in class Object
Returns:
A string representation of this GroupBy in the specified format.

toWire

public String toWire()
Returns the wire format of this GroupBy. This method is not intended for public use because the wire format is subject to change.

Specified by:
toWire in interface QueryNode
Returns:
A wire format representation of this GroupBy.

validateSyntax

public void validateSyntax()
                    throws SyntaxException
Validates the syntax of this GroupBy. A GroupBy is valid if the grouping key name is non-null and non-empty, and the depth is non-negative.

Specified by:
validateSyntax in interface QueryNode
Throws:
SyntaxException - if the syntax requirements are not satisfied.


2010 Endeca Technologies, Inc.
Endeca Confidential