All Implemented Interfaces:
ContentDescriptor ,
AbstractReadHandle ,
AbstractWriteHandle ,
BinaryReadHandle ,
BinaryWriteHandle ,
BufferableContentHandle <InputStream ,InputStream >, BufferableHandle ,
ContentHandle <InputStream >, CtsQueryWriteHandle ,
DocumentMetadataReadHandle ,
DocumentMetadataWriteHandle ,
DocumentPatchHandle ,
GenericReadHandle ,
GenericWriteHandle ,
JSONReadHandle ,
JSONWriteHandle ,
QuadsWriteHandle ,
QueryOptionsListReadHandle ,
QueryOptionsReadHandle ,
QueryOptionsWriteHandle ,
RuleListReadHandle ,
RuleReadHandle ,
RuleWriteHandle ,
SearchReadHandle ,
SPARQLResultsReadHandle ,
StreamingContentHandle <InputStream ,InputStream >, StructureReadHandle ,
StructureWriteHandle ,
TextReadHandle ,
TextWriteHandle ,
TriplesReadHandle ,
TriplesWriteHandle ,
TuplesReadHandle ,
ValuesListReadHandle ,
ValuesReadHandle ,
XMLReadHandle ,
XMLWriteHandle ,
Closeable , AutoCloseable
public class InputStreamHandle
extends BaseHandle <InputStream ,InputStream >
implements StreamingContentHandle <InputStream ,InputStream >, BinaryReadHandle , BinaryWriteHandle , GenericReadHandle , GenericWriteHandle , JSONReadHandle , JSONWriteHandle , TextReadHandle , TextWriteHandle , XMLReadHandle , XMLWriteHandle , StructureReadHandle , StructureWriteHandle , CtsQueryWriteHandle , TriplesReadHandle , TriplesWriteHandle , QuadsWriteHandle , SPARQLResultsReadHandle , Closeable
An InputStreamHandle represents a resource as an InputStream for
reading or writing.
When writing JSON, text, or XML content, you should use an
InputStream only if the stream is encoded in UTF-8. If the
characters have a different encoding, use a ReaderHandle
and specify the correct character encoding for the stream when
creating the Reader.
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 an input stream 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
InputStream.
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 an input stream for a resource read from
the database.
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 an InputStreamHandle
instance for an input stream.
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 input stream 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 input stream and returns the buffer
as a string with the assumption that the stream is encoded in
UTF-8.
Assigns an input stream 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.
Methods inherited from
class com.marklogic.client.impl.HandleImplementation
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
Constructor Details
InputStreamHandle
public InputStreamHandle ()
Zero-argument constructor.
InputStreamHandle
Initializes the handle with an input stream for
the content.
Parameters:
content - an input stream
Method Details
newFactory
Creates a factory to create an InputStreamHandle
instance for an input stream.
Returns:
the factory
get
Returns an input stream for a resource read from
the database. When finished with the input stream, close the input
stream to release the response.
Specified by:
get in
interface ContentHandle <InputStream >
Returns:
the input stream
set
Assigns an input stream as the content.
Specified by:
set in
interface ContentHandle <InputStream >
Parameters:
content - an input stream
with
Assigns an input stream as the content and
returns the handle as a fluent convenience.
Parameters:
content - an input stream
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 <InputStream >
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 <InputStream ,InputStream >
Specified by:
newHandle in
interface ContentHandle <InputStream >
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 <InputStream ,InputStream >
Parameters:
length - the number of positions in the array
Returns:
the uninitialized array
newArray
Constructs an array for the handled content
representation
Specified by:
newArray in
interface ContentHandle <InputStream >
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
bytesToContent
Converts a byte serialization to the content
representation.
Specified by:
bytesToContent in
interface BufferableContentHandle <InputStream ,InputStream >
Parameters:
buffer - the byte serialization
Returns:
the content representation
contentToBytes
Converts the content representation to
bytes.
Specified by:
contentToBytes in
interface BufferableContentHandle <InputStream ,InputStream >
Parameters:
content - the content
Returns:
the byte serialization of the content
toContent
Converts the serialization to the content
representation.
Specified by:
toContent in
interface BufferableContentHandle <InputStream ,InputStream >
Parameters:
serialization - a serialization of the
content
Returns:
the content representation
toString
Buffers the input stream and returns the buffer
as a string with the assumption that the stream is encoded in
UTF-8. If the stream has a different encoding, use
InputStreamReader instead of calling this method.
Overrides:
toString in
class Object
receiveAs
Overrides:
receiveAs in
class com.marklogic.client.impl.HandleImplementation<InputStream ,InputStream >
receiveContent
Overrides:
receiveContent in
class com.marklogic.client.impl.HandleImplementation<InputStream ,InputStream >
sendContent
Overrides:
sendContent in
class com.marklogic.client.impl.HandleImplementation<InputStream ,InputStream >
close
public void close ()
Either call close() or get().close() when
finished with this handle to close the underlying
InputStream.
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.