|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.xml.bind.JAXBContext
com.sun.jersey.api.json.JSONJAXBContext
public final class JSONJAXBContext
An adaption of JAXBContext
that supports marshalling
and unmarshalling of JAXB beans using the JSON format.
The JSON format may be configured by using a JSONConfiguration
object
as a constructor parameter of this class.
Nested Class Summary | |
---|---|
static class |
JSONJAXBContext.JSONNotation
Deprecated. |
Field Summary | |
---|---|
static java.lang.String |
JSON_ARRAYS
Deprecated. |
static java.lang.String |
JSON_ATTRS_AS_ELEMS
Deprecated. |
static java.lang.String |
JSON_ENABLED
Deprecated. |
static java.lang.String |
JSON_NON_STRINGS
Deprecated. |
static java.lang.String |
JSON_NOTATION
Deprecated. |
static java.lang.String |
JSON_ROOT_UNWRAPPING
Deprecated. |
static java.lang.String |
JSON_XML2JSON_NS
Deprecated. |
static java.lang.String |
NAMESPACE
Deprecated. |
Fields inherited from class javax.xml.bind.JAXBContext |
---|
JAXB_CONTEXT_FACTORY |
Constructor Summary | |
---|---|
JSONJAXBContext(java.lang.Class... classesToBeBound)
Constructs a new instance with default JSONConfiguration . |
|
JSONJAXBContext(java.lang.Class[] classesToBeBound,
java.util.Map<java.lang.String,java.lang.Object> properties)
Constructs a new instance with a custom set of properties. |
|
JSONJAXBContext(JSONConfiguration config,
java.lang.Class... classesToBeBound)
Constructs a new instance with given JSONConfiguration . |
|
JSONJAXBContext(JSONConfiguration config,
java.lang.Class[] classesToBeBound,
java.util.Map<java.lang.String,java.lang.Object> properties)
Constructs a new instance with a custom set of properties. |
|
JSONJAXBContext(JSONConfiguration config,
java.lang.String contextPath)
Construct a new instance of using context class loader of the thread with given JSONConfiguration . |
|
JSONJAXBContext(JSONConfiguration config,
java.lang.String contextPath,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.Object> properties)
Construct a new instance using a specified class loader, set of properties and JSONConfiguration . |
|
JSONJAXBContext(java.lang.String contextPath)
Construct a new instance of using context class loader of the thread with default JSONConfiguration . |
|
JSONJAXBContext(java.lang.String contextPath,
java.lang.ClassLoader classLoader)
Construct a new instance using a specified class loader with default JSONConfiguration . |
|
JSONJAXBContext(java.lang.String contextPath,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.Object> properties)
Construct a new instance using a specified class loader and a custom set of properties. |
Method Summary | |
---|---|
JSONMarshaller |
createJSONMarshaller()
Create a JSON marshaller. |
JSONUnmarshaller |
createJSONUnmarshaller()
Create a JSON unmarshaller. |
javax.xml.bind.Marshaller |
createMarshaller()
Overrides underlaying createMarshaller method and returns a marshaller which is capable of JSON serialization. |
javax.xml.bind.Unmarshaller |
createUnmarshaller()
Overrides underlaying createUnmarshaller method and returns an unmarshaller which is capable of JSON deserialization. |
javax.xml.bind.Validator |
createValidator()
Simply delegates to underlying JAXBContext implementation. |
JSONConfiguration |
getJSONConfiguration()
Get the JSON configuration. |
static JSONMarshaller |
getJSONMarshaller(javax.xml.bind.Marshaller marshaller,
javax.xml.bind.JAXBContext jaxbContext)
Get a JSONMarshaller from a Marshaller . |
static JSONUnmarshaller |
getJSONUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller,
javax.xml.bind.JAXBContext jaxbContext)
Get a JSONUnmarshaller from a Unmarshaller . |
javax.xml.bind.JAXBContext |
getOriginalJaxbContext()
Returns the underlying JAXBContext . |
Methods inherited from class javax.xml.bind.JAXBContext |
---|
createBinder, createBinder, createJAXBIntrospector, generateSchema, newInstance, newInstance, newInstance, newInstance, newInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated public static final java.lang.String NAMESPACE
@Deprecated public static final java.lang.String JSON_NOTATION
JSONConfiguration
.
The type of this property is enum type JSONJAXBContext.JSONNotation
.
The value may be one of the following that are the currently supported JSON
notations: JSONNotation.MAPPED
,
JSONNotation.MAPPED_JETTISON
and JSONNotation.BADGERFISH
The default value is JSONNotation.MAPPED
.
@Deprecated public static final java.lang.String JSON_ENABLED
JSONConfiguration
.
The type of this property is Boolean
If set to true, JSON will be serialized/deserialized instead of XML
The default value is false.
@Deprecated public static final java.lang.String JSON_ROOT_UNWRAPPING
JSONConfiguration
.
The type of this property is Boolean
If set to true, JSON code corresponding to the XML root element will be stripped out
for JSONNotation.MAPPED
(default) notation.
The default value is false.
@Deprecated public static final java.lang.String JSON_ARRAYS
JSONConfiguration
.
This property is valid for the JSONNotation.MAPPED
notation only.
The type of this property is java.util.Collection<String>
.
The value is a collection of string values that are object names. The value of an object name in the JSON document that exists in the collection of object names will be declared as an array, even if only one element is present.
For example, consider that the property value is not set and the
JSON document is { ..., "arr1":"single element", ... }
.
If the property value is set to contain "arr1"
then
the JSON document would be { ..., "arr1":["single element"], ... }
.
The default value is an empty collection.
@Deprecated public static final java.lang.String JSON_NON_STRINGS
JSONConfiguration
.
This property is valid for the JSONNotation.MAPPED
notation only.
The type of this property is Collection<String>
.
The value is collection of string values that are object names. The value of an object name in the JSON document that exists in the collection of object names will be declared as non-string value, which is not surrounded by double quotes.
For example, consider that the property value is not set and the
JSON document is { ..., "anumber":"12", ... }
.
If the property value is set to contain "anumber"
then the JSON document would be { ..., "anumber":12, ... }
.
The default value is an empty collection.
@Deprecated public static final java.lang.String JSON_ATTRS_AS_ELEMS
JSONConfiguration
.
This property is valid for the JSONNotation.MAPPED
notation only.
The type of this property is Collection<String>
.
The value is a collection of string values that are object names that correspond to XML attribute information items. The value of an object name in the JSON document that exists in the collection of object names will be declared as an element as not as an attribute if the object corresponds to an XML attribute information item.
For example, consider that the property value is not set and the
JSON document is { ..., "@number":"12", ... }
.
If the property value is set contain "number"
then the JSON document would be { ..., "number":"12", ... }
.
The default value is an empty collection.
@Deprecated public static final java.lang.String JSON_XML2JSON_NS
JSONConfiguration
.
This property is valid for the MAPPED_JETTISON notation only.
The type of this property is Map<String,String>
.
The value is a map with zero or more key/value pairs, where the key is an XML namespace and the value is the prefix to use as the replacement for the XML namespace.
The default value is a map with zero key/value pairs.
Constructor Detail |
---|
public JSONJAXBContext(java.lang.Class... classesToBeBound) throws javax.xml.bind.JAXBException
JSONConfiguration
.
classesToBeBound
- list of java classes to be recognized by the
new JSONJAXBContext. Can be empty, in which case a JSONJAXBContext
that only knows about spec-defined classes will be returned.
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(JSONConfiguration config, java.lang.Class... classesToBeBound) throws javax.xml.bind.JAXBException
JSONConfiguration
.
config
- JSONConfiguration
, can not be nullclassesToBeBound
- list of java classes to be recognized by the
new JSONJAXBContext. Can be empty, in which case a JSONJAXBContext
that only knows about spec-defined classes will be returned.
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(java.lang.Class[] classesToBeBound, java.util.Map<java.lang.String,java.lang.Object> properties) throws javax.xml.bind.JAXBException
JSONConfiguration
is used if no (now deprecated)
JSON related properties are specified
classesToBeBound
- list of java classes to be recognized by the
new JSONJAXBContext. Can be empty, in which case a JSONJAXBContext
that only knows about spec-defined classes will be returned.properties
- the custom set of properties. If it contains(now deprecated) JSON related properties,
then a non-default JSONConfiguration
is used reflecting the JSON properties
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(JSONConfiguration config, java.lang.Class[] classesToBeBound, java.util.Map<java.lang.String,java.lang.Object> properties) throws javax.xml.bind.JAXBException
JSONConfiguration.DEFAULT
is used as JSONConfiguration
config
- JSONConfiguration
, can not be nullclassesToBeBound
- list of java classes to be recognized by the
new JSONJAXBContext. Can be empty, in which case a JSONJAXBContext
that only knows about spec-defined classes will be returned.properties
- the custom set of properties.
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(java.lang.String contextPath) throws javax.xml.bind.JAXBException
JSONConfiguration
.
contextPath
- list of java package names that contain schema
derived class and/or java to schema (JAXB-annotated) mapped
classes
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(JSONConfiguration config, java.lang.String contextPath) throws javax.xml.bind.JAXBException
JSONConfiguration
.
config
- JSONConfiguration
, can not be nullcontextPath
- list of java package names that contain schema
derived class and/or java to schema (JAXB-annotated) mapped
classes
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(java.lang.String contextPath, java.lang.ClassLoader classLoader) throws javax.xml.bind.JAXBException
JSONConfiguration
.
contextPath
- list of java package names that contain schema
derived class and/or java to schema (JAXB-annotated) mapped
classesclassLoader
-
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map<java.lang.String,java.lang.Object> properties) throws javax.xml.bind.JAXBException
JSONConfiguration
is set to default,
if user does not specify any (now deprecated) JSON related properties
contextPath
- list of java package names that contain schema
derived class and/or java to schema (JAXB-annotated) mapped
classesclassLoader
- properties
- the custom set of properties.
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.public JSONJAXBContext(JSONConfiguration config, java.lang.String contextPath, java.lang.ClassLoader classLoader, java.util.Map<java.lang.String,java.lang.Object> properties) throws javax.xml.bind.JAXBException
JSONConfiguration
.
config
- JSONConfiguration
, can not be nullcontextPath
- list of java package names that contain schema
derived class and/or java to schema (JAXB-annotated) mapped
classesclassLoader
- properties
- the custom set of properties.
javax.xml.bind.JAXBException
- if an error was encountered while creating the
underlying JAXBContext.Method Detail |
---|
public static JSONMarshaller getJSONMarshaller(javax.xml.bind.Marshaller marshaller, javax.xml.bind.JAXBContext jaxbContext)
JSONMarshaller
from a Marshaller
.
marshaller
- the JAXB marshaller.
public static JSONUnmarshaller getJSONUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller, javax.xml.bind.JAXBContext jaxbContext)
JSONUnmarshaller
from a Unmarshaller
.
unmarshaller
- the JAXB unmarshaller.
public JSONConfiguration getJSONConfiguration()
getJSONConfiguration
in interface JSONConfigurated
public JSONUnmarshaller createJSONUnmarshaller() throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
- if there is an error creating the unmarshaller.public JSONMarshaller createJSONMarshaller() throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
- if there is an error creating the marshaller.public javax.xml.bind.Unmarshaller createUnmarshaller() throws javax.xml.bind.JAXBException
createUnmarshaller
in class javax.xml.bind.JAXBContext
javax.xml.bind.JAXBException
public javax.xml.bind.Marshaller createMarshaller() throws javax.xml.bind.JAXBException
createMarshaller
in class javax.xml.bind.JAXBContext
javax.xml.bind.JAXBException
public javax.xml.bind.Validator createValidator() throws javax.xml.bind.JAXBException
createValidator
in class javax.xml.bind.JAXBContext
javax.xml.bind.JAXBException
public javax.xml.bind.JAXBContext getOriginalJaxbContext()
JAXBContext
.
JAXBContext
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |