T
- The type to wrap.public class JacksonRepresentation<T> extends WriterRepresentation
UNKNOWN_SIZE
Constructor and Description |
---|
JacksonRepresentation(MediaType mediaType,
T object)
Constructor.
|
JacksonRepresentation(Representation representation,
Class<T> objectClass)
Constructor.
|
JacksonRepresentation(T object)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected org.codehaus.jackson.map.ObjectMapper |
createObjectMapper()
Creates a Jackson object mapper based on a media type.
|
T |
getObject()
Returns the wrapped object, deserializing the representation with Jackson
if necessary.
|
Class<T> |
getObjectClass()
Returns the object class to instantiate.
|
org.codehaus.jackson.map.ObjectMapper |
getObjectMapper()
Returns the modifiable Jackson object mapper.
|
void |
setObject(T object)
Sets the object to format.
|
void |
setObjectClass(Class<T> objectClass)
Sets the object class to instantiate.
|
void |
setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
Sets the Jackson object mapper.
|
void |
write(Writer writer)
Writes the representation to a characters writer.
|
getReader
getChannel, getStream, write, write
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
getModificationDate, getTag, setModificationDate, setTag
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
public JacksonRepresentation(MediaType mediaType, T object)
mediaType
- The target media type.object
- The object to format.public JacksonRepresentation(Representation representation, Class<T> objectClass)
representation
- The representation to parse.public JacksonRepresentation(T object)
object
- The object to format.protected org.codehaus.jackson.map.ObjectMapper createObjectMapper()
ObjectMapper.ObjectMapper(JsonFactory)
.public T getObject() throws IOException
IOException
public Class<T> getObjectClass()
public org.codehaus.jackson.map.ObjectMapper getObjectMapper()
public void setObject(T object)
object
- The object to format.public void setObjectClass(Class<T> objectClass)
objectClass
- The object class to instantiate.public void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
objectMapper
- The Jackson object mapper.public void write(Writer writer) throws IOException
Representation
Writer
after writing to it as this will be handled
by the Restlet connectors automatically.write
in class Representation
writer
- The characters writer.IOException
Copyright © 2005–2013. All rights reserved.