public final class SourceSection extends Object
Source
of program code.; supports
multiple modes of access to the text and its location.
Two available source sections are considered equal if their sources, start and length are equal.
Unavailable
source sections are compared by identity. Source sections are
designed to be used as keys in hash maps.Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
CharSequence |
getCharacters()
Returns the source code fragment described by this section.
|
int |
getCharEndIndex()
Returns the index of the text position immediately following the last character in the
section.
|
int |
getCharIndex()
Returns the 0-based index of the first character in this section.
|
int |
getCharLength()
Returns the length of this section in characters.
|
int |
getEndColumn()
Returns the 1-based column number of the last character in this section (inclusive).
|
int |
getEndLine()
Returns 1-based line number of the last character in this section (inclusive).
|
Source |
getSource()
Representation of the source program that contains this section.
|
int |
getStartColumn()
Returns the 1-based column number of the first character in this section (inclusive).
|
int |
getStartLine()
Returns 1-based line number of the first character in this section (inclusive).
|
boolean |
hasCharIndex()
Returns
true if this section has a character index information,
false otherwise. |
boolean |
hasColumns()
Returns
true if this section has a column number information, false
otherwise. |
int |
hashCode() |
boolean |
hasLines()
Returns
true if this section has a line number information, false
otherwise. |
boolean |
isAvailable()
Returns whether this is a special instance that signifies that source information is
available.
|
String |
toString()
Returns an implementation-defined string representation of this source section to be used for
debugging purposes only.
|
public boolean isAvailable()
0
.public boolean hasLines()
true
if this section has a line number information, false
otherwise. When true
, SourceSection.getStartLine()
and SourceSection.getEndLine()
return
valid line numbers, when false
, SourceSection.getStartLine()
and
SourceSection.getEndLine()
return 1
.public boolean hasColumns()
true
if this section has a column number information, false
otherwise. When true
, SourceSection.hasLines()
is true
as well,
SourceSection.getStartColumn()
and SourceSection.getEndColumn()
return valid column numbers. When
false
, SourceSection.getStartColumn()
and SourceSection.getEndColumn()
return
1
.public boolean hasCharIndex()
true
if this section has a character index information,
false
otherwise. When true
, SourceSection.getCharIndex()
,
SourceSection.getCharEndIndex()
and SourceSection.getCharLength()
return valid character indices, when
false
, SourceSection.getCharIndex()
, SourceSection.getCharEndIndex()
and
SourceSection.getCharLength()
return 0
.public Source getSource()
public int getStartLine()
1
for out of bounds or unavailable
source sections, or
source sections not having lines
.SourceSection.hasLines()
public int getStartColumn()
1
for out of bounds or unavailable
source sections, or
source sections not having columns
.SourceSection.hasColumns()
public int getEndLine()
1
for out of bounds or unavailable
source sections, or
source sections not having lines
.SourceSection.hasLines()
public int getEndColumn()
1
for out of bounds or unavailable
source sections, or
source sections not having columns
.SourceSection.hasColumns()
public int getCharIndex()
0
for
unavailable
source sections, or sections not having character index
. The returned index might be out of bounds of the source code if
assertions (-ea) are not enabled.SourceSection.hasCharIndex()
public int getCharLength()
0
for
unavailable
source sections, or sections not having character index
. The returned length might be out of bounds of the source code if
assertions (-ea) are not enabled.SourceSection.hasCharIndex()
public int getCharEndIndex()
0
for unavailable
source sections, or
sections not having character index
. The returned index might be out
of bounds of the source code if assertions (-ea) are not enabled.SourceSection.hasCharIndex()
public CharSequence getCharacters()
unavailable
source sections.public String toString()
toString
in class Object
SourceSection.getCharacters()