public class FileHandle extends BaseHandle<java.io.File,java.io.File> implements ResendableContentHandle<java.io.File,java.io.File>, BinaryReadHandle, BinaryWriteHandle, GenericReadHandle, GenericWriteHandle, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle, QuadsWriteHandle, TriplesReadHandle, TriplesWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
FileHandle()
Zero-argument constructor.
|
FileHandle(java.io.File content)
Initializes the handle with a file containing the content.
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
bytesToContent(byte[] buffer)
Converts a byte serialization to the content representation.
|
byte[] |
contentToBytes(java.io.File 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.File |
get()
Returns the file for the handle content.
|
java.lang.Class<java.io.File> |
getContentClass()
Returns the class of the handled content, which may be a base
class of the actual class of a content object.
|
java.io.File[] |
newArray(int length)
Constructs an array for the handled content representation
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a FileHandle for a file.
|
FileHandle |
newHandle()
Constructs a new handle for the same content representation,
initializing the new handle with the same format and mime type.
|
protected java.lang.Class<java.io.File> |
receiveAs() |
protected void |
receiveContent(java.io.File content) |
protected java.io.File |
sendContent() |
void |
set(java.io.File content)
Assigns a file as the content.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array buffer
encoded in UTF-8.
|
java.io.File |
toContent(java.io.File serialization)
Converts the serialization to the content representation.
|
FileHandle |
with(java.io.File content)
Assigns a file as the content and returns the handle
as a fluent convenience.
|
FileHandle |
withFormat(Format format)
Specifies the format of the content and returns the handle
as a fluent convenience.
|
FileHandle |
withMimetype(java.lang.String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
getByteLength, getFormat, getMimetype, getServerTimestamp, setByteLength, setFormat, setMimetype, setServerTimestamp
getPointInTimeQueryTimestamp, isResendable, setPointInTimeQueryTimestamp, setResendable, setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resendableHandleFor
resendableHandleFor
newHandle
public FileHandle()
public FileHandle(java.io.File content)
content
- the filepublic static ContentHandleFactory newFactory()
public java.io.File get()
get
in interface ContentHandle<java.io.File>
public void set(java.io.File content)
set
in interface ContentHandle<java.io.File>
content
- the filepublic FileHandle with(java.io.File content)
content
- the filepublic java.lang.Class<java.io.File> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<java.io.File>
public FileHandle newHandle()
ContentHandle
newHandle
in interface ContentHandle<java.io.File>
public java.io.File[] newArray(int length)
ContentHandle
newArray
in interface ContentHandle<java.io.File>
length
- the size of the array (zero or more)public FileHandle withFormat(Format format)
format
- the format of the contentpublic FileHandle withMimetype(java.lang.String mimetype)
mimetype
- the mime type of the contentpublic java.io.File toContent(java.io.File serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<java.io.File,java.io.File>
serialization
- a serialization of the contentprotected java.lang.Class<java.io.File> receiveAs()
receiveAs
in class com.marklogic.client.impl.HandleImplementation<java.io.File,java.io.File>
protected void receiveContent(java.io.File content)
receiveContent
in class com.marklogic.client.impl.HandleImplementation<java.io.File,java.io.File>
protected java.io.File sendContent()
sendContent
in class com.marklogic.client.impl.HandleImplementation<java.io.File,java.io.File>
public void fromBuffer(byte[] buffer)
BufferableHandle
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public java.io.File bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<java.io.File,java.io.File>
buffer
- the byte serializationpublic byte[] contentToBytes(java.io.File content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<java.io.File,java.io.File>
content
- the contentCopyright © 2013-2020 MarkLogic Corporation.