OffsetRange (Lucene 10.5.1 highlighter API)
Description: declaration: package: org.apache.lucene.search.matchhighlight, class: OffsetRange

Package org.apache.lucene.search.matchhighlight

# Class OffsetRange

java.lang.Object
org.apache.lucene.search.matchhighlight.OffsetRange

All Implemented Interfaces:
  `Cloneable`

Direct Known Subclasses:
  `MatchHighlighter.QueryOffsetRange`, `Passage`

public class OffsetRange extends Object implements Cloneable
A non-empty range of offset positions.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final int`
  `from`
  Start index, inclusive.
  `final int`
  `to`
  End index, exclusive.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OffsetRange(int from, int to)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `OffsetRange`
  `clone()`
  `boolean`
  `contains(OffsetRange other)`
  `boolean`
  `equals(Object other)`
  `int`
  `hashCode()`
  `int`
  `length()`
  `OffsetRange`
  `slice(int from, int to)`
  Returns a sub-range of this range (a copy).
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### from

    public final int from
    Start index, inclusive.

  - ### to

    public final int to
    End index, exclusive.

- ## Constructor Details

  - ### OffsetRange

    public OffsetRange(int from, int to)
    Parameters:
      `from` - Start index, inclusive.
      `to` - End index, exclusive.

- ## Method Details

  - ### length

    public int length()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### equals

    public boolean equals(Object other)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### slice

    public OffsetRange slice(int from, int to)
    Returns a sub-range of this range (a copy). Subclasses should override and return an appropriate type covariant so that payloads are not lost.

  - ### contains

    public boolean contains(OffsetRange other)
    Returns:
      `true` if this range contains or is equal to `other`.

  - ### clone

    public OffsetRange clone()
    Overrides:
      `clone` in class `Object`