public class BaseJSONMarshaller extends Object implements JSONMarshaller, JSONConfigurated
Modifier and Type | Field and Description |
---|---|
protected Marshaller |
jaxbMarshaller |
protected JSONConfiguration |
jsonConfig |
FORMATTED
Constructor and Description |
---|
BaseJSONMarshaller(JAXBContext jaxbContext,
JSONConfiguration jsonConfig) |
BaseJSONMarshaller(Marshaller jaxbMarshaller,
JAXBContext jaxbContext,
JSONConfiguration jsonConfig) |
Modifier and Type | Method and Description |
---|---|
JSONConfiguration |
getJSONConfiguration()
Provides information on current JSON configuration options for this object.
|
void |
marshallToJSON(Object o,
OutputStream outputStream)
Marshall the content tree rooted at
jaxbElement into an
output stream. |
void |
marshallToJSON(Object o,
Writer writer)
Marshall the content tree rooted at
jaxbElement into an
output stream. |
void |
setProperty(String key,
Object value)
Set the particular property in the underlying implementation of
JSONMarshaller . |
protected final Marshaller jaxbMarshaller
protected JSONConfiguration jsonConfig
public BaseJSONMarshaller(JAXBContext jaxbContext, JSONConfiguration jsonConfig) throws JAXBException
JAXBException
public BaseJSONMarshaller(Marshaller jaxbMarshaller, JAXBContext jaxbContext, JSONConfiguration jsonConfig)
public JSONConfiguration getJSONConfiguration()
JSONConfigurated
getJSONConfiguration
in interface JSONConfigurated
JSONConfiguration
instance.public void marshallToJSON(Object o, OutputStream outputStream) throws JAXBException
JSONMarshaller
jaxbElement
into an
output stream. The content tree may be an instance of a class that is
mapped to a XML root element (for example, annotated with
XmlRootElement
) or an instance of JAXBElement
.
The UTF-8 character encoding scheme will be used to encode the characters of the JSON data.
marshallToJSON
in interface JSONMarshaller
o
- the root of the content tree to be marshalled.outputStream
- the JSON will be added to this stream.JAXBException
- if any unexpected problem occurs during the
marshalling.MarshalException
- if the JSONMarshaller
is unable to
marshal jaxbElement
(or any object reachable from obj)public void marshallToJSON(Object o, Writer writer) throws JAXBException
JSONMarshaller
jaxbElement
into an
output stream. The content tree may be an instance of a class that is
mapped to a XML root element (for example, annotated with
XmlRootElement
) or an instance of JAXBElement
.
The character encoding scheme of the writer
will be used to
encode the characters of the JSON data.
marshallToJSON
in interface JSONMarshaller
o
- the root of the content tree to be marshalled.writer
- the JSON will be added to this writer.JAXBException
- if any unexpected problem occurs during the
marshalling.MarshalException
- if the JSONMarshaller
is unable to
marshal jaxbElement
(or any object reachable from obj)public void setProperty(String key, Object value) throws PropertyException
JSONMarshaller
JSONMarshaller
. Attempting to set an undefined property
will result in a PropertyException being thrown.setProperty
in interface JSONMarshaller
key
- the name of the property to be set. This value can either
be specified using one of the constant fields or a user
supplied string.value
- the value of the property to be setPropertyException
- when there is an error processing the given
property or valueCopyright © 2013 Oracle Corporation. All rights reserved.