Class LocalScopeTransformer

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, Pausable, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesHandler, VariablesInspectionHandler, FlowPauseStateListener, VariableChangeListener, AtomicExecution, LocalScopeHandler, ScopeHandler, StorageHandler, Actor, ActorHandler, ControlActor, ErrorHandler, Flushable, InputConsumer, MutableActorHandler, OutputProducer, StopRestrictor, SubFlowWrapUp, Serializable, Comparable

    public class LocalScopeTransformer
    extends AbstractControlActor
    implements InputConsumer, OutputProducer, MutableActorHandler, VariablesHandler, StorageHandler, LocalScopeHandler, StopRestrictor, AtomicExecution
    Provides a local scope for the sub-actors.
    It is possible to 'propagate' or 'leak' variables and storage items from within the local scope back to the output scope. However, storage items from caches cannot be propagated.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: LocalScopeTransformer
     
    -annotation <adams.core.base.BaseAnnotation> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow execution at this level gets stopped in case this
        actor encounters an error; the error gets propagated; useful for critical
        actors.
        default: false
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console; Note: the enclosing
        actor handler must have this enabled as well.
        default: false
     
    -actor <adams.flow.core.Actor> [-actor ...] (property: actors)
        The actors to execute in the loop.
        default:
     
    -scope-handling-variables <EMPTY|COPY|SHARE> (property: scopeHandlingVariables)
        Defines how variables are handled in the local scope; whether to start with
        empty set, a copy of the outer scope variables or share variables with the
        outer scope.
        default: EMPTY
     
    -variables-filter <adams.core.base.BaseRegExp> (property: variablesFilter)
        The regular expression that variable names must match in order to get into
        the local scope (when using COPY).
        default: .*
     
    -propagate-variables <boolean> (property: propagateVariables)
        If enabled and variables are not shared with outer scope, variables that
        match the specified regular expression get propagated to the outer scope.
        default: false
     
    -variables-regexp <adams.core.base.BaseRegExp> (property: variablesRegExp)
        The regular expression that variable names must match in order to get propagated.
        default: .*
     
    -scope-handling-storage <EMPTY|COPY|SHARE> (property: scopeHandlingStorage)
        Defines how storage is handled in the local scope; whether to start with
        empty set, a (deep) copy of the outer scope storage or share the storage
        with the outer scope.
        default: EMPTY
     
    -storage-filter <adams.core.base.BaseRegExp> (property: storageFilter)
        The regular expression that storage item names must match in order to get
        into the local scope (when using COPY).
        default: .*
     
    -propagate-storage <boolean> (property: propagateStorage)
        If enabled and storage is not shared with outer scope, storage items which
        names match the specified regular expression get propagated to the outer
        scope.
        default: false
     
    -storage-regexp <adams.core.base.BaseRegExp> (property: storageRegExp)
        The regular expression that the names of storage items must match in order
        to get propagated.
        default: .*
     
    -finish-before-stopping <boolean> (property: finishBeforeStopping)
        If enabled, actor first finishes processing all data before stopping.
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Actors

        protected SubProcess m_Actors
        the actors to execute.
      • m_LocalStorage

        protected transient Storage m_LocalStorage
        the storage for temporary data.
      • m_LocalVariables

        protected FlowVariables m_LocalVariables
        the variables manager.
      • m_EnforceCallableNameCheck

        protected boolean m_EnforceCallableNameCheck
        whether the callable name check is enforced.
      • m_VariablesFilter

        protected BaseRegExp m_VariablesFilter
        the regular expression of the variables to allow into the local scope.
      • m_StorageFilter

        protected BaseRegExp m_StorageFilter
        the regular expression of the storage items to allow into the local scope.
      • m_PropagateVariables

        protected boolean m_PropagateVariables
        whether to propagate variables from the local scope to the outer scope.
      • m_VariablesRegExp

        protected BaseRegExp m_VariablesRegExp
        the regular expression of the variables to propagate.
      • m_PropagateStorage

        protected boolean m_PropagateStorage
        whether to propagate variables from the local scope to the outer scope.
      • m_StorageRegExp

        protected BaseRegExp m_StorageRegExp
        the regular expression of the variables to propagate.
      • m_RestrictedStop

        protected boolean m_RestrictedStop
        whether a restricted stop occurred.
    • Constructor Detail

      • LocalScopeTransformer

        public LocalScopeTransformer()
        Default constructor.
      • LocalScopeTransformer

        public LocalScopeTransformer​(String name)
        Initializes with the specified name.
        Parameters:
        name - the name to use
    • Method Detail

      • setSkip

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

        public void setActors​(Actor[] value)
        Sets the actors of the loop.
        Parameters:
        value - the actors
      • getActors

        public Actor[] getActors()
        Returns the actors of the loop.
        Returns:
        the actors
      • actorsTipText

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

        public String scopeHandlingVariablesTipText()
        Returns the tip text for this property.
        Specified by:
        scopeHandlingVariablesTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setVariablesFilter

        public void setVariablesFilter​(BaseRegExp value)
        Sets the regular expression that variable names must match to get into the local scope.
        Specified by:
        setVariablesFilter in interface LocalScopeHandler
        Parameters:
        value - the expression
      • getVariablesFilter

        public BaseRegExp getVariablesFilter()
        Returns the regular expression that variable names must match to get into the local scope.
        Specified by:
        getVariablesFilter in interface LocalScopeHandler
        Returns:
        the expression
      • variablesFilterTipText

        public String variablesFilterTipText()
        Returns the tip text for this property.
        Specified by:
        variablesFilterTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPropagateVariables

        public void setPropagateVariables​(boolean value)
        Sets whether to propagate variables from the local to the outer scope.
        Specified by:
        setPropagateVariables in interface LocalScopeHandler
        Parameters:
        value - if true then variables get propagated
      • getPropagateVariables

        public boolean getPropagateVariables()
        Returns whether to propagate variables from the local to the outer scope.
        Specified by:
        getPropagateVariables in interface LocalScopeHandler
        Returns:
        true if variables get propagated
      • propagateVariablesTipText

        public String propagateVariablesTipText()
        Returns the tip text for this property.
        Specified by:
        propagateVariablesTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setVariablesRegExp

        public void setVariablesRegExp​(BaseRegExp value)
        Sets the regular expression that variable names must match to get propagated.
        Specified by:
        setVariablesRegExp in interface LocalScopeHandler
        Parameters:
        value - the expression
      • getVariablesRegExp

        public BaseRegExp getVariablesRegExp()
        Returns the regular expression that variable names must match to get propagated.
        Specified by:
        getVariablesRegExp in interface LocalScopeHandler
        Returns:
        the expression
      • variablesRegExpTipText

        public String variablesRegExpTipText()
        Returns the tip text for this property.
        Specified by:
        variablesRegExpTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • scopeHandlingStorageTipText

        public String scopeHandlingStorageTipText()
        Returns the tip text for this property.
        Specified by:
        scopeHandlingStorageTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStorageFilter

        public void setStorageFilter​(BaseRegExp value)
        Sets the regular expression that storage item names must match to get into the local scope.
        Specified by:
        setStorageFilter in interface LocalScopeHandler
        Parameters:
        value - the expression
      • getStorageFilter

        public BaseRegExp getStorageFilter()
        Returns the regular expression that storage item names must match to get into the local scope.
        Specified by:
        getStorageFilter in interface LocalScopeHandler
        Returns:
        the expression
      • storageFilterTipText

        public String storageFilterTipText()
        Returns the tip text for this property.
        Specified by:
        storageFilterTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPropagateStorage

        public void setPropagateStorage​(boolean value)
        Sets whether to propagate storage items from the local to the outer scope.
        Specified by:
        setPropagateStorage in interface LocalScopeHandler
        Parameters:
        value - if true then storage items get propagated
      • getPropagateStorage

        public boolean getPropagateStorage()
        Returns whether to propagate storage items from the local to the outer scope.
        Specified by:
        getPropagateStorage in interface LocalScopeHandler
        Returns:
        true if storage items get propagated
      • propagateStorageTipText

        public String propagateStorageTipText()
        Returns the tip text for this property.
        Specified by:
        propagateStorageTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStorageRegExp

        public void setStorageRegExp​(BaseRegExp value)
        Sets the regular expression that storage item names must match to get propagated.
        Specified by:
        setStorageRegExp in interface LocalScopeHandler
        Parameters:
        value - the expression
      • getStorageRegExp

        public BaseRegExp getStorageRegExp()
        Returns the regular expression that storage item names must match to get propagated.
        Specified by:
        getStorageRegExp in interface LocalScopeHandler
        Returns:
        the expression
      • storageRegExpTipText

        public String storageRegExpTipText()
        Returns the tip text for this property.
        Specified by:
        storageRegExpTipText in interface LocalScopeHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFinishBeforeStopping

        public void setFinishBeforeStopping​(boolean value)
        Sets whether to finish processing before stopping execution.
        Specified by:
        setFinishBeforeStopping in interface AtomicExecution
        Parameters:
        value - if true then actor finishes processing first
      • getFinishBeforeStopping

        public boolean getFinishBeforeStopping()
        Returns whether to finish processing before stopping execution.
        Specified by:
        getFinishBeforeStopping in interface AtomicExecution
        Returns:
        true if actor finishes processing first
      • finishBeforeStoppingTipText

        public String finishBeforeStoppingTipText()
        Returns the tip text for this property.
        Specified by:
        finishBeforeStoppingTipText in interface AtomicExecution
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStoppingTimeout

        public void setStoppingTimeout​(int value)
        Sets the timeout for waiting for the sub-flow to stop.
        Specified by:
        setStoppingTimeout in interface AtomicExecution
        Parameters:
        value - timeout in milliseconds (<= 0 for infinity)
      • getStoppingTimeout

        public int getStoppingTimeout()
        Returns the timeout for waiting for the sub-flow to stop.
        Specified by:
        getStoppingTimeout in interface AtomicExecution
        Returns:
        timeout in milliseconds (<= 0 for infinity)
      • stoppingTimeoutTipText

        public String stoppingTimeoutTipText()
        Returns the tip text for this property.
        Specified by:
        stoppingTimeoutTipText in interface AtomicExecution
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStoppingWarningInterval

        public void setStoppingWarningInterval​(int value)
        Sets the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).
        Parameters:
        value - interval in milliseconds (<= 0 no warning)
      • getStoppingWarningInterval

        public int getStoppingWarningInterval()
        Returns the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).
        Returns:
        interval in milliseconds (<= 0 no warning)
      • stoppingWarningIntervalTipText

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

        public void setEnforceCallableNameCheck​(boolean value)
        Sets whether to enforce the callable name check.
        Specified by:
        setEnforceCallableNameCheck in interface ScopeHandler
        Parameters:
        value - true if to enforce check
      • getEnforceCallableNameCheck

        public boolean getEnforceCallableNameCheck()
        Returns whether the check of callable names is enforced.
        Specified by:
        getEnforceCallableNameCheck in interface ScopeHandler
        Returns:
        true if check enforced
      • get

        public Actor get​(int index)
        Returns the actor at the given position.
        Specified by:
        get in interface ActorHandler
        Specified by:
        get in class AbstractControlActor
        Parameters:
        index - the position
        Returns:
        the actor
      • set

        public String set​(int index,
                          Actor actor)
        Sets the actor at the given position.
        Specified by:
        set in interface ActorHandler
        Specified by:
        set in class AbstractControlActor
        Parameters:
        index - the position
        actor - the actor to set at this position
        Returns:
        null if successful, otherwise error message
      • indexOf

        public int indexOf​(String actor)
        Returns the index of the actor.
        Specified by:
        indexOf in interface ActorHandler
        Specified by:
        indexOf in class AbstractControlActor
        Parameters:
        actor - the name of the actor to look for
        Returns:
        the index of -1 if not found
      • add

        public String add​(Actor actor)
        Inserts the actor at the end.
        Specified by:
        add in interface MutableActorHandler
        Parameters:
        actor - the actor to insert
        Returns:
        null if successful, otherwise error message
      • add

        public String add​(int index,
                          Actor actor)
        Inserts the actor at the given position.
        Specified by:
        add in interface MutableActorHandler
        Parameters:
        index - the position
        actor - the actor to insert
        Returns:
        null if successful, otherwise error message
      • remove

        public Actor remove​(int index)
        Removes the actor at the given position and returns the removed object.
        Specified by:
        remove in interface MutableActorHandler
        Parameters:
        index - the position
        Returns:
        the removed actor
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        the Class of objects that can be processed
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        the Class of the generated tokens
      • setUpSubActors

        protected String setUpSubActors()
        Gets called in the setUp() method. Returns null if loop-actors are fine, otherwise error message.
        Overrides:
        setUpSubActors in class AbstractControlActor
        Returns:
        null if everything OK, otherwise error message
      • input

        public void input​(Token token)
        Does nothing.
        Specified by:
        input in interface InputConsumer
        Parameters:
        token - the token to accept and process
      • hasInput

        public boolean hasInput()
        Returns whether an input token is currently present.
        Specified by:
        hasInput in interface InputConsumer
        Returns:
        true if input token present
      • currentInput

        public Token currentInput()
        Returns the current input token, if any.
        Specified by:
        currentInput in interface InputConsumer
        Returns:
        the input token, null if none present
      • isRestrictingStops

        public boolean isRestrictingStops()
        Returns whether stops are being restricted.
        Specified by:
        isRestrictingStops in interface StopRestrictor
        Returns:
        true if restricting stops
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message
      • hasPendingOutput

        public boolean hasPendingOutput()
        Checks whether there is pending output to be collected after executing the flow item.
        Specified by:
        hasPendingOutput in interface OutputProducer
        Returns:
        true if there is pending output
      • output

        public Token output()
        Returns the generated token.
        Specified by:
        output in interface OutputProducer
        Returns:
        the generated token
      • isRestrictedStop

        public boolean isRestrictedStop()
        Returns whether the stop was a restricted one (that can be resumed).
        Specified by:
        isRestrictedStop in interface StopRestrictor
        Returns:
        true if restricted stop occurred
      • restrictedStopExecution

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