org.glassfish.jersey.jettison.internal
Class BaseJsonMarshaller

java.lang.Object
  extended by org.glassfish.jersey.jettison.internal.BaseJsonMarshaller
All Implemented Interfaces:
JettisonConfigured, JettisonMarshaller
Direct Known Subclasses:
JettisonJaxbMarshaller

public class BaseJsonMarshaller
extends Object
implements JettisonMarshaller, JettisonConfigured

Base JSON marshaller implementation class.

Author:
Jakub Podlesak (jakub.podlesak at oracle.com), Michal Gajdos (michal.gajdos at oracle.com)

Field Summary
protected  Marshaller jaxbMarshaller
           
protected  JettisonConfig jsonConfig
           
 
Fields inherited from interface org.glassfish.jersey.jettison.JettisonMarshaller
FORMATTED
 
Constructor Summary
BaseJsonMarshaller(JAXBContext jaxbContext, JettisonConfig jsonConfig)
           
BaseJsonMarshaller(Marshaller jaxbMarshaller, JettisonConfig jsonConfig)
           
 
Method Summary
 JettisonConfig 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 JettisonMarshaller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jaxbMarshaller

protected final Marshaller jaxbMarshaller

jsonConfig

protected JettisonConfig jsonConfig
Constructor Detail

BaseJsonMarshaller

public BaseJsonMarshaller(JAXBContext jaxbContext,
                          JettisonConfig jsonConfig)
                   throws JAXBException
Throws:
JAXBException

BaseJsonMarshaller

public BaseJsonMarshaller(Marshaller jaxbMarshaller,
                          JettisonConfig jsonConfig)
Method Detail

getJSONConfiguration

public JettisonConfig getJSONConfiguration()
Description copied from interface: JettisonConfigured
Provides information on current JSON configuration options for this object.

Specified by:
getJSONConfiguration in interface JettisonConfigured
Returns:
a non-null JettisonConfig instance.

marshallToJSON

public void marshallToJSON(Object o,
                           OutputStream outputStream)
                    throws JAXBException
Description copied from interface: JettisonMarshaller
Marshall the content tree rooted at 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.

Specified by:
marshallToJSON in interface JettisonMarshaller
Parameters:
o - the root of the content tree to be marshalled.
outputStream - the JSON will be added to this stream.
Throws:
JAXBException - if any unexpected problem occurs during the marshalling.
MarshalException - if the JsonMarshaller is unable to marshal jaxbElement (or any object reachable from obj)

marshallToJSON

public void marshallToJSON(Object o,
                           Writer writer)
                    throws JAXBException
Description copied from interface: JettisonMarshaller
Marshall the content tree rooted at 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.

Specified by:
marshallToJSON in interface JettisonMarshaller
Parameters:
o - the root of the content tree to be marshalled.
writer - the JSON will be added to this writer.
Throws:
JAXBException - if any unexpected problem occurs during the marshalling.
MarshalException - if the JsonMarshaller is unable to marshal jaxbElement (or any object reachable from obj)

setProperty

public void setProperty(String key,
                        Object value)
                 throws PropertyException
Description copied from interface: JettisonMarshaller
Set the particular property in the underlying implementation of JettisonMarshaller. Attempting to set an undefined property will result in a PropertyException being thrown.

Specified by:
setProperty in interface JettisonMarshaller
Parameters:
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 set
Throws:
PropertyException - when there is an error processing the given property or value


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.