Class Switch

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

    public class Switch
    extends AbstractDirectedControlActor
    implements InputConsumer, OutputProducer, MutableActorHandler, IndexedBooleanConditionSupporter, LenientModeSupporter
    Emulates a Switch control statement. The first 'condition' that evaluates to 'true' executes the corresponding 'case' actor and stops evaluation of conditions.
    A catch-all or default can be set up as well by having one more 'case' than 'conditions' (the last case acts as default).
    If any output is generated then this gets recorded and forwarded in the flow.
    Normally, the number of conditions and number of switch branches have to be the same. A special case are adams.flow.condition.bool.IndexedBooleanCondition conditions. They can be used alone, as they determine which switch branch to use.

    Input/output:
    - accepts:
       adams.flow.core.Unknown
    - generates:
       adams.flow.core.Unknown


    -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: Switch
     
    -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
     
    -finish-before-stopping <boolean> (property: finishBeforeStopping)
        If enabled, actor first finishes processing all data before stopping.
        default: false
     
    -stopping-timeout <int> (property: stoppingTimeout)
        The timeout in milliseconds when waiting for actors to finish (<= 0 for
        infinity; see 'finishBeforeStopping').
        default: -1
        minimum: -1
     
    -condition <adams.flow.condition.bool.BooleanCondition> [-condition ...] (property: conditions)
        The switch conditions to evaluate - the first condition that evaluates to
        'true' triggers the execution of the corresponding 'case' actor.
        default: adams.flow.condition.bool.True
     
    -case <adams.flow.core.Actor> [-case ...] (property: cases)
        The 'cases' - one of them gets executed if the corresponding 'condition'
        evaluates to 'true'.
        default: adams.flow.sink.Null
     
    -lenient <boolean> (property: lenient)
        If enabled, the token passing through is not required to have a payload
        (eg generated by the Start source).
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_INPUT

        public static final String BACKUP_INPUT
        the key for storing the current input token in the backup.
        See Also:
        Constant Field Values
      • m_Conditions

        protected BooleanCondition[] m_Conditions
        the "conditions" for the various switch cases.
      • m_Cases

        protected List<Actor> m_Cases
        the "cases" to execute if the corresponding expression matches.
      • m_Lenient

        protected boolean m_Lenient
        whether we operate in lenient mode, ie not requiring a payload.
      • m_InputToken

        protected transient Token m_InputToken
        the input token.
      • m_Queue

        protected List m_Queue
        the generated tokens.
    • Constructor Detail

      • Switch

        public Switch()