ContentDescriptor
,
AbstractReadHandle
,
AbstractWriteHandle
,
BufferableHandle
,
ContentHandle<T>
,
CtsQueryWriteHandle
,
DocumentMetadataReadHandle
,
DocumentMetadataWriteHandle
,
DocumentPatchHandle
,
JSONReadHandle
,
JSONWriteHandle
,
QueryOptionsListReadHandle
,
QueryOptionsReadHandle
,
QueryOptionsWriteHandle
,
RuleListReadHandle
,
RuleReadHandle
,
RuleWriteHandle
,
SearchReadHandle
,
SPARQLResultsReadHandle
,
StructureReadHandle
,
StructureWriteHandle
,
TextReadHandle
,
TextWriteHandle
,
TriplesReadHandle
,
TriplesWriteHandle
,
TuplesReadHandle
,
ValuesListReadHandle
,
ValuesReadHandle
,
XMLReadHandle
,
XMLWriteHandle
,
OutputStreamSender
public class JacksonDatabindHandle<T> extends com.marklogic.client.impl.JacksonBaseHandle<T> implements ContentHandle<T>, OutputStreamSender, BufferableHandle, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle
UNKNOWN_LENGTH
Constructor | 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 | 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(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.
|
static ContentHandleFactory |
newFactory(java.lang.Class<?>... pojoClasses) |
Creates a factory to create a
JacksonDatabindHandle instance for POJO instances of the specified
classes.
|
protected void |
receiveContent(java.io.InputStream 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.
|
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.
|
void |
write(java.io.OutputStream out) |
Implements a callback to write content to the
provided output stream for sending to the database server.
|
getByteLength,
getFormat,
getMimetype,
getServerTimestamp,
setByteLength,
setFormat,
setMimetype,
setServerTimestamp
fromBuffer,
toBuffer
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
public 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 T get()
get
in interface ContentHandle<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 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>
protected void receiveContent(java.io.InputStream content)
receiveContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected boolean hasContent()
hasContent
in
class com.marklogic.client.impl.JacksonBaseHandle<T>
public void write(java.io.OutputStream out) throws java.io.IOException
OutputStreamSender
write
in interface OutputStreamSender
write
in
class com.marklogic.client.impl.JacksonBaseHandle<T>
out
- the output stream receiving the contentjava.io.IOException
- if io problems ariseCopyright © 2013-2019 MarkLogic Corporation.