-
public interface ScriptEngineManage scriptEngine variables, statements and script execution.- Author:
- Matti Rinta-Nikkola
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voiddel(String... vars)Deletes variables.default Objectdeserialize(String value)Deserialize valueObjectdeserialize(String value, String format)Deserialize valuedefault Objectexecute(File script)Executes scriptEngine scriptObjectexecute(File script, Object[] args)Executes scriptEngine scriptObjectexecute(Object closure, Object... args)Executes scriptEngine closureObjectexecute(String statement)Executes scriptEngine statementdefault Map<String,Object>find()Gets all variables with valuesMap<String,Object>find(String name)Gets all the variables that match the name.Objectget(String name)Gets variable valueList<String>getDeserializationFormats()StringgetEngineName()Collection<String>getExtensions()CompletergetScriptCompleter()List<String>getSerializationFormats()booleanhasVariable(String name)Tests if console variable existsvoidpersist(Path file, Object object)Persists object value to file.voidpersist(Path file, Object object, String format)Persists object value to file.voidput(String name, Object value)Creates variableStringtoJson(Object object)Serialize object to JSON string.Map<String,Object>toMap(Object object)Converts object fields to map.StringtoString(Object object)Converts object to string.
-
-
-
Method Detail
-
getEngineName
String getEngineName()
- Returns:
- scriptEngine name
-
getExtensions
Collection<String> getExtensions()
- Returns:
- script file name extensions
-
getScriptCompleter
Completer getScriptCompleter()
- Returns:
- script tab completer
-
hasVariable
boolean hasVariable(String name)
Tests if console variable exists- Parameters:
name- variable name- Returns:
- true if variable exists
-
put
void put(String name, Object value)
Creates variable- Parameters:
name- variable namevalue- value
-
get
Object get(String name)
Gets variable value- Parameters:
name- variable name- Returns:
- value of the variable
-
find
default Map<String,Object> find()
Gets all variables with values- Returns:
- map of the variables
-
find
Map<String,Object> find(String name)
Gets all the variables that match the name. Name can contain * wild cards.- Parameters:
name- variable name- Returns:
- map the variables
-
del
void del(String... vars)
Deletes variables. Variable name can contain * wild cards.- Parameters:
vars- variables to be deleted
-
toJson
String toJson(Object object)
Serialize object to JSON string.- Parameters:
object- object to serialize to JSON- Returns:
- formatted JSON string
-
toString
String toString(Object object)
Converts object to string.- Parameters:
object- the object- Returns:
- object string value
-
toMap
Map<String,Object> toMap(Object object)
Converts object fields to map.- Parameters:
object- the object- Returns:
- object fields map
-
deserialize
default Object deserialize(String value)
Deserialize value- Parameters:
value- the value- Returns:
- deserialized value
-
deserialize
Object deserialize(String value, String format)
Deserialize value- Parameters:
value- the valueformat- serialization format- Returns:
- deserialized value
-
getSerializationFormats
List<String> getSerializationFormats()
- Returns:
- Supported serialization formats
-
getDeserializationFormats
List<String> getDeserializationFormats()
- Returns:
- Supported deserialization formats
-
persist
void persist(Path file, Object object)
Persists object value to file.- Parameters:
file- fileobject- object
-
persist
void persist(Path file, Object object, String format)
Persists object value to file.- Parameters:
file- the fileobject- the objectformat- serialization format
-
execute
Object execute(String statement) throws Exception
Executes scriptEngine statement- Parameters:
statement- the statement- Returns:
- result
- Throws:
Exception- in case of error
-
execute
default Object execute(File script) throws Exception
Executes scriptEngine script- Parameters:
script- the script- Returns:
- result
- Throws:
Exception- in case of error
-
execute
Object execute(File script, Object[] args) throws Exception
Executes scriptEngine script- Parameters:
script- the scriptargs- arguments- Returns:
- result
- Throws:
Exception- in case of error
-
-