Class StringRange
java.lang.Object
dev.polv.taleapi.command.suggestion.StringRange
Represents a range within a string, used for suggestion placement.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringRangeat(int pos) Creates a range at a single position.static StringRangebetween(int start, int end) Creates a range between two positions.static StringRangeCreates a range encompassing both given ranges.booleanExtracts the substring covered by this range.intgetEnd()Returns the end index (exclusive).intReturns the length of this range.intgetStart()Returns the start index (inclusive).inthashCode()booleanisEmpty()Checks if this range is empty.toString()
-
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
Creates a range at a single position.- Parameters:
pos- the position- Returns:
- a zero-length range at that position
-
between
Creates a range between two positions.- Parameters:
start- the start indexend- the end index- Returns:
- a new range
-
encompassing
Creates a range encompassing both given ranges.- Parameters:
a- the first rangeb- 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:
trueif the range has zero length
-
get
Extracts the substring covered by this range.- Parameters:
string- the string to extract from- Returns:
- the substring
-
equals
-
hashCode
public int hashCode() -
toString
-