info.bioinfweb.jphyloio.formats.xml.stax

## Class MetaXMLEventWriter

- java.lang.Object
- - info.bioinfweb.jphyloio.formats.xml.stax.AbstractMetaXMLWriter
  - - info.bioinfweb.jphyloio.formats.xml.stax.MetaXMLEventWriter

- All Implemented Interfaces:
    javax.xml.stream.util.XMLEventConsumer, javax.xml.stream.XMLEventWriter

      public class MetaXMLEventWriter
      extends AbstractMetaXMLWriter
      implements javax.xml.stream.XMLEventWriter

  This writer can be used by applications already implementing iterator-based StAX-writing of metadata as an adapter to a `JPhyloIOEventWriter`. Instances of this class should not (and cannot) be created directly in application code, but `JPhyloIOXMLEventWriter.createMetaXMLEventWriter(JPhyloIOEventReceiver)` should be used instead.

  Attributes of a start document event are not processed, since it is not possible to write them at this position of the document.

  This writer does not have the necessary information (e.g. predicate) to be able to write literal meta start and end events, therefore this has to be done by the application itself.

  This writer does not manage namespaces of custom XML elements. The application needs to ensure that all used prefixes (either in any elements, attributes or character data) are properly declared within the custom XML (e.g. by adding `Namespace` events). Any methods of this writer changing the namespace mapping or obtaining information about it refer to the underlying writer. Note that if the default namespace is changed (either by setting a new default namespace or a completely new namespace context object) while this reader is on the top level of custom XML, it is possible that the literal meta end tag is written with the wrong default namespace (it would be written with a prefix then).

  Author:
    Sarah Wiechers, Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaXMLEventWriter(JPhyloIOEventReceiver receiver, javax.xml.stream.XMLStreamWriter underlyingXMLWriter)` Creates a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(javax.xml.stream.events.XMLEvent event)`
    `void` | `add(javax.xml.stream.XMLEventReader xmlReader)`
    `void` | `close()` This method has no effect in this writer.
    `void` | `flush()` This method has no effect in this writer, since the underlying `JPhyloIOEventWriter` does not implement a flush() method.
    `javax.xml.namespace.NamespaceContext` | `getNamespaceContext()` Returns the current namespace context of the underlying XML event writer, if
    `java.lang.String` | `getPrefix(java.lang.String uri)`
    `void` | `setDefaultNamespace(java.lang.String uri)`
    `void` | `setNamespaceContext(javax.xml.namespace.NamespaceContext context)`
    `void` | `setPrefix(java.lang.String prefix, java.lang.String uri)`

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.xml.stax.AbstractMetaXMLWriter

      `getReceiver, getUnderlyingXMLWriter`

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

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

- - ### Constructor Detail

    - #### MetaXMLEventWriter

          public MetaXMLEventWriter(JPhyloIOEventReceiver receiver,
                                    javax.xml.stream.XMLStreamWriter underlyingXMLWriter)

      Creates a new instance of this class.
      Parameters:
        `receiver` - the event receiver to write the JPhyloIO events created by this writer to

  - ### Method Detail

    - #### add

          public void add(javax.xml.stream.events.XMLEvent event)
                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `add` in interface `javax.xml.stream.util.XMLEventConsumer`
      Specified by:
        `add` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### add

          public void add(javax.xml.stream.XMLEventReader xmlReader)
                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `add` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### close

          public void close()
                     throws javax.xml.stream.XMLStreamException

      This method has no effect in this writer. Freeing resources of this writer is not necessary, since it just delegates to another writer.
      Specified by:
        `close` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### flush

          public void flush()
                     throws javax.xml.stream.XMLStreamException

      This method has no effect in this writer, since the underlying `JPhyloIOEventWriter` does not implement a flush() method.
      Specified by:
        `flush` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### getNamespaceContext

          public javax.xml.namespace.NamespaceContext getNamespaceContext()

      Returns the current namespace context of the underlying XML event writer, if
      Specified by:
        `getNamespaceContext` in interface `javax.xml.stream.XMLEventWriter`
      See Also:
        `XMLEventWriter.getNamespaceContext()`

    - #### getPrefix

          public java.lang.String getPrefix(java.lang.String uri)
                                     throws javax.xml.stream.XMLStreamException

      Specified by:
        `getPrefix` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setDefaultNamespace

          public void setDefaultNamespace(java.lang.String uri)
                                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `setDefaultNamespace` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setNamespaceContext

          public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
                                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `setNamespaceContext` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setPrefix

          public void setPrefix(java.lang.String prefix,
                                java.lang.String uri)
                         throws javax.xml.stream.XMLStreamException

      Specified by:
        `setPrefix` in interface `javax.xml.stream.XMLEventWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`