org.apache.cxf.jaxrs.provider.json
Class JSONProvider<T>
java.lang.Object
org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
org.apache.cxf.jaxrs.provider.AbstractJAXBProvider<T>
org.apache.cxf.jaxrs.provider.json.JSONProvider<T>
- All Implemented Interfaces:
- javax.ws.rs.ext.MessageBodyReader<T>, javax.ws.rs.ext.MessageBodyWriter<T>
@Produces(value={"application/json","application/*+json"})
@Consumes(value={"application/json","application/*+json"})
@Provider
public class JSONProvider<T>
- extends AbstractJAXBProvider<T>
Fields inherited from class org.apache.cxf.jaxrs.provider.AbstractJAXBProvider |
BUNDLE, classContexts, collectionContextClasses, inAppendMap, inDropElements, inElementsMap, jaxbElementClassMap, LOG, marshalAsJaxbElement, NS_MAPPER_PROPERTY_RI, NS_MAPPER_PROPERTY_RI_INT, outAppendMap, outDropElements, outElementsMap, packageContexts, unmarshalAsJaxbElement, xmlTypeAsJaxbElementOnly |
Method Summary |
protected void |
copyReaderToWriter(XMLStreamReader reader,
XMLStreamWriter writer)
|
protected XMLStreamReader |
createReader(Class<?> type,
InputStream is,
boolean isCollection,
String enc)
|
protected XMLStreamReader |
createReader(Class<?> type,
InputStream is,
String enc)
|
protected XMLStreamWriter |
createWriter(Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os,
boolean isCollection)
|
protected List<String> |
getArrayKeys()
|
protected boolean |
getBooleanJsonProperty(String name,
boolean defaultValue)
|
protected DocumentDepthProperties |
getDepthProperties()
|
protected InputStream |
getInputStream(Class<T> cls,
Type type,
InputStream is)
|
protected String |
getRootName(Class<T> cls,
Type type)
|
boolean |
isReadable(Class<?> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt)
|
protected boolean |
isRootArray(List<String> theArrayKeys)
|
boolean |
isWriteable(Class<?> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt)
|
protected void |
marshal(Marshaller ms,
Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os,
boolean isCollection)
|
protected void |
marshal(Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os)
|
protected void |
marshalCollection(Class<?> originalCls,
Object collection,
Type genericType,
String encoding,
OutputStream os,
javax.ws.rs.core.MediaType m,
Annotation[] anns)
|
protected void |
marshalCollectionMember(Object obj,
Class<?> cls,
Type genericType,
String enc,
OutputStream os)
|
T |
readFrom(Class<T> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
InputStream is)
|
void |
setArrayKeys(List<String> keys)
|
void |
setAttributesToElements(boolean value)
|
void |
setConsumeMediaTypes(List<String> types)
Sets custom Consumes media types; can be used to override static
Consumes annotation value set on the provider. |
void |
setConvention(String value)
|
void |
setConvertTypesToStrings(boolean convert)
|
void |
setDropCollectionWrapperElement(boolean drop)
|
void |
setDropElementsInXmlStream(boolean drop)
|
void |
setDropRootElement(boolean drop)
|
void |
setEnableBuffering(boolean enableBuf)
Enables the buffering mode. |
void |
setIgnoreEmptyArrayValues(boolean ignoreEmptyArrayElements)
|
void |
setIgnoreMixedContent(boolean ignore)
|
void |
setIgnoreNamespaces(boolean ignoreNamespaces)
|
void |
setMessageContext(MessageContext mc)
|
void |
setNamespaceMap(Map<String,String> namespaceMap)
|
void |
setPrimitiveArrayKeys(List<String> primitiveArrayKeys)
|
void |
setProduceMediaTypes(List<String> types)
Sets custom Produces media types; can be used to override static
Produces annotation value set on the provider. |
void |
setReadXsiType(boolean readXsiType)
|
void |
setSerializeAsArray(boolean asArray)
|
void |
setSupportUnwrapped(boolean unwrap)
|
void |
setTypeConverter(org.codehaus.jettison.mapped.TypeConverter converter)
|
void |
setWrapperMap(Map<String,String> map)
|
void |
setWrapperName(String wName)
|
void |
setWriteNullAsString(boolean writeNullAsString)
|
void |
setWriteXsiType(boolean writeXsiType)
|
void |
writeTo(T obj,
Class<?> cls,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType m,
javax.ws.rs.core.MultivaluedMap<String,Object> headers,
OutputStream os)
|
Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractJAXBProvider |
canBeReadAsJaxbElement, checkAdapter, clearContexts, configureReaderRestrictions, convertToJaxbElementIfNeeded, createDepthReaderIfNeeded, createMarshaller, createTransformReaderIfNeeded, createTransformWriterIfNeeded, createUnmarshaller, createUnmarshaller, getActualType, getClassContext, getClassContext, getCollectionContext, getCollectionWrapperQName, getContext, getJAXBContext, getJaxbElementClass, getJaxbQName, getPackageContext, getPackageContext, getSchema, getSchema, getSize, getStackTrace, getStreamHandlerFromCurrentMessage, handleExceptionEnd, handleExceptionStart, handleJAXBException, handleXMLStreamException, init, isSkipJaxbChecks, isSupported, isXmlRoot, isXmlType, objectFactoryOrIndexAvailable, reportEmptyContentLength, setCatalogLocation, setCollectionWrapperMap, setCollectionWrapperName, setContext, setContextProperties, setDepthProperties, setExtraClass, setInAppendElements, setInDropElements, setInTransformElements, setJaxbElementClassMap, setJaxbElementClassNames, setMarshallAsJaxbElement, setMarshallerListener, setMarshallerProp, setNamespaceMapper, setNamespaceMapperPropertyName, setOutAppendElements, setOutDropElements, setOutTransformElements, setSchema, setSchemaHandler, setSchemaHandlers, setSchemaLocations, setSingleJaxbContext, setSkipJaxbChecks, setUnmarshallAsJaxbElement, setUnmarshallerListener, setUnmarshallerProperties, setUseSingleContextForPackages, setValidateBeforeWrite, setValidateInput, setValidateOutput, setValidationHandler, setXmlRootAsJaxbElement, setXmlTypeAsJaxbElementOnly, validateObjectIfNeeded, writeTo |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JSONProvider
public JSONProvider()
setAttributesToElements
public void setAttributesToElements(boolean value)
- Overrides:
setAttributesToElements
in class AbstractJAXBProvider<T>
setConvention
public void setConvention(String value)
setConvertTypesToStrings
public void setConvertTypesToStrings(boolean convert)
setTypeConverter
public void setTypeConverter(org.codehaus.jettison.mapped.TypeConverter converter)
setIgnoreNamespaces
public void setIgnoreNamespaces(boolean ignoreNamespaces)
setMessageContext
@Context
public void setMessageContext(MessageContext mc)
setDropRootElement
public void setDropRootElement(boolean drop)
setDropCollectionWrapperElement
public void setDropCollectionWrapperElement(boolean drop)
setIgnoreMixedContent
public void setIgnoreMixedContent(boolean ignore)
setSupportUnwrapped
public void setSupportUnwrapped(boolean unwrap)
setWrapperName
public void setWrapperName(String wName)
setWrapperMap
public void setWrapperMap(Map<String,String> map)
setEnableBuffering
public void setEnableBuffering(boolean enableBuf)
- Description copied from class:
AbstractConfigurableProvider
- Enables the buffering mode. If set to true then the runtime will ensure
that the provider writes to a cached stream.
For example, the JAXB marshalling process may fail after the initial XML
tags have already been written out to the HTTP output stream. Enabling
the buffering ensures no incomplete payloads are sent back to clients
in case of marshalling errors at the cost of the initial buffering - which
might be negligible for small payloads.
- Overrides:
setEnableBuffering
in class AbstractConfigurableProvider
- Parameters:
enableBuf
- the value of the buffering mode, false is default.
setConsumeMediaTypes
public void setConsumeMediaTypes(List<String> types)
- Description copied from class:
AbstractConfigurableProvider
- Sets custom Consumes media types; can be used to override static
Consumes
annotation value set on the provider.
- Overrides:
setConsumeMediaTypes
in class AbstractConfigurableProvider
- Parameters:
types
- the media types
setProduceMediaTypes
public void setProduceMediaTypes(List<String> types)
- Description copied from class:
AbstractConfigurableProvider
- Sets custom Produces media types; can be used to override static
Produces
annotation value set on the provider.
- Overrides:
setProduceMediaTypes
in class AbstractConfigurableProvider
- Parameters:
types
- the media types
setSerializeAsArray
public void setSerializeAsArray(boolean asArray)
setArrayKeys
public void setArrayKeys(List<String> keys)
setNamespaceMap
public void setNamespaceMap(Map<String,String> namespaceMap)
isReadable
public boolean isReadable(Class<?> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt)
- Specified by:
isReadable
in interface javax.ws.rs.ext.MessageBodyReader<T>
- Overrides:
isReadable
in class AbstractJAXBProvider<T>
readFrom
public T readFrom(Class<T> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
InputStream is)
throws IOException
- Throws:
IOException
createReader
protected XMLStreamReader createReader(Class<?> type,
InputStream is,
boolean isCollection,
String enc)
throws Exception
- Throws:
Exception
createReader
protected XMLStreamReader createReader(Class<?> type,
InputStream is,
String enc)
throws Exception
- Throws:
Exception
getInputStream
protected InputStream getInputStream(Class<T> cls,
Type type,
InputStream is)
throws Exception
- Throws:
Exception
getRootName
protected String getRootName(Class<T> cls,
Type type)
throws Exception
- Throws:
Exception
isWriteable
public boolean isWriteable(Class<?> type,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType mt)
- Specified by:
isWriteable
in interface javax.ws.rs.ext.MessageBodyWriter<T>
- Overrides:
isWriteable
in class AbstractJAXBProvider<T>
writeTo
public void writeTo(T obj,
Class<?> cls,
Type genericType,
Annotation[] anns,
javax.ws.rs.core.MediaType m,
javax.ws.rs.core.MultivaluedMap<String,Object> headers,
OutputStream os)
throws IOException
- Throws:
IOException
copyReaderToWriter
protected void copyReaderToWriter(XMLStreamReader reader,
XMLStreamWriter writer)
throws Exception
- Throws:
Exception
marshalCollection
protected void marshalCollection(Class<?> originalCls,
Object collection,
Type genericType,
String encoding,
OutputStream os,
javax.ws.rs.core.MediaType m,
Annotation[] anns)
throws Exception
- Throws:
Exception
marshalCollectionMember
protected void marshalCollectionMember(Object obj,
Class<?> cls,
Type genericType,
String enc,
OutputStream os)
throws Exception
- Throws:
Exception
marshal
protected void marshal(Marshaller ms,
Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os,
boolean isCollection)
throws Exception
- Throws:
Exception
createWriter
protected XMLStreamWriter createWriter(Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os,
boolean isCollection)
throws Exception
- Throws:
Exception
getArrayKeys
protected List<String> getArrayKeys()
isRootArray
protected boolean isRootArray(List<String> theArrayKeys)
getBooleanJsonProperty
protected boolean getBooleanJsonProperty(String name,
boolean defaultValue)
marshal
protected void marshal(Object actualObject,
Class<?> actualClass,
Type genericType,
String enc,
OutputStream os)
throws Exception
- Throws:
Exception
setWriteXsiType
public void setWriteXsiType(boolean writeXsiType)
setReadXsiType
public void setReadXsiType(boolean readXsiType)
setPrimitiveArrayKeys
public void setPrimitiveArrayKeys(List<String> primitiveArrayKeys)
setDropElementsInXmlStream
public void setDropElementsInXmlStream(boolean drop)
setWriteNullAsString
public void setWriteNullAsString(boolean writeNullAsString)
setIgnoreEmptyArrayValues
public void setIgnoreEmptyArrayValues(boolean ignoreEmptyArrayElements)
getDepthProperties
protected DocumentDepthProperties getDepthProperties()
- Overrides:
getDepthProperties
in class AbstractJAXBProvider<T>
Apache CXF