Class PhraseSegmentItem

    • Constructor Detail

      • PhraseSegmentItem

        public PhraseSegmentItem​(AndSegmentItem andSegment)
        Creates a phrase containing the same words and state (as pertinent) as the given SegmentAndItem.
      • PhraseSegmentItem

        public PhraseSegmentItem​(String rawWord,
                                 boolean isFromQuery,
                                 boolean stemmed)
      • PhraseSegmentItem

        public PhraseSegmentItem​(String rawWord,
                                 String current,
                                 boolean isFromQuery,
                                 boolean stemmed)
        Creates a phrase segment from strings
        Parameters:
        rawWord - the raw text as received in the request
        current - the normalized form of the raw text, or the raw text repeated if no normalized form is known
        isFromQuery - whether this originates in the request
        stemmed - whether this is stemmed
      • PhraseSegmentItem

        public PhraseSegmentItem​(String rawWord,
                                 String current,
                                 boolean isFromQuery,
                                 boolean stemmed,
                                 Substring substring)
    • Method Detail

      • 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
      • setWeight

        public void setWeight​(int weight)
        Description copied from class: Item
        Sets the relative importance of this term
        Overrides:
        setWeight in class Item
      • addItem

        public void addItem​(Item item)
        Adds subitem. The word will have its index name set to the index name of this phrase. If the item is a word, it will simply be added, if the item is a phrase, each of the words of the phrase will be added.
        Overrides:
        addItem in class SegmentItem
        Throws:
        IllegalArgumentException - if the given item is not a WordItem or PhraseItem
      • extractSingleChild

        public Optional<Item> extractSingleChild()
        Description copied from class: CompositeItem
        Will return its single child if itself can safely be omitted.
        Overrides:
        extractSingleChild in class CompositeItem
        Returns:
        a valid Item or empty Optional if it can not be done
      • getWordItem

        public WordItem getWordItem​(int index)
        Returns a subitem as a word item
        Parameters:
        index - the (0-base) index of the item to return
        Throws:
        IndexOutOfBoundsException - if there is no subitem at index
      • encodeContent

        public int encodeContent​(ByteBuffer buffer)
      • shouldParenthize

        protected boolean shouldParenthize()
        Returns false, no parenthezes for phrases
        Overrides:
        shouldParenthize in class CompositeItem
      • appendHeadingString

        protected void appendHeadingString​(StringBuilder buffer)
        Segment phrase items uses a empty heading instead of "SPHRASE "
        Overrides:
        appendHeadingString in class Item
      • appendBodyString

        protected void appendBodyString​(StringBuilder buffer)
        Description copied from class: Item
        Override to append the item body in the canonical query language of this item. An item is usually represented by the string
         ([itemName] [body])
         
        The body must be appended appended by this method.
        Overrides:
        appendBodyString in class CompositeItem
      • isExplicit

        public boolean isExplicit()
      • setExplicit

        public void setExplicit​(boolean explicit)
      • equals

        public boolean equals​(Object other)
        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 IndexedSegmentItem