Class SaxEventToXmlElementConverter
java.lang.Object
org.codice.ddf.transformer.xml.streaming.lib.SaxEventToXmlElementConverter
A library class used to turn SAX events back into their corresponding XML snippets
Not threadsafe
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNamespace(String prefix, String uri) Method used in aSaxEventHandler#startElement(String, String, String, Attributes)to populate theSaxEventToXmlElementConverter#namespaceMapping, which allows namespaceURI/prefix lookup.voidremoveNamespace(String prefix) reset()Resets all stateful variables of theSaxEventToXmlElementConverterShould be used before expecting a fresh XML snippet Can be used instead of declaring a new onetoElement(char[] ch, int start, int length) Method used to reconstruct the characters/value of an XML element.Method used to reconstruct the end tag of an XML element.toElement(String uri, String localName, Attributes atts) Used to reconstruct the start tag of an XML element.toString()Overridden toString method to return the XML snippet that has been reconstructed
-
Constructor Details
-
SaxEventToXmlElementConverter
-
-
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 bySaxEventHandlerlocalName- the localName that is passed in bySaxEventHandleratts- the attributes that are passed in bySaxEventHandler- 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 bySaxEventHandlerlocalName- the localName that is passed in bySaxEventHandler- 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 bySaxEventHandlerstart- the start that is passed in bySaxEventHandlerlength- the length that is passed in bySaxEventHandler- Returns:
- this
- Throws:
XMLStreamException
-
toString
Overridden toString method to return the XML snippet that has been reconstructed -
reset
Resets all stateful variables of theSaxEventToXmlElementConverterShould be used before expecting a fresh XML snippet Can be used instead of declaring a new one- Returns:
- this
-
addNamespace
Method used in aSaxEventHandler#startElement(String, String, String, Attributes)to populate theSaxEventToXmlElementConverter#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 bySaxEventHandleruri- the namespace uri that is passed in bySaxEventHandler- Throws:
XMLStreamException
-
removeNamespace
-