public class ReaderHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements OutputStreamSender, StreamingContentHandle<java.io.Reader,java.io.InputStream>, 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 |
---|---|
java.io.Reader |
bytesToContent(byte[] buffer)
Converts a byte serialization to the content
representation.
|
void |
close()
Either call close() or get().close() when
finished with this handle to close the underlying Reader.
|
byte[] |
contentToBytes(java.io.Reader content)
Converts the content representation to
bytes.
|
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.
|
java.lang.Class<java.io.Reader> |
getContentClass()
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
java.io.Reader[] |
newArray(int length)
Constructs an array for the handled content
representation
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a ReaderHandle
instance for a Reader.
|
ReaderHandle |
newHandle()
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
ReaderHandle[] |
newHandleArray(int length)
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
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.io.Reader |
toContent(java.io.InputStream serialization)
Converts the serialization to the content
representation.
|
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
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait
resendableHandleFor
newHandle,
resendableHandleFor
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 java.lang.Class<java.io.Reader> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<java.io.Reader>
public ReaderHandle newHandle()
ContentHandle
newHandle
in interface BufferableContentHandle<java.io.Reader,java.io.InputStream>
newHandle
in interface ContentHandle<java.io.Reader>
public ReaderHandle[] newHandleArray(int length)
BufferableContentHandle
newHandleArray
in interface BufferableContentHandle<java.io.Reader,java.io.InputStream>
length
- the number of positions in the arraypublic java.io.Reader[] newArray(int length)
ContentHandle
newArray
in interface ContentHandle<java.io.Reader>
length
- the size of the array (zero or more)public 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.io.Reader toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<java.io.Reader,java.io.InputStream>
serialization
- a serialization of the
contentpublic java.io.Reader bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<java.io.Reader,java.io.InputStream>
buffer
- the byte serializationpublic byte[] contentToBytes(java.io.Reader content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<java.io.Reader,java.io.InputStream>
content
- the contentpublic 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 © 2024 MarkLogic Corporation. All Rights Reserved.