Class RootItem

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
QueryTree

public class RootItem extends CompositeItem
The root node of a query tree. This is always present above the actual semantic root to ease query manipulation, especially replacing the actual semantic root, but does not have any search semantics on its own.

To ease recursive manipulation of the query tree, this is a composite having one child, which is the actual root.

  • Setting the root item (at position 0, either directly or though the iterator of this, works as expected. Setting at any other position is disallowed.
  • Removing the root is allowed and causes this to be a null query.
  • Adding an item is only allowed if this is currently a null query (having no root)
Author:
Arne Bergene Fossaa
  • Constructor Details

    • RootItem

      public RootItem()
    • RootItem

      public RootItem(Item root)
  • Method Details

    • setIndexName

      public void setIndexName(String index)
      Description copied from class: CompositeItem
      Sets the index name of all subitems of this
      Overrides:
      setIndexName in class CompositeItem
    • getItemType

      public Item.ItemType getItemType()
      Description copied from class: Item
      Return the enumerated type of this item.
      Specified by:
      getItemType in class Item
    • getName

      public String getName()
      Description copied from class: Item
      Returns the name of this item
      Specified by:
      getName in class Item
    • encode

      public int encode(ByteBuffer buffer)
      Overrides:
      encode in class CompositeItem
    • toProtobufQueryTree

      public ai.vespa.searchlib.searchprotocol.protobuf.SearchProtocol.QueryTree toProtobufQueryTree()
      Convert this query tree to protobuf format.
      Returns:
      a SearchProtocol.QueryTree protobuf message
    • appendHeadingString

      protected void appendHeadingString(StringBuilder sb)
      Description copied from class: Item
      Appends the heading of this string. As default getName() followed by a space.
      Overrides:
      appendHeadingString in class Item
    • getRoot

      public Item getRoot()
      Returns the query root. This is null if this is a null query.
    • setRoot

      public final void setRoot(Item root)
    • equals

      public boolean equals(Object o)
      Description copied from class: CompositeItem
      Returns whether this item is of the same class and contains the same state as the given item.
      Overrides:
      equals in class CompositeItem
    • clone

      public RootItem clone()
      Returns a deep copy of this
      Overrides:
      clone in class CompositeItem
    • addItem

      public void addItem(Item item)
      Overrides:
      addItem in class CompositeItem
    • addItem

      public void addItem(int index, Item item)
      Description copied from class: CompositeItem
      Inserts the item at a position and increases the index of existing items starting on this position by one
      Overrides:
      addItem in class CompositeItem
    • isEmpty

      public boolean isEmpty()
      Returns true if this represents the null query