Class IntItem

  • All Implemented Interfaces:
    BlockItem, HasIndexItem, IndexedItem, TaggableItem, java.lang.Cloneable
    Direct Known Subclasses:
    RangeItem

    public class IntItem
    extends TermItem
    This represents either
    • a number (integer or floating point)
    • a partial range, given by "<number" or ">number", where the numbers are exclusive, or
    • a full or open range "[number;number], "[number;]" or "[;number]" where the numbers are inclusive, or exclusive if a square bracket is replaced with a pointy one
    If a range is specified in brackets, it is also permissible to add a third number specifying the number of hits this will match on each node - [from;to;hitLimit]
    Author:
    bratseth
    • Constructor Detail

      • IntItem

        public IntItem​(int number,
                       java.lang.String indexName)
        Creates an int item which must be equal to the given int number - that is both the lower and upper limit is this number
      • IntItem

        public IntItem​(long number,
                       java.lang.String indexName)
        Creates an int item which must be equal to the given long number - that is both the lower and upper limit is this number
      • IntItem

        public IntItem​(Limit from,
                       Limit to,
                       java.lang.String indexName)
      • IntItem

        public IntItem​(java.lang.String expression)
      • IntItem

        public IntItem​(java.lang.String expression,
                       boolean isFromQuery)
      • IntItem

        public IntItem​(java.lang.String expression,
                       java.lang.String indexName)
      • IntItem

        public IntItem​(java.lang.String expression,
                       java.lang.String indexName,
                       boolean isFromQuery)
      • IntItem

        public IntItem​(Limit from,
                       Limit to,
                       int hitLimit,
                       java.lang.String indexName,
                       boolean isFromQuery)
    • Method Detail

      • setNumber

        public void setNumber​(java.lang.String expression)
        Sets the number expression of this - a number or range following the syntax specified in the class javadoc
      • getNumber

        public java.lang.String getNumber()
        Sets the number expression of this - a number or range
      • getFromLimit

        public final Limit getFromLimit()
        Returns the lower limit of this range, which may be negative infinity
      • getToLimit

        public final Limit getToLimit()
        Returns the upper limit of this range, which may be positive infinity
      • getHitLimit

        public final int getHitLimit()
        Returns the number of hits this will match, or 0 if all should be matched. If this number is positive, the hits closest to from are returned, and if this number is negative the hits closest to to are returned.
      • setHitLimit

        public final void setHitLimit​(int hitLimit)
        Sets the number of hits this will match, or 0 if all should be matched. If this number is positive, the hits closest to from are returned, and if this number is negative the hits closest to to are returned.
        Parameters:
        hitLimit - number of hits to match for this operator
      • getRawWord

        public java.lang.String getRawWord()
        Description copied from class: TermItem
        Returns the raw form of the text leading to this term, exactly as received, including original casing
        Specified by:
        getRawWord in interface BlockItem
        Specified by:
        getRawWord in class TermItem
      • 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 java.lang.String getName()
        Description copied from class: Item
        Returns the name of this item
        Specified by:
        getName in class Item
      • stringValue

        public java.lang.String stringValue()
        Description copied from interface: BlockItem
        Returns the value of this term as a string
      • appendHeadingString

        protected void appendHeadingString​(java.lang.StringBuilder buffer)
        Int items uses a empty heading instead of "INT "
        Overrides:
        appendHeadingString in class Item
      • equals

        public boolean equals​(java.lang.Object object)
        Description copied from class: Item
        Returns whether this item is of the same class and contains the same state as the given item
        Overrides:
        equals in class SimpleIndexedItem
      • getEncodedInt

        protected java.lang.String getEncodedInt()
        Returns the number for encoding; the number expression as-is.
      • getIndexedString

        public java.lang.String getIndexedString()
        Description copied from interface: IndexedItem
        Return the searchable term contents of this item.
        Specified by:
        getIndexedString in interface IndexedItem
        Specified by:
        getIndexedString in class SimpleIndexedItem
        Returns:
        a string representation of what is presumably stored in an index which will match this item
      • getNumWords

        public int getNumWords()
        Description copied from interface: HasIndexItem
        Returns how many phrase words does this item contain
      • isStemmed

        public boolean isStemmed()
      • isWords

        public boolean isWords()
        Description copied from interface: BlockItem
        Does this item represent "usual words"?
        Specified by:
        isWords in interface BlockItem
        Specified by:
        isWords in class TermItem
      • from

        public static IntItem from​(java.lang.String indexName,
                                   Limit from,
                                   Limit to,
                                   int hitLimit)
        Creates an int item from arguments. This will return an instance of the RankItem subclass if either hitLimit or both from and to is set to a value other than defaults (respectively 0, double negative and positive infinity). And different from each other.
        Parameters:
        indexName - the index this searches
        from - the lower limit (inclusive) on hits
        to - the higher limit (inclusive) on hits
        hitLimit - the number of hits to match, or 0 to return all