public abstract 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 can
be used as keys in hash maps.
Modifier and Type | Method and Description |
---|---|
abstract boolean |
equals(Object obj) |
abstract CharSequence |
getCharacters()
Returns the source code fragment described by this section.
|
abstract int |
getCharEndIndex()
Returns the index of the text position immediately following the last character in the
section.
|
abstract int |
getCharIndex()
Returns the 0-based index of the first character in this section.
|
abstract int |
getCharLength()
Returns the length of this section in characters.
|
abstract int |
getEndColumn()
Returns the 1-based column number of the last character in this section (inclusive).
|
abstract 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.
|
abstract int |
getStartColumn()
Returns the 1-based column number of the first character in this section (inclusive).
|
abstract int |
getStartLine()
Returns 1-based line number of the first character in this section (inclusive).
|
abstract boolean |
hasCharIndex()
Returns
true if this section has a character index information,
false otherwise. |
abstract boolean |
hasColumns()
Returns
true if this section has a column number information, false
otherwise. |
abstract int |
hashCode() |
abstract boolean |
hasLines()
Returns
true if this section has a line number information, false
otherwise. |
abstract 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 abstract boolean isAvailable()
Source.createUnavailableSection()
. Available source sections are never equal to
unavailable source sections. Unavailable source sections return the same indices and lengths
as empty source sections starting at character index 0
.Source.createUnavailableSection()
public abstract 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 abstract 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 abstract 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 final Source getSource()
public abstract int getStartLine()
1
for out of bounds or unavailable
source sections, or
source sections not having lines
.SourceSection.hasLines()
public abstract int getStartColumn()
1
for out of bounds or unavailable
source sections, or
source sections not having columns
.SourceSection.hasColumns()
public abstract int getEndLine()
1
for out of bounds or unavailable
source sections, or
source sections not having lines
.SourceSection.hasLines()
public abstract int getEndColumn()
1
for out of bounds or unavailable
source sections, or
source sections not having columns
.SourceSection.hasColumns()
public abstract 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 abstract 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 abstract 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 abstract CharSequence getCharacters()
unavailable
source sections, or sections
whose source does not have characters
.Source.hasCharacters()
public final String toString()
toString
in class Object
SourceSection.getCharacters()