info.bioinfweb.jphyloio.formats.newick

## Class NewickFactory

- java.lang.Object
- - info.bioinfweb.jphyloio.factory.AbstractSingleReaderWriterFactory
  - - info.bioinfweb.jphyloio.formats.newick.NewickFactory

- All Implemented Interfaces:
    SingleReaderWriterFactory, JPhyloIOFormatIDs, NewickConstants

      public class NewickFactory
      extends AbstractSingleReaderWriterFactory
      implements SingleReaderWriterFactory, JPhyloIOFormatIDs, NewickConstants

  Reader and writer factory for the Newick format.
  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Field Summary

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.JPhyloIOFormatIDs

      `FASTA_FORMAT_ID, FORMAT_ID_PREFIX, MEGA_FORMAT_ID, NEWICK_FORMAT_ID, NEXML_FORMAT_ID, NEXUS_FORMAT_ID, PDE_FORMAT_ID, PHYLIP_FORMAT_ID, PHYLOXML_FORMAT_ID, SEQUENTIAL_PHYLIP_FORMAT_ID, XTG_FORMAT_ID`

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.newick.NewickConstants

      `ALLOCATION_SEPARATOR_SYMBOL, ALLOCATION_SYMBOL, ALTERNATIVE_NAME_DELIMITER, COMMENT_END, COMMENT_START, DATA_TYPE_NEWICK_ARRAY, E_NEWICK_EDGE_TYPE_HYBRIDIZATION, E_NEWICK_EDGE_TYPE_LATERAL_GENE_TRANSFER, E_NEWICK_EDGE_TYPE_RECOMBINATION, E_NEWICK_NAMESPACE_PREFIX, E_NEWICK_NETWORK_DATA_SEPARATOR, ELEMENT_SEPERATOR, FIELD_END_SYMBOL, FIELD_START_SYMBOL, FIELD_VALUE_SEPARATOR_SYMBOL, FREE_NAME_BLANK, HOT_COMMENT_START_SYMBOL, INDEX_END_SYMBOL, INDEX_START_SYMBOL, LENGTH_SEPERATOR, NAME_DELIMITER, NEWICK_DATA_TYPE_NAMESPACE, NEWICK_FORMAT_NAME, NEWICK_NAMESPACE_PREFIX, NHX_KEY_CONFIDENCE, NHX_KEY_EVENT, NHX_KEY_GENE_NAME, NHX_KEY_PREFIX, NHX_KEY_SCIENTIFIC_NAME, NHX_KEY_SEQUENCE_ACCESSION, NHX_KEY_TAXONOMY_ID, NHX_START, NHX_VALUE_SEPARATOR_SYMBOL, PREDICATE_E_NEWICK_EDGE_TYPE, ROOTED_HOT_COMMENT, SUBTREE_END, SUBTREE_START, TERMINAL_SYMBOL, UNROOTED_HOT_COMMENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NewickFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkFormat(java.io.Reader reader, ReadWriteParameterMap parameters)` Since there is no real characteristic starting string for any Newick file, it is just checked whether at least five events (if available) can be created from the input without an exception.
    `protected JPhyloIOFormatInfo` | `createFormatInfo()`
    `JPhyloIOEventReader` | `getReader(java.io.InputStream stream, ReadWriteParameterMap parameters)` Creates a new reader instance for the target format of this factory.
    `JPhyloIOEventReader` | `getReader(java.io.Reader reader, ReadWriteParameterMap parameters)` Creates a new reader instance for the target format of this factory.
    `JPhyloIOEventWriter` | `getWriter()` Creates a new writer instance for the target format of this factory.
    `boolean` | `hasReader()` Determines whether this factory is able to create reader instances for its target format.
    `boolean` | `hasWriter()` Determines whether this factory is able to create writer instances for its target format.

    - ### Methods inherited from class info.bioinfweb.jphyloio.factory.AbstractSingleReaderWriterFactory

      `checkFormat, getFormatInfo`

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

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

    - ### Methods inherited from interface info.bioinfweb.jphyloio.factory.SingleReaderWriterFactory

      `checkFormat, getFormatInfo`

- - ### Constructor Detail

    - #### NewickFactory

          public NewickFactory()

  - ### Method Detail

    - #### checkFormat

          public boolean checkFormat(java.io.Reader reader,
                                     ReadWriteParameterMap parameters)

      Since there is no real characteristic starting string for any Newick file, it is just checked whether at least five events (if available) can be created from the input without an exception. Since this method may fail in some cases, factories should test this format after all the others have been tested unsuccessfully.
      Specified by:
        `checkFormat` in interface `SingleReaderWriterFactory`
      Parameters:
        `reader` - the reader to read the first bytes from
        `parameters` - the parameters map that would also be used to create a reader
      Returns:
        `true` if the tested reader may return content in target format or `false` if the content is not in valid target format
      See Also:
        `SingleReaderWriterFactory.checkFormat(java.io.Reader, info.bioinfweb.jphyloio.ReadWriteParameterMap)`

    - #### getReader

          public JPhyloIOEventReader getReader(java.io.InputStream stream,
                                               ReadWriteParameterMap parameters)
                                        throws java.io.IOException

      Description copied from interface: `SingleReaderWriterFactory`
      Creates a new reader instance for the target format of this factory.
      Specified by:
        `getReader` in interface `SingleReaderWriterFactory`
      Parameters:
        `stream` - the stream to provide the content for the reader
        `parameters` - the parameter map for the new reader instance
      Returns:
        the new reader instance
      Throws:
        `java.io.IOException`

    - #### getReader

          public JPhyloIOEventReader getReader(java.io.Reader reader,
                                               ReadWriteParameterMap parameters)
                                        throws java.io.IOException

      Description copied from interface: `SingleReaderWriterFactory`
      Creates a new reader instance for the target format of this factory.
      Specified by:
        `getReader` in interface `SingleReaderWriterFactory`
        `parameters` - the parameter map for the new reader instance
      Returns:
        the new reader instance or `null` if this factory is not able to create readers
      Throws:
        `java.io.IOException`
      See Also:
        `SingleReaderWriterFactory.hasReader()`

    - #### getWriter

          public JPhyloIOEventWriter getWriter()

      Description copied from interface: `SingleReaderWriterFactory`
      Creates a new writer instance for the target format of this factory.
      Specified by:
        `getWriter` in interface `SingleReaderWriterFactory`
      Returns:
        the new writer instance or `null` if this factory is not able to create writers
      See Also:
        `SingleReaderWriterFactory.hasWriter()`

    - #### hasReader

          public boolean hasReader()

      Description copied from interface: `SingleReaderWriterFactory`
      Determines whether this factory is able to create reader instances for its target format.
      Specified by:
        `hasReader` in interface `SingleReaderWriterFactory`
      Returns:
        `true` if creating readers is supported or `false` otherwise

    - #### hasWriter

          public boolean hasWriter()

      Description copied from interface: `SingleReaderWriterFactory`
      Determines whether this factory is able to create writer instances for its target format.
      Specified by:
        `hasWriter` in interface `SingleReaderWriterFactory`
      Returns:
        `true` if creating writers is supported or `false` otherwise

    - #### createFormatInfo

          protected JPhyloIOFormatInfo createFormatInfo()

      Specified by:
        `createFormatInfo` in class `AbstractSingleReaderWriterFactory`