public class JAXBSerialiser extends Object
JAXBRuntimeException
Modifier and Type | Method | Description |
---|---|---|
Object |
deserialise(File file) |
Deserialise a File of XML to an Object (or JAXBElement)
|
Object |
deserialise(InputStream is) |
Deserialise a stream of XML to an Object (or JAXBElement)
|
Object |
deserialise(Reader reader) |
Deserialise a Reader of XML to an Object (or JAXBElement)
|
<T> T |
deserialise(Class<T> clazz,
String xml) |
Deserialise and cast to a particular type
|
<T> T |
deserialise(Class<T> clazz,
InputSource source) |
Deserialise an input and cast to a particular type
|
Object |
deserialise(String xml) |
Deserialise a String of XML to an Object (or JAXBElement)
|
Object |
deserialise(Node node) |
Deserialise a DOM Node to an Object (or JAXBElement)
|
Object |
deserialise(InputSource source) |
|
JAXBContext |
getContext() |
Retrieve the inner JAXBContext
NOTE: use of this method is strongly discouraged! |
static JAXBSerialiser |
getInstance(Class<?>... classes) |
Helper method to get a JAXBSerialiser for a set of classes with the underlying JAXB implementation picked using the
default
rules for JAXB acquisition
This is an expensive operation and so the result should ideally be cached |
static JAXBSerialiser |
getInstance(String contextPath) |
Helper method to get a JAXBSerialiser from a JAXB Context Path (i.e.
|
static JAXBSerialiser |
getInstance(JAXBContext context) |
Helper method to get a JAXBSerialiser from an existing JAXBContext.
This is an expensive operation and so the result should ideally be cached |
static JAXBSerialiser |
getMoxy(Class<?>... classes) |
Helper method to get a JAXBSerialiser that uses EclipseLink MOXy for all operations
|
static JAXBSerialiser |
getMoxy(String contextPath) |
Helper method to get a JAXBSerialiser that uses EclipseLink MOXy for all operations
|
static void |
print(Object obj) |
Helper method to print a serialised object to stdout (for dev/debugging use)
|
String |
serialise(Object obj) |
|
void |
serialise(Object obj,
File file) |
|
void |
serialise(Object obj,
OutputStream os) |
|
void |
serialise(Object obj,
Writer writer) |
|
void |
serialise(Object obj,
Node node) |
|
Document |
serialiseToDocument(Object obj) |
Helper method to serialise an Object to an org.w3c.dom.Document
|
JAXBSerialiser |
setEncoding(String encoding) |
Specify an output encoding to use when marshalling the XML data.
|
JAXBSerialiser |
setFragment(boolean fragment) |
Specify the value of jaxb.fragment used by the underlying marshaller
|
JAXBSerialiser |
setNoNamespaceSchemaLocation(String noNamespaceSchemaLocation) |
Specify an xsi:noNamespaceSchemaLocation in the generated XML
|
JAXBSerialiser |
setPrettyOutput(boolean pretty) |
Enable/Disable pretty printing
|
JAXBSerialiser |
setSchema(Schema schema) |
Optionally specify the schema to use for all future serialisation/deserialisation methods
|
JAXBSerialiser |
setSchemaLocation(String schemaLocation) |
Specify an xsi:schemaLocation attribute in the generated XML
|
public JAXBContext getContext()
public JAXBSerialiser setSchema(Schema schema)
Note that if this serializer is returned from and cached by a JAXBSerialiserFactory
then use of this method could result in unintended side effects for other classes sharing the
JAXBSerialiserFactory
schema
- public JAXBSerialiser setPrettyOutput(boolean pretty)
pretty
- public JAXBSerialiser setEncoding(String encoding)
Note that if this serializer is returned from and cached by a JAXBSerialiserFactory
then use of this method could result in unintended side effects for other classes sharing the
JAXBSerialiserFactory
encoding
- public JAXBSerialiser setSchemaLocation(String schemaLocation)
Note that if this serializer is returned from and cached by a JAXBSerialiserFactory
then use of this method could result in unintended side effects for other classes sharing the
JAXBSerialiserFactory
schemaLocation
- public JAXBSerialiser setNoNamespaceSchemaLocation(String noNamespaceSchemaLocation)
Note that if this serializer is returned from and cached by a JAXBSerialiserFactory
then use of this method could result in unintended side effects for other classes sharing the
JAXBSerialiserFactory
noNamespaceSchemaLocation
- public JAXBSerialiser setFragment(boolean fragment)
Note that if this serializer is returned from and cached by a JAXBSerialiserFactory
then use of this method could result in unintended side effects for other classes sharing the
JAXBSerialiserFactory
fragment
- Marshaller
public Object deserialise(String xml)
xml
- public Object deserialise(InputStream is)
is
- public Object deserialise(Reader reader)
reader
- public <T> T deserialise(Class<T> clazz, InputSource source)
clazz
- source
- public <T> T deserialise(Class<T> clazz, String xml)
clazz
- xml
- a String of XMLpublic Object deserialise(File file)
file
- public Object deserialise(InputSource source)
public Object deserialise(Node node)
node
- public Document serialiseToDocument(Object obj)
obj
- the object to serialisepublic void serialise(Object obj, OutputStream os)
public static void print(Object obj)
obj
- public static JAXBSerialiser getInstance(JAXBContext context)
context
- an existing JAXBContextpublic static JAXBSerialiser getInstance(Class<?>... classes)
classes
- public static JAXBSerialiser getInstance(String contextPath)
contextPath
- a package name or colon-delimited list of package namespublic static JAXBSerialiser getMoxy(String contextPath)
contextPath
- public static JAXBSerialiser getMoxy(Class<?>... classes)
classes
- Copyright © 2018. All rights reserved.