public class JacksonHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<com.fasterxml.jackson.databind.JsonNode>, JSONReadHandle, JSONWriteHandle, StructureReadHandle, StructureWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
JacksonHandle()
Zero-argument constructor.
|
JacksonHandle(com.fasterxml.jackson.databind.JsonNode content)
Provides a handle on JSON content as a Jackson 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.fasterxml.jackson.databind.JsonNode |
get()
Returns the root node of the JSON tree.
|
com.fasterxml.jackson.databind.ObjectMapper |
getMapper()
Returns the mapper used to construct node objects from JSON.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a JacksonHandle instance for a JSON node.
|
void |
set(com.fasterxml.jackson.databind.JsonNode 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.
|
JacksonHandle |
with(com.fasterxml.jackson.databind.JsonNode content)
Assigns a JSON tree as the content and returns the handle.
|
void |
write(OutputStream out)
Implements a callback to write content to the provided output stream
for sending to the database server.
|
getByteLength, getFormat, getMimetype, setByteLength, setMimetype
public JacksonHandle()
public JacksonHandle(com.fasterxml.jackson.databind.JsonNode content)
content
- the JSON root node of the tree.public static ContentHandleFactory newFactory()
public com.fasterxml.jackson.databind.ObjectMapper getMapper()
public com.fasterxml.jackson.databind.JsonNode get()
get
in interface ContentHandle<com.fasterxml.jackson.databind.JsonNode>
public void set(com.fasterxml.jackson.databind.JsonNode content)
set
in interface ContentHandle<com.fasterxml.jackson.databind.JsonNode>
content
- the JSON root node.public JacksonHandle with(com.fasterxml.jackson.databind.JsonNode content)
content
- the JSON root node.public void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<InputStream,OutputStreamSender>
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 String toString()
public void write(OutputStream out) throws IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentIOException
Copyright © 2013-2015 MarkLogic Corporation.