Package adams.core.scripting
Class AbstractJepScriptlet
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.scripting.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 Summary
Fields Modifier and Type Field Description protected boolean
m_Finished
whether the scriplet has been executed.protected adams.flow.core.Actor
m_FlowContext
the flow context.protected String
m_ID
the ID of the scriptlet.protected String
m_LastError
the last error.protected JepScriptingEngineThread
m_Owner
the owning thread (with the interpreter).
-
Constructor Summary
Constructors Constructor Description AbstractJepScriptlet(String id)
Initializes the scriptlet.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
configureLogger()
Initializes the logger.abstract String
execute()
Executes the script.void
fail(String msg)
Sets the error message and that the script has finished to true.adams.flow.core.Actor
getFlowContext()
Returns the flow context, if any.String
getID()
Returns the ID of the script.String
getLastError()
Returns any error that was encountered.JepScriptingEngineThread
getOwner()
Returns the owning thread.boolean
hasFinished()
Whether the scriptlet has finished execution.boolean
hasLastError()
Checks whether an error is present.void
setFlowContext(adams.flow.core.Actor value)
Sets the flow context.void
setOwner(JepScriptingEngineThread value)
Sets the owning thread.-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Owner
protected JepScriptingEngineThread m_Owner
the owning thread (with the interpreter).
-
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 classadams.core.logging.LoggingObject
-
setOwner
public void setOwner(JepScriptingEngineThread value)
Sets the owning thread.- Parameters:
value
- the owner
-
getOwner
public JepScriptingEngineThread getOwner()
Returns the owning thread.- Returns:
- the owner
-
setFlowContext
public void setFlowContext(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Parameters:
value
- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in interfaceadams.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
-
-