Class IntItem

All Implemented Interfaces:
BlockItem, HasIndexItem, IndexedItem, TaggableItem, 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 Details

    • IntItem

      public IntItem(int number, 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, 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, String indexName)
    • IntItem

      public IntItem(String expression)
    • IntItem

      public IntItem(String expression, boolean isFromQuery)
    • IntItem

      public IntItem(String expression, String indexName)
    • IntItem

      public IntItem(String expression, String indexName, boolean isFromQuery)
    • IntItem

      public IntItem(Limit from, Limit to, int hitLimit, String indexName, boolean isFromQuery)
  • Method Details

    • setNumber

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

      public 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 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 String getName()
      Description copied from class: Item
      Returns the name of this item
      Specified by:
      getName in class Item
    • stringValue

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

      public void setValue(String value)
      Specified by:
      setValue in class TermItem
    • appendHeadingString

      protected void appendHeadingString(StringBuilder buffer)
      Int items uses a empty heading instead of "INT "
      Overrides:
      appendHeadingString in class Item
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class TermItem
    • equals

      public boolean equals(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 TermItem
    • getEncodedInt

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

      public 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
    • encodeThis

      protected void encodeThis(ByteBuffer buffer)
      Overrides:
      encodeThis in class SimpleIndexedItem
    • 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
      Returns whether this item represents normal text
      Specified by:
      isWords in interface BlockItem
      Specified by:
      isWords in class TermItem
    • from

      public static IntItem from(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