Additional top-level class in compilation unit: SourceSnippets.
context. Each source is associated with the the ID of the language.
SourceSnippets#fromFile
The starting point is Source#newBuilder(String, java.io.File) method.
Source#newBuilder(String, java.net.URL)
factory: SourceSnippets#fromURL
Each URL source is represented as a canonical object, indexed by the URL. Contents are read
eagerly once the Builder#build() method is called.
Source#newBuilder(String, java.lang.CharSequence, String) factory method: SourceSnippets#fromAString
Reader one can convert its content into a Source via
Source#newBuilder(String, java.io.Reader, String) method: SourceSnippets#fromReader
the content is read eagerly once the Builder#build() method is called.
UnsupportedOperationException if that is the case.
SourceSnippets#fromBytes
getName() and
getURI(), getMimeType() and these are immutable. The system makes the best
effort to derive values of these attributes from the location and/or content of the
Source object. However, to give the user that creates the source control over these
attributes, the API offers an way to alter values of these attributes.
byte or character based, or none of
those when no content is specified. For literal sources it depends on whether the byte or
character based factory method was used. When the source was loaded from a file or
url then the default MIME type of the provided
language will be used to determine whether bytes or characters should be loaded. The behavior can
be customized by specifying a MIME type or
content explicitly. If the specified or inferred MIME type
starts with 'text/ or the MIME types is null then it will be
interpreted as character based, otherwise byte based.
To evaluate sources., To detect a language using a File, To detect a language using a URL., To detect a MIME type using a File., To detect a MIME type using a URL.
| Modifier and Type | Class and Description |
|---|---|
| public class | Source.
Represents a builder to build |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final AbstractPolyglotImpl. | |
| private static final Source | |
| private static volatile AbstractPolyglotImpl | |
| pack-priv final Object |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static Source | create(String language, CharSequence source)
Shortcut for creating a source object from a language and char sequence. |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public static String | findLanguage(File
the file to find the first language for file)Returns the id of the first language that supports evaluating the probed mime type of a given
|
| public static String | findLanguage(URL
the url to find the first language for url)Returns the id of the first language that supports evaluating the probed mime type of a given
|
| public static String | findLanguage(String mimeType)
Returns the first installed language that supports evaluating sources for a given MIME type. |
| public static String | findMimeType(File file)
Returns the probed MIME type for a given file, or |
| public static String | findMimeType(URL url)
Returns the probed MIME type for a given url, or |
| public ByteSequence | |
| public CharSequence | |
| public CharSequence | getCharacters(int lineNumber)
Gets the text (not including a possible terminating newline) in a (1-based) numbered line. |
| public int | getColumnNumber(int offset)
Given a 0-based character offset, return the 1-based number of the column at the position. |
| pack-priv static AbstractPolyglotImpl | |
| public InputStream | |
| public String | |
| public int | |
| public int | getLineCount()
The number of text lines of a character based source, including empty lines; characters at the end of the source without a terminating newline count as a line. |
| public int | getLineLength(int lineNumber)
The number of characters (not counting a possible terminating newline) in a (1-based) numbered line. |
| public int | getLineNumber(int offset)
Given a 0-based character offset, return the 1-based number of the line that includes the position. |
| public int | getLineStartOffset(int lineNumber)
Given a 1-based line number, return the 0-based offset of the first character in the line. |
| public String | Returns: MIME type of this source ornull, if not explicitly set.Returns the MIME type that is associated with this source. |
| public String | Returns: the name of the guest language programReturns the name of this resource holding a guest language program. |
| public String | |
| public Reader | |
| public URI | |
| public URL | |
| public boolean | |
| public boolean | |
| public int | |
| private static IllegalArgumentException | |
| public boolean | Returns: whether this source is marked as interactiveCheck whether this source has been marked as interactive. |
| public boolean | Returns: whether this source is marked as internalGets whether this source has been marked as internal, meaning that it has been provided by the infrastructure, language implementation, or system library. |
| public static Source. | newBuilder(String
the language id, must not be language, CharSequence nullthe character sequence or string, must not be characters, String nullthe name of the source, if name)null then "Unnamed" will be
used as name.Creates a new character based literal source from a character sequence. |
| public static Source. | newBuilder(String
the language id, must not be language, ByteSequence nullthe byte sequence or string, must not be bytes, String nullthe name of the source, if name)null then "Unnamed" will be
used as name.Creates a new byte based literal source from a byte sequence. |
| public static Source. | newBuilder(String
the language id, must not be language, File nullthe file to use, must not be file)nullCreates a new file based source builder from a given file. |
| public static Source. | newBuilder(String
the language id, must not be language, URL nullthe URL to use and load, must not be url)nullCreates a new URL based source builder from a given URL. |
| public static Source. | newBuilder(String language, Reader source, String name)
Creates new character based literal source from a reader. |
| pack-priv static <E extends Exception> RuntimeException | |
| public String | |
| private static void |