Package org.opennms.core.xml
Class JaxbUtils
- java.lang.Object
-
- org.opennms.core.xml.JaxbUtils
-
public abstract class JaxbUtils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JaxbUtils.LoggingValidationEventHandler
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
duplicateObject(T obj, java.lang.Class<T> clazz)
static java.lang.Class<?>
getClassForElement(java.lang.String elementName)
static javax.xml.bind.JAXBContext
getContextFor(java.lang.Class<?> clazz)
static javax.xml.bind.Marshaller
getMarshallerFor(java.lang.Object obj, javax.xml.bind.JAXBContext jaxbContext)
static <T> java.lang.String
getNamespaceForClass(java.lang.Class<T> clazz)
static <T> java.util.List<java.lang.String>
getNamespacesForClass(java.lang.Class<T> clazz)
static javax.xml.bind.Unmarshaller
getUnmarshallerFor(java.lang.Object obj, javax.xml.bind.JAXBContext jaxbContext, boolean validate)
Get a JAXB unmarshaller for the given object.static <T> org.xml.sax.XMLFilter
getXMLFilterForClass(java.lang.Class<T> clazz)
static java.lang.String
marshal(java.lang.Object obj)
static void
marshal(java.lang.Object obj, java.io.File file)
static void
marshal(java.lang.Object obj, java.io.Writer writer)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.File file)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.File file, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.InputStream stream)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.InputStream stream, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.Reader reader)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.io.Reader reader, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.lang.String xml)
static <T> T
unmarshal(java.lang.Class<T> clazz, java.lang.String xml, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.springframework.core.io.Resource resource)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.springframework.core.io.Resource resource, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, boolean validate)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, javax.xml.bind.JAXBContext jaxbContext)
static <T> T
unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, javax.xml.bind.JAXBContext jaxbContext, boolean validate)
-
-
-
Method Detail
-
marshal
public static java.lang.String marshal(java.lang.Object obj)
-
marshal
public static void marshal(java.lang.Object obj, java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
getClassForElement
public static java.lang.Class<?> getClassForElement(java.lang.String elementName)
-
getNamespacesForClass
public static <T> java.util.List<java.lang.String> getNamespacesForClass(java.lang.Class<T> clazz)
-
marshal
public static void marshal(java.lang.Object obj, java.io.Writer writer)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.File file)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.File file, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.Reader reader)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.Reader reader, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.InputStream stream)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.io.InputStream stream, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.lang.String xml)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, java.lang.String xml, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.springframework.core.io.Resource resource)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.springframework.core.io.Resource resource, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, boolean validate)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, javax.xml.bind.JAXBContext jaxbContext)
-
unmarshal
public static <T> T unmarshal(java.lang.Class<T> clazz, org.xml.sax.InputSource inputSource, javax.xml.bind.JAXBContext jaxbContext, boolean validate)
-
getNamespaceForClass
public static <T> java.lang.String getNamespaceForClass(java.lang.Class<T> clazz)
-
getXMLFilterForClass
public static <T> org.xml.sax.XMLFilter getXMLFilterForClass(java.lang.Class<T> clazz) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
getMarshallerFor
public static javax.xml.bind.Marshaller getMarshallerFor(java.lang.Object obj, javax.xml.bind.JAXBContext jaxbContext)
-
getUnmarshallerFor
public static javax.xml.bind.Unmarshaller getUnmarshallerFor(java.lang.Object obj, javax.xml.bind.JAXBContext jaxbContext, boolean validate)
Get a JAXB unmarshaller for the given object. If no JAXBContext is provided, JAXBUtils will create and cache a context for the given object.- Parameters:
obj
- The object type to be unmarshalled.jaxbContext
- An optional JAXB context to create the unmarshaller from.validate
- TODO- Returns:
- an Unmarshaller
-
getContextFor
public static javax.xml.bind.JAXBContext getContextFor(java.lang.Class<?> clazz) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
duplicateObject
public static <T> T duplicateObject(T obj, java.lang.Class<T> clazz)
-
-