@Provider public class JsonEncoder extends Encoder implements javax.ws.rs.ext.MessageBodyWriter
${services_rest_encoders_JsonEncoder_Title}
${services_rest_encoders_JsonEncoder_Description}
Constructor and Description |
---|
JsonEncoder()
${services_rest_encoders_JsonEncoder_constructor_JsonEncoder_Title}
|
Modifier and Type | Method and Description |
---|---|
protected java.util.List<MediaType> |
createSupportedMediaTypes()
${services_rest_encoders_JsonEncoder_method_createSupportedMediaTypes_Title}
|
long |
getSize(java.lang.Object o, java.lang.Class type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Determines the length of the object to be written after serialization.
|
protected boolean |
isindent()
Whether to generate a string in an indented format.
|
boolean |
isWriteable(java.lang.Class type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Determines whether the present expression supports the representation of the specified media type.
|
protected java.lang.Object |
toFormatedObject(java.lang.Object obj)
Converts an object to an object of type JSONObject.
|
protected java.lang.String |
toFormatedString(java.lang.Object resultObj)
Will be standard objects such as: JSONObject, JSONArray converted to meet certain specifications of the string, such as JSON, JSONP and so on.
|
Representation |
toRepresentation(MediaType mediaType, java.lang.Object resourceObj)
${services_rest_encoders_JsonEncoder_method_toRepresentation_Title}
|
void |
writeTo(java.lang.Object o, 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 httpHeaders, java.io.OutputStream entityStream)
Generates an HTTP response for the specified media type.
|
getSupportedMediaTypes, isEncodeAllow
public JsonEncoder()
${services_rest_encoders_JsonEncoder_constructor_JsonEncoder_Title}
${services_rest_encoders_JsonEncoder_constructor_JsonEncoder_Description}
public boolean isWriteable(java.lang.Class type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Determines whether the present expression supports the representation of the specified media type.
isWriteable
in interface javax.ws.rs.ext.MessageBodyWriter
type
- The type of object to generate the expression.genericType
- the specified object type.annotations
- annotation array, the resource has these annotation methods to return to the object to be written.mediaType
- The media type of the expected response.public long getSize(java.lang.Object o, java.lang.Class type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Determines the length of the object to be written after serialization. Is called before the HTTP response is generated.
getSize
in interface javax.ws.rs.ext.MessageBodyWriter
o
- To generate an expression object.type
- The Java class that corresponds to the object to be generated.genericType
- To generate an expression object type.annotations
- annotation array, the resource has these annotation methods to return to the object to be written.mediaType
- The media type of the HTTP response.public void writeTo(java.lang.Object o, 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 httpHeaders, java.io.OutputStream entityStream) throws java.io.IOException, javax.ws.rs.WebApplicationException
Generates an HTTP response for the specified media type.
writeTo
in interface javax.ws.rs.ext.MessageBodyWriter
o
- To generate an expression object.type
- The Java class that corresponds to the object to be generated.genericType
- To generate an expression object type.annotations
- annotation array, the resource has these annotation methods to return to the object to be written.mediaType
- HTTP The media type of the response.httpHeaders
- HTTP Response to the message header.entityStream
- HTTP response.java.io.IOException
- When the read and write process is wrong.javax.ws.rs.WebApplicationException
- When the HTTP response fails.protected java.util.List<MediaType> createSupportedMediaTypes()
${services_rest_encoders_JsonEncoder_method_createSupportedMediaTypes_Title}
${services_rest_encoders_JsonEncoder_method_createSupportedMediaTypes_Description}
createSupportedMediaTypes
in class Encoder
public Representation toRepresentation(MediaType mediaType, java.lang.Object resourceObj)
${services_rest_encoders_JsonEncoder_method_toRepresentation_Title}
${services_rest_encoders_JsonEncoder_method_toRepresentation_Description}
toRepresentation
in class Encoder
mediaType
- ${services_rest_encoders_JsonEncoder_method_toRepresentation_param_mediaType}resourceObj
- ${services_rest_encoders_JsonEncoder_method_toRepresentation_param_resourceObj}protected java.lang.Object toFormatedObject(java.lang.Object obj)
Converts an object to an object of type JSONObject. If the incoming parameter is of the base type, it is not converted and returns null.
obj
- The Java object to be converted.protected java.lang.String toFormatedString(java.lang.Object resultObj)
Will be standard objects such as: JSONObject, JSONArray converted to meet certain specifications of the string, such as JSON, JSONP and so on.
resultObj
- The object to be converted.protected boolean isindent()
Whether to generate a string in an indented format.