public class JacksonDatabindHandle<T> extends com.marklogic.client.impl.JacksonBaseHandle<T> implements ResendableContentHandle<T,java.io.InputStream>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle
UNKNOWN_LENGTH| Constructor and Description |
|---|
JacksonDatabindHandle(java.lang.Class<T> contentClass)
Specify the type of content this
JacksonDatabindHandle will manage.
|
JacksonDatabindHandle(T content)
Provides a handle on POJO content.
|
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Returns the content.
|
java.lang.Class<T> |
getContentClass()
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
com.fasterxml.jackson.databind.ObjectMapper |
getMapper()
Provides access to the ObjectMapper used
internally so you can configure it to fit your JSON.
|
protected boolean |
hasContent() |
static ContentHandleFactory |
newFactory(java.lang.Class<?>... pojoClasses)
Creates a factory to create a
JacksonDatabindHandle instance for POJO instances of the specified
classes.
|
static ContentHandleFactory |
newFactory(com.fasterxml.jackson.databind.ObjectMapper mapper,
java.lang.Class<?>... pojoClasses)
Creates a factory to create a
JacksonDatabindHandle instance for POJO instances of the specified
classes.
|
JacksonDatabindHandle<T> |
newHandle()
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
JacksonDatabindHandle<T>[] |
newHandleArray(int length)
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
protected void |
receiveContent(java.io.InputStream content) |
protected OutputStreamSender |
sendContent() |
protected OutputStreamSender |
sendContent(T content) |
void |
set(T content)
Assigns your custom POJO as the content.
|
void |
setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Enables clients to specify their own
ObjectMapper instance, including databinding mappers for formats
other than JSON.
|
T |
toContent(java.io.InputStream serialization)
Converts the serialization to the content
representation.
|
JacksonDatabindHandle<T> |
with(T content)
Assigns a your custom POJO as the content and
returns the handle.
|
JacksonDatabindHandle<T> |
withFormat(Format format)
Specifies the format of the content and returns
the handle as a fluent convenience.
|
JacksonDatabindHandle<T> |
withMimetype(java.lang.String mimetype)
Specifies the mime type of the content and
returns the handle as a fluent convenience.
|
void |
write(java.io.OutputStream out)
Implements a callback to write content to the
provided output stream for sending to the database server.
|
bytesToContent, contentToBytes, fromBuffer, receiveAs,
toBuffer, toStringgetByteLength,
getFormat,
getMimetype,
getServerTimestamp,
setByteLength,
setFormat,
setMimetype,
setServerTimestampgetPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestampclone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, waitnewHandle,
resendableHandleForbytesToContent,
contentToBytes,
resendableHandleForfromBuffer,
toBuffernewArraypublic JacksonDatabindHandle(java.lang.Class<T> contentClass)
contentClass - the class of your custom POJO for
databindingpublic JacksonDatabindHandle(T content)
content - the POJO which should be serializedpublic static ContentHandleFactory newFactory(java.lang.Class<?>... pojoClasses)
pojoClasses - the POJO classes for which this
factory provides a handlepublic static ContentHandleFactory newFactory(com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.Class<?>... pojoClasses)
mapper - the Jackson ObjectMapper for marshaling
the POJO classespojoClasses - the POJO classes for which this
factory provides a handlepublic JacksonDatabindHandle<T> withFormat(Format format)
format - the format of the contentpublic JacksonDatabindHandle<T> withMimetype(java.lang.String mimetype)
mimetype - the mime type of the contentpublic T get()
get in interface ContentHandle<T>get in
class com.marklogic.client.impl.JacksonBaseHandle<T>JacksonDatabindHandle(Object) or
set(Object) or if the content is being
de-serialized, a pojo of the specified type populated with the
datapublic void set(T content)
set in interface ContentHandle<T>set in
class com.marklogic.client.impl.JacksonBaseHandle<T>content - your custom POJOpublic JacksonDatabindHandle<T> with(T content)
content - your custom POJOpublic java.lang.Class<T> getContentClass()
ContentHandle
getContentClass in interface ContentHandle<T>public JacksonDatabindHandle<T> newHandle()
ContentHandle
newHandle in interface BufferableContentHandle<T,java.io.InputStream>
newHandle in interface ContentHandle<T>
newHandle in interface ResendableContentHandle<T,java.io.InputStream>public JacksonDatabindHandle<T>[] newHandleArray(int length)
BufferableContentHandle
newHandleArray in interface BufferableContentHandle<T,java.io.InputStream>
newHandleArray in interface ResendableContentHandle<T,java.io.InputStream>length - the number of positions in the arraypublic com.fasterxml.jackson.databind.ObjectMapper getMapper()
getMapper in
class com.marklogic.client.impl.JacksonBaseHandle<T>public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
ObjectMapper mapper = new CsvMapper();
mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
mapper.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
handle.setMapper(mapper);
Use at your own risk! Note that you most likely want to set to
false the two options we demonstrate above
(JsonGenerator.Feature.AUTO_CLOSE_TARGET and
JsonParser.Feature.AUTO_CLOSE_SOURCE) as we do so your mapper will
not close streams which we may need to reuse if we have to resend a
network request.setMapper in
class com.marklogic.client.impl.JacksonBaseHandle<T>public T toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent in interface BufferableContentHandle<T,java.io.InputStream>toContent in
class com.marklogic.client.impl.JacksonBaseHandle<T>serialization - a serialization of the
contentprotected boolean hasContent()
hasContent in
class com.marklogic.client.impl.JacksonBaseHandle<T>protected OutputStreamSender sendContent()
sendContent in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>protected OutputStreamSender sendContent(T content)
sendContent in
class com.marklogic.client.impl.JacksonBaseHandle<T>protected void receiveContent(java.io.InputStream content)
receiveContent in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
public void write(java.io.OutputStream out)
throws java.io.IOException
OutputStreamSender
write in interface OutputStreamSenderout - the output stream receiving the contentjava.io.IOException - if io problems ariseCopyright © 2024 MarkLogic Corporation. All Rights Reserved.