public abstract class ArtifactScript
extends javax.script.CompiledScript
ArtifactScript
is an implementation of CompiledScript
and is extended by each script class that is evaluated by this Artifact ScriptEngine
implementation.
The purpose with this class, is to supply all script writers with a simple API they can use when writing their scripts.
Modifier | Constructor and Description |
---|---|
protected |
ArtifactScript(javax.script.ScriptEngine scriptEngine)
Constructs a new
ArtifactScript instance. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
eval(java.lang.String script)
Executes
script as script. |
java.lang.Object |
get(java.lang.String key)
Returns the value assigned to
key , or null if no value is assigned to key . |
javax.script.ScriptEngine |
getEngine()
Returns the
ScriptEngine whose compile method created this ArtifactScript . |
void |
set(java.lang.String key,
java.lang.Object value)
Sets the value
value for the key key . |
protected ArtifactScript(javax.script.ScriptEngine scriptEngine)
ArtifactScript
instance.
If scriptEngine
is null
, a NullPointerException
will be thrown.
scriptEngine
- a ScriptEngine
java.lang.NullPointerException
- thrown if, and only if, scriptEngine
is null
public final java.lang.Object eval(java.lang.String script) throws javax.script.ScriptException
script
as script.
Returns the return value of the script.
If script
is null
, a NullPointerException
will be thrown.
If an error occurs in the script, a ScriptException
will be thrown.
script
- the script to executejava.lang.NullPointerException
- thrown if, and only if, script
is null
javax.script.ScriptException
- thrown if, and only if, an error occurs in the scriptpublic final java.lang.Object get(java.lang.String key)
key
, or null
if no value is assigned to key
.
If key
is null
, a NullPointerException
will be thrown.
If key
is an empty String
, an IllegalArgumentException
will be thrown.
key
- a String
key
, or null
if no value is assigned to key
java.lang.IllegalArgumentException
- thrown if, and only if, key
is an empty String
java.lang.NullPointerException
- thrown if, and only if, key
is null
public final javax.script.ScriptEngine getEngine()
ScriptEngine
whose compile method created this ArtifactScript
.getEngine
in class javax.script.CompiledScript
ScriptEngine
whose compile method created this ArtifactScript
public final void set(java.lang.String key, java.lang.Object value)
value
for the key key
.
If key
is null
, a NullPointerException
will be thrown.
If key
is an empty String
, an IllegalArgumentException
will be thrown.
key
- the keyvalue
- the valuejava.lang.IllegalArgumentException
- thrown if, and only if, key
is an empty String
java.lang.NullPointerException
- thrown if, and only if, key
is null