public class ReaderHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<Reader>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, QuadsWriteHandle, TriplesReadHandle, TriplesWriteHandle, Closeable
UNKNOWN_LENGTH| Constructor and Description |
|---|
ReaderHandle()
Zero-argument constructor.
|
ReaderHandle(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.
|
Reader |
get()
Returns a character reader for reading content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a ReaderHandle instance for a Reader.
|
void |
set(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.
|
String |
toString()
Buffers the character stream and returns the buffer as a string.
|
ReaderHandle |
with(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(String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
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, setFormat, setMimetypepublic ReaderHandle()
public ReaderHandle(Reader content)
content - a character readerpublic static ContentHandleFactory newFactory()
public Reader get()
get in interface ContentHandle<Reader>public void set(Reader content)
set in interface ContentHandle<Reader>content - a readerpublic ReaderHandle with(Reader content)
content - a readerpublic ReaderHandle withFormat(Format format)
format - the format of the contentpublic ReaderHandle withMimetype(String mimetype)
mimetype - the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandlefromBuffer in interface BufferableHandlebuffer - the byte arraypublic byte[] toBuffer()
BufferableHandletoBuffer in interface BufferableHandlepublic String toString()
public void write(OutputStream out) throws IOException
OutputStreamSenderwrite in interface OutputStreamSenderout - the output stream receiving the contentIOException - if io problems arisepublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2013-2016 MarkLogic Corporation.