au.gov.nehta.vendorlibrary.common
Class JAXBUtil

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

public final class JAXBUtil
extends java.lang.Object

JAXBUtil implementation for JAXB object marshal and unmarshal.


Method Summary
static
<T> java.lang.String
marshaller(java.lang.Class instanceClass, java.lang.String qName, java.lang.String className, T object)
          Marshall the provided object and return the XML content of the object.
static
<T> java.lang.String
marshaller(java.lang.Class instanceClass, java.lang.String className, T object)
          Marshalls the provided JAXWS object to String[XML String].
static
<T> T
unmarshaller(java.lang.Class parameterObject, org.w3c.dom.Document doc)
          Gets the JAXB/JAXWS instance for the provided XML data and jaxws class object.
static
<T> T
unmarshaller(java.lang.Class parameterObject, java.lang.String xmlSource)
          Gets the JAXB/JAXWS instance for the provided XML data and jaxws class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

marshaller

public static <T> java.lang.String marshaller(java.lang.Class instanceClass,
                                              java.lang.String qName,
                                              java.lang.String className,
                                              T object)
                                   throws javax.xml.bind.JAXBException
Marshall the provided object and return the XML content of the object.

Type Parameters:
T - instance value of T
Parameters:
instanceClass - The class instance of the object to be marshalled (Mandatory).
qName - the namespace URI of the object to be marshalled.

If the Namespace URI is null, it is set to XMLConstants.NULL_NS_URI. This value represents no explicitly defined Namespace as defined by the Namespaces in XML specification. This action preserves compatible behaviour with QName 1.0. Explicitly providing the XMLConstants.NULL_NS_URI value is the preferred coding style
className - the Class name of the object to be marshalled (Mandatory).
object - the instance to be marshalled (Mandatory).
IllegalArgumentException will be thrown if the object is null
Returns:
XML source of the marshalled object.
Throws:
javax.xml.bind.JAXBException - in an event of error.

marshaller

public static <T> java.lang.String marshaller(java.lang.Class instanceClass,
                                              java.lang.String className,
                                              T object)
                                   throws javax.xml.bind.JAXBException
Marshalls the provided JAXWS object to String[XML String].

Type Parameters:
T -
T - instance value of T
Parameters:
instanceClass - of type Class
className - of the object to be marshalled
object - the instance to be marshalled (Mandatory).
IllegalArgumentException will be thrown if the object is null
Returns:
Serialized value of T. Else returns null.
Throws:
javax.xml.bind.JAXBException - in an event of error.

unmarshaller

public static <T> T unmarshaller(java.lang.Class parameterObject,
                                 java.lang.String xmlSource)
                      throws javax.xml.bind.JAXBException
Gets the JAXB/JAXWS instance for the provided XML data and jaxws class.

Type Parameters:
T - JAXWS generic type for unmarshalling xml data.
Parameters:
parameterObject - of type Class
xmlSource - of type String
Returns:
of type parameterObject
Throws:
javax.xml.bind.JAXBException - in an event of error.

unmarshaller

public static <T> T unmarshaller(java.lang.Class parameterObject,
                                 org.w3c.dom.Document doc)
                      throws javax.xml.bind.JAXBException
Gets the JAXB/JAXWS instance for the provided XML data and jaxws class object.

Type Parameters:
T - jaxws generic type for un-marshalling xml data.
Parameters:
parameterObject - of type Class
doc - // * @param xmlSource of type String
Returns:
of type parameterObject Note: throws IllegalArgumentExceptuion if either of the arguments are null.
Throws:
javax.xml.bind.JAXBException - in an event of error.