public class ReaderHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<java.io.Reader>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle, QuadsWriteHandle, TriplesReadHandle, TriplesWriteHandle, java.io.Closeable
UNKNOWN_LENGTH
Constructor and Description |
---|
ReaderHandle()
Zero-argument constructor.
|
ReaderHandle(java.io.Reader content)
Initializes the handle with a character reader for the content.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Either call close() or get().close() when finished with this handle to close the underlying Reader.
|
void |
fromBuffer(byte[] buffer)
Sets the content of the handle by copying from a byte array buffer
encoded in UTF-8.
|
java.io.Reader |
get()
Returns a character reader for reading content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a ReaderHandle instance for a Reader.
|
protected java.lang.Class<java.io.InputStream> |
receiveAs() |
protected void |
receiveContent(java.io.InputStream content) |
protected ReaderHandle |
sendContent() |
void |
set(java.io.Reader content)
Assigns an character reader as the content.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer
encoded in UTF-8.
|
java.lang.String |
toString()
Buffers the character stream and returns the buffer as a string.
|
ReaderHandle |
with(java.io.Reader content)
Assigns a character reader as the content and returns the handle
as a fluent convenience.
|
ReaderHandle |
withFormat(Format format)
Specifies the format of the content and returns the handle
as a fluent convenience.
|
ReaderHandle |
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.
|
getByteLength, getFormat, getMimetype, getServerTimestamp, setByteLength, setFormat, setMimetype, setServerTimestamp
public ReaderHandle()
public ReaderHandle(java.io.Reader content)
content
- a character readerpublic static ContentHandleFactory newFactory()
public java.io.Reader get()
get
in interface ContentHandle<java.io.Reader>
public void set(java.io.Reader content)
set
in interface ContentHandle<java.io.Reader>
content
- a readerpublic ReaderHandle with(java.io.Reader content)
content
- a readerpublic ReaderHandle withFormat(Format format)
format
- the format of the contentpublic ReaderHandle withMimetype(java.lang.String mimetype)
mimetype
- the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandle
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.Class<java.io.InputStream> receiveAs()
receiveAs
in class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected void receiveContent(java.io.InputStream content)
receiveContent
in class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected ReaderHandle sendContent()
sendContent
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 OutputStreamSender
out
- the output stream receiving the contentjava.io.IOException
- if io problems arisepublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
Copyright © 2013-2018 MarkLogic Corporation.