public class GsonRepresentation<T> extends WriterRepresentation
UNKNOWN_SIZE| Constructor and Description |
|---|
GsonRepresentation(Representation representation,
java.lang.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.
|
java.lang.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(java.lang.Class<T> objectClass)
Sets the object class to instantiate.
|
void |
write(java.io.Writer writer) |
getReadergetChannel, getStream, write, writeappend, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransientgetModificationDate, getTag, setModificationDate, setTagcreateClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toStringpublic GsonRepresentation(Representation representation, java.lang.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 java.io.IOException
java.io.IOExceptionpublic java.lang.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(java.lang.Class<T> objectClass)
objectClass - The object class to instantiate.public void write(java.io.Writer writer)
throws java.io.IOException
write in class Representationjava.io.IOExceptionCopyright © 2005-2024 Restlet.