java.lang.Object
be.yildizgames.module.script.ScriptInterpreter
- All Implemented Interfaces:
AutoCloseable
Behavior for scripting languages.
- Author:
- Grégory Van den Borre
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Object
getClassMethods
(Class<?> classToGet) Print all methods of a java class.static ScriptInterpreter
abstract String
abstract String
abstract boolean
isClosed()
abstract void
Utility function, print a line in console.abstract Object
runCommand
(String command) Execute a command.abstract ParsedScript
Parse and run a script file.abstract void
Redirect the output.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
-
Constructor Details
-
ScriptInterpreter
public ScriptInterpreter()
-
-
Method Details
-
getEngine
-
runScript
Parse and run a script file.- Parameters:
file
- File to execute.- Returns:
- A ParsedScript object to run the script again without parsing it.
- Throws:
ScriptException
- If an exception occurs while parsing the script.
-
runCommand
Execute a command.- Parameters:
command
- Command to execute.- Returns:
- The object resulting from the command, Long for numeric result.
- Throws:
ScriptException
- If an exception occurs while parsing the command.
-
print
Utility function, print a line in console.- Parameters:
toPrint
- Line to print.
-
setOutput
Redirect the output.- Parameters:
output
- New script engine output.
-
getClassMethods
Print all methods of a java class.- Parameters:
classToGet
- Class to retrieve methods.- Returns:
- The object resulting from the command.
-
getFileHeader
- Returns:
- The header to set in a script file.
-
getFileExtension
- Returns:
- The script file extension, without ".".
-
isClosed
public abstract boolean isClosed()
-