public class JAXBHelper
extends java.lang.Object
| Constructor and Description |
|---|
JAXBHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
cacheKeyExists(java.lang.Class<?> klass)
This method exists to support unit testing.
|
static <T> T |
fromXML(java.lang.Class<T> klass,
java.lang.String xml)
Utility function for using the cached JAXB context to read in out an object's XML representation.
|
protected static javax.xml.bind.JAXBContext |
getCachedValue(java.lang.Class<?> klass)
This method exists to support unit testing.
|
protected static int |
getCacheSize()
This method exists to support unit testing.
|
static javax.xml.bind.JAXBContext |
getContext(java.lang.Class<?> klass)
Retrieves the JAXBContext instance for the specified class.
|
protected static javax.xml.bind.JAXBContext |
removeCachedValue(java.lang.Class<?> klass)
This method exists to support unit testing.
|
static <T> java.lang.String |
toXML(java.lang.Class<T> klass,
T objWithXmlRoot)
Utility function for using the cached JAXB context to write out the object's XML representation.
|
static <T> java.lang.String |
toXML(javax.xml.bind.JAXBElement<T> element)
Utility function for using the cached JAXB context to write out the object's XML representation.
|
static <T> java.lang.String |
TryToXML(java.lang.Class<T> klass,
T objWithXmlRoot,
java.lang.String error)
Utility function for using the cached JAXB context to write out the object's XML representation.
|
static <T> java.lang.String |
TryToXML(javax.xml.bind.JAXBElement<T> element,
java.lang.String error)
Utility function for using the cached JAXB context to write out the object's XML.
|
public static javax.xml.bind.JAXBContext getContext(java.lang.Class<?> klass)
throws javax.xml.bind.JAXBException
klass - JAXBContext for the given classjavax.xml.bind.JAXBExceptionpublic static <T> java.lang.String toXML(javax.xml.bind.JAXBElement<T> element)
throws javax.xml.bind.JAXBException
element - The element to marshaljavax.xml.bind.JAXBExceptionpublic static <T> java.lang.String TryToXML(javax.xml.bind.JAXBElement<T> element,
java.lang.String error)
element - The element to marshalerror - An error string to return if unable to marshaltoXML(JAXBElement)public static <T> java.lang.String toXML(java.lang.Class<T> klass,
T objWithXmlRoot)
throws javax.xml.bind.JAXBException
klass - the type of the object passed. Separate parameter for cleaner null handling.objWithXmlRoot - object that is an instance of a class with XmlRootElement annotationjavax.xml.bind.JAXBExceptionpublic static <T> T fromXML(java.lang.Class<T> klass,
java.lang.String xml)
throws javax.xml.bind.JAXBException
klass - the type of the object to deserialize.xml - XML Stringjavax.xml.bind.JAXBExceptionpublic static <T> java.lang.String TryToXML(java.lang.Class<T> klass,
T objWithXmlRoot,
java.lang.String error)
klass - the type of the object passed. Separate parameter for cleaner null handling.objWithXmlRoot - object that is an instance of a class with XmlRootElement annotationtoXML(Class, Object)protected static int getCacheSize()
protected static javax.xml.bind.JAXBContext removeCachedValue(java.lang.Class<?> klass)
klass - protected static boolean cacheKeyExists(java.lang.Class<?> klass)
getContext(Class) directly, which will always return a context.klass - protected static javax.xml.bind.JAXBContext getCachedValue(java.lang.Class<?> klass)
getContext(Class) directly, which will always return a context.klass - JAXBContextCopyright 2003, 2014, Oracle and/or its affiliates. All rights reserved.