au.gov.nehta.vendorlibrary.common
Class DOMUtil

java.lang.Object
  extended by au.gov.nehta.vendorlibrary.common.DOMUtil

public final class DOMUtil
extends java.lang.Object

DOMUtil provides utility classes for converting a XML document to DOM instance and vice versa.


Method Summary
static
<T> org.w3c.dom.Element
getDocumentElementFromInstance(java.lang.Class instanceClass, java.lang.String qName, java.lang.String className, T object)
          Obtains the Element instance for the provided AJX instance.
static org.w3c.dom.Element getDocumentElementFromXML(java.lang.String xmlSource)
          Returns the provided XML source as Element.
static
<T> org.w3c.dom.Document
getDocumentFromInstance(java.lang.Class instanceClass, java.lang.String qName, java.lang.String className, T object)
          Obtains the Document instance for the provided AJX instance.
static org.w3c.dom.Document getDocumentFromXML(java.lang.String xmlSource)
          Returns the provided XML source as Document.
static java.lang.String serialiseToString(org.w3c.dom.Document xmlDoc)
          Converts the provided Document into a XML data string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocumentElementFromXML

public static org.w3c.dom.Element getDocumentElementFromXML(java.lang.String xmlSource)
Returns the provided XML source as Element.

Parameters:
xmlSource - the XML document source as String
Returns:
Element instance for the provided XML Source

getDocumentFromXML

public static org.w3c.dom.Document getDocumentFromXML(java.lang.String xmlSource)
Returns the provided XML source as Document.

Parameters:
xmlSource - the XML document source as String
Returns:
Document instance for the provided XML Source

getDocumentElementFromInstance

public static <T> org.w3c.dom.Element getDocumentElementFromInstance(java.lang.Class instanceClass,
                                                                     java.lang.String qName,
                                                                     java.lang.String className,
                                                                     T object)
                                                          throws javax.xml.bind.JAXBException
Obtains the Element instance for the provided AJX instance.

Type Parameters:
T - the JAXB generic type for marshalling
Parameters:
instanceClass - the JAXB object class
qName - of the element element
className - local classname for the JAXB object [Non- fully qualified class name]
object - the JAXB instance to be marshalled to Element
Returns:
Document instance for the marshalled JAXB instance
Throws:
javax.xml.bind.JAXBException - in an event of error.

getDocumentFromInstance

public static <T> org.w3c.dom.Document getDocumentFromInstance(java.lang.Class instanceClass,
                                                               java.lang.String qName,
                                                               java.lang.String className,
                                                               T object)
                                                    throws javax.xml.bind.JAXBException
Obtains the Document instance for the provided AJX instance.

Type Parameters:
T - the JAXB generic type for marshalling
Parameters:
instanceClass - the JAXB object class
qName - of the element element
className - local classname for the JAXB object [Non- fully qualified class name]
object - the JAXB instance to be marshalled to Document
Returns:
Document instance for the marshalled JAXB instance
Throws:
javax.xml.bind.JAXBException - in an event of error.

serialiseToString

public static java.lang.String serialiseToString(org.w3c.dom.Document xmlDoc)
                                          throws javax.xml.transform.TransformerException,
                                                 java.io.IOException
Converts the provided Document into a XML data string.

Parameters:
xmlDoc - the document object
Returns:
XML data as String
Throws:
{@link - TransformerException}, IOException in an event of error.
javax.xml.transform.TransformerException
java.io.IOException