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 a GroupingOperation. You may manually construct this expression, or you may use the GroupingParser to generate one from a query-string.
Author:
Simon Thoresen Hult
  • Constructor Details

    • GroupingExpression

      protected GroupingExpression(String image, String label, Integer level)
  • Method Details

    • 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:
    • getLevelOrNull

      protected final Integer getLevelOrNull()
    • visit

      public void visit(ExpressionVisitor visitor)
      Recursively calls ExpressionVisitor.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 own GroupingNode.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 of GroupingNode. 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 class GroupingNode
      Parameters:
      label - The label to assign to this.
      Returns:
      This, to allow chaining.