@Provider
@Consumes(value="*/*")
@Produces(value="*/*")
public class FastJsonProvider
extends java.lang.Object
implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
MessageBodyReader,
MessageBodyWriter| Modifier and Type | Field and Description |
|---|---|
protected java.nio.charset.Charset |
charset
Deprecated.
|
private java.lang.Class<?>[] |
clazzes
allow serialize/deserialize types in clazzes
|
protected java.lang.String |
dateFormat
Deprecated.
|
static java.lang.Class<?>[] |
DEFAULT_UNREADABLES
These are classes that we never use for reading
(never try to deserialize instances of these types).
|
static java.lang.Class<?>[] |
DEFAULT_UNWRITABLES
These are classes that we never use for writing
(never try to serialize instances of these types).
|
private FastJsonConfig |
fastJsonConfig
with fastJson config
|
protected SerializerFeature[] |
features
Deprecated.
|
protected SerializeFilter[] |
filters
Deprecated.
|
private boolean |
pretty
whether set PrettyFormat while exec WriteTo()
|
protected javax.ws.rs.ext.Providers |
providers
Injectable context object used to locate configured
instance of
FastJsonConfig to use for actual
serialization. |
| Constructor and Description |
|---|
FastJsonProvider()
Can serialize/deserialize all types.
|
FastJsonProvider(java.lang.Class<?>[] clazzes)
Only serialize/deserialize all types in clazzes.
|
FastJsonProvider(java.lang.String charset)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
java.nio.charset.Charset |
getCharset()
Deprecated.
|
java.lang.String |
getDateFormat()
Deprecated.
|
FastJsonConfig |
getFastJsonConfig() |
SerializerFeature[] |
getFeatures()
Deprecated.
|
SerializeFilter[] |
getFilters()
Deprecated.
|
long |
getSize(java.lang.Object t,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to figure out serialized length
of given value.
|
protected boolean |
hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
Check media type like "application/json".
|
protected boolean |
isAssignableFrom(java.lang.Class<?> type,
java.lang.Class<?>[] classes)
Check some are interface/abstract classes to exclude.
|
boolean |
isReadable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether values of
given type (and media type) can be deserialized by this provider.
|
protected boolean |
isValidType(java.lang.Class<?> type,
java.lang.annotation.Annotation[] classAnnotations)
Check whether a class can be serialized or deserialized.
|
boolean |
isWriteable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether given value
(of specified type) can be serialized by this provider.
|
protected FastJsonConfig |
locateConfigProvider(java.lang.Class<?> type,
javax.ws.rs.core.MediaType mediaType)
Helper method that is called if no config has been explicitly configured.
|
java.lang.Object |
readFrom(java.lang.Class<java.lang.Object> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders,
java.io.InputStream entityStream)
Method that JAX-RS container calls to deserialize given value.
|
void |
setCharset(java.nio.charset.Charset charset)
Deprecated.
|
void |
setDateFormat(java.lang.String dateFormat)
Deprecated.
|
void |
setFastJsonConfig(FastJsonConfig fastJsonConfig) |
void |
setFeatures(SerializerFeature... features)
Deprecated.
|
void |
setFilters(SerializeFilter... filters)
Deprecated.
|
FastJsonProvider |
setPretty(boolean p)
Set pretty format
|
(package private) static int |
writeJSONStringWithFastJsonConfig(java.io.OutputStream os,
java.nio.charset.Charset charset,
java.lang.Object object,
SerializeConfig config,
SerializeFilter[] filters,
java.lang.String dateFormat,
int defaultFeatures,
SerializerFeature... features) |
void |
writeTo(java.lang.Object obj,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
java.io.OutputStream entityStream)
Method that JAX-RS container calls to serialize given value.
|
public static final java.lang.Class<?>[] DEFAULT_UNREADABLES
public static final java.lang.Class<?>[] DEFAULT_UNWRITABLES
@Deprecated protected java.nio.charset.Charset charset
@Deprecated protected SerializerFeature[] features
@Deprecated protected SerializeFilter[] filters
@Deprecated protected java.lang.String dateFormat
@Context protected javax.ws.rs.ext.Providers providers
FastJsonConfig to use for actual
serialization.private FastJsonConfig fastJsonConfig
private java.lang.Class<?>[] clazzes
private boolean pretty
public FastJsonProvider()
public FastJsonProvider(java.lang.Class<?>[] clazzes)
@Deprecated public FastJsonProvider(java.lang.String charset)
charset - the charsetFastJsonConfig.setCharset(Charset)public FastJsonConfig getFastJsonConfig()
public void setFastJsonConfig(FastJsonConfig fastJsonConfig)
fastJsonConfig - the fastJsonConfig to set.public FastJsonProvider setPretty(boolean p)
@Deprecated public java.nio.charset.Charset getCharset()
FastJsonConfig.getCharset()@Deprecated public void setCharset(java.nio.charset.Charset charset)
charset - the charsetFastJsonConfig.setCharset(Charset)@Deprecated public java.lang.String getDateFormat()
FastJsonConfig.getDateFormat()@Deprecated public void setDateFormat(java.lang.String dateFormat)
dateFormat - the date formatFastJsonConfig.setDateFormat(String)@Deprecated public SerializerFeature[] getFeatures()
FastJsonConfig.getFeatures()@Deprecated public void setFeatures(SerializerFeature... features)
features - the featuresFastJsonConfig.setFeatures(Feature...)@Deprecated public SerializeFilter[] getFilters()
FastJsonConfig.getSerializeFilters()@Deprecated public void setFilters(SerializeFilter... filters)
filters - the filtersFastJsonConfig.setSerializeFilters(SerializeFilter...)protected boolean isAssignableFrom(java.lang.Class<?> type,
java.lang.Class<?>[] classes)
type - the typeclasses - the classesprotected boolean isValidType(java.lang.Class<?> type,
java.lang.annotation.Annotation[] classAnnotations)
type - class need to checkprotected boolean hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
mediaType - media typepublic boolean isWriteable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>public long getSize(java.lang.Object t,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
getSize in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>public void writeTo(java.lang.Object obj,
java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
java.io.OutputStream entityStream)
throws java.io.IOException,
javax.ws.rs.WebApplicationException
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>java.io.IOExceptionjavax.ws.rs.WebApplicationExceptionstatic final int writeJSONStringWithFastJsonConfig(java.io.OutputStream os,
java.nio.charset.Charset charset,
java.lang.Object object,
SerializeConfig config,
SerializeFilter[] filters,
java.lang.String dateFormat,
int defaultFeatures,
SerializerFeature... features)
throws java.io.IOException
java.io.IOExceptionpublic boolean isReadable(java.lang.Class<?> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
isReadable in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>public java.lang.Object readFrom(java.lang.Class<java.lang.Object> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders,
java.io.InputStream entityStream)
throws java.io.IOException,
javax.ws.rs.WebApplicationException
readFrom in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>java.io.IOExceptionjavax.ws.rs.WebApplicationExceptionprotected FastJsonConfig locateConfigProvider(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)