Class JepScriptingEngineThread

  • All Implemented Interfaces:
    adams.core.Stoppable, Runnable

    public class JepScriptingEngineThread
    extends Thread
    implements adams.core.Stoppable
    A thread class for processing Jep scriptlets.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Running

        protected boolean m_Running
        whether the thread is running.
      • m_Processing

        protected boolean m_Processing
        whether any command is currently being processed.
      • m_Interpreter

        protected jep.SharedInterpreter m_Interpreter
        the central interpreter.
    • Constructor Detail

      • JepScriptingEngineThread

        public JepScriptingEngineThread​(JepScriptingEngine owner)
        Initializes the thread.
        Parameters:
        owner - the owning scripting engine
    • Method Detail

      • getOwner

        public JepScriptingEngine getOwner()
        Returns the owning scripting engine.
        Returns:
        the owner
      • getInterpreter

        public jep.SharedInterpreter getInterpreter()
        Returns the interpreter in use.
        Returns:
        the interpreter
      • clear

        public void clear()
        Clears the queue of scriplets.
      • add

        public void add​(JepScriptlet scriptlet)
        Adds the scriptlet to the queue.
        Parameters:
        scriptlet - the scriptlet to add
      • runScript

        protected void runScript​(File scriptFile)
                          throws jep.JepException
        Executes the script.
        Parameters:
        scriptFile - the script to execute
        Throws:
        jep.JepException - if execution fails
      • stopExecution

        public void stopExecution()
        Stops the execution of scripting commands.
        Specified by:
        stopExecution in interface adams.core.Stoppable
      • isRunning

        public boolean isRunning()
        Returns whether the thread is still active and waits for commands to execute.
        Returns:
        true if accepting commands to process
      • isProcessing

        public boolean isProcessing()
        Returns whether a command is currently being processed.
        Returns:
        true if a command is being processed
      • isEmpty

        public boolean isEmpty()
        Returns whether there are no commands currently in the queue.
        Returns:
        true if no commands waiting to be executed
      • preProcess

        protected void preProcess​(JepScriptlet scriptlet)
        Performs some preprocessing.
        Parameters:
        scriptlet - the scriptlet that is about to be executed
      • doProcess

        protected String doProcess​(JepScriptlet scriptlet)
        Executes the given scriptlet.
        Parameters:
        scriptlet - the scriptlet to execute
        Returns:
        the error message, null if no problems occurred
      • postProcess

        protected void postProcess​(JepScriptlet scriptlet,
                                   boolean success,
                                   String lastError)
        Performs some postprocessing.
        Parameters:
        scriptlet - the scriptlet that was executed
        success - true if successfully executed
        lastError - the error, or null if none happened
      • run

        public void run()
        Executes the scripting commands.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread