com.sun.jersey.json.impl
Class BaseJSONMarshaller

java.lang.Object
  extended by com.sun.jersey.json.impl.BaseJSONMarshaller
All Implemented Interfaces:
JSONConfigurated, JSONMarshaller
Direct Known Subclasses:
JSONMarshallerImpl

public class BaseJSONMarshaller
extends java.lang.Object
implements JSONMarshaller, JSONConfigurated

Author:
Jakub.Podlesak@Sun.COM

Field Summary
protected  javax.xml.bind.Marshaller jaxbMarshaller
           
protected  JSONConfiguration jsonConfig
           
 
Fields inherited from interface com.sun.jersey.api.json.JSONMarshaller
FORMATTED
 
Constructor Summary
BaseJSONMarshaller(javax.xml.bind.JAXBContext jaxbContext, JSONConfiguration jsonConfig)
           
BaseJSONMarshaller(javax.xml.bind.Marshaller jaxbMarshaller, JSONConfiguration jsonConfig)
           
 
Method Summary
 JSONConfiguration getJSONConfiguration()
          Provides information on current JSON configuration options for this object.
 void marshallToJSON(java.lang.Object o, java.io.OutputStream outputStream)
          Marshall the content tree rooted at jaxbElement into an output stream.
 void marshallToJSON(java.lang.Object o, java.io.Writer writer)
          Marshall the content tree rooted at jaxbElement into an output stream.
 void setProperty(java.lang.String key, java.lang.Object value)
          Set the particular property in the underlying implementation of JSONMarshaller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jaxbMarshaller

protected final javax.xml.bind.Marshaller jaxbMarshaller

jsonConfig

protected JSONConfiguration jsonConfig
Constructor Detail

BaseJSONMarshaller

public BaseJSONMarshaller(javax.xml.bind.JAXBContext jaxbContext,
                          JSONConfiguration jsonConfig)
                   throws javax.xml.bind.JAXBException
Throws:
javax.xml.bind.JAXBException

BaseJSONMarshaller

public BaseJSONMarshaller(javax.xml.bind.Marshaller jaxbMarshaller,
                          JSONConfiguration jsonConfig)
Method Detail

getJSONConfiguration

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

Specified by:
getJSONConfiguration in interface JSONConfigurated
Returns:
a non-null JSONConfiguration instance.

marshallToJSON

public void marshallToJSON(java.lang.Object o,
                           java.io.OutputStream outputStream)
                    throws javax.xml.bind.JAXBException
Description copied from interface: JSONMarshaller
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 JSONMarshaller
Parameters:
o - the root of the content tree to be marshalled.
outputStream - the JSON will be added to this stream.
Throws:
javax.xml.bind.JAXBException - if any unexpected problem occurs during the marshalling.
javax.xml.bind.MarshalException - if the JSONMarshaller is unable to marshal jaxbElement (or any object reachable from obj)

marshallToJSON

public void marshallToJSON(java.lang.Object o,
                           java.io.Writer writer)
                    throws javax.xml.bind.JAXBException
Description copied from interface: JSONMarshaller
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 JSONMarshaller
Parameters:
o - the root of the content tree to be marshalled.
writer - the JSON will be added to this writer.
Throws:
javax.xml.bind.JAXBException - if any unexpected problem occurs during the marshalling.
javax.xml.bind.MarshalException - if the JSONMarshaller is unable to marshal jaxbElement (or any object reachable from obj)

setProperty

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

Specified by:
setProperty in interface JSONMarshaller
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:
javax.xml.bind.PropertyException - when there is an error processing the given property or value


Copyright © 2011 Sun Microsystems, Inc. All Rights Reserved.