Package org.opennms.core.xml
Class JaxbUtils
- java.lang.Object
-
- org.opennms.core.xml.JaxbUtils
-
public abstract class JaxbUtils extends 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, Class<T> clazz)
static Class<?>
getClassForElement(String elementName)
static JAXBContext
getContextFor(Class<?> clazz)
static Marshaller
getMarshallerFor(Object obj, JAXBContext jaxbContext)
static <T> String
getNamespaceForClass(Class<T> clazz)
static <T> List<String>
getNamespacesForClass(Class<T> clazz)
static Unmarshaller
getUnmarshallerFor(Object obj, JAXBContext jaxbContext, boolean validate)
Get a JAXB unmarshaller for the given object.static <T> XMLFilter
getXMLFilterForClass(Class<T> clazz)
static String
marshal(Object obj)
static void
marshal(Object obj, File file)
static void
marshal(Object obj, Writer writer)
static <T> T
unmarshal(Class<T> clazz, File file)
static <T> T
unmarshal(Class<T> clazz, File file, boolean validate)
static <T> T
unmarshal(Class<T> clazz, InputStream stream)
static <T> T
unmarshal(Class<T> clazz, InputStream stream, boolean validate)
static <T> T
unmarshal(Class<T> clazz, Reader reader)
static <T> T
unmarshal(Class<T> clazz, Reader reader, boolean validate)
static <T> T
unmarshal(Class<T> clazz, String xml)
static <T> T
unmarshal(Class<T> clazz, String xml, boolean validate)
static <T> T
unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource)
static <T> T
unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource, boolean validate)
static <T> T
unmarshal(Class<T> clazz, InputSource inputSource)
static <T> T
unmarshal(Class<T> clazz, InputSource inputSource, boolean validate)
static <T> T
unmarshal(Class<T> clazz, InputSource inputSource, JAXBContext jaxbContext)
static <T> T
unmarshal(Class<T> clazz, InputSource inputSource, JAXBContext jaxbContext, boolean validate)
-
-
-
Method Detail
-
marshal
public static void marshal(Object obj, File file) throws IOException
- Throws:
IOException
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputStream stream)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputStream stream, boolean validate)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource, boolean validate)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputSource inputSource)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputSource inputSource, boolean validate)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputSource inputSource, JAXBContext jaxbContext)
-
unmarshal
public static <T> T unmarshal(Class<T> clazz, InputSource inputSource, JAXBContext jaxbContext, boolean validate)
-
getXMLFilterForClass
public static <T> XMLFilter getXMLFilterForClass(Class<T> clazz) throws SAXException
- Throws:
SAXException
-
getMarshallerFor
public static Marshaller getMarshallerFor(Object obj, JAXBContext jaxbContext)
-
getUnmarshallerFor
public static Unmarshaller getUnmarshallerFor(Object obj, 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 JAXBContext getContextFor(Class<?> clazz) throws JAXBException
- Throws:
JAXBException
-
duplicateObject
public static <T> T duplicateObject(T obj, Class<T> clazz)
-
-