com.ca.commons.datamodel
Class JAXBHelper

java.lang.Object
  extended by com.ca.commons.datamodel.JAXBHelper

public class JAXBHelper
extends Object

Helper for getting correctly configured marshallers/unmarshallers.


Field Summary
static javax.xml.bind.JAXBContext dataModelJaxbContext
          The JAXB context for the data model XML bindings.
static javax.xml.bind.ValidationEventHandler detailedLocatorHandler
           
static Logger logger
           
static ObjectFactory objectFactory
           
static Schema xmlSchema
           
 
Method Summary
static javax.xml.bind.Marshaller createMarshaller()
           
static javax.xml.bind.Unmarshaller createUnmarshaller()
           
static String marshalCompact(Object jaxbObject)
          Calls JAXB marshaller with provided jaxbObject, inhibiting XML header.
static Object unmarshalCompact(String xml, String namespace)
          Calls unmarshalCompact(String, String, String) with charEncoding=UTF-8.
static Object unmarshalCompact(String xml, String charEncoding, String namespace)
          Unmarshals provided xml string, inserting provided charEncoding in XML header and xmlns= definition for namespace if they are not already present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final Logger logger

dataModelJaxbContext

public static final javax.xml.bind.JAXBContext dataModelJaxbContext
The JAXB context for the data model XML bindings. Although not required by the JAXB specification, in practice JAXBContext implementations are thread safe.


xmlSchema

public static final Schema xmlSchema

objectFactory

public static final ObjectFactory objectFactory

detailedLocatorHandler

public static final javax.xml.bind.ValidationEventHandler detailedLocatorHandler
Method Detail

createUnmarshaller

@NotNull
public static javax.xml.bind.Unmarshaller createUnmarshaller()
                                                      throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

unmarshalCompact

@NotNull
public static Object unmarshalCompact(@NotNull
                                              String xml,
                                              @NotNull
                                              String charEncoding,
                                              @NotNull
                                              String namespace)
                               throws javax.xml.bind.JAXBException
Unmarshals provided xml string, inserting provided charEncoding in XML header and xmlns= definition for namespace if they are not already present.

Parameters:
xml - String to be unmarshalled.
charEncoding - Character encoding used for xml.
namespace - Namespace forcibly written to xml if it is not alaready present.
Returns:
Objects resulting when JAXB unmarshals (possibly rewritten) xml.
Throws:
javax.xml.bind.JAXBException

unmarshalCompact

@NotNull
public static Object unmarshalCompact(@NotNull
                                              String xml,
                                              @NotNull
                                              String namespace)
                               throws javax.xml.bind.JAXBException
Calls unmarshalCompact(String, String, String) with charEncoding=UTF-8.

Throws:
javax.xml.bind.JAXBException

createMarshaller

@NotNull
public static javax.xml.bind.Marshaller createMarshaller()
                                                  throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

marshalCompact

@NotNull
public static String marshalCompact(@NotNull
                                            Object jaxbObject)
                             throws javax.xml.bind.JAXBException
Calls JAXB marshaller with provided jaxbObject, inhibiting XML header.

Throws:
javax.xml.bind.JAXBException


Created 2011-07-14 13:27 EST