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 classJaxbUtils.LoggingValidationEventHandler
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TduplicateObject(T obj, Class<T> clazz)static Class<?>getClassForElement(String elementName)static JAXBContextgetContextFor(Class<?> clazz)static MarshallergetMarshallerFor(Object obj, JAXBContext jaxbContext)static <T> StringgetNamespaceForClass(Class<T> clazz)static <T> List<String>getNamespacesForClass(Class<T> clazz)static UnmarshallergetUnmarshallerFor(Object obj, JAXBContext jaxbContext, boolean validate)Get a JAXB unmarshaller for the given object.static <T> XMLFiltergetXMLFilterForClass(Class<T> clazz)static Stringmarshal(Object obj)static voidmarshal(Object obj, File file)static voidmarshal(Object obj, Writer writer)static <T> Tunmarshal(Class<T> clazz, File file)static <T> Tunmarshal(Class<T> clazz, File file, boolean validate)static <T> Tunmarshal(Class<T> clazz, InputStream stream)static <T> Tunmarshal(Class<T> clazz, InputStream stream, boolean validate)static <T> Tunmarshal(Class<T> clazz, Reader reader)static <T> Tunmarshal(Class<T> clazz, Reader reader, boolean validate)static <T> Tunmarshal(Class<T> clazz, String xml)static <T> Tunmarshal(Class<T> clazz, String xml, boolean validate)static <T> Tunmarshal(Class<T> clazz, org.springframework.core.io.Resource resource)static <T> Tunmarshal(Class<T> clazz, org.springframework.core.io.Resource resource, boolean validate)static <T> Tunmarshal(Class<T> clazz, InputSource inputSource)static <T> Tunmarshal(Class<T> clazz, InputSource inputSource, boolean validate)static <T> Tunmarshal(Class<T> clazz, InputSource inputSource, JAXBContext jaxbContext)static <T> Tunmarshal(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)
-
-