Package adams.flow.core
Class AbstractScriptedActor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.core.AbstractScriptedActor
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,FileBasedScripting
,FileBasedScriptingWithOptions
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,ErrorHandler
,Serializable
,Comparable
- Direct Known Subclasses:
AbstractGroovyActor
,AbstractScriptingHandlerActor
public abstract class AbstractScriptedActor extends AbstractActor implements FileBasedScriptingWithOptions
Abstract ancestor for actors that execute external scripts.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKUP_SCRIPTOBJECT
the key for storing the script object in the backup.protected PlaceholderFile
m_ScriptFile
the script.protected Object
m_ScriptObject
the loaded script object.protected String
m_ScriptOptions
the options for the script.-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description AbstractScriptedActor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.protected abstract String
checkScriptObject()
Checks the script object.void
defineOptions()
Adds options to the internal list of options.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.PlaceholderFile
getScriptFile()
Gets the script file.BaseText
getScriptOptions()
Gets the script options.protected String
initScriptObject()
Tries to initialize the scripts object, sets its options and performs some checks.protected abstract String
loadScriptObject()
Loads the scripts object and sets its options.String
preExecute()
Pre-execute hook.protected void
pruneBackup()
Removes entries from the backup.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.String
scriptFileTipText()
Returns the tip text for this property.String
scriptOptionsTipText()
Returns the tip text for this property.void
setScriptFile(PlaceholderFile value)
Sets the script file.void
setScriptOptions(BaseText value)
Sets the script options.void
stopExecution()
Stops the execution.void
wrapUp()
Cleans up after the execution has finished.-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, doExecute, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
toCommandLine
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
-
-
-
Field Detail
-
BACKUP_SCRIPTOBJECT
public static final String BACKUP_SCRIPTOBJECT
the key for storing the script object in the backup.- See Also:
- Constant Field Values
-
m_ScriptFile
protected PlaceholderFile m_ScriptFile
the script.
-
m_ScriptOptions
protected String m_ScriptOptions
the options for the script.
-
m_ScriptObject
protected transient Object m_ScriptObject
the loaded script object.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
setScriptFile
public void setScriptFile(PlaceholderFile value)
Sets the script file.- Specified by:
setScriptFile
in interfaceFileBasedScripting
- Parameters:
value
- the script
-
getScriptFile
public PlaceholderFile getScriptFile()
Gets the script file.- Specified by:
getScriptFile
in interfaceFileBasedScripting
- Returns:
- the script
-
scriptFileTipText
public String scriptFileTipText()
Returns the tip text for this property.- Specified by:
scriptFileTipText
in interfaceFileBasedScripting
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setScriptOptions
public void setScriptOptions(BaseText value)
Sets the script options.- Specified by:
setScriptOptions
in interfaceFileBasedScriptingWithOptions
- Parameters:
value
- the options
-
getScriptOptions
public BaseText getScriptOptions()
Gets the script options.- Specified by:
getScriptOptions
in interfaceFileBasedScriptingWithOptions
- Returns:
- the options
-
scriptOptionsTipText
public String scriptOptionsTipText()
Returns the tip text for this property.- Specified by:
scriptOptionsTipText
in interfaceFileBasedScriptingWithOptions
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackup
in classAbstractActor
- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupState
in classAbstractActor
- Returns:
- the backup
- See Also:
AbstractActor.updateVariables()
,AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreState
in classAbstractActor
- Parameters:
state
- the backup of the state to restore from- See Also:
AbstractActor.updateVariables()
,AbstractActor.backupState()
-
loadScriptObject
protected abstract String loadScriptObject()
Loads the scripts object and sets its options.- Returns:
- null if OK, otherwise the error message
-
checkScriptObject
protected abstract String checkScriptObject()
Checks the script object.- Returns:
- null if OK, otherwise the error message
-
initScriptObject
protected String initScriptObject()
Tries to initialize the scripts object, sets its options and performs some checks.- Returns:
- null if OK, otherwise the error message
-
preExecute
public String preExecute()
Pre-execute hook.- Overrides:
preExecute
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractActor
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractActor
-
-