java.lang.Object
de.grogra.pf.ui.autocomplete.impl.DocumentRange
- All Implemented Interfaces:
Comparable<DocumentRange>
A range of text in a document.
- Version:
- 1.0
- Author:
- Robert Futrell
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(DocumentRange other) Compares this document range to another.boolean
Returns whether this document range is equal to another one.int
Gets the end offset of the range.int
Gets the starting offset of the range.int
hashCode()
Overridden simply as a best practice, sinceequals(Object)
is overridden.boolean
Returns whether this document range has zero length.void
set
(int start, int end) Sets the document range.toString()
Returns a string representation of this object.translate
(int amount) Translates this document range by a given amount.
-
Constructor Details
-
DocumentRange
public DocumentRange(int startOffs, int endOffs) Constructor.- Parameters:
startOffs
- The starting offset in the document, inclusive.endOffs
- The ending offset in the document, exclusive.- Throws:
IllegalArgumentException
- IfendOffs
is less thanstartOffs
, or either argument is less than zero.
-
-
Method Details
-
compareTo
Compares this document range to another.- Specified by:
compareTo
in interfaceComparable<DocumentRange>
- Parameters:
other
- Another document range.- Returns:
- How the two should be sorted relative to each other.
-
equals
Returns whether this document range is equal to another one. -
getEndOffset
public int getEndOffset()Gets the end offset of the range.- Returns:
- The end offset.
- See Also:
-
getStartOffset
public int getStartOffset()Gets the starting offset of the range.- Returns:
- The starting offset.
- See Also:
-
hashCode
public int hashCode()Overridden simply as a best practice, sinceequals(Object)
is overridden. -
isZeroLength
public boolean isZeroLength()Returns whether this document range has zero length. This can happen, for example, with regex searches of forms like"foo|"
, where the right-hand sub-expression matches empty strings.- Returns:
- Whether this document range has zero length.
-
set
public void set(int start, int end) Sets the document range.- Parameters:
start
- The new start value, inclusive.end
- The new end value, exclusive.- Throws:
IllegalArgumentException
- Ifend
is less thanstart
, or either argument is less than zero.
-
toString
Returns a string representation of this object. -
translate
Translates this document range by a given amount.- Parameters:
amount
- The amount to translate this range by.- Returns:
- This (modified) range.
-