Class SequenceToCollection

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable

    public class SequenceToCollection
    extends AbstractTransformer
    Turns a sequence of tokens into a collection.
    In case of unspecified length (ie -1), a collection containing all elements collected so far is output each time a token arrives, i.e., the internal buffer never gets reset.

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


    -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: SequenceToCollection
     
    -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; Note: the enclosing 
        actor handler must have this enabled as well.
        default: false
     
    -size <int> (property: collectionSize)
        The size of the collection(s).
        default: 1
        minimum: -1
     
    -overlap <int> (property: overlap)
        The overlap of elements between collections; e.g., sequence of 1,2,3,4 with 
        length=2 and overlap=0 gets packaged in to (1,2),(3,4); with overlap=1, 
        this changes to (1,2),(2,3),(3,4); collection size option must be > 0.
        default: 0
        minimum: 0
     
    -collection-class <java.lang.String> (property: collectionClass)
        The class to use for the collection.
        default: java.util.ArrayList
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_ELEMENTS

        public static final String BACKUP_ELEMENTS
        the key for storing the current elements in the backup.
        See Also:
        Constant Field Values
      • m_Elements

        protected List m_Elements
        the buffered elements of the collection that still need to be broadcasted.
      • m_CollectionSize

        protected int m_CollectionSize
        the length of the collections.
      • m_Overlap

        protected int m_Overlap
        the overlap in elements between collections.
      • m_CollectionClass

        protected String m_CollectionClass
        the class for the collection.
    • Constructor Detail

      • SequenceToCollection

        public SequenceToCollection()
    • Method Detail

      • setCollectionSize

        public void setCollectionSize​(int value)
        Sets the size of the collection.
        Parameters:
        value - the size
      • getCollectionSize

        public int getCollectionSize()
        Returns the length of the collection.
        Returns:
        the size
      • collectionSizeTipText

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

        public void setOverlap​(int value)
        Sets the overlap of elements between collections.
        Parameters:
        value - the overlap
      • getOverlap

        public int getOverlap()
        Returns the overlap of elements between collections.
        Returns:
        the overlap
      • overlapTipText

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

        public void setCollectionClass​(String value)
        Sets the class for the collection.
        Parameters:
        value - the classname, use empty string to use class of first element
      • getCollectionClass

        public String getCollectionClass()
        Returns the class for the collection.
        Returns:
        the classname
      • collectionClassTipText

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

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class AbstractActor
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Returns:
        adams.flow.core.Unknown.class
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Returns:
        java.util.ArrayList.class
      • doExecute

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