Class ScriptInterpreter

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 Details

    • ScriptInterpreter

      public ScriptInterpreter()
  • Method Details

    • 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()