Class AbstractJepScriptlet

  • All Implemented Interfaces:
    adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.SizeOfHandler, adams.flow.core.FlowContextHandler, Serializable
    Direct Known Subclasses:
    FlowJepScriptlet, SimpleJepScriptlet

    public abstract class AbstractJepScriptlet
    extends adams.core.logging.CustomLoggingLevelObject
    implements adams.flow.core.FlowContextHandler
    Ancestor for Jep/Python scripts.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_ID

        protected String m_ID
        the ID of the scriptlet.
      • m_LastError

        protected String m_LastError
        the last error.
      • m_FlowContext

        protected adams.flow.core.Actor m_FlowContext
        the flow context.
      • m_Finished

        protected boolean m_Finished
        whether the scriplet has been executed.
    • Constructor Detail

      • AbstractJepScriptlet

        public AbstractJepScriptlet​(String id)
        Initializes the scriptlet.
        Parameters:
        id - the ID of the script
    • Method Detail

      • configureLogger

        protected void configureLogger()
        Initializes the logger.
        Overrides:
        configureLogger in class adams.core.logging.LoggingObject
      • setOwner

        public void setOwner​(JepScriptingEngineThread value)
        Sets the owning thread.
        Parameters:
        value - the owner
      • setFlowContext

        public void setFlowContext​(adams.flow.core.Actor value)
        Sets the flow context.
        Specified by:
        setFlowContext in interface adams.flow.core.FlowContextHandler
        Parameters:
        value - the actor
      • getFlowContext

        public adams.flow.core.Actor getFlowContext()
        Returns the flow context, if any.
        Specified by:
        getFlowContext in interface adams.flow.core.FlowContextHandler
        Returns:
        the actor, null if none available
      • getID

        public String getID()
        Returns the ID of the script.
        Returns:
        the ID
      • hasFinished

        public boolean hasFinished()
        Whether the scriptlet has finished execution.
        Returns:
        true when finished
      • hasLastError

        public boolean hasLastError()
        Checks whether an error is present.
        Returns:
        true if error present
      • getLastError

        public String getLastError()
        Returns any error that was encountered.
        Returns:
        the error, null if none encountered
      • execute

        public abstract String execute()
        Executes the script.
        Returns:
        null if successful, otherwise error message
      • fail

        public void fail​(String msg)
        Sets the error message and that the script has finished to true.
        Parameters:
        msg - the error message to set