Package com.storedobject.common
Class Script
java.lang.Object
com.storedobject.common.Script
A simple wrapper class to execute scripting languages from Java. If GraalVM is used as the JVM, multiple languages
can be made available. Otherwise, at least JavaScript would be available.
- Author:
- Syam
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionScript()
Constructor.Script
(Script.Language language) Constructor.Script
(Script.Language language, String script) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append more to the existing script.void
clear()
Clear the current script and variables.evaluate()
Evaluate script which was already set.Evaluate script supplied by aReader
.Evaluate script.Get current value of a variable that was set.boolean
Check whether the language is available or not.void
Set a value for the variable in the script.void
Set the script for execution.
-
Constructor Details
-
Script
public Script()Constructor. Default language is JavaScript. -
Script
Constructor. Default language is JavaScript.- Parameters:
script
- Script to set for execution.
-
Script
-
Script
Constructor.- Parameters:
language
- Language.script
- Script to set for execution.
-
-
Method Details
-
isAvailable
public boolean isAvailable()Check whether the language is available or not.- Returns:
- True if the requested language is available.
-
setScript
-
addScript
Append more to the existing script.- Parameters:
script
- Script to add.
-
clear
public void clear()Clear the current script and variables. -
set
-
get
-
evaluate
Evaluate script.- Parameters:
script
- Script to evaluate. (Script that was set earlier, if any, will be cleared).- Returns:
- Value returned by the scripting engine.
- Throws:
SOException
- Error if any from the scripting engine.
-
evaluate
Evaluate script which was already set.- Returns:
- Value returned by the scripting engine.
- Throws:
SOException
- Error if any from the scripting engine.
-
evaluate
Evaluate script supplied by aReader
.- Parameters:
script
- Reader to read the script from. (Script that was set earlier, if any, will be cleared).- Returns:
- Value returned by the scripting engine.
- Throws:
SOException
- Error if any from the scripting engine.
-