EntityType
- The expected Java type.@Supports(value="application/json") public abstract class AbstractJsonReader<EntityType> extends Object implements Reader<EntityType>
Reader
.
This class provides an easy way to create java object from json and also provides the current context:
ctx
. It provides you a JsonNode
to manage the unmarshalling.
The use of this class optimize the JsonFactory usage especially when aggregating unmarshallers.
Constructor and Description |
---|
AbstractJsonReader() |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Class<?> clazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Checks if this marshaller can handle the marshalling request.
|
EntityType |
read(Class<?> clazz,
Type genericType,
javax.ws.rs.core.MediaType mediaType,
InputStream in)
Read the entity from in
InputStream using mediatype format. |
abstract EntityType |
read(org.codehaus.jackson.JsonNode jn)
Implement this method, read the entity data in the provided
JsonNode and return corresponding java
object. |
public boolean accept(Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Marshaller
Please note it's useless to check that clazz is an instance of EntityType or if generic type and entity type are
compatible (unlike JAX-RS which just checks the clazz, not the generic type). It's also useless to check
Supports
is compatible with mediatype. This is already done by the MarshallerRegistry
This method implementation can use injected properties. So you can check the current RenderingContext
to
accept or reject a marshalling request.
accept
in interface Marshaller<EntityType>
clazz
- The type to marshall.genericType
- The generic type to marshall.mediatype
- The managed mimetype.public EntityType read(Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediaType, InputStream in) throws IOException
Reader
InputStream
using mediatype format.
This method implementation can use injected properties.
read
in interface Reader<EntityType>
clazz
- The requested marshalled class.genericType
- The requested marshalled generic type.in
- The input of this marshaller.IOException
- If some error append while reading entity from in.public abstract EntityType read(org.codehaus.jackson.JsonNode jn) throws IOException
JsonNode
and return corresponding java
object.jn
- A ready to use JsonNode
.IOException
Copyright © 2015 Nuxeo SA. All rights reserved.