Class AbstractActor

    • Field Detail

      • m_Self

        protected Actor m_Self
        the actor itself.
      • m_Name

        protected String m_Name
        the name of the actor.
      • m_FullName

        protected String m_FullName
        the full name of the actor.
      • m_LoggingPrefix

        protected String m_LoggingPrefix
        the logging prefix.
      • m_Parent

        protected transient Actor m_Parent
        the parent actor this actor is part of, e.g., a sequence.
      • m_Executed

        protected boolean m_Executed
        whether the actor was executed at least once after setup.
      • m_Executing

        protected boolean m_Executing
        whether the actor is currently being executed.
      • m_Stopped

        protected boolean m_Stopped
        whether the execution was stopped.
      • m_StopMessage

        protected String m_StopMessage
        the message that was used when stopping the execution.
      • m_Annotations

        protected BaseAnnotation m_Annotations
        annotations for the actor.
      • m_Skip

        protected boolean m_Skip
        whether to skip the transformation and just forward the token.
      • m_StopFlowOnError

        protected boolean m_StopFlowOnError
        whether to stop the flow in case of an error.
      • m_Silent

        protected boolean m_Silent
        whether to suppress output in the console.
      • m_DetectedVariables

        protected HashSet<String> m_DetectedVariables
        the variable names that are used within this actor.
      • m_DetectedObjectVariables

        protected HashSet<String> m_DetectedObjectVariables
        the variable names (referencing callable actors or storage) that are used within this actor.
      • m_VariablesUpdated

        protected HashSet<String> m_VariablesUpdated
        whether the actor needs re-setting up because of modified variables.
      • m_BackupState

        protected Hashtable<String,​Object> m_BackupState
        for backing up the state of an actor.
      • m_StorageHandler

        protected StorageHandler m_StorageHandler
        the storage handler.
      • m_ScopeHandler

        protected ScopeHandler m_ScopeHandler
        the scope handler.
      • m_ErrorHandler

        protected ErrorHandler m_ErrorHandler
        the error handler to use.
    • Constructor Detail

      • AbstractActor

        public AbstractActor()
    • Method Detail

      • updatePrefix

        protected void updatePrefix()
        Updates the prefix of the logger.
      • getDefaultName

        public String getDefaultName()
        Returns the default name of the actor.
        Specified by:
        getDefaultName in interface Actor
        Returns:
        the default name
      • isHeadless

        public boolean isHeadless()
        Returns whether the actor is run in headless mode.
        Specified by:
        isHeadless in interface Actor
        Returns:
        true if GUI components are suppressed
      • setName

        public void setName​(String value)
        Sets the name of the actor.
        Specified by:
        setName in interface Actor
        Parameters:
        value - the name
      • getName

        public String getName()
        Returns the name of the actor.
        Specified by:
        getName in interface Actor
        Returns:
        the name
      • nameTipText

        public String nameTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setAnnotations

        public void setAnnotations​(BaseAnnotation value)
        Sets the annoations.
        Specified by:
        setAnnotations in interface Actor
        Parameters:
        value - the annotations
      • getAnnotations

        public BaseAnnotation getAnnotations()
        Returns the current annotations.
        Specified by:
        getAnnotations in interface Actor
        Returns:
        the annotations
      • annotationsTipText

        public String annotationsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setSkip

        public void setSkip​(boolean value)
        Sets whether the transformation is skipped or not.
        Specified by:
        setSkip in interface Actor
        Parameters:
        value - true if transformation is to be skipped
      • getSkip

        public boolean getSkip()
        Returns whether transformation is skipped.
        Specified by:
        getSkip in interface Actor
        Returns:
        true if transformation is skipped
      • skipTipText

        public String skipTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStopFlowOnError

        public void setStopFlowOnError​(boolean value)
        Sets whether to stop the flow execution at this level in case this actor encounters an error.
        Specified by:
        setStopFlowOnError in interface Actor
        Parameters:
        value - true if flow gets stopped in case of an error
      • getStopFlowOnError

        public boolean getStopFlowOnError()
        Returns whether to stop the flow execution at this level in case this actor encounters an error.
        Specified by:
        getStopFlowOnError in interface Actor
        Returns:
        true if flow gets stopped in case of an error
      • stopFlowOnErrorTipText

        public String stopFlowOnErrorTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSilent

        public void setSilent​(boolean value)
        Sets whether to suppress output in the console. Note: the enclosing actor handler needs to have this enabled as well.
        Specified by:
        setSilent in interface Actor
        Parameters:
        value - true if to suppress output in the console
      • getSilent

        public boolean getSilent()
        Returns whether to suppress output in the console. Note: the enclosing actor handler needs to have this enabled as well.
        Specified by:
        getSilent in interface Actor
        Returns:
        true if to suppress output in the console
      • silentTipText

        public String silentTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • handleException

        protected String handleException​(String msg,
                                         Throwable t)
        Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.
        Parameters:
        msg - the message for the exception
        t - the exception
        Returns:
        the full error message (message + stacktrace)
      • setParent

        public void setParent​(Actor value)
        Sets the parent of this actor, e.g., the group it belongs to.
        Specified by:
        setParent in interface Actor
        Parameters:
        value - the new parent
      • getParent

        public Actor getParent()
        Returns the parent of this actor, e.g., the group.
        Specified by:
        getParent in interface Actor
        Returns:
        the current parent, can be null
      • getParentComponent

        public Component getParentComponent()
        Returns the current parent component for interactive actors.
        Specified by:
        getParentComponent in interface Actor
        Returns:
        the parent, null if not set
      • index

        public int index()
        Returns the index of this actor in its parent's collection.
        Specified by:
        index in interface Actor
        Returns:
        the index, -1 if not applicable (e.g., no parent set)
      • getRoot

        public Actor getRoot()
        Returns the root of this actor, e.g., the group at the highest level.
        Specified by:
        getRoot in interface Actor
        Returns:
        the root, can be null
      • updateDetectedVariables

        protected void updateDetectedVariables()
        Updates the detected variables.
      • forceVariables

        protected void forceVariables​(Variables value)
        Updates the Variables instance in use.

        Use with caution!
        Parameters:
        value - the instance to use
      • setVariables

        public void setVariables​(Variables value)
        Updates the Variables instance in use, if different from current one.

        Use with caution!
        Specified by:
        setVariables in interface Actor
        Parameters:
        value - the instance to use
        See Also:
        forceVariables(Variables)
      • getVariables

        public Variables getVariables()
        Returns the Variables instance to use.
        Specified by:
        getVariables in interface Actor
        Returns:
        the variables instance
      • getStorageHandler

        public StorageHandler getStorageHandler()
        Returns the storage handler to use.
        Specified by:
        getStorageHandler in interface Actor
        Returns:
        the storage handler
      • getScopeHandler

        public ScopeHandler getScopeHandler()
        Returns the scope handler for this actor.
        Specified by:
        getScopeHandler in interface Actor
        Returns:
        the scope handler
      • getFullName

        public String getFullName()
        Returns the full name of the actor, i.e., the concatenated names of all parents. Used in error messages.
        Specified by:
        getFullName in interface Actor
        Returns:
        the full name
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the actor, which will be displayed in the GUI.

        Default implementation returns null.
        Specified by:
        getQuickInfo in interface Actor
        Specified by:
        getQuickInfo in interface QuickInfoSupporter
        Returns:
        null if no info available, otherwise short string
      • hasErrorHandler

        public boolean hasErrorHandler()
        Checks if an error handler is set.
        Specified by:
        hasErrorHandler in interface Actor
        Returns:
        true if an error handler is set
      • setErrorHandler

        public void setErrorHandler​(ErrorHandler value)
        Sets the error handler to use for handling errors in the flow.
        Specified by:
        setErrorHandler in interface Actor
        Parameters:
        value - the error handler
      • getErrorHandler

        public ErrorHandler getErrorHandler()
        Returns the current error handler for handling errors in the flow.
        Specified by:
        getErrorHandler in interface Actor
        Returns:
        the error handler
      • canInspectOptions

        public boolean canInspectOptions​(Class cls)
        Checks whether the class' options can be inspected.

        Default implementation returns true.
        Specified by:
        canInspectOptions in interface VariablesInspectionHandler
        Parameters:
        cls - the class to check
        Returns:
        true if it can be inspected, false otherwise
      • findVariables

        public HashSet<String> findVariables()
        Recursively finds all the variables used in the actor's setup.
        Specified by:
        findVariables in interface Actor
        Returns:
        the variables that were found
      • findVariables

        protected HashSet<String> findVariables​(Actor actor)
        Recursively finds all the variables used in the specified actor's setup.
        Parameters:
        actor - the actor to search
        Returns:
        the variables that were found
      • getDetectedVariables

        public HashSet<String> getDetectedVariables()
        Returns the variables this actor is responsible for.
        Specified by:
        getDetectedVariables in interface Actor
        Returns:
        the variables
      • setUp

        public String setUp()
        Initializes the item for flow execution. Also calls the reset() method first before anything else.
        Specified by:
        setUp in interface Actor
        Returns:
        null if everything is fine, otherwise error message
        See Also:
        reset()
      • isBackedUp

        protected boolean isBackedUp​(String key)
        Checks whether a specified key is present in the current backup state.
        Parameters:
        key - the key of the object to look for in the backup state
        Returns:
        true if key present
      • pruneBackup

        protected void pruneBackup​(String key)
        Removes the object with the specified key from the current backup state.
        Parameters:
        key - the key of the object to remove from the backup state
      • pruneBackup

        protected void pruneBackup()
        Removes entries from the backup.

        Default implementation does nothing.
        See Also:
        reset()
      • restoreState

        protected void restoreState​(Hashtable<String,​Object> state)
        Restores the state of the actor before the variables got updated.

        Default implementation does nothing.
        Parameters:
        state - the backup of the state to restore from
        See Also:
        updateVariables(), backupState()
      • updateVariables

        protected String updateVariables()
        Gets called when the actor needs to be re-setUp when a variable changes.
        Returns:
        null if everything is fine, otherwise error message
      • canPerformSetUpCheck

        protected boolean canPerformSetUpCheck​(boolean fromSetUp,
                                               String property)
        Returns whether a check can be performed currently. Depending on whether a variable is attached to a property the property cannot be checked at setUp() time, but needs to be done at preExecute() time.
        Parameters:
        fromSetUp - whether the method has been called from within setUp()
        property - the property to check
        Returns:
        true if the check can be performed
      • performSetUpChecks

        protected String performSetUpChecks​(boolean fromSetUp)
        Hook for performing setup checks -- used in setUp() and preExecute().

        Default implementation performs no checks.
        Parameters:
        fromSetUp - whether the method has been called from within setUp()
        Returns:
        null if everything OK, otherwise error message
        See Also:
        setUp(), preExecute()
      • performVariableChecks

        protected String performVariableChecks()
        For performing variable checks.
        Returns:
        null if checks passed, otherwise error messages
        See Also:
        preExecute()
      • preExecute

        protected String preExecute()
        Pre-execute hook.

        Default implementation checks only whether the actor needs to be setup again due to changes in variables.
        Returns:
        null if everything is fine, otherwise error message
      • doExecute

        protected abstract String doExecute()
        Executes the flow item.
        Returns:
        null if everything is fine, otherwise error message
      • postExecute

        protected String postExecute()
        Post-execute hook.

        Default implementation does nothing apart from setting m_Executed to true and only returns null.
        Returns:
        null if everything is fine, otherwise error message
        See Also:
        m_Executed
      • execute

        public String execute()
        Executes the flow item.
        Specified by:
        execute in interface Actor
        Returns:
        null if everything is fine, otherwise error message
      • isFinished

        public boolean isFinished()
        Returns whether the item has finished. The execute() will be called as long as the isFinished() method returns false.
        Specified by:
        isFinished in interface Actor
        Returns:
        true if finished, false if further calls to execute() are necessary. Default implementation returns always true, i.e., fires only once.
      • finalUpdateVariables

        protected void finalUpdateVariables()
        Gets called when the actor needs to re-evaluate variables before wrapping up.
      • wrapUp

        public void wrapUp()
        Cleans up after the execution has finished. Graphical output is left untouched.
        Specified by:
        wrapUp in interface Actor
      • cleanUp

        public void cleanUp()
        Cleans up after the execution has finished. Also removes graphical components.
        Specified by:
        cleanUp in interface Actor
        Specified by:
        cleanUp in interface CleanUpHandler
      • stopExecution

        public void stopExecution​(String msg)
        Stops the execution.
        Specified by:
        stopExecution in interface Actor
        Parameters:
        msg - the message to set as reason for stopping, can be null
      • isStopped

        public boolean isStopped()
        Returns whether the execution was stopped.
        Specified by:
        isStopped in interface Actor
        Specified by:
        isStopped in interface StoppableWithFeedback
        Returns:
        true if the execution was stopped
      • hasStopMessage

        public boolean hasStopMessage()
        Returns whether a stop message is available (in case the flow was stopped with a message).
        Specified by:
        hasStopMessage in interface Actor
        Returns:
        true if a message is available
      • getStopMessage

        public String getStopMessage()
        Returns the stop message.
        Specified by:
        getStopMessage in interface Actor
        Returns:
        the message, can be null
      • isExecuted

        public boolean isExecuted()
        Returns whether the actor has been executed, after setting it up.
        Specified by:
        isExecuted in interface Actor
        Returns:
        true if the actor has been executed
      • isExecuting

        public boolean isExecuting()
        Returns whether the actor is currently being executed, i.e., processing some data or similar.
        Returns:
        true if currently active
      • getPreviousSibling

        public Actor getPreviousSibling()
        If the actor is part of a group, this method returns the actor preceding it in that group.
        Specified by:
        getPreviousSibling in interface Actor
        Returns:
        the preceding actor, null if not available
      • getNextSibling

        public Actor getNextSibling()
        If the actor is part of a group, this method returns the actor following it in that group.
        Specified by:
        getNextSibling in interface Actor
        Returns:
        the following actor, null if not available
      • compareTo

        public int compareTo​(Object o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

        Only compares the commandlines of the two objects.
        Specified by:
        compareTo in interface Actor
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object o)
        Returns whether the two objects are the same.

        Only compares the commandlines of the two objects.
        Specified by:
        equals in interface Actor
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • shallowCopy

        public Actor shallowCopy​(boolean expand)
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Specified by:
        shallowCopy in interface Actor
        Specified by:
        shallowCopy in interface ShallowCopySupporter<Actor>
        Parameters:
        expand - whether to expand variables to their current values
        Returns:
        the shallow copy
      • getFlowActors

        public static String[] getFlowActors()
        Returns a list with classnames of items.
        Returns:
        the item classnames
      • forName

        public static Actor forName​(String classname,
                                    String[] options)
        Instantiates the item with the given options.
        Parameters:
        classname - the classname of the item to instantiate
        options - the options for the item
        Returns:
        the instantiated item or null if an error occurred
      • forName

        public static Actor forName​(String classname,
                                    String[] options,
                                    boolean quiet)
        Instantiates the item with the given options.
        Parameters:
        classname - the classname of the item to instantiate
        options - the options for the item
        quiet - whether to suppress error messages
        Returns:
        the instantiated item or null if an error occurred
      • forCommandLine

        public static Actor forCommandLine​(String cmdline)
        Instantiates the item from the given commandline (i.e., classname and optional options).
        Parameters:
        cmdline - the classname (and optional options) of the item to instantiate
        Returns:
        the instantiated item or null if an error occurred