public class Position extends Object
This is an immutable value object.
| Modifier and Type | Field and Description |
|---|---|
int |
length
The length of the position
|
int |
offset
The offset of the position
|
| Constructor and Description |
|---|
Position(int offset)
Creates a new position with the given offset and length 0.
|
Position(int offset,
int length)
Creates a new position with the given offset and length.
|
| Modifier and Type | Method and Description |
|---|---|
static Position |
createStartEnd(int start,
int end)
Static factory method to create a position based on its start and end offsets.
|
boolean |
equals(Object obj) |
int |
getEndOffset()
Calculates the end offset of this position.
|
int |
getLength()
Returns the length of this position.
|
int |
getOffset()
Returns the offset of this position.
|
int |
hashCode() |
boolean |
overlapsWith(int rangeOffset,
int rangeLength)
Checks whether the intersection of the given text range and the text range represented by
this position is empty or not.
|
String |
toString() |
public final int offset
public final int length
public Position(int offset)
offset - the position offset, must be >= 0public Position(int offset,
int length)
offset - the position offset, must be >= 0length - the position length, must be >= 0public int getLength()
public int getOffset()
public int getEndOffset()
public boolean overlapsWith(int rangeOffset,
int rangeLength)
rangeOffset - the offset of the range to checkrangeLength - the length of the range to checktrue if intersection is not emptypublic static Position createStartEnd(int start, int end)
start - the start offset of the positionend - the end offset of the positionCopyright © 2003–2016 Community Z Tools Project. All rights reserved.