Class SourceSection
java.lang.Object
org.graalvm.polyglot.SourceSection
Description of contiguous section of text within a 
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.- Since:
 - 19.0
 
- 
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the source code fragment described by this section.intReturns the index of the text position immediately following the last character in the section.intReturns the 0-based index of the first character in this section.intReturns the length of this section in characters.getCode()Deprecated.intReturns the 1-based column number of the last character in this section (inclusive).intReturns 1-based line number of the last character in this section (inclusive).Representation of the source program that contains this section.intReturns the 1-based column number of the first character in this section (inclusive).intReturns 1-based line number of the first character in this section (inclusive).booleanReturnstrueif this section has a character index information,falseotherwise.booleanReturnstrueif this section has a column number information,falseotherwise.inthashCode()booleanhasLines()Returnstrueif this section has a line number information,falseotherwise.booleanReturns whether this is a special instance that signifies that source information is available.toString()Returns an implementation-defined string representation of this source section to be used for debugging purposes only. 
- 
Method Details
- 
isAvailable
public boolean isAvailable()Returns whether this is a special instance that signifies that source information is available. 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 index0.- Since:
 - 19.0
 
 - 
hasLines
public boolean hasLines()Returnstrueif this section has a line number information,falseotherwise. Whentrue,getStartLine()andgetEndLine()return valid line numbers, whenfalse,getStartLine()andgetEndLine()return1.- Since:
 - 19.0
 
 - 
hasColumns
public boolean hasColumns()Returnstrueif this section has a column number information,falseotherwise. Whentrue,hasLines()istrueas well,getStartColumn()andgetEndColumn()return valid column numbers. Whenfalse,getStartColumn()andgetEndColumn()return1.- Since:
 - 19.0
 
 - 
hasCharIndex
public boolean hasCharIndex()Returnstrueif this section has a character index information,falseotherwise. Whentrue,getCharIndex(),getCharEndIndex()andgetCharLength()return valid character indices, whenfalse,getCharIndex(),getCharEndIndex()andgetCharLength()return0.- Since:
 - 19.0
 
 - 
getSource
Representation of the source program that contains this section.- Returns:
 - the source object.
 - Since:
 - 19.0
 
 - 
getStartLine
public int getStartLine()Returns 1-based line number of the first character in this section (inclusive). Returns1for out of bounds orunavailablesource sections, or source sections nothaving lines.- Returns:
 - the starting line number.
 - Since:
 - 19.0
 - See Also:
 
 - 
getStartColumn
public int getStartColumn()Returns the 1-based column number of the first character in this section (inclusive). Returns1for out of bounds orunavailablesource sections, or source sections nothaving columns.- Returns:
 - the starting column number.
 - Since:
 - 19.0
 - See Also:
 
 - 
getEndLine
public int getEndLine()Returns 1-based line number of the last character in this section (inclusive). Returns1for out of bounds orunavailablesource sections, or source sections nothaving lines.- Returns:
 - the starting line number.
 - Since:
 - 19.0
 - See Also:
 
 - 
getEndColumn
public int getEndColumn()Returns the 1-based column number of the last character in this section (inclusive). Returns1for out of bounds orunavailablesource sections, or source sections nothaving columns.- Returns:
 - the starting column number.
 - Since:
 - 19.0
 - See Also:
 
 - 
getCharIndex
public int getCharIndex()Returns the 0-based index of the first character in this section. Returns0forunavailablesource sections, or sections nothaving character index. The returned index might be out of bounds of the source code if assertions (-ea) are not enabled.- Returns:
 - the starting character index.
 - Since:
 - 19.0
 - See Also:
 
 - 
getCharLength
public int getCharLength()Returns the length of this section in characters. Returns0forunavailablesource sections, or sections nothaving character index. The returned length might be out of bounds of the source code if assertions (-ea) are not enabled.- Returns:
 - the number of characters in the section.
 - Since:
 - 19.0
 - See Also:
 
 - 
getCharEndIndex
public int getCharEndIndex()Returns the index of the text position immediately following the last character in the section. Returns0forunavailablesource sections, or sections nothaving character index. The returned index might be out of bounds of the source code if assertions (-ea) are not enabled.- Returns:
 - the end position of the section.
 - Since:
 - 19.0
 - See Also:
 
 - 
getCode
Deprecated.usegetCharacters()instead.- Since:
 - 19.0
 
 - 
getCharacters
Returns the source code fragment described by this section. Returns an empty string for out of bounds orunavailablesource sections.- Returns:
 - the code as a string.
 - Since:
 - 19.0
 
 - 
toString
 - 
hashCode
 - 
equals
 
 - 
 
getCharacters()instead.