public final class Source.LiteralBuilder extends Source.SourceBuilder
For examples on how to use it.| Modifier and Type | Method and Description |
|---|---|
Source |
build()
Uses configuration of this builder to create new
Source object. |
Source.LiteralBuilder |
cached(boolean cached)
Enables or disables code caching for this source.
|
Source.LiteralBuilder |
interactive(boolean enabled)
Marks the source as interactive.
|
Source.LiteralBuilder |
internal(boolean enabled)
Marks the source as internal.
|
Source.LiteralBuilder |
mimeType(String newMimeType)
|
Source.LiteralBuilder |
name(String newName)
Specifies a name to the
to-be-built Source. |
Source.LiteralBuilder |
uri(URI ownUri)
|
content, contentpublic Source.LiteralBuilder name(String newName)
to-be-built Source.name in class Source.SourceBuildernewName - name that replaces the previously given one. If set to null
then "Unnamed" will be used.this builderpublic Source.LiteralBuilder mimeType(String newMimeType)
MIME type to the to-be-built Source. If the MIME type is null then the
default MIME type of the language will be used to
interpret the source. If set explicitly then the language needs to
support the MIME type in order to
parse a
source. If not null then the MIME type will be verified containing no spaces
and a '/' between group and sub-group. An example for a valid MIME type is:
text/javascript.
The MIME type can be guessed by the system based on files or urls.
mimeType in class Source.SourceBuildernewMimeType - the new mime type to be assigned, or null if default MIME
type should be used.this builder ready to create new sourceLanguageInfo.getDefaultMimeType(),
LanguageInfo.getMimeTypes(),
Source.findMimeType(TruffleFile),
Source.findMimeType(URL)public Source.LiteralBuilder cached(boolean cached)
true then the source does not require parsing every time this source is
evaluated. If false then the source requires parsing every time the source
is evaluated but does not remember any code. Disabling caching may be useful if the
source is known to only be evaluated once.
If a source instance is no longer referenced by the client then all code caches will be freed automatically. Also, if the underlying context or engine is no longer referenced then cached code for evaluated sources will be freed automatically.
cached in class Source.SourceBuilderthis builder ready to create new sourcepublic Source.LiteralBuilder internal(boolean enabled)
Source.isInternal()internal in class Source.SourceBuilderpublic Source.LiteralBuilder interactive(boolean enabled)
interactive
language can use the environment
streams to print the result and read an input. However, non-interactive languages are
expected to ignore the interactive property of sources and not use the environment
streams. Any desired printing of the evaluated result provided by a non-interactive
language needs to be handled by the caller. Calling of this method influences the result
of Source.isInteractive().interactive in class Source.SourceBuilderpublic Source.LiteralBuilder uri(URI ownUri)
URI to the to-be-created Source. Each source
provides Source.getURI() as a persistent identification of its location. A
default value for the method is deduced from the location or content, but one can change
it by using this methoduri in class Source.SourceBuilderownUri - the URL to use instead of default one, cannot be nullpublic Source build()
Source object.build in class Source.SourceBuilder