public abstract class LanguageAdapterBase extends Object implements LanguageAdapter
DEFAULT_EXTENSION, DEFAULT_TAG, EXTENSIONS, LANGUAGE_NAME, LANGUAGE_VERSION, NAME, TAGS, VERSION
Constructor and Description |
---|
LanguageAdapterBase(String name,
String version,
String languageName,
String languageVersion,
Collection<String> extensions,
String defaultExtension,
Collection<String> tags,
String defaultTag)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
enter(String entryPointName,
Executable executable,
ExecutionContext executionContext,
Object... arguments)
Enters the executable at a stored, named location.
|
Map<String,Object> |
getAttributes()
Adapter attributes.
|
Lock |
getLock()
Used when
LanguageAdapter.isThreadSafe() returns false. |
LanguageManager |
getManager()
The language manager.
|
String |
getSourceCodeForExpressionInclude(String expression,
Executable executable)
Creates source code for including the output of a text-with-scriptlets
document.
|
String |
getSourceCodeForExpressionOutput(String expression,
Executable executable)
Creates source code for outputting a source code expression to standard
output.
|
String |
getSourceCodeForLiteralOutput(String literal,
Executable executable)
Creates source code for outputting literal text to standard output.
|
boolean |
isEphemeral()
Some languages are meant for use in one segment only.
|
boolean |
isThreadSafe()
Some languages or their script engines are inherently broken when called
by multiple threads.
|
void |
releaseContext(ExecutionContext executionContext)
Cleans up any resources used for an execution context.
|
void |
setManager(LanguageManager manager)
The language manager.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createProgram
public LanguageAdapterBase(String name, String version, String languageName, String languageVersion, Collection<String> extensions, String defaultExtension, Collection<String> tags, String defaultTag) throws LanguageAdapterException
name
- The name of the language adapter implementationversion
- The version of the language adapter implementationlanguageName
- The name of the implemented languagelanguageVersion
- The version of the implemented languageextensions
- Standard source code filename extensionsdefaultExtension
- Default source code filename extensiontags
- Language tags supported for scriptletsdefaultTag
- Default language tag used for scriptletsLanguageAdapterException
- In case of an initialization errorpublic LanguageManager getManager()
LanguageAdapter
getManager
in interface LanguageAdapter
public void setManager(LanguageManager manager)
LanguageAdapter
setManager
in interface LanguageAdapter
manager
- The managerpublic Map<String,Object> getAttributes()
LanguageAdapter
getAttributes
in interface LanguageAdapter
public boolean isThreadSafe()
LanguageAdapter
isThreadSafe
in interface LanguageAdapter
public boolean isEphemeral()
LanguageAdapter
isEphemeral
in interface LanguageAdapter
public Lock getLock()
LanguageAdapter
LanguageAdapter.isThreadSafe()
returns false.getLock
in interface LanguageAdapter
public Object enter(String entryPointName, Executable executable, ExecutionContext executionContext, Object... arguments) throws NoSuchMethodException, ParsingException, ExecutionException
LanguageAdapter
enter
in interface LanguageAdapter
entryPointName
- The entry point nameexecutable
- The executableexecutionContext
- The executable contextarguments
- Optional state to pass to the entry pointNoSuchMethodException
- In case the entry point does not existParsingException
- In case of a parsing errorExecutionException
- In case of an execution errorpublic void releaseContext(ExecutionContext executionContext)
LanguageAdapter
releaseContext
in interface LanguageAdapter
executionContext
- The execution contextExecutionContext.getAttributes()
public String getSourceCodeForLiteralOutput(String literal, Executable executable) throws ParsingException
LanguageAdapter
getSourceCodeForLiteralOutput
in interface LanguageAdapter
literal
- The literal textexecutable
- The executableParsingException
- In case of a parsing errorpublic String getSourceCodeForExpressionOutput(String expression, Executable executable) throws ParsingException
LanguageAdapter
getSourceCodeForExpressionOutput
in interface LanguageAdapter
expression
- The source code expressionexecutable
- The executableParsingException
- In case of a parsing errorpublic String getSourceCodeForExpressionInclude(String expression, Executable executable) throws ParsingException
LanguageAdapter
For this to work, the executable must have been created with a container
that supports an inclusion command named according to the language
manager attribute
LanguageManager.CONTAINER_INCLUDE_COMMAND_ATTRIBUTE
.
getSourceCodeForExpressionInclude
in interface LanguageAdapter
expression
- The source code expressionexecutable
- The executableParsingException
- In case of a parsing errorLanguageManager.getAttributes()
Copyright © 2009-2015 Three Crickets LLC.