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.FlowContextHandlerAncestor 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 booleanm_Finishedwhether the scriplet has been executed.protected adams.flow.core.Actorm_FlowContextthe flow context.protected Stringm_IDthe ID of the scriptlet.protected Stringm_LastErrorthe last error.protected JepScriptingEngineThreadm_Ownerthe 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 voidconfigureLogger()Initializes the logger.abstract Stringexecute()Executes the script.voidfail(String msg)Sets the error message and that the script has finished to true.adams.flow.core.ActorgetFlowContext()Returns the flow context, if any.StringgetID()Returns the ID of the script.StringgetLastError()Returns any error that was encountered.JepScriptingEngineThreadgetOwner()Returns the owning thread.booleanhasFinished()Whether the scriptlet has finished execution.booleanhasLastError()Checks whether an error is present.voidsetFlowContext(adams.flow.core.Actor value)Sets the flow context.voidsetOwner(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:
configureLoggerin 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:
setFlowContextin interfaceadams.flow.core.FlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin 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
-
-