Class Phrase

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  Phrase.Parameter
      Parameter Linked List.
    • Constructor Summary

      Constructors 
      Constructor Description
      Phrase()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      Phrase clone()  
      boolean containsParameters()
      Does this phrase operand contain any parameters in a non-default state.
      boolean containsParameters​(boolean compact)
      Does this phrase operand contain any parameters in a non-default state.
      void copyParameters​(Phrase other)
      Add all parameters from other.
      boolean equals​(java.lang.Object other)
      int getBoost()
      Get the boost for this phrase.
      abstract int getEndOffset()
      Get the end offset (0 indexed, exclusive) for this term in the original query string.
      java.lang.Object getParameter​(java.lang.String name)
      Get a parameter by name.
      boolean getParameter​(java.lang.String name, boolean defaultValue)
      Get a boolean parameter by name, returning defaultValue if not found.
      int getParameter​(java.lang.String name, int defaultValue)
      Get an int parameter by name, returning defaultValue if not found.
      java.lang.String getParameter​(java.lang.String name, java.lang.String defaultValue)
      Get a string parameter by name, returning defaultValue if not found.
      protected java.lang.Object getParameterInternal​(java.lang.String name)  
      abstract int getStartOffset()
      Get the start offset (0 indexed, inclusive) for this term in the original query string.
      int hashCode()
      boolean isMatchAll()
      Returns true if this phrase will match all documents.
      java.util.Iterator<java.util.Map.Entry<java.lang.String,​java.lang.Object>> parameters()
      Get an iterator for returning all custom parameters.
      protected int parseIntParameter​(java.lang.Object value, int defaultValue)  
      java.lang.Object removeParameter​(java.lang.String name)
      Remove custom parameter named name
      Phrase rewrite​(PhraseHandler handler)
      Recursively rewrite this phrase using handler.
      abstract Phrase rewriteChildren​(PhraseHandler handler)
      Rewrite any children of this phrase using handler.
      void setBoost​(int value)
      Set the boost for this phrase.
      void setParameter​(java.lang.String name, java.lang.Object value)
      Set parameter name to value.
      void setParameters​(java.util.Map<java.lang.String,​java.lang.Object> value)
      Add all parameters from value.
      static Phrase[] toArray​(java.util.List<Phrase> terms)
      Get an array of phrases from terms.
      java.lang.String toString()
      java.lang.String toString​(boolean compact)
      Construct the string representation of this phrase.
      abstract void toString​(java.lang.StringBuilder buffer, boolean compact)
      Appends the string representation of this query to buffer.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Phrase

        public Phrase()
    • Method Detail

      • getStartOffset

        public abstract int getStartOffset()
        Get the start offset (0 indexed, inclusive) for this term in the original query string.

        This value is set during parsing and indicates the start offset into the original query string that this term represents. In general, offsets should not be set/modified by query transformers and it is recommended that start and end offsets are set to zero when cloning.

        NOTE: if getStartOffset() == getEndOffset(), this indicates that the term did not come from a parsed query string.

      • getEndOffset

        public abstract int getEndOffset()
        Get the end offset (0 indexed, exclusive) for this term in the original query string.

        This value is set during parsing and indicates the end offset of the original query string that this term represents. In general, offsets should not be set/modified by query transformers and it is recommended that start and end offsets are set to zero when cloning.

        NOTE: if getStartOffset() == getEndOffset(), this indicates that the term did not come from a parsed query string.

      • getBoost

        public int getBoost()
        Get the boost for this phrase.
      • setBoost

        public void setBoost​(int value)
        Set the boost for this phrase.
      • isMatchAll

        public boolean isMatchAll()
        Returns true if this phrase will match all documents.
      • containsParameters

        public final boolean containsParameters()
        Does this phrase operand contain any parameters in a non-default state.
      • containsParameters

        public boolean containsParameters​(boolean compact)
        Does this phrase operand contain any parameters in a non-default state.

        If compact is true this will only return true if at least one parameter in the compact representation of this phrase exists.

      • parameters

        public java.util.Iterator<java.util.Map.Entry<java.lang.String,​java.lang.Object>> parameters()
        Get an iterator for returning all custom parameters.
      • getParameter

        public final java.lang.Object getParameter​(java.lang.String name)
        Get a parameter by name.

        NOTE: name is case insensitive.

      • getParameterInternal

        protected java.lang.Object getParameterInternal​(java.lang.String name)
      • getParameter

        public final java.lang.String getParameter​(java.lang.String name,
                                                   java.lang.String defaultValue)
        Get a string parameter by name, returning defaultValue if not found.

        NOTE: name is case insensitive.

      • getParameter

        public final boolean getParameter​(java.lang.String name,
                                          boolean defaultValue)
        Get a boolean parameter by name, returning defaultValue if not found.

        NOTE: name is case insensitive.

      • getParameter

        public final int getParameter​(java.lang.String name,
                                      int defaultValue)
        Get an int parameter by name, returning defaultValue if not found.

        NOTE: name is case insensitive.

      • setParameters

        public final void setParameters​(java.util.Map<java.lang.String,​java.lang.Object> value)
        Add all parameters from value.
      • copyParameters

        public void copyParameters​(Phrase other)
        Add all parameters from other.
      • setParameter

        public void setParameter​(java.lang.String name,
                                 java.lang.Object value)
        Set parameter name to value.

        NOTE: name is case insensitive.

      • parseIntParameter

        protected int parseIntParameter​(java.lang.Object value,
                                        int defaultValue)
      • removeParameter

        public java.lang.Object removeParameter​(java.lang.String name)
        Remove custom parameter named name

        NOTE: parameter names are case insensitive.

      • rewrite

        public Phrase rewrite​(PhraseHandler handler)
        Recursively rewrite this phrase using handler.

        NOTE: If a phrase has any children, the phrase itself will be passed to handler first, prior to its children. If handler returns a new phrase, its children will not be traversed automatically.

      • rewriteChildren

        public abstract Phrase rewriteChildren​(PhraseHandler handler)
        Rewrite any children of this phrase using handler.

        Returns the modified phrase, which may be null if all children were removed by handler.

        This method may have no effect if this Phrase represents a leaf in the tree.

        NOTE: child phrases are not recursively traversed.

      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public final java.lang.String toString​(boolean compact)
        Construct the string representation of this phrase.

        If compact is true, a more compact representation will be returned. This compact representation will omit common parameters that don't have any impact on search.

      • toString

        public abstract void toString​(java.lang.StringBuilder buffer,
                                      boolean compact)
        Appends the string representation of this query to buffer.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • clone

        public Phrase clone()
        Overrides:
        clone in class java.lang.Object
      • toArray

        public static Phrase[] toArray​(java.util.List<Phrase> terms)
        Get an array of phrases from terms.