info.bioinfweb.jphyloio.formatinfo

## Class DefaultFormatInfo

- java.lang.Object
- - info.bioinfweb.jphyloio.formatinfo.DefaultFormatInfo

- All Implemented Interfaces:
    JPhyloIOFormatInfo, JPhyloIOFormatSpecificObject

      public class DefaultFormatInfo
      extends java.lang.Object
      implements JPhyloIOFormatInfo

  Default implementation of `JPhyloIOFormatInfo`.
  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultFormatInfo(SingleReaderWriterFactory factory, java.lang.String formatID, java.lang.String formatName, java.util.Set<EventContentType> supportedReaderContentTypes, java.util.Set<EventContentType> supportedWriterContentTypes, java.util.Map<EventContentType,MetadataModeling> supportedReaderMetadataModeling, java.util.Map<EventContentType,MetadataModeling> supportedWriterMetadataModeling, java.util.Set<java.lang.String> supportedReaderParameters, java.util.Set<java.lang.String> supportedWriterParameters, ReadWriteParameterMap filterParameters, java.lang.String filterDescription, java.lang.String... filterExtensions)` Creates a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JPhyloIOContentExtensionFileFilter` | `createFileFilter(ContentExtensionFileFilter.TestStrategy testStrategy)` Creates a new file filter instance that is associated with the modeled format.
    `java.lang.String` | `getFormatID()` Returns a string ID uniquely identifying the target format of this instance.
    `java.lang.String` | `getFormatName()` Returns the human readable name of the modeled format.
    `MetadataModeling` | `getMetadataModeling(EventContentType parentContentType, boolean forReading)` Determines which kind of metadata the represented format allows to model nested under the specified data element Readers will not produce metaevents under an unsupported type, while writers will accept but ignore metaevents under this type.
    `java.util.Set<java.lang.String>` | `getSupportedParameters(boolean forReading)` Returns a set of the parameters supported by the associated reader or writer.
    `boolean` | `isElementModeled(EventContentType contentType, boolean forReading)` Determines whether the represented format allows to model the specified data element (content type).

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

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

