|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.endeca.portal.util.JAXBHelper
public class JAXBHelper
Manages caching and retrieval of JAXBContext instances for specified classes. JAXBContext instances should be reused. This class keeps an in-memory cache of Class:JAXBContext instances. Also contains useful utilities for actually marshalling JAXB objects to XML strings. *
Constructor Summary | |
---|---|
JAXBHelper()
|
Method Summary | ||
---|---|---|
protected static boolean |
cacheKeyExists(java.lang.Class<?> klass)
This method exists to support unit testing. |
|
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
|
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
|
toXML(javax.xml.bind.JAXBElement<T> element)
Utility function for using the cached JAXB context to write out the object's XML representation. |
|
static
|
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
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JAXBHelper()
Method Detail |
---|
public static javax.xml.bind.JAXBContext getContext(java.lang.Class<?> klass) throws javax.xml.bind.JAXBException
klass
-
JAXBContext
for the given class
javax.xml.bind.JAXBException
public static <T> java.lang.String toXML(javax.xml.bind.JAXBElement<T> element) throws javax.xml.bind.JAXBException
element
- The element to marshal
javax.xml.bind.JAXBException
public 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 marshal
toXML(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 annotation
javax.xml.bind.JAXBException
public 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 annotation
toXML(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
-
JAXBContext
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |