ScriptEngine implementation called Artifact that evaluates a super-set of Java source code.See: Description
| Class | Description |
|---|---|
| ArtifactScript |
ArtifactScript is an implementation of CompiledScript and is extended by each script class that is evaluated by this Artifact ScriptEngine implementation. |
| ArtifactScriptEngineFactory |
ArtifactScriptEngineFactory is a ScriptEngineFactory that manages a ScriptEngine called Artifact that evaluates a super-set of Java source code. |
| Main |
This class is the entry-point for the CLI- and GUI-program.
|
ScriptEngine implementation called Artifact that evaluates a super-set of Java source code.
The ScriptEngine provided compiles the source code into CompiledScripts and loads them, using the context ClassLoader. It caches the CompiledScripts using a normalized version of the source code provided for that
CompiledScript. By doing so, no re-compilation will be performed when you add whitespace in other places than String literals.
To demonstrate its use, here is an example:
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine scriptEngine = scriptEngineManager.getEngineByExtension("java");
scriptEngine.eval("System.out.println(\"Hello, World!\"); return true;");
As you can see in the example above, you can return a result. Although you can, it's not necessary. If nothing is returned by you, null will be returned by default.
If a variable starts with a dollar sign ($), followed by a variable name (a Java identifier), that variable will be substituted for a variable in the ScriptContext and cast to its type. Lets say you have a variable $string
that refers to a variable called "string" in the ScriptContext, and that variable is of type String. A call such as $string.length() would return the length of the String variable. Note, however, that this
assumes the variable already exists in the ScriptContext prior to the evaluation of the current script. Adding a variable to the ScriptContext and then using this variable substitution mechanism to get that variable in the same
script won't work. The reason for this, is that the variable substitution is performed prior to the evaluation of the script itself.