public class PositionRegion extends Object
PositionRegion.getStartOffset()
<= PositionRegion.getEndOffset()
.Constructor and Description |
---|
PositionRegion(Document doc,
int startOffset,
int endOffset)
Construct new position region based on the knowledge
of the document and starting and ending offset.
|
PositionRegion(Position startPosition,
Position endPosition)
Construct new position region.
|
Modifier and Type | Method and Description |
---|---|
static Position |
createFixedPosition(int offset)
Create a fixed position instance that just wraps a given integer offset.
|
static Comparator<PositionRegion> |
getComparator()
Get comparator for position regions comparing start offsets
of the two given regions.
|
int |
getEndOffset()
Get ending offset of this region.
|
Position |
getEndPosition()
Get ending position of this region.
|
int |
getLength()
Get length of this region.
|
int |
getStartOffset()
Get starting offset of this region.
|
Position |
getStartPosition()
Get starting position of this region.
|
String |
getString(Document doc)
Get text enclosed by this position region as a String.
|
CharSequence |
getText(Document doc)
Get text enclosed by this position region as a character sequence.
|
static boolean |
isRegionsSorted(List<? extends PositionRegion> positionRegionList)
Check whether a list of position regions is sorted
according the start offsets of the regions.
|
String |
toString()
Debug info about this region.
|
String |
toString(Document doc)
Debug info about this region that includes line and column info.
|
public PositionRegion(Position startPosition, Position endPosition)
startPosition
- non-null start position of the region <= end position.endPosition
- non-null end position of the region >= start position.public PositionRegion(Document doc, int startOffset, int endOffset) throws BadLocationException
BadLocationException
public static final Comparator<PositionRegion> getComparator()
public static Position createFixedPosition(int offset)
offset
- >=0 offset at which the position should be created.public static boolean isRegionsSorted(List<? extends PositionRegion> positionRegionList)
positionRegionList
- list of the regions to be compared.public final int getStartOffset()
public final Position getStartPosition()
public final int getEndOffset()
public final Position getEndPosition()
public final int getLength()
getEndOffset() - getStartOffset()
.public CharSequence getText(Document doc)
doc
- non-null document to which this position region belongs.IndexOutOfBoundsException
- if the bounds are wrong
(likely positions were created for another document).public String getString(Document doc) throws BadLocationException
doc
- non-null document to which this position region belongs.BadLocationException
- if the bounds are wrong
(likely positions were created for another document).public String toString(Document doc)
doc
- non-null document to which this position region belongs.