All Implemented Interfaces:
ContentDescriptor ,
AbstractReadHandle ,
AbstractWriteHandle ,
BinaryReadHandle ,
BinaryWriteHandle ,
BufferableContentHandle <File ,File >, BufferableHandle ,
ContentHandle <File >, CtsQueryWriteHandle ,
DocumentMetadataReadHandle ,
DocumentMetadataWriteHandle ,
DocumentPatchHandle ,
GenericReadHandle ,
GenericWriteHandle ,
JSONReadHandle ,
JSONWriteHandle ,
QuadsWriteHandle ,
QueryOptionsListReadHandle ,
QueryOptionsReadHandle ,
QueryOptionsWriteHandle ,
ResendableContentHandle <File ,File >, RuleListReadHandle ,
RuleReadHandle ,
RuleWriteHandle ,
SearchReadHandle ,
SPARQLResultsReadHandle ,
StructureReadHandle ,
StructureWriteHandle ,
TextReadHandle ,
TextWriteHandle ,
TriplesReadHandle ,
TriplesWriteHandle ,
TuplesReadHandle ,
ValuesListReadHandle ,
ValuesReadHandle ,
XMLReadHandle ,
XMLWriteHandle
public class FileHandle extends BaseHandle <File ,File >
implements ResendableContentHandle <File ,File >, BinaryReadHandle , BinaryWriteHandle , GenericReadHandle , GenericWriteHandle , JSONReadHandle , JSONWriteHandle , TextReadHandle , TextWriteHandle , XMLReadHandle , XMLWriteHandle , StructureReadHandle , StructureWriteHandle , CtsQueryWriteHandle , QuadsWriteHandle , TriplesReadHandle , TriplesWriteHandle
A File Handle represents document content as a
file for reading or writing. When you read a database document into
a file handle, the API creates a temporary file. You can then open
the file or move it with the File.renameTo() method. When writing
JSON, text, or XML content, you should use a File only if the file
is encoded in UTF-8. If the characters have a different encoding,
use a ReaderHandle and specify the correct character encoding for
the file when creating the Reader.
Field Summary
Constructor Summary
Constructors
Zero-argument constructor.
Initializes the handle with a file containing
the content.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Converts a byte serialization to the content
representation.
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 the file 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.
Constructs an array for the handled content
representation
Creates a factory to create a FileHandle for a
file.
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 a file 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.
Assigns a file 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
Methods
inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
Constructor Details
Method Details
newFactory
Creates a factory to create a FileHandle for a
file.
Returns:
the factory
get
Returns the file for the handle content.
Specified by:
get in
interface ContentHandle <File >
Returns:
the file
set
public void set (File content)
Assigns a file as the content.
Specified by:
set in
interface ContentHandle <File >
Parameters:
content - the file
with
Assigns a file as the content and returns the
handle as a fluent convenience.
Parameters:
content - the file
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 <File >
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 <File ,File >
Specified by:
newHandle in
interface ContentHandle <File >
Specified by:
newHandle in
interface ResendableContentHandle <File ,File >
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 <File ,File >
Specified by:
newHandleArray in
interface ResendableContentHandle <File ,File >
Parameters:
length - the number of positions in the array
Returns:
the uninitialized array
newArray
public File [] newArray (int length)
Constructs an array for the handled content
representation
Specified by:
newArray in
interface ContentHandle <File >
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
toContent
public File toContent (File serialization)
Converts the serialization to the content
representation.
Specified by:
toContent in
interface BufferableContentHandle <File ,File >
Parameters:
serialization - a serialization of the
content
Returns:
the content representation
receiveAs
Overrides:
receiveAs in
class com.marklogic.client.impl.HandleImplementation<File ,File >
receiveContent
protected void receiveContent (File content)
Overrides:
receiveContent in
class com.marklogic.client.impl.HandleImplementation<File ,File >
sendContent
protected File sendContent ()
Overrides:
sendContent in
class com.marklogic.client.impl.HandleImplementation<File ,File >
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
public File bytesToContent (byte[] buffer)
Converts a byte serialization to the content
representation.
Specified by:
bytesToContent in
interface BufferableContentHandle <File ,File >
Parameters:
buffer - the byte serialization
Returns:
the content representation
contentToBytes
public byte[] contentToBytes (File content)
Converts the content representation to
bytes.
Specified by:
contentToBytes in
interface BufferableContentHandle <File ,File >
Parameters:
content - the content
Returns:
the byte serialization of the content
Copyright (c) 2010-2025 Progress
Software Corporation and/or its subsidiaries or affiliates. All
Rights Reserved.