info.bioinfweb.jphyloio.formats.nexus.commandreaders

## Class NexusCommandReaderFactory

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

-     public class NexusCommandReaderFactory
      extends java.lang.Object

  A factory class that creates instance of `NexusCommandEventReader`. Each Nexus command can have a specific reader, which can be created by an instance of this class. The readers that can be created by a factory instance depend on the registered reader classes (see below).

  An instance of this class needs to be passed to the constructor of `NexusEventReader`. The readers added to this factory determine the Nexus commands that will be supported by that reader instance.

  Any class of command reader can be added to this factory to be associated with a certain Nexus command in a certain Nexus block. The method `addJPhyloIOReaders()` can be used to add all command readers that are defined in JPhyloIO to an instance. If additional custom readers are defined on application level, these can be added using `addReaderClass(Class)`.

  Author:
    Ben Stöver

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ALL_BLOCKS_IDENTIFIER`
    `static char` | `BLOCK_COMMAND_CONNECTOR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NexusCommandReaderFactory()` Creates a new empty instance of this class.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addJPhyloIOReaders()` Adds all Nexus command readers available in JPhyloIO to this instance.
    `void` | `addReaderClass(java.lang.Class<? extends NexusCommandEventReader> readerClass)` Adds a new type of reader to this factory instance.
    `NexusCommandEventReader` | `createReader(java.lang.String blockName, java.lang.String commandName, NexusReaderStreamDataProvider streamDataProvider)` Creates a new reader instance that is able to parse the specified command in the specified block, if an according class was registered in this factory instance.
    `static NexusCommandReaderFactory` | `newJPhyloIOInstance()` Returns a new instance of this class, already containing all command readers available in the core module of JPhyloIO.

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

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

- - ### Field Detail

    - #### ALL_BLOCKS_IDENTIFIER

          public static final java.lang.String ALL_BLOCKS_IDENTIFIER

      See Also:
        Constant Field Values

    - #### BLOCK_COMMAND_CONNECTOR

          public static final char BLOCK_COMMAND_CONNECTOR

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NexusCommandReaderFactory

          public NexusCommandReaderFactory()

      Creates a new empty instance of this class.
      See Also:
        `addJPhyloIOReaders()`, `newJPhyloIOInstance()`

  - ### Method Detail

    - #### newJPhyloIOInstance

          public static NexusCommandReaderFactory newJPhyloIOInstance()

      Returns a new instance of this class, already containing all command readers available in the core module of JPhyloIO. (`addJPhyloIOReaders()` is called internally.)
      Returns:
        the new instance

    - #### addJPhyloIOReaders

          public void addJPhyloIOReaders()

      Adds all Nexus command readers available in JPhyloIO to this instance.

    - #### addReaderClass

          public void addReaderClass(java.lang.Class<? extends NexusCommandEventReader> readerClass)
                              throws java.lang.IllegalArgumentException

      Adds a new type of reader to this factory instance.
      Parameters:
        `readerClass` - the class of the Nexus command reader type to be added
      Throws:
        `java.lang.IllegalArgumentException` - if the specified class does not offer an constructor as described in `NexusCommandEventReader`

    - #### createReader

          public NexusCommandEventReader createReader(java.lang.String blockName,
                                                      java.lang.String commandName,
                                                      NexusReaderStreamDataProvider streamDataProvider)

      Creates a new reader instance that is able to parse the specified command in the specified block, if an according class was registered in this factory instance.
      Parameters:
        `blockName` - the name of the block the command to parse is contained in
        `commandName` - the name of the command to be parsed
        `streamDataProvider` - the stream and data provider to be used by the returned reader
      Returns:
        the reader or `null` if no according reader was found in this factory