public class GSONHandle extends BaseHandle<InputStream,String> implements BufferableHandle, ContentHandle<com.google.gson.JsonElement>, JSONReadHandle, JSONWriteHandle, StructureReadHandle, StructureWriteHandle
UNKNOWN_LENGTH| Constructor and Description |
|---|
GSONHandle()
Zero-argument constructor.
|
GSONHandle(com.google.gson.JsonElement content)
Provides a handle on JSON content as a tree.
|
| Modifier and Type | Method and Description |
|---|---|
void |
fromBuffer(byte[] buffer)
Sets the content of the handle by copying from a byte array buffer
encoded in UTF-8.
|
com.google.gson.JsonElement |
get()
Returns the root node of the JSON tree.
|
com.google.gson.JsonParser |
getParser()
Returns the parser used to construct element objects from JSON.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a GSONHandle instance for a JsonElement node.
|
void |
set(com.google.gson.JsonElement content)
Assigns a JSON tree as the content.
|
void |
setFormat(Format format)
Restricts the format to JSON.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer
encoded in UTF-8.
|
String |
toString()
Returns the JSON tree as a string.
|
GSONHandle |
with(com.google.gson.JsonElement content)
Assigns a JSON tree as the content and returns the handle.
|
getByteLength, getFormat, getMimetype, setByteLength, setMimetypepublic GSONHandle()
public GSONHandle(com.google.gson.JsonElement content)
content - the JSON root element of the tree.public static ContentHandleFactory newFactory()
public com.google.gson.JsonParser getParser()
public com.google.gson.JsonElement get()
get in interface ContentHandle<com.google.gson.JsonElement>public void set(com.google.gson.JsonElement content)
set in interface ContentHandle<com.google.gson.JsonElement>content - the JSON root element.public GSONHandle with(com.google.gson.JsonElement content)
content - the JSON root element.public void setFormat(Format format)
setFormat in interface ContentDescriptorsetFormat in class BaseHandle<InputStream,String>format - the format of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandlefromBuffer in interface BufferableHandlebuffer - the byte arraypublic byte[] toBuffer()
BufferableHandletoBuffer in interface BufferableHandleCopyright © 2013-2016 MarkLogic Corporation.