- java.lang.Object
-
- be.yildizgames.module.script.ScriptInterpreter
-
- All Implemented Interfaces:
AutoCloseable
public abstract class ScriptInterpreter extends Object implements AutoCloseable
Behavior for scripting languages.- Author:
- Grégory Van den Borre
-
-
Constructor Summary
Constructors Constructor Description ScriptInterpreter()
-
Method Summary
Modifier and Type Method Description abstract ObjectgetClassMethods(Class<?> classToGet)Print all methods of a java class.static ScriptInterpretergetEngine()abstract StringgetFileExtension()abstract StringgetFileHeader()abstract booleanisClosed()abstract voidprint(String toPrint)Utility function, print a line in console.abstract ObjectrunCommand(String command)Execute a command.abstract ParsedScriptrunScript(String file)Parse and run a script file.abstract voidsetOutput(Writer output)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
-
-
-
-
Method Detail
-
getEngine
public static ScriptInterpreter getEngine()
-
runScript
public abstract ParsedScript runScript(String file) throws ScriptException
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
public abstract Object runCommand(String command) throws ScriptException
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
public abstract void print(String toPrint)
Utility function, print a line in console.- Parameters:
toPrint- Line to print.
-
setOutput
public abstract void setOutput(Writer output)
Redirect the output.- Parameters:
output- New script engine output.
-
getClassMethods
public abstract Object getClassMethods(Class<?> classToGet)
Print all methods of a java class.- Parameters:
classToGet- Class to retrieve methods.- Returns:
- The object resulting from the command.
-
getFileHeader
public abstract String getFileHeader()
- Returns:
- The header to set in a script file.
-
getFileExtension
public abstract String getFileExtension()
- Returns:
- The script file extension, without ".".
-
isClosed
public abstract boolean isClosed()
-
-