Class GroupingExpression
- java.lang.Object
-
- com.yahoo.search.grouping.request.GroupingNode
-
- com.yahoo.search.grouping.request.GroupingExpression
-
- Direct Known Subclasses:
AggregatorNode
,BucketValue
,ConstantValue
,DocumentValue
,FunctionNode
public abstract class GroupingExpression extends GroupingNode
This class represents an expression in aGroupingOperation
. You may manually construct this expression, or you may use theGroupingParser
to generate one from a query-string.- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupingExpression(String image, String label, Integer level)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static String
asImage(Object obj)
Returns a string representation of an object that can be used in the 'image' constructor argument ofGroupingNode
.static String
asString(List<GroupingExpression> lst)
Returns a string description of the given list of expressions.abstract GroupingExpression
copy()
Returns a deep copy of thisint
getLevel()
Returns the conceptual level of this expression.protected Integer
getLevelOrNull()
void
resolveLevel(int level)
Resolves the conceptual level of this expression.GroupingExpression
setLabel(String label)
Assigns a label to this grouping expression.void
visit(ExpressionVisitor visitor)
Recursively callsExpressionVisitor.visitExpression(GroupingExpression)
for this expression and all of its argument expressions.-
Methods inherited from class com.yahoo.search.grouping.request.GroupingNode
getImage, getLabel, toString
-
-
-
-
Method Detail
-
copy
public abstract GroupingExpression copy()
Returns a deep copy of this
-
resolveLevel
public void resolveLevel(int level)
Resolves the conceptual level of this expression. This level represents the type of data that is consumed by this expression, where level 0 is a single hit, level 1 is a group, level 2 is a list of groups, and so forth. This method verifies the input level against the expression type, and recursively resolves the level of all argument expressions.- Parameters:
level
- The level of the input data.- Throws:
IllegalArgumentException
- Thrown if the level of this expression could not be resolved.IllegalStateException
- Thrown if type failed to accept the number of arguments provided.
-
getLevel
public int getLevel()
Returns the conceptual level of this expression.- Returns:
- the level.
- Throws:
IllegalArgumentException
- thrown if the level of this expression has not been resolved.- See Also:
resolveLevel(int)
-
getLevelOrNull
protected final Integer getLevelOrNull()
-
visit
public void visit(ExpressionVisitor visitor)
Recursively callsExpressionVisitor.visitExpression(GroupingExpression)
for this expression and all of its argument expressions.- Parameters:
visitor
- The visitor to call.
-
asString
public static String asString(List<GroupingExpression> lst)
Returns a string description of the given list of expressions. This is a comma-separated list of the expressions ownGroupingNode.toString()
output.- Parameters:
lst
- The list of expressions to output.- Returns:
- The string description.
-
asImage
public static String asImage(Object obj)
Returns a string representation of an object that can be used in the 'image' constructor argument ofGroupingNode
. This method ensures that strings are quoted, and that all complex characters are escaped.- Parameters:
obj
- The object to output.- Returns:
- The string representation.
-
setLabel
public GroupingExpression setLabel(String label)
Description copied from class:GroupingNode
Assigns a label to this grouping expression. The label is applied to the results of this expression so that they can be identified by the caller when processing the output.- Overrides:
setLabel
in classGroupingNode
- Parameters:
label
- The label to assign to this.- Returns:
- This, to allow chaining.
-
-