com.sun.jersey.json.impl
Class BaseJSONUnmarshaller

java.lang.Object
  extended by com.sun.jersey.json.impl.BaseJSONUnmarshaller
All Implemented Interfaces:
JSONConfigurated, JSONUnmarshaller
Direct Known Subclasses:
JSONUnmarshallerImpl

public class BaseJSONUnmarshaller
extends java.lang.Object
implements JSONUnmarshaller, JSONConfigurated

Author:
Jakub.Podlesak@Sun.COM

Field Summary
protected  javax.xml.bind.Unmarshaller jaxbUnmarshaller
           
protected  JSONConfiguration jsonConfig
           
 
Constructor Summary
BaseJSONUnmarshaller(javax.xml.bind.JAXBContext jaxbContext, JSONConfiguration jsonConfig)
           
BaseJSONUnmarshaller(javax.xml.bind.Unmarshaller jaxbUnmarshaller, JSONConfiguration jsonConfig)
           
 
Method Summary
 JSONConfiguration getJSONConfiguration()
          Provides information on current JSON configuration options for this object.
<T> T
unmarshalFromJSON(java.io.InputStream inputStream, java.lang.Class<T> expectedType)
          Unmarshal JSON data from the specified InputStream and return the resulting Java content tree.
<T> T
unmarshalFromJSON(java.io.Reader reader, java.lang.Class<T> expectedType)
          Unmarshal JSON data from the specified Reader and return the resulting Java content tree.
<T> javax.xml.bind.JAXBElement<T>
unmarshalJAXBElementFromJSON(java.io.InputStream inputStream, java.lang.Class<T> declaredType)
          Unmarshal JSON data from the InputStream by declaredType and return the resulting content tree.
<T> javax.xml.bind.JAXBElement<T>
unmarshalJAXBElementFromJSON(java.io.Reader reader, java.lang.Class<T> declaredType)
          Unmarshal JSON data from the Reader by declaredType and return the resulting content tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jaxbUnmarshaller

protected final javax.xml.bind.Unmarshaller jaxbUnmarshaller

jsonConfig

protected final JSONConfiguration jsonConfig
Constructor Detail

BaseJSONUnmarshaller

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

BaseJSONUnmarshaller

public BaseJSONUnmarshaller(javax.xml.bind.Unmarshaller jaxbUnmarshaller,
                            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.

unmarshalFromJSON

public <T> T unmarshalFromJSON(java.io.InputStream inputStream,
                               java.lang.Class<T> expectedType)
                    throws javax.xml.bind.JAXBException
Description copied from interface: JSONUnmarshaller
Unmarshal JSON data from the specified InputStream and return the resulting Java content tree.

The UTF-8 character encoding scheme will be used to decode the encoded characters of the JSON data.

Specified by:
unmarshalFromJSON in interface JSONUnmarshaller
Type Parameters:
T - the type of the Java content tree.
Parameters:
inputStream - the InputStream to unmarshal JSON data from.
expectedType - the expected type of the Java content tree.
Returns:
the newly created root object of the Java content tree. The content tree may be an instance of a class that is mapped to a XML root element (for example, annotated with XmlRootElement) or mapped to an XML type (for example, annotated with XmlType).
Throws:
javax.xml.bind.JAXBException - if any unexpected errors occur while unmarshalling.
javax.xml.bind.UnmarshalException - if the JSONUnmarshaller is unable to perform the JSON to Java binding.

unmarshalFromJSON

public <T> T unmarshalFromJSON(java.io.Reader reader,
                               java.lang.Class<T> expectedType)
                    throws javax.xml.bind.JAXBException
Description copied from interface: JSONUnmarshaller
Unmarshal JSON data from the specified Reader and return the resulting Java content tree.

The character encoding scheme of the reader will be used to encode the characters of the JSON data.

Specified by:
unmarshalFromJSON in interface JSONUnmarshaller
Type Parameters:
T - the type of the Java content tree.
Parameters:
reader - the Reader to unmarshal JSON data from.
expectedType - the expected type of the Java content tree.
Returns:
the newly created root object of the Java content tree. The content tree may be an instance of a class that is mapped to a XML root element (for example, annotated with XmlRootElement) or mapped to an XML type (for example, annotated with XmlType).
Throws:
javax.xml.bind.JAXBException - if any unexpected errors occur while unmarshalling.
javax.xml.bind.UnmarshalException - if the JSONUnmarshaller is unable to perform the JSON to Java binding.

unmarshalJAXBElementFromJSON

public <T> javax.xml.bind.JAXBElement<T> unmarshalJAXBElementFromJSON(java.io.InputStream inputStream,
                                                                      java.lang.Class<T> declaredType)
                                                           throws javax.xml.bind.JAXBException
Description copied from interface: JSONUnmarshaller
Unmarshal JSON data from the InputStream by declaredType and return the resulting content tree.

The UTF-8 character encoding scheme will be used to decode the encoded characters of the JSON data.

Specified by:
unmarshalJAXBElementFromJSON in interface JSONUnmarshaller
Type Parameters:
T - the type of the Java content tree.
Parameters:
inputStream - the InputStream to unmarshal JSON data from.
declaredType - a class that is mapped to a XML root element (for example, annotated with XmlRootElement) or mapped to an XML type (for example, annotated with XmlType).
Returns:
the newly created root object of the Java content tree, root by a JAXBElement instance.
Throws:
javax.xml.bind.JAXBException - if any unexpected errors occur while unmarshalling.
javax.xml.bind.UnmarshalException - if the JSONUnmarshaller is unable to perform the JSON to Java binding.

unmarshalJAXBElementFromJSON

public <T> javax.xml.bind.JAXBElement<T> unmarshalJAXBElementFromJSON(java.io.Reader reader,
                                                                      java.lang.Class<T> declaredType)
                                                           throws javax.xml.bind.JAXBException
Description copied from interface: JSONUnmarshaller
Unmarshal JSON data from the Reader by declaredType and return the resulting content tree.

The character encoding scheme of the reader will be used to encode the characters of the JSON data.

Specified by:
unmarshalJAXBElementFromJSON in interface JSONUnmarshaller
Type Parameters:
T - the type of the Java content tree.
Parameters:
reader - the Reader to unmarshal JSON data from.
declaredType - a class that is mapped to a XML root element (for example, annotated with XmlRootElement) or mapped to an XML type (for example, annotated with XmlType).
Returns:
the newly created root object of the Java content tree, root by a JAXBElement instance.
Throws:
javax.xml.bind.JAXBException - if any unexpected errors occur while unmarshalling.
javax.xml.bind.UnmarshalException - if the JSONUnmarshaller is unable to perform the JSON to Java binding.


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