- - ### Constructor Detail

    - #### DefaultFormatInfo

          public DefaultFormatInfo(SingleReaderWriterFactory factory,
                                   java.lang.String formatID,
                                   java.lang.String formatName,
                                   java.util.Set<EventContentType> supportedReaderContentTypes,
                                   java.util.Set<EventContentType> supportedWriterContentTypes,
                                   java.util.Map<EventContentType,MetadataModeling> supportedReaderMetadataModeling,
                                   java.util.Map<EventContentType,MetadataModeling> supportedWriterMetadataModeling,
                                   java.util.Set<java.lang.String> supportedReaderParameters,
                                   java.util.Set<java.lang.String> supportedWriterParameters,
                                   ReadWriteParameterMap filterParameters,
                                   java.lang.String filterDescription,
                                   java.lang.String... filterExtensions)

      Creates a new instance of this class.
      Parameters:
        `factory` - the single format factory to be used with this format
        `formatID` - the ID of the format this information object is about
        `formatName` - the name of the format this information object is about
        `supportedReaderContentTypes` - the set of content types supported by the associated reader (If `null` is specified, an empty set is assumed.)
        `supportedWriterContentTypes` - the set of content types supported by the associated writer (If `null` is specified, an empty set is assumed.)
        `supportedMetadata` - the set of content types under which any kind of metadata is supported (If `null` is specified, an empty set is assumed.)
        `supportedReaderParameters` - the set of parameters that are supported by the associated reader (If `null` is specified, an empty set is assumed.)
        `supportedWriterParameters` - the set of parameters that are supported by the associated writer (If `null` is specified, an empty set is assumed.)
        `filterParameters` - the reader parameters to be used by the file filter to test the contents of a file as they will be passed to `SingleReaderWriterFactory.checkFormat(java.io.InputStream, ReadWriteParameterMap)`
        `filterDescription` - the description of this format to be displayed e.g. in open dialogs
        `filterExtensions` - the file extension of the associated format (At least one needs to be specified.)
      Throws:
        `java.lang.NullPointerException` - if `factory`, `formatID`, `formatName`, `filterDescription` or any element of `filterExtensions` is `null`
        `java.lang.IllegalArgumentException` - if not at least one extension has been specified

  - ### Method Detail

    - #### getFormatID

          public java.lang.String getFormatID()

      Description copied from interface: `JPhyloIOFormatSpecificObject`
      Returns a string ID uniquely identifying the target format of this instance. Additional information on the format can be retrieved by passing the returned ID to `JPhyloIOReaderWriterFactory.getFormatInfo(String)`.

      Third party developers that create readers or writers for additional formats must make sure to use a globally unique format ID. It is strongly recommended to use owned reverse domain names for this (e.g. `org.example.additionalformat`).

      Specified by:
        `getFormatID` in interface `JPhyloIOFormatSpecificObject`
      Returns:
        the ID of the target format of this instance
      See Also:
        `JPhyloIOReaderWriterFactory.getFormatInfo(String)`

    - #### getFormatName

          public java.lang.String getFormatName()

      Description copied from interface: `JPhyloIOFormatInfo`
      Returns the human readable name of the modeled format.
      Specified by:
        `getFormatName` in interface `JPhyloIOFormatInfo`
      Returns:
        the name of the format

    - #### createFileFilter

          public JPhyloIOContentExtensionFileFilter createFileFilter(ContentExtensionFileFilter.TestStrategy testStrategy)

      Description copied from interface: `JPhyloIOFormatInfo`
      Creates a new file filter instance that is associated with the modeled format. It will check valid file extensions and possibly the contents of the file, if the extension is not unique.
      Specified by:
        `createFileFilter` in interface `JPhyloIOFormatInfo`
      Parameters:
        `testStrategy` - the strategy to be used to accept a file or not
      Returns:
        a new file filter instance

    - #### isElementModeled

          public boolean isElementModeled(EventContentType contentType,
                                          boolean forReading)

      Description copied from interface: `JPhyloIOFormatInfo`
      Determines whether the represented format allows to model the specified data element (content type). Readers will not produce events of an unsupported type, while writers will accept but ignore events of this type.

      Note that the values returned here indicate the capabilities of the provided readers and writers and not the capabilities of the respective format. It may happen that elements of a format are not supported by its reader and writer. In such cases `false` would be returned here for the according content type.

      Note that this method will return `true` for content types that may occur at multiple positions in the event stream (e.g. `EventContentType.LITERAL_META` or `EventContentType.SET_ELEMENT`), if they are supported at least at one position. Use `#isMetadataModeled(EventContentType)` to check at which position metadata elements are supported.

      Specified by:
        `isElementModeled` in interface `JPhyloIOFormatInfo`
      Parameters:
        `contentType` - the content type to be tested
        `forReading` - Specify `true` here, if support for `contentType` in reading this format or `false` for writing it should be returned.
      Returns:
        `true` if the specified content type is supported, `false` otherwise
      See Also:
        `#isMetadataModeled(EventContentType)`

    - #### getMetadataModeling

          public MetadataModeling getMetadataModeling(EventContentType parentContentType,
                                                      boolean forReading)

      Description copied from interface: `JPhyloIOFormatInfo`
      Determines which kind of metadata the represented format allows to model nested under the specified data element Readers will not produce metaevents under an unsupported type, while writers will accept but ignore metaevents under this type.

      Note that the values returned here indicate the capabilities of the provided readers and writers and not the capabilities of the respective format.

      Specified by:
        `getMetadataModeling` in interface `JPhyloIOFormatInfo`
        `forReading` - Specify `true` here, if support for metadata nested under `contentType` in reading this format or `false` for writing it should be returned.
      Returns:
        an object describing which metadata is supported, never `null`
      See Also:
        `#isElementModeled(EventContentType)`

    - #### getSupportedParameters

          public java.util.Set<java.lang.String> getSupportedParameters(boolean forReading)

      Description copied from interface: `JPhyloIOFormatInfo`
      Returns a set of the parameters supported by the associated reader or writer. Parameter names used by readers and writers included in JPhyloIO are defined as string constants in `ReadWriteParameterNames`. Readers and writers from third party developers may introduce additional parameter names defined elsewhere.
      Specified by:
        `getSupportedParameters` in interface `JPhyloIOFormatInfo`
      Parameters:
        `forReading` - Specify `true` here, if support for `parameterName` in reading this format or `false` for writing it should be returned.
      Returns:
        an unmodifiable set of supported parameters