Class Count

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

    public class Count
    extends Tee
    implements VariableMonitor
    Counts the number of tokens that pass through and meet the condition and tees off the current count every n-th token.

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


    Conditional equivalent:
       adams.flow.control.ConditionalTee

    -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: Count
     
    -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 gets stopped in case this actor encounters an error;
         useful for critical actors.
        default: false
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console.
        default: false
     
    -finish-before-stopping <boolean> (property: finishBeforeStopping)
        If enabled, actor first finishes processing all data before stopping.
        default: false
     
    -asynchronous <boolean> (property: asynchronous)
        If enabled, the sub-actors get executed asynchronously rather than the flow 
        waiting for them to finish before proceeding with execution.
        default: false
     
    -tee <adams.flow.core.AbstractActor> [-tee ...] (property: actors)
        The actors to siphon-off the tokens to.
        default: 
     
    -condition <adams.flow.condition.bool.BooleanCondition> (property: condition)
        The boolean condition to evaluate.
        default: adams.flow.condition.bool.Counting
     
    -increment-only-if-condition-met <boolean> (property: incrementOnlyIfConditionMet)
        If enabled, the counter gets only incremented if the condition is met; useful 
        if you want to count tokens of a certain value.
        default: false
     
    -var-name <adams.core.VariableName> (property: variableName)
        The variable to monitor.
        default: variable
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_CURRENT

        public static final String BACKUP_CURRENT
        the key for storing the current counter in the backup.
        See Also:
        Constant Field Values
      • m_IncrementOnlyIfConditionMet

        protected boolean m_IncrementOnlyIfConditionMet
        only increments the counter when the condition is met.
      • m_VariableName

        protected VariableName m_VariableName
        the variable to listen to.
      • m_Current

        protected int m_Current
        the current count.
    • Constructor Detail

      • Count

        public Count()
    • Method Detail

      • setCondition

        public void setCondition​(BooleanCondition value)
        Sets the condition responsible for tee-ing of the token.
        Parameters:
        value - the condition
      • getCondition

        public BooleanCondition getCondition()
        Returns the condition responsible for tee-ing of the token.
        Returns:
        the condition
      • conditionTipText

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

        public void setIncrementOnlyIfConditionMet​(boolean value)
        Sets whether to increment the counter only if the condition is met.
        Parameters:
        value - if true then the counter is only increment if the boolean condition returns true
      • getIncrementOnlyIfConditionMet

        public boolean getIncrementOnlyIfConditionMet()
        Returns whether the counter is only incremented if the condition is met.
        Returns:
        true if the counter is only incremented of the boolean condition returns true
      • incrementOnlyIfConditionMetTipText

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

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

        public void input​(Token token)
        The method that accepts the input token and then processes it.
        Specified by:
        input in interface InputConsumer
        Overrides:
        input in class AbstractTee
        Parameters:
        token - the token to accept and process
      • canFire

        protected boolean canFire()
        Checks whether we can process the token.
        Returns:
        true if token can be processed
      • canProcessInput

        protected boolean canProcessInput​(Token token)
        Returns whether the token can be processed in the tee actor.
        Overrides:
        canProcessInput in class AbstractTee
        Parameters:
        token - the token to process
        Returns:
        true if token can be processed
      • createTeeToken

        protected Token createTeeToken​(Token token)
        Creates the token to tee-off.
        Overrides:
        createTeeToken in class AbstractTee
        Parameters:
        token - the input token
        Returns:
        the token to tee-off
      • processInput

        protected String processInput​(Token token)
        Processes the token normal, i.e., not in thread.
        Overrides:
        processInput in class AbstractTee
        Parameters:
        token - the token to process
        Returns:
        an optional error message, null if everything OK