info.bioinfweb.jphyloio.formats.nexus

## Class NexusReaderStreamDataProvider

- java.lang.Object
- - info.bioinfweb.jphyloio.ReaderStreamDataProvider<R>
  - - info.bioinfweb.jphyloio.formats.text.TextReaderStreamDataProvider<NexusEventReader>
    - - info.bioinfweb.jphyloio.formats.nexus.NexusReaderStreamDataProvider

- All Implemented Interfaces:
    NexusConstants

      public class NexusReaderStreamDataProvider
      extends TextReaderStreamDataProvider<NexusEventReader>
      implements NexusConstants

  Stores data that shall be shared among different implementations of `NexusCommandEventReader` reading from the same document.
  Author:
    Ben Stöver

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `INFO_CHARACTER_NAME_TO_INDEX_MAP`
    `static java.lang.String` | `INFO_KEY_BLOCK_ID_MAP`
    `static java.lang.String` | `INFO_KEY_BLOCK_LINKS`
    `static java.lang.String` | `INFO_KEY_BLOCK_START_EVENT_FIRED`
    `static java.lang.String` | `INFO_KEY_BLOCK_TITLE` Used to store the title of the current block if specified by a TITLE command.
    `static java.lang.String` | `INFO_KEY_CURRENT_BLOCK_ID` Used to store the ID of the according JPhyloIO event to the current Nexus block (if one exists).
    `static java.lang.String` | `INFO_KEY_ELEMENT_LIST`
    `static java.lang.String` | `INFO_KEY_MATRIX_WIDTHS_MAP` Used to Determine the lengths of character set intervals that shall reach until the end of a matrix.
    `static java.lang.String` | `INFO_KEY_NEXUS_NAME_TO_ID_MAP`
    `static java.lang.String` | `INFO_KEY_TREES_TRANSLATION`

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.nexus.NexusConstants

      `ALTERNATIVE_END_COMMAND, BEGIN_COMMAND, BLOCK_NAME_CHARACTERS, BLOCK_NAME_DATA, BLOCK_NAME_NETWORKS, BLOCK_NAME_SETS, BLOCK_NAME_TAXA, BLOCK_NAME_TREES, BLOCK_NAME_UNALIGNED, CHARACTER_NAME_STATES_SEPARATOR, COMMAND_END, COMMAND_NAME_CHAR_LABELS, COMMAND_NAME_CHAR_SET, COMMAND_NAME_CHAR_STATE_LABELS, COMMAND_NAME_DIMENSIONS, COMMAND_NAME_FORMAT, COMMAND_NAME_LINK, COMMAND_NAME_MATRIX, COMMAND_NAME_NETWORK, COMMAND_NAME_TAX_LABELS, COMMAND_NAME_TAXON_SET, COMMAND_NAME_TITLE, COMMAND_NAME_TRANSLATE, COMMAND_NAME_TREE, COMMAND_NAME_TREE_SET, COMMENT_END, COMMENT_START, DIMENSIONS_SUBCOMMAND_NCHAR, DIMENSIONS_SUBCOMMAND_NEW_TAXA, DIMENSIONS_SUBCOMMAND_NTAX, ELEMENT_SEPARATOR, END_COMMAND, FIRST_LINE, FORMAT_NAME_STANDARD, FORMAT_NAME_VECTOR, FORMAT_SUBCOMMAND_DATA_TYPE, FORMAT_SUBCOMMAND_GAP_CHAR, FORMAT_SUBCOMMAND_INTERLEAVE, FORMAT_SUBCOMMAND_MATCH_CHAR, FORMAT_SUBCOMMAND_MISSING_CHAR, FORMAT_SUBCOMMAND_NO_LABELS, FORMAT_SUBCOMMAND_NO_TOKENS, FORMAT_SUBCOMMAND_SYMBOLS, FORMAT_SUBCOMMAND_TOKENS, FORMAT_SUBCOMMAND_TRANSPOSE, FORMAT_VALUE_CONTINUOUS_DATA_TYPE, FORMAT_VALUE_DNA_DATA_TYPE, FORMAT_VALUE_MIXED_DATA_TYPE, FORMAT_VALUE_NUCLEOTIDE_DATA_TYPE, FORMAT_VALUE_PROTEIN_DATA_TYPE, FORMAT_VALUE_RNA_DATA_TYPE, FORMAT_VALUE_STANDARD_DATA_TYPE, KEY_VALUE_SEPARATOR, MATRIX_POLYMORPHIC_TOKEN_END, MATRIX_POLYMORPHIC_TOKEN_START, MATRIX_UNCERTAINS_TOKEN_END, MATRIX_UNCERTAINS_TOKEN_START, NEXUS_FORMAT_NAME, NEXUS_NAMESPACE_PREFIX, NEXUS_PREDICATE_NAMESPACE, SET_END_INDEX_SYMBOL, SET_KEY_WORD_ALL, SET_KEY_WORD_REMAINING, SET_REGULAR_INTERVAL_SYMBOL, SET_TO_SYMBOL, SET_VECTOR_CONTAINED, SET_VECTOR_NOT_CONTAINED, UNTIL_WHITESPACE_COMMENT_COMMAND_EQUAL_PATTERN, UNTIL_WHITESPACE_COMMENT_COMMAND_PATTERN, VALUE_DELIMITER, WORD_DELIMITER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NexusReaderStreamDataProvider(NexusEventReader nexusReader)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearBlockInformation()`
    `void` | `consumeWhiteSpaceAndComments()` Calls `#consumeWhiteSpaceAndComments(char, char)` with according parameters and ensures visibility for `NexusReaderStreamDataProvider`.
    `java.util.Map<java.lang.String,java.lang.String>` | `getBlockLinks()` Returns the map that contains links to other blocks that are explicitly linked to this block.
    `BlockTitleToIDMap` | `getBlockTitleToIDMap()` Returns a map object that can translate Nexus block titles to the IDs of the according JPhyloIO start events.
    `java.lang.String` | `getCurrentLinkedBlockID(java.lang.String blockTypeName)` Returns the JPhyloIO ID of the start event describing the Nexus block of the specified type that is linked to the current block.
    `java.util.List<java.lang.String>` | `getElementList(EventContentType type, java.lang.String listID)`
    `NexusEventReader` | `getEventReader()`
    `java.util.Map<?,?>` | `getMap(java.lang.String key)` Gets a map object from the shared information map.
    `java.lang.String` | `getMatrixLink()` Returns the ID if a `CHARACTERS`, `DATA` or `UNALIGNED` block that is linked to the current block.
    `java.util.Map<java.lang.String,java.lang.Long>` | `getMatrixWidthsMap()` Returns a map object that stores the widths of all sequence matrices encountered until now.
    `java.util.Map<java.lang.String,java.lang.String>` | `getNexusNameToIDMap(EventContentType type, java.lang.String listID)` Returns a map object that translates between a Nexus name and the JPhyloIO ID of the according event.
    `ParameterMap` | `getSharedInformationMap()` This map can be used to store objects to be shared between different instances of `NexusCommandEventReader`.
    `NexusTranslationTable` | `getTreesTranslationTable()` Returns the current Nexus translation table object.
    `void` | `readComment()`
    `KeyValueInformation` | `readKeyValueMetaInformation()`
    `java.lang.String` | `readNexusWord()`
    `long` | `readPositiveInteger(long startOrEndIndex)` Tries to read a positive integer from the current position of the underlying stream-

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.text.TextReaderStreamDataProvider

      `getDataReader`

    - ### Methods inherited from class info.bioinfweb.jphyloio.ReaderStreamDataProvider

      `eventsUpcoming, getCurrentEventCollection, getIDManager, getParameters, getSequenceTokensEventManager, hasSpecialEventCollection, resetCurrentEventCollection, setCurrentEventCollection`

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

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

