public class JAXBUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
deleteStateFile(File file)
This will delete the state file.
|
static JAXBContext |
getContext(Class<?> contextClass)
This small utility method allows retrieval of the JAXBContext for a given class.
|
static void |
marshalToFile(Object object,
File file)
Marshal an object to file.
|
static String |
marshalToString(Object object)
Marshal an object to a String.
|
static JAXBContext |
registerContext(Class<?> contextClass)
Allows registration of a specific context class to the jaxb context.
|
static JAXBContext |
registerContext(Class<?> contextClass,
JAXBContext context)
Allows registration of a specific context with a specified jaxb context class.
|
static <T> T |
unmarshalFromFile(Class<T> clazz,
File file)
Unmarshals XML from file.
|
static Object |
unmarshalFromString(Class<?> clazz,
String xml)
Unmarshals an String based on the JAXB annotated class.
|
public static void deleteStateFile(File file)
file
- the state file to delete.public static JAXBContext getContext(Class<?> contextClass) throws JAXBException
contextClass
- The context class to load the JAXBContext forJAXBException
- If unable to create the jaxbcontextpublic static JAXBContext registerContext(Class<?> contextClass, JAXBContext context)
contextClass
- The context class for which the jaxb context applies tocontext
- The context to use for the context classpublic static JAXBContext registerContext(Class<?> contextClass) throws JAXBException
contextClass
- The context class for which the jaxb context applies toJAXBException
- If unable to register a contextpublic static String marshalToString(Object object) throws JAXBException
object
- The JAXB annotated object.JAXBException
- on a marshal exception.public static void marshalToFile(Object object, File file) throws JAXBException, IOException
object
- The JAXB annotated object.file
- The file to marshal to.JAXBException
- on a marshal exception.IOException
- on any I/O exception while writing to file.public static <T> T unmarshalFromFile(Class<T> clazz, File file) throws JAXBException
clazz
- The JAXB annotated class.file
- The file to read from.JAXBException
- on a marshal exception.Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries