public class GsonRepresentation<T> extends WriterRepresentation
UNKNOWN_SIZE
Constructor and Description |
---|
GsonRepresentation(Representation representation,
Class<T> objectClass)
Constructor.
|
GsonRepresentation(T object)
Constructor for the JSON media type.
|
Modifier and Type | Method and Description |
---|---|
protected com.google.gson.GsonBuilder |
createBuilder()
Returns a new instance of the builder for Gson instances.
|
com.google.gson.GsonBuilder |
getBuilder()
Returns the builder for Gson instances.
|
T |
getObject()
Returns the wrapped object, deserializing the representation with Gson if
necessary.
|
Class<T> |
getObjectClass()
Returns the object class to instantiate.
|
void |
setBuilder(com.google.gson.GsonBuilder builder)
Sets the Gson builder.
|
void |
setObject(T object)
Sets the object to format.
|
void |
setObjectClass(Class<T> objectClass)
Sets the object class to instantiate.
|
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 GsonRepresentation(Representation representation, Class<T> objectClass)
representation
- The representation to parse.objectClass
- The object class to instantiate.public GsonRepresentation(T object)
object
- The object to format.protected com.google.gson.GsonBuilder createBuilder()
public com.google.gson.GsonBuilder getBuilder()
public T getObject() throws IOException
IOException
public Class<T> getObjectClass()
public void setBuilder(com.google.gson.GsonBuilder builder)
builder
- The Gson builder.public void setObject(T object)
object
- The object to format.public void setObjectClass(Class<T> objectClass)
objectClass
- The object class to instantiate.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–2015. All rights reserved.