public class ReaderHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<Reader>, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle
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 |
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, setMimetype
public 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)
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.