All Implemented Interfaces:
ContentDescriptor ,
AbstractReadHandle ,
AbstractWriteHandle ,
BinaryReadHandle ,
BinaryWriteHandle ,
BufferableContentHandle <byte[], byte[]>,
BufferableHandle ,
ContentHandle <byte[]>,
CtsQueryWriteHandle ,
DocumentMetadataReadHandle ,
DocumentMetadataWriteHandle ,
DocumentPatchHandle ,
GenericReadHandle ,
GenericWriteHandle ,
JSONReadHandle ,
JSONWriteHandle ,
QuadsWriteHandle ,
QueryOptionsListReadHandle ,
QueryOptionsReadHandle ,
QueryOptionsWriteHandle ,
ResendableContentHandle <byte[], byte[]>,
RuleListReadHandle ,
RuleReadHandle ,
RuleWriteHandle ,
SearchReadHandle ,
SPARQLResultsReadHandle ,
StructureReadHandle ,
StructureWriteHandle ,
TextReadHandle ,
TextWriteHandle ,
TriplesReadHandle ,
TriplesWriteHandle ,
TuplesReadHandle ,
ValuesListReadHandle ,
ValuesReadHandle ,
XMLReadHandle ,
XMLWriteHandle
public class BytesHandle extends BaseHandle <byte[], byte[]>
implements ResendableContentHandle <byte[], byte[]>, BinaryReadHandle , BinaryWriteHandle , GenericReadHandle , GenericWriteHandle , JSONReadHandle , JSONWriteHandle , TextReadHandle , TextWriteHandle , XMLReadHandle , XMLWriteHandle , StructureReadHandle , StructureWriteHandle , CtsQueryWriteHandle , QuadsWriteHandle , TriplesReadHandle , TriplesWriteHandle
A Bytes Handle represents document content as a
byte array for reading or writing. When writing JSON, text, or XML
content, you should use a byte[] array only if the bytes are
encoded in UTF-8. If the characters have a different encoding, use
a StringHandle and specify the correct character encoding for the
bytes when creating the String.
Field Summary
Constructor Summary
Constructors
Zero-argument constructor.
Initializes the handle with a byte array for the
content.
Initializes the handle from the byte content of
another handle
Initializes the handle by reading a byte array
from an input stream.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
byte[]
Converts a byte serialization to the content
representation.
byte[]
Converts the content representation to
bytes.
Assigns a byte array by reading all bytes from
an input stream and returns the handle as a fluent
convenience.
void
Sets the content of the handle by copying from a
byte array buffer encoded in UTF-8.
byte[]
Returns the byte array for the handle
content.
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
byte[][]
Constructs an array for the handled content
representation
Creates a factory to create a BytesHandle
instance for a byte[] array.
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
protected byte[]
void
Assigns a byte array as the content.
byte[]
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
byte[]
Converts the serialization to the content
representation.
Returns a byte array as a string with the
assumption that the bytes are encoded in UTF-8.
Assigns a byte array 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
BytesHandle
public BytesHandle ()
Zero-argument constructor.
BytesHandle
public BytesHandle (byte[] content)
Initializes the handle with a byte array for the
content.
Parameters:
content - the byte array
BytesHandle
Initializes the handle by reading a byte array
from an input stream.
Parameters:
content - the input stream with the content
BytesHandle
Initializes the handle from the byte content of
another handle
Parameters:
content - the other handle
Method Details
newFactory
Creates a factory to create a BytesHandle
instance for a byte[] array.
Returns:
the factory
get
public byte[] get ()
Returns the byte array for the handle
content.
Specified by:
get in
interface ContentHandle <byte[]>
Returns:
the byte array
set
public void set (byte[] content)
Assigns a byte array as the content.
Specified by:
set in
interface ContentHandle <byte[]>
Parameters:
content - the byte array
from
Assigns a byte array by reading all bytes from
an input stream and returns the handle as a fluent
convenience.
Parameters:
content - the input stream with the content
Returns:
this handle
with
Assigns a byte array as the content and returns
the handle as a fluent convenience.
Parameters:
content - the byte array
Returns:
this handle
getContentClass
public Class <byte[]> 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 <byte[]>
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 <byte[], byte[]>
Specified by:
newHandle in
interface ContentHandle <byte[]>
Specified by:
newHandle in
interface ResendableContentHandle <byte[], byte[]>
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 <byte[], byte[]>
Specified by:
newHandleArray in
interface ResendableContentHandle <byte[], byte[]>
Parameters:
length - the number of positions in the array
Returns:
the uninitialized array
newArray
public byte[][] newArray (int length)
Constructs an array for the handled content
representation
Specified by:
newArray in
interface ContentHandle <byte[]>
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
public byte[] toContent (byte[] serialization)
Converts the serialization to the content
representation.
Specified by:
toContent in
interface BufferableContentHandle <byte[], byte[]>
Parameters:
serialization - a serialization of the
content
Returns:
the content representation
bytesToContent
public byte[] bytesToContent (byte[] buffer)
Converts a byte serialization to the content
representation.
Specified by:
bytesToContent in
interface BufferableContentHandle <byte[], byte[]>
Parameters:
buffer - the byte serialization
Returns:
the content representation
contentToBytes
public byte[] contentToBytes (byte[] content)
Converts the content representation to
bytes.
Specified by:
contentToBytes in
interface BufferableContentHandle <byte[], byte[]>
Parameters:
content - the content
Returns:
the byte serialization of the content
toString
Returns a byte array as a string with the
assumption that the bytes are encoded in UTF-8. If the bytes have a
different encoding, instantiate a String directly instead of
calling this method.
Overrides:
toString in
class Object
receiveAs
protected Class <byte[]> receiveAs ()
Overrides:
receiveAs in
class com.marklogic.client.impl.HandleImplementation<byte[], byte[]>
receiveContent
protected void receiveContent (byte[] content)
Overrides:
receiveContent in
class com.marklogic.client.impl.HandleImplementation<byte[], byte[]>
sendContent
protected byte[] sendContent ()
Overrides:
sendContent in
class com.marklogic.client.impl.HandleImplementation<byte[], byte[]>
Copyright (c) 2010-2025 Progress
Software Corporation and/or its subsidiaries or affiliates. All
Rights Reserved.