public final class HtmlJsonProvider extends Object implements MessageBodyWriter<Object>, MessageBodyReader<Object>
Model
annotation provided by
net.java.html.json
library. Include
this JAR in your project and you can then use your
model classes as Jersey's entities.
@Model(className="Query", properties={@Property(name="items", type=Item.class, array=true) }) class QueryImpl {@Model(className="Item", properties={@Property(name="id", type=String.class),@Property(name="kind", type=Kind.class) }) class ItemImpl { } enum Kind { GOOD, BAD } public static List<Item>doQuery() {WebTargettarget = ...; Query q = target.request(MediaType.APPLICATION_JSON).get().readEntity(Query.class); return q.getItems(); } }
| Constructor and Description |
|---|
HtmlJsonProvider() |
| Modifier and Type | Method and Description |
|---|---|
long |
getSize(Object t,
Class type,
Type type1,
Annotation[] antns,
MediaType mt) |
boolean |
isReadable(Class<?> type,
Type type1,
Annotation[] antns,
MediaType mt) |
boolean |
isWriteable(Class clazz,
Type type,
Annotation[] antns,
MediaType mt) |
Object |
readFrom(Class<Object> clazz,
Type type,
Annotation[] antns,
MediaType mt,
MultivaluedMap<String,String> mm,
InputStream in) |
void |
writeTo(Object t,
Class type,
Type type1,
Annotation[] antns,
MediaType mt,
MultivaluedMap mm,
OutputStream out) |
public boolean isWriteable(Class clazz, Type type, Annotation[] antns, MediaType mt)
isWriteable in interface MessageBodyWriter<Object>public long getSize(Object t, Class type, Type type1, Annotation[] antns, MediaType mt)
getSize in interface MessageBodyWriter<Object>public void writeTo(Object t, Class type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap mm, OutputStream out) throws IOException, WebApplicationException
writeTo in interface MessageBodyWriter<Object>IOExceptionWebApplicationExceptionpublic boolean isReadable(Class<?> type, Type type1, Annotation[] antns, MediaType mt)
isReadable in interface MessageBodyReader<Object>public Object readFrom(Class<Object> clazz, Type type, Annotation[] antns, MediaType mt, MultivaluedMap<String,String> mm, InputStream in) throws IOException, WebApplicationException
readFrom in interface MessageBodyReader<Object>IOExceptionWebApplicationExceptionCopyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.