info.bioinfweb.jphyloio.formats.nexus.commandreaders

## Class AbstractNexusCommandEventReader

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

- All Implemented Interfaces:
    NexusCommandEventReader
  Direct Known Subclasses:
    AbstractCharLabelsReader, AbstractKeyValueCommandReader, AbstractNexusSetReader, DefaultCommandReader, MatrixReader, TaxLabelsReader, TitleReader, TranslateReader, TreeReader

      public abstract class AbstractNexusCommandEventReader
      extends java.lang.Object
      implements NexusCommandEventReader

  Implements shared functionality for classes implementing `NexusCommandEventReader`.
  Author:
    Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractNexusCommandEventReader(java.lang.String commandName, java.lang.String[] validBlocks, NexusReaderStreamDataProvider streamDataProvider)` Creates a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `consumeWhiteSpaceAndCommentsToBuffer(java.util.Collection<JPhyloIOEvent> buffer)`
    `protected abstract boolean` | `doReadNextEvent()`
    `java.lang.String` | `getCommandName()` Returns the name of the Nexus command that can be parsed by this instance.
    `protected NexusReaderStreamDataProvider` | `getStreamDataProvider()`
    `java.util.Collection<java.lang.String>` | `getValidBlocks()` Returns a collection with the names of the Nexus blocks the command parsed by the implementing class may be contained in.
    `protected boolean` | `isAllDataProcessed()` Returns `true` if the whole command this instance was created on has been parsed or `false` if another events can be generated by the next call of `readNextEvent()`.
    `boolean` | `readNextEvent()` Adds at least one additional event (generated from the current Nexus command) to the event queue.
    `protected void` | `setAllDataProcessed(boolean allDataProcessed)`

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

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

- - ### Constructor Detail

    - #### AbstractNexusCommandEventReader

          public AbstractNexusCommandEventReader(java.lang.String commandName,
                                                 java.lang.String[] validBlocks,
                                                 NexusReaderStreamDataProvider streamDataProvider)

      Creates a new instance of this class.

      Note that non-abstract inherited classes need to specify a constructor matching the requirements defined by `NexusCommandEventReader`.

      Parameters:
        `validBlocks` - an array with the names of the Nexus blocks the command parsed by the implementing class may be contained in

  - ### Method Detail

    - #### getCommandName

          public java.lang.String getCommandName()

      Description copied from interface: `NexusCommandEventReader`
      Returns the name of the Nexus command that can be parsed by this instance.
      Specified by:
        `getCommandName` in interface `NexusCommandEventReader`
      Returns:
        a non-empty string

    - #### getValidBlocks

          public java.util.Collection<java.lang.String> getValidBlocks()

      Description copied from interface: `NexusCommandEventReader`
      Returns a collection with the names of the Nexus blocks the command parsed by the implementing class may be contained in.

      An empty collection returned here indicates that this reader is valid in all Nexus blocks.

      Specified by:
        `getValidBlocks` in interface `NexusCommandEventReader`
      Returns:
        a collection with the block names

    - #### isAllDataProcessed

          protected boolean isAllDataProcessed()

      Returns `true` if the whole command this instance was created on has been parsed or `false` if another events can be generated by the next call of `readNextEvent()`.
      Returns:
        whether more events are available

    - #### setAllDataProcessed

          protected void setAllDataProcessed(boolean allDataProcessed)

    - #### getStreamDataProvider

          protected NexusReaderStreamDataProvider getStreamDataProvider()

    - #### consumeWhiteSpaceAndCommentsToBuffer

          protected void consumeWhiteSpaceAndCommentsToBuffer(java.util.Collection<JPhyloIOEvent> buffer)
                                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### doReadNextEvent

          protected abstract boolean doReadNextEvent()
                                              throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readNextEvent

          public boolean readNextEvent()
                                throws java.io.IOException

      Description copied from interface: `NexusCommandEventReader`
      Adds at least one additional event (generated from the current Nexus command) to the event queue.
      Specified by:
        `readNextEvent` in interface `NexusCommandEventReader`
      Returns:
        `true` if at least one additional event was added or `false` if the underlying Nexus command was already completely processed an no more events can generated from it
      Throws:
        `java.io.IOException`