Class SaxEventToXmlElementConverter

java.lang.Object
org.codice.ddf.transformer.xml.streaming.lib.SaxEventToXmlElementConverter

public class SaxEventToXmlElementConverter extends Object
A library class used to turn SAX events back into their corresponding XML snippets

Not threadsafe

  • Constructor Details

  • Method Details

    • toElement

      public SaxEventToXmlElementConverter toElement(String uri, String localName, Attributes atts) throws XMLStreamException
      Used to reconstruct the start tag of an XML element.
      Parameters:
      uri - the URI that is passed in by
      invalid reference
      SaxEventHandler
      localName - the localName that is passed in by
      invalid reference
      SaxEventHandler
      atts - the attributes that are passed in by
      invalid reference
      SaxEventHandler
      Returns:
      this
      Throws:
      XMLStreamException
    • toElement

      public SaxEventToXmlElementConverter toElement(String uri, String localName) throws XMLStreamException
      Method used to reconstruct the end tag of an XML element.
      Parameters:
      uri - the namespaceURI that is passed in by
      invalid reference
      SaxEventHandler
      localName - the localName that is passed in by
      invalid reference
      SaxEventHandler
      Returns:
      this
      Throws:
      XMLStreamException
    • toElement

      public SaxEventToXmlElementConverter toElement(char[] ch, int start, int length) throws XMLStreamException
      Method used to reconstruct the characters/value of an XML element.
      Parameters:
      ch - the ch that is passed in by
      invalid reference
      SaxEventHandler
      start - the start that is passed in by
      invalid reference
      SaxEventHandler
      length - the length that is passed in by
      invalid reference
      SaxEventHandler
      Returns:
      this
      Throws:
      XMLStreamException
    • toString

      public String toString()
      Overridden toString method to return the XML snippet that has been reconstructed
      Overrides:
      toString in class Object
      Returns:
      the reconstructed XML snippet
    • reset

      Resets all stateful variables of the SaxEventToXmlElementConverter Should be used before expecting a fresh XML snippet Can be used instead of declaring a new one
      Returns:
      this
    • addNamespace

      public void addNamespace(String prefix, String uri) throws XMLStreamException
      Method used in a
      invalid reference
      SaxEventHandler#startElement(String, String, String, Attributes)
      to populate the
      invalid reference
      SaxEventToXmlElementConverter#namespaceMapping
      , which allows namespaceURI/prefix lookup. (Could potentially be used elsewhere, but one would have to ensure correct use)
      Parameters:
      prefix - the namespace prefix that is passed in by
      invalid reference
      SaxEventHandler
      uri - the namespace uri that is passed in by
      invalid reference
      SaxEventHandler
      Throws:
      XMLStreamException
    • removeNamespace

      public void removeNamespace(String prefix)