info.bioinfweb.jphyloio.utils

## Class SequenceTokensEventManager

- java.lang.Object
- - info.bioinfweb.jphyloio.utils.SequenceTokensEventManager

-     public class SequenceTokensEventManager
      extends java.lang.Object

  Class used by implementations of `JPhyloIOEventReader` to keep track of the current alignment position and replacing match tokens by the according tokens from the first sequence.
  Author:
    Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SequenceTokensEventManager(JPhyloIOEventReader owner, java.lang.String matchToken)` Creates a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SequenceTokensEvent` | `createEvent(java.lang.String sequenceID, java.util.List<java.lang.String> tokens)` Creates a sequence character event object from the provided data and manages the replacement of match tokens by tokens of the first sequence.
    `long` | `getCurrentBlockLength()`
    `long` | `getCurrentBlockStartPosition()`
    `long` | `getCurrentPosition()`
    `java.lang.String` | `getCurrentSequenceName()`
    `java.util.List<java.lang.String>` | `getFirstSequence()`
    `java.lang.String` | `getFirstSequenceName()`
    `java.lang.String` | `getMatchToken()`
    `JPhyloIOEventReader` | `getOwner()` Returns the reader instance using this object.
    `void` | `setMatchToken(java.lang.String matchToken)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SequenceTokensEventManager

          public SequenceTokensEventManager(JPhyloIOEventReader owner,
                                            java.lang.String matchToken)

      Creates a new instance of this class.
      Parameters:
        `owner` - the PhyloIO event reader using the returned instance
        `matchToken` - the match token to be replaced in sequences or `null` if no replacement shall be performed
      Throws:
        `java.lang.NullPointerException` - if `owner` is set to `null`

  - ### Method Detail

    - #### getOwner

          public JPhyloIOEventReader getOwner()

      Returns the reader instance using this object.
      Returns:
        the reader class (never `null`)

    - #### getMatchToken

          public java.lang.String getMatchToken()

    - #### setMatchToken

          public void setMatchToken(java.lang.String matchToken)

    - #### getCurrentPosition

          public long getCurrentPosition()

    - #### getCurrentBlockStartPosition

          public long getCurrentBlockStartPosition()

    - #### getCurrentBlockLength

          public long getCurrentBlockLength()

    - #### getFirstSequenceName

          public java.lang.String getFirstSequenceName()

    - #### getCurrentSequenceName

          public java.lang.String getCurrentSequenceName()

    - #### getFirstSequence

          public java.util.List<java.lang.String> getFirstSequence()

    - #### createEvent

          public SequenceTokensEvent createEvent(java.lang.String sequenceID,
                                                 java.util.List<java.lang.String> tokens)

      Creates a sequence character event object from the provided data and manages the replacement of match tokens by tokens of the first sequence.

      This method stores the tokens of the first sequence and the current sequence position. Therefore implementing readers supporting match token replacement must always use this method to create sequence character event objects and never do this directly, otherwise the replacement by this method will not work.

      Note that the algorithm for position monitoring will only work for interleaved formats where each sequence part has the same length in each block or for non-interleaved formats (where each sequence only occurs once).

      Parameters:
        `sequenceID` - the event ID or another unique name of the sequence to append the tokens to
        `tokens` - the newly read tokens
      Returns:
        the event object
      Throws:
        `java.lang.NullPointerException` - if either `sequenceID` or `tokens` is `null`