@Provider public class GeoJSONEncoder extends JsonEncoder
| 构造器和说明 |
|---|
GeoJSONEncoder() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected java.util.List<MediaType> |
createSupportedMediaTypes()
创建支持的媒体类型,这里是 JSON 类型。
|
boolean |
isWriteable(java.lang.Class type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
判断本表述生成器是否支持指定媒体类型的表述。
|
Representation |
toRepresentation(MediaType mediaType, java.lang.Object obj)
将一个 Java 对象序列化为表述。
|
getSize, isindent, toFormatedObject, toFormatedString, writeTogetSupportedMediaTypes, isEncodeAllowprotected java.util.List<MediaType> createSupportedMediaTypes()
JsonEncoder创建支持的媒体类型,这里是 JSON 类型。
用户扩展一个 Encoder 时,需要指定该 Encoder 支持将格式化的对象转换为什么媒体类型的表述。
createSupportedMediaTypes 在类中 JsonEncoder
public Representation toRepresentation(MediaType mediaType,
java.lang.Object obj)
JsonEncoder将一个 Java 对象序列化为表述。
toRepresentation 在类中 JsonEncodermediaType - 表述的类型。obj - 欲序列化为表述的 Java 对象。
public boolean isWriteable(java.lang.Class type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
JsonEncoder判断本表述生成器是否支持指定媒体类型的表述。
isWriteable 在接口中 javax.ws.rs.ext.MessageBodyWriterisWriteable 在类中 JsonEncodertype - 要生成表述的对象类型。genericType - 指定的对象类型。annotations - 注记数组,资源中有这些注记的方法返回要写入的对象。mediaType - 预期响应的媒体类型。