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 can
be used as keys in hash maps.
Source.createSection(int),
Source.createSection(int, int),
Source.createSection(int, int, int),
Source.createUnavailableSection()| 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).
|
int |
hashCode() |
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()
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 Source getSource()
public int getStartLine()
1 for out of bounds or unavailable source sections.
Please note that calling this method causes the code of the
source to be loaded if it was not yet loaded.public int getStartColumn()
1 for out of bounds or unavailable source sections.
Please note that calling this method causes the code of the
source to be loaded if it was not yet loaded.public int getEndLine()
1 for out of bounds or unavailable source sections.
Please note that calling this method causes the code of the
source to be loaded if it was not yet loaded.public int getEndColumn()
1 for out of bounds or unavailable source sections.
Please note that calling this method causes the code of the
source to be loaded if it was not yet loaded.public int getCharIndex()
0 for
unavailable source sections. Please note that calling this method does
not cause the code of the source to be
loaded. The returned index might be out of bounds of the source code if assertions (-ea) are
not enabled.public int getCharLength()
0 for
unavailable source sections. Please note that calling this method does
not cause the code of the source to be
loaded. The returned length might be out of bounds of the source code if assertions (-ea) are
not enabled.public int getCharEndIndex()
0 for unavailable source sections.
Please note that calling this method does not cause the code
of the source to be loaded. The returned index might be out of bounds of
the source code if assertions (-ea) are not enabled.public CharSequence getCharacters()
unavailable source sections. Please note
that calling this method causes the code of the
source to be loaded if it was not yet loaded.public String toString()
toString in class ObjectSourceSection.getCharacters()