Package org.apache.any23.writer

## Class WriterFactoryRegistry

- java.lang.Object
- - org.apache.any23.writer.WriterFactoryRegistry

-     public class WriterFactoryRegistry
      extends Object

  Registry class for `WriterFactory`s.
  Author:
    Michele Mostarda (mostarda@fbk.eu), Hans Brende (hansbrende@apache.org)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `WriterFactoryRegistry()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static String` | `getIdentifier​(WriterFactory writerClass)` | Reads the identifier specified for the given `WriterFactory`.
    `List<String>` | `getIdentifiers()` |
    `static WriterFactoryRegistry` | `getInstance()` |
    `static String` | `getMimeType​(WriterFactory writerClass)` | Reads the MIME Type specified for the given `WriterFactory`.
    `Collection<String>` | `getMimeTypes()` |
    `WriterFactory` | `getWriterByIdentifier​(String id)` | Returns the `WriterFactory` identified by `id`.
    `FormatWriter` | `getWriterInstanceByIdentifier​(String id, OutputStream os)` | Deprecated. since 2.3.
    `List<WriterFactory>` | `getWriters()` |
    `Collection<WriterFactory>` | `getWritersByMimeType​(String mimeType)` | Returns all the writers matching the specified `mimeType`.
    `boolean` | `hasIdentifier​(String id)` | Verifies if a `WriterFactory` with given `id` identifier has been registered.
    `void` | `register​(WriterFactory f)` | Registers a new `WriterFactory` to the registry.

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

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

- - ### Constructor Detail

    - #### WriterFactoryRegistry

          public WriterFactoryRegistry()

  - ### Method Detail

    - #### getIdentifier

          public static String getIdentifier​(WriterFactory writerClass)

      Reads the identifier specified for the given `WriterFactory`.
      Parameters:
        `writerClass` - writer class.
      Returns:
        identifier.

    - #### getMimeType

          public static String getMimeType​(WriterFactory writerClass)

      Reads the MIME Type specified for the given `WriterFactory`.
      Parameters:
        `writerClass` - writer class.
      Returns:
        MIME type.

    - #### getInstance

          public static WriterFactoryRegistry getInstance()

      Returns:
        the `WriterFactoryRegistry` singleton instance.

    - #### register

          public void register​(WriterFactory f)

      Registers a new `WriterFactory` to the registry.
      Parameters:
        `f` - the writer factory to be registered.
      Throws:
        `IllegalArgumentException` - if the id or the mimetype are null or empty strings or if the identifier has been already defined.

    - #### hasIdentifier

          public boolean hasIdentifier​(String id)

      Verifies if a `WriterFactory` with given `id` identifier has been registered.
      Parameters:
        `id` - identifier.
      Returns:
        `true` if the identifier has been registered, `false` otherwise.

    - #### getIdentifiers

          public List<String> getIdentifiers()

      Returns:
        the list of all the specified identifiers.

    - #### getMimeTypes

          public Collection<String> getMimeTypes()

      Returns:
        the list of MIME types covered by the registered `WriterFactory` instances.

    - #### getWriters

          public List<WriterFactory> getWriters()

      Returns:
        the list of all the registered `WriterFactory` instances.

    - #### getWriterByIdentifier

          public WriterFactory getWriterByIdentifier​(String id)

      Returns the `WriterFactory` identified by `id`.
      Parameters:
        `id` - the writer identifier.
      Returns:
        the `WriterFactory` matching the `id` or `null` if not found.

    - #### getWritersByMimeType

          public Collection<WriterFactory> getWritersByMimeType​(String mimeType)

      Returns all the writers matching the specified `mimeType`.
      Parameters:
        `mimeType` - a MIMEType.
      Returns:
        a list of matching writers or an empty list.

    - #### getWriterInstanceByIdentifier

          @Deprecated
          public FormatWriter getWriterInstanceByIdentifier​(String id,
                                                            OutputStream os)

      Deprecated.
      since 2.3. Use `getWriterByIdentifier(String)` in combination with `TripleWriterFactory.getTripleWriter(OutputStream, Settings)` instead.
      Returns an instance of `FormatWriter` ready to write on the given `OutputStream`.
      Parameters:
        `id` - the identifier of the `FormatWriter` to instantiate.
        `os` - the output stream.
      Returns:
        the not `null` `FormatWriter` instance.
      Throws:
        `NullPointerException` - if the `id` doesn't match any registered writer.