info.bioinfweb.jphyloio.factory

## Interface SingleReaderWriterFactory

- All Known Implementing Classes:
    AbstractPhylipFactory, AbstractSingleReaderWriterFactory, AbstractStartStringSingleFactory, AbstractXMLFactory, FASTAFactory, MEGAFactory, NewickFactory, NeXMLFactory, NexusFactory, PDEFactory, PhylipFactory, PhyloXMLFactory, SequentialPhylipFactory, XTGFactory

      public interface SingleReaderWriterFactory

  Implementations of this interface are used internally by `JPhyloIOReaderWriterFactory` to create reader and writer instances of a specific format. There must be one implementation if this interface for each format provided to `JPhyloIOReaderWriterFactory`.

  Application or third party library developers who wish to add readers or writers for additional formats to `JPhyloIOReaderWriterFactory`, should provide an according implementation of this interface which may than be regisgered using `JPhyloIOReaderWriterFactory.addFactory(SingleReaderWriterFactory)`.

  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkFormat(java.io.InputStream stream, ReadWriteParameterMap parameters)` Implementations should read the start of the stream here and determine whether the content could be valid according to the target format.
    `boolean` | `checkFormat(java.io.Reader reader, ReadWriteParameterMap parameters)` Implementations should read the start of the characters returned by the reader here and determine whether the content could be valid according to the target format.
    `JPhyloIOFormatInfo` | `getFormatInfo()` Returns an information objects describing the target format and providing according file filters.
    `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.

- - ### Method Detail

    - #### checkFormat

          boolean checkFormat(java.io.InputStream stream,
                              ReadWriteParameterMap parameters)
                       throws java.lang.Exception

      Implementations should read the start of the stream here and determine whether the content could be valid according to the target format.
      Parameters:
        `stream` - the stream to read the first bytes from
        `parameters` - the parameters map that would also be used to create a reader
      Returns:
        `true` if the tested stream may be in the target format or `false` if the stream is not in valid target format
      Throws:
        `java.lang.Exception`

    - #### checkFormat

          boolean checkFormat(java.io.Reader reader,
                              ReadWriteParameterMap parameters)
                       throws java.lang.Exception

      Implementations should read the start of the characters returned by the reader here and determine whether the content could be valid according to the target format.
      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
      Throws:
        `java.lang.Exception`

    - #### getReader

          JPhyloIOEventReader getReader(java.io.InputStream stream,
                                        ReadWriteParameterMap parameters)
                                 throws java.lang.Exception

      Creates a new reader instance for the target format of this factory.
      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.lang.Exception`

    - #### getReader

          JPhyloIOEventReader getReader(java.io.Reader reader,
                                        ReadWriteParameterMap parameters)
                                 throws java.lang.Exception

      Creates a new reader instance for the target format of this factory.
      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 or `null` if this factory is not able to create readers
      Throws:
        `java.lang.Exception`
      See Also:
        `hasReader()`

    - #### getWriter

          JPhyloIOEventWriter getWriter()

      Creates a new writer instance for the target format of this factory.
      Returns:
        the new writer instance or `null` if this factory is not able to create writers
      See Also:
        `hasWriter()`

    - #### getFormatInfo

          JPhyloIOFormatInfo getFormatInfo()

      Returns an information objects describing the target format and providing according file filters.
      Returns:
        the format information object

    - #### hasReader

          boolean hasReader()

      Determines whether this factory is able to create reader instances for its target format.
      Returns:
        `true` if creating readers is supported or `false` otherwise

    - #### hasWriter

          boolean hasWriter()

      Determines whether this factory is able to create writer instances for its target format.
      Returns:
        `true` if creating writers is supported or `false` otherwise