info.bioinfweb.jphyloio.formats.xml

## Class XMLReadWriteUtils

- java.lang.Object
- - info.bioinfweb.jphyloio.formats.xml.XMLReadWriteUtils

-     public class XMLReadWriteUtils
      extends java.lang.Object

  Provides commonly used tool methods and constants used for XML reader and writer classes.
  Since:
    0.0.0
  Author:
    Sarah Wiechers

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_NAMESPACE_PREFIX`
    `static java.lang.String` | `NAMESPACE_RDF`
    `static java.lang.String` | `RDF_DEFAULT_PRE`
    `static java.lang.String` | `SCHEMA_LOCATION`
    `static java.lang.String` | `XSD_DEFAULT_PRE`
    `static java.lang.String` | `XSI_DEFAULT_PRE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLReadWriteUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `getDefaultNamespacePrefix(javax.xml.stream.XMLStreamWriter writer, java.lang.String givenPrefix, java.lang.String namespaceURI)` This method returns a predefined default prefix for a number of namespaces or, if the given namespace does not have a predefined prefix and the given prefix was `null`, `DEFAULT_NAMESPACE_PREFIX`.
    `static java.lang.String` | `getXSDPrefix(javax.xml.stream.XMLStreamWriter writer)`
    `static java.lang.String` | `getXSIPrefix(javax.xml.stream.XMLStreamWriter writer)`
    `static void` | `manageLiteralContentMetaNamespaces(XMLWriterStreamDataProvider streamDataProvider, ReadWriteParameterMap parameters, LiteralMetadataContentEvent event)` This method manages namespaces used or declared in any custom XML events depending on the parameter `ReadWriteParameterNames.KEY_CUSTOM_XML_NAMESPACE_HANDLING`.
    `static void` | `writeCustomXML(javax.xml.stream.XMLStreamWriter writer, ReadWriteParameterMap parameters, javax.xml.stream.events.XMLEvent event)`

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

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

- - ### Field Detail

    - #### XSI_DEFAULT_PRE

          public static final java.lang.String XSI_DEFAULT_PRE

      See Also:
        Constant Field Values

    - #### XSD_DEFAULT_PRE

          public static final java.lang.String XSD_DEFAULT_PRE

      See Also:
        Constant Field Values

    - #### RDF_DEFAULT_PRE

          public static final java.lang.String RDF_DEFAULT_PRE

      See Also:
        Constant Field Values

    - #### SCHEMA_LOCATION

          public static final java.lang.String SCHEMA_LOCATION

      See Also:
        Constant Field Values

    - #### NAMESPACE_RDF

          public static final java.lang.String NAMESPACE_RDF

      See Also:
        Constant Field Values

    - #### DEFAULT_NAMESPACE_PREFIX

          public static final java.lang.String DEFAULT_NAMESPACE_PREFIX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XMLReadWriteUtils

          public XMLReadWriteUtils()

  - ### Method Detail

    - #### getXSIPrefix

          public static java.lang.String getXSIPrefix(javax.xml.stream.XMLStreamWriter writer)
                                               throws javax.xml.stream.XMLStreamException

      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### getXSDPrefix

          public static java.lang.String getXSDPrefix(javax.xml.stream.XMLStreamWriter writer)
                                               throws javax.xml.stream.XMLStreamException

      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### getDefaultNamespacePrefix

          public static java.lang.String getDefaultNamespacePrefix(javax.xml.stream.XMLStreamWriter writer,
                                                                   java.lang.String givenPrefix,
                                                                   java.lang.String namespaceURI)
                                                            throws javax.xml.stream.XMLStreamException

      This method returns a predefined default prefix for a number of namespaces or, if the given namespace does not have a predefined prefix and the given prefix was `null`, `DEFAULT_NAMESPACE_PREFIX`.
      Parameters:
        `writer` - the currently used `XMLStreamWriter`
        `givenPrefix` - the prefix that shall be bound to a namespace
        `namespaceURI` - the namespace a prefix shall be bound to
      Returns:
        either the given prefix or a default prefix
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeCustomXML

          public static void writeCustomXML(javax.xml.stream.XMLStreamWriter writer,
                                            ReadWriteParameterMap parameters,
                                            javax.xml.stream.events.XMLEvent event)
                                     throws javax.xml.stream.XMLStreamException

      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### manageLiteralContentMetaNamespaces

          public static void manageLiteralContentMetaNamespaces(XMLWriterStreamDataProvider streamDataProvider,
                                                                ReadWriteParameterMap parameters,
                                                                LiteralMetadataContentEvent event)
                                                         throws javax.xml.stream.XMLStreamException

      This method manages namespaces used or declared in any custom XML events depending on the parameter `ReadWriteParameterNames.KEY_CUSTOM_XML_NAMESPACE_HANDLING`. In case this parameter is set to `false` or not set at all application developers need to make sure that all prefixes used in the custom XML are properly declared within the custom XML. In case it is set to `true` it is possible that the prefix a namespace is bound to is altered. In both cases default namespace declarations are written to the according custom XML elements, therefore these are never managed here.

      Namespaces used in object values of type `QName` are always managed.

      Parameters:
        `streamDataProvider` - the StreamDataProvider used by the current writer
        `event` - the LiteralMetadataContentEvent containing some content
      Throws:
        `javax.xml.stream.XMLStreamException` - if the underlying writer encounters an exception while writing