- - ### Field Detail

    - #### INFO_KEY_BLOCK_START_EVENT_FIRED

          public static final java.lang.String INFO_KEY_BLOCK_START_EVENT_FIRED

      See Also:
        Constant Field Values

    - #### INFO_KEY_CURRENT_BLOCK_ID

          public static final java.lang.String INFO_KEY_CURRENT_BLOCK_ID

      Used to store the ID of the according JPhyloIO event to the current Nexus block (if one exists).
      See Also:
        Constant Field Values

    - #### INFO_KEY_BLOCK_TITLE

          public static final java.lang.String INFO_KEY_BLOCK_TITLE

      Used to store the title of the current block if specified by a TITLE command.
      See Also:
        Constant Field Values

    - #### INFO_KEY_BLOCK_LINKS

          public static final java.lang.String INFO_KEY_BLOCK_LINKS

      See Also:
        Constant Field Values

    - #### INFO_KEY_BLOCK_ID_MAP

          public static final java.lang.String INFO_KEY_BLOCK_ID_MAP

      See Also:
        Constant Field Values

    - #### INFO_KEY_ELEMENT_LIST

          public static final java.lang.String INFO_KEY_ELEMENT_LIST

      See Also:
        Constant Field Values

    - #### INFO_KEY_NEXUS_NAME_TO_ID_MAP

          public static final java.lang.String INFO_KEY_NEXUS_NAME_TO_ID_MAP

      See Also:
        Constant Field Values

    - #### INFO_CHARACTER_NAME_TO_INDEX_MAP

          public static final java.lang.String INFO_CHARACTER_NAME_TO_INDEX_MAP

      See Also:
        Constant Field Values

    - #### INFO_KEY_TREES_TRANSLATION

          public static final java.lang.String INFO_KEY_TREES_TRANSLATION

      See Also:
        Constant Field Values

    - #### INFO_KEY_MATRIX_WIDTHS_MAP

          public static final java.lang.String INFO_KEY_MATRIX_WIDTHS_MAP

      Used to Determine the lengths of character set intervals that shall reach until the end of a matrix.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NexusReaderStreamDataProvider

          public NexusReaderStreamDataProvider(NexusEventReader nexusReader)

  - ### Method Detail

    - #### getEventReader

          public NexusEventReader getEventReader()

      Overrides:
        `getEventReader` in class `ReaderStreamDataProvider<NexusEventReader>`

    - #### consumeWhiteSpaceAndComments

          public void consumeWhiteSpaceAndComments()
                                            throws java.io.IOException

      Calls `#consumeWhiteSpaceAndComments(char, char)` with according parameters and ensures visibility for `NexusReaderStreamDataProvider`.
      Throws:
        `java.io.IOException` - if an I/O error occurs during the read operation

    - #### readNexusWord

          public java.lang.String readNexusWord()
                                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readPositiveInteger

          public long readPositiveInteger(long startOrEndIndex)
                                   throws java.io.IOException

      Tries to read a positive integer from the current position of the underlying stream-
      Parameters:
        `startOrEndIndex` - the value to be returned, if `'.'` is encountered (It is used as a placeholder for the highest possible index in some commands.)
      Returns:
        the read positive integer or `startOrEndIndex` or -2 if neither a positive integer nor `'.'` was found
      Throws:
        `java.io.IOException`

    - #### readComment

          public void readComment()
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readKeyValueMetaInformation

          public KeyValueInformation readKeyValueMetaInformation()
                                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getSharedInformationMap

          public ParameterMap getSharedInformationMap()

      This map can be used to store objects to be shared between different instances of `NexusCommandEventReader`.
      Returns:
        a map providing access to shared data objects

    - #### getBlockLinks

          public java.util.Map<java.lang.String,java.lang.String> getBlockLinks()

      Returns the map that contains links to other blocks that are explicitly linked to this block.

      The returned map is used internally in JPhyloIO to manage links of the current block that are defined with a `LINK` command. It should never be used to determine a currently linked block, but `getCurrentLinkedBlockID(String)` should be used instead.

      Returns:
        the map containing the blocks explicitly linked to the current block

    - #### getMatrixLink

          public java.lang.String getMatrixLink()

      Returns the ID if a `CHARACTERS`, `DATA` or `UNALIGNED` block that is linked to the current block. If none of these blocks is explicitly linked, returning a default linked block will be tried in this order. If no default linked block is found, `null` will be returned.
      Returns:
        a linked block containing sequences or `null`

    - #### clearBlockInformation

          public void clearBlockInformation()

    - #### getMap

          public java.util.Map<?,?> getMap(java.lang.String key)

      Gets a map object from the shared information map. If no such object if found, a new `HashMap` instance is stored under the specified key and returned.
      Parameters:
        `key` - the key in the shared information map
      Returns:
        the map object contained in the shared information map

    - #### getBlockTitleToIDMap

          public BlockTitleToIDMap getBlockTitleToIDMap()

      Returns a map object that can translate Nexus block titles to the IDs of the according JPhyloIO start events. The returned object can also determine default block links.
      Returns:
        the translation map

    - #### getCurrentLinkedBlockID

          public java.lang.String getCurrentLinkedBlockID(java.lang.String blockTypeName)

      Returns the JPhyloIO ID of the start event describing the Nexus block of the specified type that is linked to the current block. It will first look for an explicitly linked block in `getBlockLinks()`. If no link is found, the default link from `BlockTitleToIDMap.getDefaultBlockID(String)` will be returned.
      Parameters:
        `blockTypeName` - the name of the Nexus block type that could be linked
      Returns:
        the start event ID or `null` if no according block could be found

    - #### getElementList

          public java.util.List<java.lang.String> getElementList(EventContentType type,
                                                                 java.lang.String listID)

    - #### getNexusNameToIDMap

          public java.util.Map<java.lang.String,java.lang.String> getNexusNameToIDMap(EventContentType type,
                                                                                      java.lang.String listID)

      Returns a map object that translates between a Nexus name and the JPhyloIO ID of the according event.
      Parameters:
        `type` - the event type of events of the requested ID
        `listID` - the JPhyloIO ID of the according OTU list start event
      Returns:
        the map
      Throws:
        `java.lang.NullPointerException` - if `listID is null`

    - #### getTreesTranslationTable

          public NexusTranslationTable getTreesTranslationTable()

      Returns the current Nexus translation table object. If none is present, a new empty instance will be created and stored in the shared information map.
      Returns:
        the current table

    - #### getMatrixWidthsMap

          public java.util.Map<java.lang.String,java.lang.Long> getMatrixWidthsMap()

      Returns a map object that stores the widths of all sequence matrices encountered until now. It is used by readers of set commands to determine the last column of a matrix, which may be referred by a set definition.
      Returns:
        the map