All Implemented Interfaces:
ContentDescriptor ,
AbstractReadHandle ,
AbstractWriteHandle ,
BufferableContentHandle <Reader ,InputStream >, BufferableHandle ,
ContentHandle <Reader >, CtsQueryWriteHandle ,
DocumentMetadataReadHandle ,
DocumentMetadataWriteHandle ,
DocumentPatchHandle ,
JSONReadHandle ,
JSONWriteHandle ,
QuadsWriteHandle ,
QueryOptionsListReadHandle ,
QueryOptionsReadHandle ,
QueryOptionsWriteHandle ,
RuleListReadHandle ,
RuleReadHandle ,
RuleWriteHandle ,
SearchReadHandle ,
SPARQLResultsReadHandle ,
StreamingContentHandle <Reader ,InputStream >, StructureReadHandle ,
StructureWriteHandle ,
TextReadHandle ,
TextWriteHandle ,
TriplesReadHandle ,
TriplesWriteHandle ,
TuplesReadHandle ,
ValuesListReadHandle ,
ValuesReadHandle ,
XMLReadHandle ,
XMLWriteHandle ,
OutputStreamSender ,
Closeable , AutoCloseable
public class ReaderHandle extends BaseHandle <InputStream ,OutputStreamSender >
implements OutputStreamSender , StreamingContentHandle <Reader ,InputStream >, JSONReadHandle , JSONWriteHandle , TextReadHandle , TextWriteHandle , XMLReadHandle , XMLWriteHandle , StructureReadHandle , StructureWriteHandle , CtsQueryWriteHandle , QuadsWriteHandle , TriplesReadHandle , TriplesWriteHandle , Closeable
A Reader Handle represents a character content as a reader for
reading to or writing from the database.
Either call close() or
get() .close() when finished with
this handle to release the resources.
Field Summary
Constructor Summary
Constructors
Zero-argument constructor.
Initializes the handle with a character reader
for the content.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Converts a byte serialization to the content
representation.
void
Either call close() or get().close() when
finished with this handle to close the underlying Reader.
byte[]
Converts the content representation to
bytes.
void
Sets the content of the handle by copying from a
byte array buffer encoded in UTF-8.
Returns a character reader for reading
content.
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
Constructs an array for the handled content
representation
Creates a factory to create a ReaderHandle
instance for a Reader.
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
Constructs an uninitialized array with the
specified length with items of the same content
representation.
protected void
void
Assigns an character reader as the
content.
byte[]
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
Converts the serialization to the content
representation.
Buffers the character stream and returns the
buffer as a string.
Assigns a character reader as the content and
returns the handle as a fluent convenience.
Specifies the format of the content and returns
the handle as a fluent convenience.
Specifies the mime type of the content and
returns the handle as a fluent convenience.
void
Implements a callback to write content to the
provided output stream for sending to the database server.
Methods inherited from
class com.marklogic.client.impl.HandleImplementation
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
Constructor Details
Method Details
newFactory
Creates a factory to create a ReaderHandle
instance for a Reader.
Returns:
the factory
get
Returns a character reader for reading content.
When finished with the reader, close the reader to release the
resource.
Specified by:
get in
interface ContentHandle <Reader >
Returns:
the character reader
set
public void set (Reader content)
Assigns an character reader as the
content.
Specified by:
set in
interface ContentHandle <Reader >
Parameters:
content - a reader
with
Assigns a character reader as the content and
returns the handle as a fluent convenience.
Parameters:
content - a reader
Returns:
this handle
getContentClass
Returns the class of the handled content, which
may be a base class of the actual class of a content object. Note
that implementations should override the default method, which
returns null if the handle doesn't have any content.
Specified by:
getContentClass in
interface ContentHandle <Reader >
Returns:
the class for the handled content
newHandle
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
Specified by:
newHandle in
interface BufferableContentHandle <Reader ,InputStream >
Specified by:
newHandle in
interface ContentHandle <Reader >
Returns:
the new handle
newHandleArray
Constructs an uninitialized array with the
specified length with items of the same content
representation.
Specified by:
newHandleArray in
interface BufferableContentHandle <Reader ,InputStream >
Parameters:
length - the number of positions in the array
Returns:
the uninitialized array
newArray
public Reader [] newArray (int length)
Constructs an array for the handled content
representation
Specified by:
newArray in
interface ContentHandle <Reader >
Parameters:
length - the size of the array (zero or more)
Returns:
the constructed array
withFormat
Specifies the format of the content and returns
the handle as a fluent convenience.
Parameters:
format - the format of the content
Returns:
this handle
withMimetype
Specifies the mime type of the content and
returns the handle as a fluent convenience.
Parameters:
mimetype - the mime type of the content
Returns:
this handle
fromBuffer
public void fromBuffer (byte[] buffer)
Sets the content of the handle by copying from a
byte array buffer encoded in UTF-8.
Specified by:
fromBuffer in
interface BufferableHandle
Parameters:
buffer - the byte array
toBuffer
public byte[] toBuffer ()
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
Specified by:
toBuffer in
interface BufferableHandle
Returns:
the byte array
toContent
Converts the serialization to the content
representation.
Specified by:
toContent in
interface BufferableContentHandle <Reader ,InputStream >
Parameters:
serialization - a serialization of the
content
Returns:
the content representation
bytesToContent
public Reader bytesToContent (byte[] buffer)
Converts a byte serialization to the content
representation.
Specified by:
bytesToContent in
interface BufferableContentHandle <Reader ,InputStream >
Parameters:
buffer - the byte serialization
Returns:
the content representation
contentToBytes
public byte[] contentToBytes (Reader content)
Converts the content representation to
bytes.
Specified by:
contentToBytes in
interface BufferableContentHandle <Reader ,InputStream >
Parameters:
content - the content
Returns:
the byte serialization of the content
toString
Buffers the character stream and returns the
buffer as a string.
Overrides:
toString in
class Object
receiveAs
Overrides:
receiveAs in
class com.marklogic.client.impl.HandleImplementation<InputStream ,OutputStreamSender >
receiveContent
Overrides:
receiveContent in
class com.marklogic.client.impl.HandleImplementation<InputStream ,OutputStreamSender >
sendContent
Overrides:
sendContent in
class com.marklogic.client.impl.HandleImplementation<InputStream ,OutputStreamSender >
write
Implements a callback to write content to the
provided output stream for sending to the database server.
Specified by:
write in
interface OutputStreamSender
Parameters:
out - the output stream receiving the content
Throws:
IOException - if io problems arise
close
public void close ()
Either call close() or get().close() when
finished with this handle to close the underlying Reader.
Specified by:
close in
interface AutoCloseable
Specified by:
close in
interface Closeable
Copyright (c) 2010-2025 Progress
Software Corporation and/or its subsidiaries or affiliates. All
Rights Reserved.