org.glassfish.jersey.media.htmljson
Class HtmlJsonProvider
java.lang.Object
org.glassfish.jersey.media.htmljson.HtmlJsonProvider
- All Implemented Interfaces:
- javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter, org.apidesign.html.json.spi.ContextProvider, org.apidesign.html.json.spi.Transfer
public final class HtmlJsonProvider
- extends Object
- implements javax.ws.rs.ext.MessageBodyWriter, javax.ws.rs.ext.MessageBodyReader<Object>, org.apidesign.html.json.spi.ContextProvider, org.apidesign.html.json.spi.Transfer
Implementation of Jersey's message body reader and writer that
can handle reading and writing of JSON models generated by 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() {
WebTarget target = ...;
Query q = target.request(MediaType.APPLICATION_JSON).get().readEntity(Query.class);
return q.getItems();
}
}
- Author:
- Jaroslav Tulach (jtulach at netbeans.org)
|
Method Summary |
void |
extract(Object jsonObject,
String[] props,
Object[] values)
|
net.java.html.json.Context |
findContext(Class<?> requestor)
|
long |
getSize(Object t,
Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
|
boolean |
isReadable(Class<?> type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
|
boolean |
isWriteable(Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
|
void |
loadJSON(org.apidesign.html.json.spi.JSONCall call)
|
Object |
readFrom(Class<Object> type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap<String,String> mm,
InputStream in)
|
Object |
toJSON(InputStream is)
|
void |
writeTo(Object t,
Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap mm,
OutputStream out)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HtmlJsonProvider
public HtmlJsonProvider()
isWriteable
public boolean isWriteable(Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
- Specified by:
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter
getSize
public long getSize(Object t,
Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
- Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter
writeTo
public void writeTo(Object t,
Class type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap mm,
OutputStream out)
throws IOException,
javax.ws.rs.WebApplicationException
- Specified by:
writeTo in interface javax.ws.rs.ext.MessageBodyWriter
- Throws:
IOException
javax.ws.rs.WebApplicationException
isReadable
public boolean isReadable(Class<?> type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt)
- Specified by:
isReadable in interface javax.ws.rs.ext.MessageBodyReader<Object>
readFrom
public Object readFrom(Class<Object> type,
Type type1,
Annotation[] antns,
javax.ws.rs.core.MediaType mt,
javax.ws.rs.core.MultivaluedMap<String,String> mm,
InputStream in)
throws IOException,
javax.ws.rs.WebApplicationException
- Specified by:
readFrom in interface javax.ws.rs.ext.MessageBodyReader<Object>
- Throws:
IOException
javax.ws.rs.WebApplicationException
findContext
public net.java.html.json.Context findContext(Class<?> requestor)
- Specified by:
findContext in interface org.apidesign.html.json.spi.ContextProvider
extract
public void extract(Object jsonObject,
String[] props,
Object[] values)
- Specified by:
extract in interface org.apidesign.html.json.spi.Transfer
toJSON
public Object toJSON(InputStream is)
throws IOException
- Specified by:
toJSON in interface org.apidesign.html.json.spi.Transfer
- Throws:
IOException
loadJSON
public void loadJSON(org.apidesign.html.json.spi.JSONCall call)
- Specified by:
loadJSON in interface org.apidesign.html.json.spi.Transfer
Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.