@Provider public class JsonDecoder extends Decoder implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
${services_rest_decoders_JsonDecoder_Title}
${services_rest_decoders_JsonDecoder_Description}
Constructor and Description |
---|
JsonDecoder()
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addResolvers(java.util.List<JsonDecoderResolver> resolvers)
Sets the deserializer.
|
void |
addTypeRestrict(java.lang.Class type, java.lang.String fieldName, JsonConverter.FieldInfo restrict)
Adds a type definition that indicates a description of a field for a type The interface is mainly used to solve the deserialization of List, Set, Map and other types, the deserialization class does not know the type of collection elements.
|
protected java.util.List<MediaType> |
createSupportedMediaTypes()
${services_rest_decoders_JsonDecoder_method_createSupportedMediaTypes_Title}
|
boolean |
isReadable(java.lang.Class<?> arg0, java.lang.reflect.Type arg1, java.lang.annotation.Annotation[] arg2, javax.ws.rs.core.MediaType arg3)
Determines whether the request body can be deserialized as a Java object.
|
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)
The request body is deserialized into Java objects.
|
java.lang.Object |
toArray(JSONArray jsonArray, java.lang.Class arrayElementType)
${services_rest_decoders_JsonDecoder_method_toArrayByJson_Title}
|
<T> java.util.List<T> |
toList(java.lang.String text, java.lang.Class<T> elementClass)
${services_rest_decoders_JsonDecoder_method_toList_Title}
|
java.util.Map<java.lang.String,java.lang.Object> |
toMap(java.lang.String str, java.util.Map<java.lang.String,java.lang.Class> nameClassMapping)
${services_rest_decoders_JsonDecoder_method_toMap_Title}
|
<T> T |
toObject(java.lang.String jsonStr, java.lang.Class<T> targetClass)
${services_rest_decoders_JsonDecoder_method_toObject_Title}
|
java.util.Set |
toSet(java.lang.String text, java.lang.Class elementClass)
${services_rest_decoders_JsonDecoder_method_toSet_Title}
|
getSupportedMediaTypes, isDecoderAllow
public <T> T toObject(java.lang.String jsonStr, java.lang.Class<T> targetClass) throws JSONException
${services_rest_decoders_JsonDecoder_method_toObject_Title}
${services_rest_decoders_JsonDecoder_method_toObject_Description}
toObject
in class Decoder
jsonStr
- ${services_rest_decoders_JsonDecoder_method_toObject_param_jsonStr}targetClass
- ${services_rest_decoders_JsonDecoder_method_toObject_param_targetClass}java.lang.IllegalArgumentException
JSONException
public java.util.Map<java.lang.String,java.lang.Object> toMap(java.lang.String str, java.util.Map<java.lang.String,java.lang.Class> nameClassMapping)
${services_rest_decoders_JsonDecoder_method_toMap_Title}
${services_rest_decoders_JsonDecoder_method_toMap_Description}
toMap
in class Decoder
str
- ${services_rest_decoders_JsonDecoder_method_toMap_param_str}nameClassMapping
- java.util.Map mapping set. Where the key is the field name and the value is the type of the field.public <T> java.util.List<T> toList(java.lang.String text, java.lang.Class<T> elementClass) throws JSONException
${services_rest_decoders_JsonDecoder_method_toList_Title}
${services_rest_decoders_JsonDecoder_method_toList_Description}
toList
in class Decoder
text
- ${services_rest_decoders_JsonDecoder_method_toList_param_text}elementClass
- ${services_rest_decoders_JsonDecoder_method_toList_param_elementClass}JSONException
- ${services_rest_decoders_JsonDecoder_method_toList_throws_Exception}public java.util.Set toSet(java.lang.String text, java.lang.Class elementClass) throws JSONException
${services_rest_decoders_JsonDecoder_method_toSet_Title}
${services_rest_decoders_JsonDecoder_method_toSet_Description}
toSet
in class Decoder
text
- ${services_rest_decoders_JsonDecoder_method_toSet_param_text}elementClass
- ${services_rest_decoders_JsonDecoder_method_toSet_param_elementClass}JSONException
- ${services_rest_decoders_JsonDecoder_method_toSet_throws_Exception}protected java.util.List<MediaType> createSupportedMediaTypes()
${services_rest_decoders_JsonDecoder_method_createSupportedMediaTypes_Title}
${services_rest_decoders_JsonDecoder_method_createSupportedMediaTypes_Description}
createSupportedMediaTypes
in class Decoder
public java.lang.Object toArray(JSONArray jsonArray, java.lang.Class arrayElementType) throws JSONException
${services_rest_decoders_JsonDecoder_method_toArrayByJson_Title}
${services_rest_decoders_JsonDecoder_method_toArrayByJson_Description}
jsonArray
- ${services_rest_decoders_JsonDecoder_method_toArrayByJson_param_jsonArray}arrayElementType
- ${services_rest_decoders_JsonDecoder_method_toArrayByJson_param_arrayElementType}JSONException
public void addResolvers(java.util.List<JsonDecoderResolver> resolvers)
resolvers
-public void addTypeRestrict(java.lang.Class type, java.lang.String fieldName, JsonConverter.FieldInfo restrict)
public boolean isReadable(java.lang.Class<?> arg0, java.lang.reflect.Type arg1, java.lang.annotation.Annotation[] arg2, javax.ws.rs.core.MediaType arg3)
Determines whether the request body can be deserialized as a Java object.
isReadable
in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
arg0
- A class of descrambled Java objects.arg1
- The type of the Java object that is deserialized.arg2
- Mark.arg3
- media type.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
The request body is deserialized into Java objects.
readFrom
in interface javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
type
- A class of descrambled Java objects.genericType
- The type of the Java object that is deserialized.annotations
- annotation.mediaType
- media type.httpHeaders
- Request body form.entityStream
- Request body stream.java.io.IOException
- IO abnormal.javax.ws.rs.WebApplicationException
- Web Application exception.