public class Range extends Object
Constructor and Description |
---|
Range(Position begin,
Position end)
A range of characters in a source file, from "begin" to "end".
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Position position)
Does this loosely contain the other range?
|
boolean |
contains(Range other)
Does this loosely contain the other range?
|
boolean |
equals(Object o) |
int |
getLineCount() |
int |
hashCode() |
boolean |
isAfter(Position position) |
boolean |
isBefore(Position position) |
boolean |
overlapsWith(Range other)
Does the other 'Range' overlap with this 'Range'?
|
static Range |
range(int beginLine,
int beginColumn,
int endLine,
int endColumn)
Create a new `Range` object using the given begin and end line/column values.
|
static Range |
range(Position begin,
Position end)
Create a new `Range` object using the given begin and end position.
|
boolean |
strictlyContains(Position position)
Does this strictly contain position.
|
boolean |
strictlyContains(Range other)
Does this strictly contain the other range?
|
String |
toString() |
Range |
withBegin(Position begin) |
Range |
withBeginColumn(int beginColumn) |
Range |
withBeginLine(int beginLine) |
Range |
withEnd(Position end) |
Range |
withEndColumn(int endColumn) |
Range |
withEndLine(int endLine) |
public Range(Position begin, Position end)
Note that if the given parameters are reversed (i.e. the end is earlier than begin, then the values are swapped.
begin
- The starting position of the range.end
- The end position of the range.public static Range range(Position begin, Position end)
begin
- The starting position of the range.end
- The end position of the range.public static Range range(int beginLine, int beginColumn, int endLine, int endColumn)
Position
.beginLine
- The start line of the range.beginColumn
- The start line column of the range.endLine
- The end line of the range.endColumn
- The end column of the range.public Range withBeginColumn(int beginColumn)
beginColumn
- The value used to replace the current begin column number.
Valid values are per the constructor ofPosition
.public Range withBeginLine(int beginLine)
beginLine
- The value used to replace the current begin line number.
Valid values are per the constructor ofPosition
.public Range withEndColumn(int endColumn)
endColumn
- The value used to replace the current end column number.
Valid values are per the constructor ofPosition
.public Range withEndLine(int endLine)
endLine
- The value used to replace the current end line number.
Valid values are per the constructor ofPosition
.public Range withBegin(Position begin)
begin
- The value used to replace the current begin position.public Range withEnd(Position end)
end
- The value used to replace the current end position.public boolean contains(Range other)
As strictlyContains(Range)
, but also allow ranges which have an equal start and/or end position.
In these cases, the `other` range is not strictly "inside" of this range.
public boolean contains(Position position)
As strictlyContains(Position)
, but a position that is on the "edge" of this range will also pass.
For example, if the given position is equal to the start or end position of this range. In these cases, the `other` range is not strictly "inside" of this range.
public boolean strictlyContains(Range other)
It means that this has to be larger than other and it has to start before other and end after other.
public boolean strictlyContains(Position position)
It means that the position is after the begin of this range and before the end of this range.
public boolean overlapsWith(Range other)
If two ranges overlap, this range or the other range contains the begin or the end of the other range.
Note that if the ends are "touching" (i.e. a begin position == end position), this counts as an overlap because the positions refer to characters, as opposed to boundary between characters.
For example, there is an overlap at "C" in the following ranges, with "C" existing within both ranges:
Range 1: ABC Range 2: CDE
public boolean isBefore(Position position)
position
- The position to compare against.public boolean isAfter(Position position)
position
- The position to compare against.public int getLineCount()
If the start line and end line are the same, this range is limited to just one line.
Copyright © 2007–2019. All rights reserved.