public class TypeMarshaller extends Object
Modifier and Type | Field and Description |
---|---|
protected static Map<Class,JAXBContext> |
jaxbContextMap |
protected static Map<Class,ThreadLocal<Marshaller>> |
jaxbMarshallerMap |
protected static Map<Class,ThreadLocal<Unmarshaller>> |
jaxbUnmarshallerMap |
Constructor and Description |
---|
TypeMarshaller() |
Modifier and Type | Method and Description |
---|---|
protected static JAXBContext |
getJAXBContext(Class clazz)
A method to manage JAXB data type contexts, as they are expensive to build
and destroy.
|
protected static Marshaller |
getJAXBMarshaller(Class clazz) |
protected static Unmarshaller |
getJAXBUnmarshaller(Class clazz) |
static File |
marshalTypeToFile(Object typeObject,
String filenamePath) |
static void |
marshalTypeToOutputStream(Object typeObject,
OutputStream os) |
static void |
marshalTypeToOutputStream(Object typeObject,
OutputStream os,
String styleSheet)
Marshalls the typeObject to the provided outputStream.
|
static <T> T |
unmarshalTypeFromFile(Class<T> domainClass,
File file)
Unmarshals the contents of the filenamePath into the specified domainClass
|
static <T> T |
unmarshalTypeFromFile(Class<T> domainClass,
String filenamePath)
Unmarshalls the contents of file parameter to the specified domainClass
|
static <T> T |
unmarshalTypeFromStream(Class<T> domainClass,
InputStream inputStream)
Unmarshals the inputStream to the specified domainClass
and unequivocally closes the passed in InputStream
|
protected static final Map<Class,JAXBContext> jaxbContextMap
protected static final Map<Class,ThreadLocal<Unmarshaller>> jaxbUnmarshallerMap
protected static final Map<Class,ThreadLocal<Marshaller>> jaxbMarshallerMap
protected static JAXBContext getJAXBContext(Class clazz) throws JAXBException
clazz
- - the class of the context neededJAXBException
protected static Unmarshaller getJAXBUnmarshaller(Class clazz) throws JAXBException
JAXBException
protected static Marshaller getJAXBMarshaller(Class clazz) throws JAXBException
JAXBException
public static File marshalTypeToFile(Object typeObject, String filenamePath) throws MarshallingException, FileNotFoundException, IOException
public static void marshalTypeToOutputStream(Object typeObject, OutputStream os) throws MarshallingException, IOException
MarshallingException
IOException
public static void marshalTypeToOutputStream(Object typeObject, OutputStream os, String styleSheet) throws MarshallingException, IOException
typeObject
- os
- styleSheet
- MarshallingException
IOException
public static <T> T unmarshalTypeFromFile(Class<T> domainClass, File file) throws IOException, InstantiationException, IllegalAccessException, MarshallingException
T
- domainClass
- file
- IOException
InstantiationException
IllegalAccessException
MarshallingException
public static <T> T unmarshalTypeFromFile(Class<T> domainClass, String filenamePath) throws IOException, InstantiationException, IllegalAccessException, MarshallingException
T
- domainClass
- filenamePath
- IOException
InstantiationException
IllegalAccessException
MarshallingException
public static <T> T unmarshalTypeFromStream(Class<T> domainClass, InputStream inputStream) throws IOException, InstantiationException, IllegalAccessException, MarshallingException
T
- domainClass
- inputStream
- IOException
InstantiationException
IllegalAccessException
MarshallingException
Copyright © 2016. All Rights Reserved.