Class StringRange

java.lang.Object
dev.polv.taleapi.command.suggestion.StringRange

public final class StringRange extends Object
Represents a range within a string, used for suggestion placement.
  • Constructor Details

    • StringRange

      public StringRange(int start, int end)
      Creates a new range.
      Parameters:
      start - the start index (inclusive)
      end - the end index (exclusive)
  • Method Details

    • at

      public static StringRange at(int pos)
      Creates a range at a single position.
      Parameters:
      pos - the position
      Returns:
      a zero-length range at that position
    • between

      public static StringRange between(int start, int end)
      Creates a range between two positions.
      Parameters:
      start - the start index
      end - the end index
      Returns:
      a new range
    • encompassing

      public static StringRange encompassing(StringRange a, StringRange b)
      Creates a range encompassing both given ranges.
      Parameters:
      a - the first range
      b - the second range
      Returns:
      a range spanning both
    • getStart

      public int getStart()
      Returns the start index (inclusive).
      Returns:
      the start index
    • getEnd

      public int getEnd()
      Returns the end index (exclusive).
      Returns:
      the end index
    • getLength

      public int getLength()
      Returns the length of this range.
      Returns:
      the length
    • isEmpty

      public boolean isEmpty()
      Checks if this range is empty.
      Returns:
      true if the range has zero length
    • get

      public String get(String string)
      Extracts the substring covered by this range.
      Parameters:
      string - the string to extract from
      Returns:
      the substring
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object