public class GSONHandle extends BaseHandle<java.io.InputStream,java.lang.String> implements ResendableContentHandle<com.google.gson.JsonElement,java.io.InputStream>, 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 |
---|---|
com.google.gson.JsonElement |
bytesToContent(byte[] buffer)
Converts a byte serialization to the content
representation.
|
byte[] |
contentToBytes(com.google.gson.JsonElement content)
Converts the content representation to
bytes.
|
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.
|
java.lang.Class<com.google.gson.JsonElement> |
getContentClass()
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
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.
|
GSONHandle |
newHandle()
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
GSONHandle[] |
newHandleArray(int length)
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
protected
java.lang.Class<java.io.InputStream> |
receiveAs() |
protected void |
receiveContent(java.io.InputStream serialization) |
protected java.lang.String |
sendContent() |
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.
|
com.google.gson.JsonElement |
toContent(java.io.InputStream serialization)
Converts the serialization to the content
representation.
|
java.lang.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,
getServerTimestamp,
setByteLength,
setMimetype,
setServerTimestamp
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait
newHandle,
resendableHandleFor
resendableHandleFor
newArray
public GSONHandle()
public GSONHandle(com.google.gson.JsonElement content)
content
- the JSON root element of the tree.public static ContentHandleFactory newFactory()
public GSONHandle newHandle()
ContentHandle
newHandle
in interface BufferableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
newHandle
in interface ContentHandle<com.google.gson.JsonElement>
newHandle
in interface ResendableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
public GSONHandle[] newHandleArray(int length)
BufferableContentHandle
newHandleArray
in interface BufferableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
newHandleArray
in interface ResendableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
length
- the number of positions in the arraypublic 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 java.lang.Class<com.google.gson.JsonElement> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<com.google.gson.JsonElement>
public void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<java.io.InputStream,java.lang.String>
format
- the format of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandle
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public com.google.gson.JsonElement bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
buffer
- the byte serializationpublic byte[] contentToBytes(com.google.gson.JsonElement content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
content
- the contentpublic java.lang.String toString()
toString
in
class java.lang.Object
public com.google.gson.JsonElement toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<com.google.gson.JsonElement,java.io.InputStream>
serialization
- a serialization of the
contentprotected java.lang.Class<java.io.InputStream> receiveAs()
receiveAs
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,java.lang.String>
protected void receiveContent(java.io.InputStream serialization)
receiveContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,java.lang.String>
protected java.lang.String sendContent()
sendContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,java.lang.String>
Copyright © 2024 MarkLogic Corporation. All Rights Reserved.