Top Description Fields Constructors Methods
org.graalvm.polyglot

public final Class SourceSection

extends Object
Class Inheritance
Imports
org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractSourceSectionDispatch

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

Field Summary

Modifier and TypeField and Description
pack-priv final AbstractPolyglotImpl.AbstractSourceSectionDispatch
pack-priv final Object
pack-priv final Source

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public CharSequence

Returns:

the code as a string.
getCharacters
()

Returns the source code fragment described by this section.

public int

Returns:

the end position of the section.
getCharEndIndex
()

Returns the index of the text position immediately following the last character in the section.

public int

Returns:

the starting character index.
getCharIndex
()

Returns the 0-based index of the first character in this section.

public int

Returns:

the number of characters in the section.
getCharLength
()

Returns the length of this section in characters.

public CharSequence
getCode()
Deprecated since 19.0. use getCharacters() instead.

public int

Returns:

the starting column number.
getEndColumn
()

Returns the 1-based column number of the last character in this section (inclusive).

public int

Returns:

the starting line number.
getEndLine
()

Returns 1-based line number of the last character in this section (inclusive).

public Source

Returns:

the source object.
getSource
()

Representation of the source program that contains this section.

public int

Returns:

the starting column number.
getStartColumn
()

Returns the 1-based column number of the first character in this section (inclusive).

public int

Returns:

the starting line number.
getStartLine
()

Returns 1-based line number of the first character in this section (inclusive).

public boolean
hasCharIndex()

Returns true if this section has a character index information, false otherwise.

public boolean
hasColumns()

Returns true if this section has a column number information, false otherwise.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
hasLines()

Returns true if this section has a line number information, false otherwise.

public boolean
isAvailable()

Returns whether this is a special instance that signifies that source information is available.

public String
toString()

Overrides java.lang.Object.toString.

Returns an implementation-defined string representation of this source section to be used for debugging purposes only.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

dispatchback to summary
pack-priv final AbstractPolyglotImpl.AbstractSourceSectionDispatch dispatch
receiverback to summary
pack-priv final Object receiver
sourceback to summary
pack-priv final Source source

Constructor Detail

SourceSectionback to summary
pack-priv SourceSection(Source source, AbstractPolyglotImpl.AbstractSourceSectionDispatch dispatch, Object receiver)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
Since
19.0 or earlier
getCharactersback to summary
public CharSequence getCharacters()

Returns the source code fragment described by this section. Returns an empty string for out of bounds or unavailable source sections.

Returns:CharSequence

the code as a string.

Since
19.0
getCharEndIndexback to summary
public int getCharEndIndex()

Returns the index of the text position immediately following the last character in the section. Returns 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.

Returns:int

the end position of the section.

Since
19.0
See Also
hasCharIndex()
getCharIndexback to summary
public int getCharIndex()

Returns the 0-based index of the first character in this section. Returns 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.

Returns:int

the starting character index.

Since
19.0
See Also
hasCharIndex()
getCharLengthback to summary
public int getCharLength()

Returns the length of this section in characters. Returns 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.

Returns:int

the number of characters in the section.

Since
19.0
See Also
hasCharIndex()
getCodeback to summary
public CharSequence getCode()

Deprecated

since 19.0.

use getCharacters() instead.

Annotations
@Deprecated
since:19.0
Since
19.0
getEndColumnback to summary
public int getEndColumn()

Returns the 1-based column number of the last character in this section (inclusive). Returns 1 for out of bounds or unavailable source sections, or source sections not having columns.

Returns:int

the starting column number.

Since
19.0
See Also
hasColumns()
getEndLineback to summary
public int getEndLine()

Returns 1-based line number of the last character in this section (inclusive). Returns 1 for out of bounds or unavailable source sections, or source sections not having lines.

Returns:int

the starting line number.

Since
19.0
See Also
hasLines()
getSourceback to summary
public Source getSource()

Representation of the source program that contains this section.

Returns:Source

the source object.

Since
19.0
getStartColumnback to summary
public int getStartColumn()

Returns the 1-based column number of the first character in this section (inclusive). Returns 1 for out of bounds or unavailable source sections, or source sections not having columns.

Returns:int

the starting column number.

Since
19.0
See Also
hasColumns()
getStartLineback to summary
public int getStartLine()

Returns 1-based line number of the first character in this section (inclusive). Returns 1 for out of bounds or unavailable source sections, or source sections not having lines.

Returns:int

the starting line number.

Since
19.0
See Also
hasLines()
hasCharIndexback to summary
public boolean hasCharIndex()

Returns true if this section has a character index information, false otherwise. When true, getCharIndex(), getCharEndIndex() and getCharLength() return valid character indices, when false, getCharIndex(), getCharEndIndex() and getCharLength() return 0.

Since
19.0
hasColumnsback to summary
public boolean hasColumns()

Returns true if this section has a column number information, false otherwise. When true, hasLines() is true as well, getStartColumn() and getEndColumn() return valid column numbers. When false, getStartColumn() and getEndColumn() return 1.

Since
19.0
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
Since
19.0 or earlier
hasLinesback to summary
public boolean hasLines()

Returns true if this section has a line number information, false otherwise. When true, getStartLine() and getEndLine() return valid line numbers, when false, getStartLine() and getEndLine() return 1.

Since
19.0
isAvailableback to summary
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 index 0.

Since
19.0
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns an implementation-defined string representation of this source section to be used for debugging purposes only.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
Since
19.0
See Also
getCharacters()