info.bioinfweb.jphyloio.formats.nexus.commandreaders.all

## Class LinkReader

- java.lang.Object
- - info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractNexusCommandEventReader
  - - info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractKeyValueCommandReader
    - - info.bioinfweb.jphyloio.formats.nexus.commandreaders.all.LinkReader

- All Implemented Interfaces:
    NexusCommandEventReader, NexusConstants

      public class LinkReader
      extends AbstractKeyValueCommandReader
      implements NexusConstants

  Reads the `LINK` command of a Nexus block and stores the links in the shared information map of the stream data provider under the key `NexusReaderStreamDataProvider.INFO_KEY_BLOCK_LINKS`.

  Note that the `LINK` command is not part of the initial Nexus definition, but was used by Mesquite as a custom command to allow references between blocks using the `TITLE` command.

  This reader is valid for all blocks, therefore `AbstractNexusCommandEventReader.getValidBlocks()` returns an empty collection.

  Example usage:

       #NEXUS

       BEGIN TAXA;
         TITLE 'taxon list 1';
         DIMENSIONS NTAX = 3;
         TAXLABELS A B C;
       END;
       BEGIN TAXA;
         TITLE TaxonList2;
         DIMENSIONS NTAX = 3;
         TAXLABELS D E F;
       END;

       BEGIN TREES;
         LINK TAXA = 'taxon list 1';
         TREE someTree = (A, (B, C));
       END;
       BEGIN TREES;
         LINK TAXA = TaxonList2;
         TREE someTree = (D, (E, F));
       END;

  The `LINK` command may also be used to link other blocks than the `TAXA` block, but JPhyloIO will not use this information.
  Author:
    Ben Stöver
  See Also:
    `TitleReader`

- - ### Field Summary

    - ### 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
    `LinkReader(NexusReaderStreamDataProvider nexusDocument)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `addStoredEvents()` Implementations that need to store events, until all generated events are known should add such events to the queue, when this method is called.
    `protected boolean` | `processSubcommand(KeyValueInformation info)` Inherited classes should implement this method by adding one or more events to the queue, which have been generated from the specified key value pair.

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractKeyValueCommandReader

      `doReadNextEvent`

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractNexusCommandEventReader

      `consumeWhiteSpaceAndCommentsToBuffer, getCommandName, getStreamDataProvider, getValidBlocks, isAllDataProcessed, readNextEvent, setAllDataProcessed`

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

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

- - ### Constructor Detail

    - #### LinkReader

          public LinkReader(NexusReaderStreamDataProvider nexusDocument)

  - ### Method Detail

    - #### processSubcommand

          protected boolean processSubcommand(KeyValueInformation info)
                                       throws java.io.IOException

      Description copied from class: `AbstractKeyValueCommandReader`
      Inherited classes should implement this method by adding one or more events to the queue, which have been generated from the specified key value pair.
      Specified by:
        `processSubcommand` in class `AbstractKeyValueCommandReader`
      Parameters:
        `info` - the key and value
      Returns:
        `true` if at least one event has been added to the queue by this or `false` otherwise
      Throws:
        `java.io.IOException` - if an exception occurs when trying to read from the underlying stream

    - #### addStoredEvents

          protected boolean addStoredEvents()

      Description copied from class: `AbstractKeyValueCommandReader`
      Implementations that need to store events, until all generated events are known should add such events to the queue, when this method is called. It is guaranteed that this method will not be called by `AbstractKeyValueCommandReader`, before the whole command was processed.
      Specified by:
        `addStoredEvents` in class `AbstractKeyValueCommandReader`
      Returns:
        `true` if events were added by this method or `false` otherwise