org.entityfs.fs.cap.entity
Interface FCFileBacked

All Superinterfaces:
ECFileResolvable, ECUriResolvable, EntityCapability

public interface FCFileBacked
extends ECFileResolvable, EntityCapability

This capability is supported by an EFile:s that is backed by a File. It contains methods to directly access the file entity's backing File object.

Be careful with using this capability on file entities with other capabilities such as compression since these methods will not take them into account.

Since:
1.0
Author:
Karl Gustafsson
See Also:
FCTFileBacked, FCFileBackedUtil

Method Summary
 FileChannel openFileChannelForAppend(RandomAccessFileFactory ff)
          Open the file for writing and return a FileChannel.
 FileChannel openFileChannelForRandomAccess(RandomAccessFileFactory ff, RandomAccessMode mode)
          Open the file for random access and return a FileChannel.
 FileChannel openFileChannelForRead(RandomAccessFileFactory ff)
          Open the file for reading and return a FileChannel.
 FileChannel openFileChannelForWrite(RandomAccessFileFactory ff)
          Open the file for writing and return a FileChannel.
 FileOutputStream openFileForAppend(FileOutputStreamFactory ff)
          Open the file for appending and return a FileOutputStream.
 RandomAccessFile openFileForRandomAccess(RandomAccessFileFactory ff, RandomAccessMode mode)
          Open the file for random access.
 FileInputStream openFileForRead(FileInputStreamFactory ff)
          Open the file for reading and return a FileInputStream.
 FileOutputStream openFileForWrite(FileOutputStreamFactory ff)
          Open the file for writing and return a FileOutputStream.
 
Methods inherited from interface org.entityfs.fs.cap.entity.ECFileResolvable
getFileObject
 
Methods inherited from interface org.entityfs.fs.cap.entity.ECUriResolvable
getUri
 
Methods inherited from interface org.entityfs.cap.EntityCapability
getEntity, isValid
 

Method Detail

openFileForRandomAccess

RandomAccessFile openFileForRandomAccess(RandomAccessFileFactory ff,
                                         RandomAccessMode mode)
                                         throws ReadOnlyException,
                                                AccessDeniedException,
                                                ReadLockRequiredException,
                                                WriteLockRequiredException
Open the file for random access. The caller is responsible for closing the file.

Parameters:
ff - A factory for the RandomAccessFile object. This factory decides the capabilities of the returned object.
mode - The mode for opening.
Returns:
An open RandomAccessFile. The caller is responsible for closing the file.
Throws:
ReadOnlyException - If a read-only file is opened for writing.
ReadLockRequiredException - If the file is opened with mode r and the client does not have a read lock for the file.
WriteLockRequiredException - If the file is opened for writing and the client does not have a write lock for the file.
AccessDeniedException - If the client does not have sufficient access rights to the entity.
Locks_required:
A read lock for the file if it is opened for reading, a write lock if it is opened for reading and writing.
Permissions_required:
Read access if the file is opened for reading, read and write access if it is opened for reading and writing.

openFileForWrite

FileOutputStream openFileForWrite(FileOutputStreamFactory ff)
                                  throws ReadOnlyException,
                                         AccessDeniedException,
                                         WriteLockRequiredException
Open the file for writing and return a FileOutputStream. The previous contents of the file will be discarded. The caller is responsible for closing the stream.

Parameters:
ff - A factory for the FileOutputStream object. This factory decides the capabilities of the returned stream.
Returns:
An open FileOutputStream.
Throws:
ReadOnlyException - If the file is read only.
WriteLockRequiredException - If the client does not have a write lock for the file.
AccessDeniedException - If the client does not have write access to the entity.
Locks_required:
A write lock on the file.
Permissions_required:
Write access.

openFileForAppend

FileOutputStream openFileForAppend(FileOutputStreamFactory ff)
                                   throws ReadOnlyException,
                                          AccessDeniedException,
                                          WriteLockRequiredException
Open the file for appending and return a FileOutputStream. The data written to the stream will be appended to the previous contents of the file. The caller is responsible for closing the stream.

Parameters:
ff - A factory for the FileOutputStream object. This factory decides the capabilities of the returned stream.
Returns:
An open FileOutputStream.
Throws:
ReadOnlyException - If the file is read only.
WriteLockRequiredException - If the client does not have a write lock for the file.
AccessDeniedException - If the client does not have write access to the entity.
Locks_required:
A write lock on the file.
Permissions_required:
Write access.

openFileForRead

FileInputStream openFileForRead(FileInputStreamFactory ff)
                                throws AccessDeniedException,
                                       ReadLockRequiredException
Open the file for reading and return a FileInputStream. The caller is responsible for closing the stream.

Parameters:
ff - A factory for the FileInputStream object. This factory decides the capabilities of the returned object.
Returns:
An open FileInputStream.
Throws:
AccessDeniedException - If the client does not have read access to the entity.
ReadLockRequiredException - If the client does not have a read lock for the file.
Locks_required:
A read lock on the file.
Permissions_required:
Read access.

openFileChannelForRandomAccess

FileChannel openFileChannelForRandomAccess(RandomAccessFileFactory ff,
                                           RandomAccessMode mode)
                                           throws ReadOnlyException,
                                                  AccessDeniedException,
                                                  ReadLockRequiredException,
                                                  WriteLockRequiredException
Open the file for random access and return a FileChannel. The caller is responsible for closing the channel.

Parameters:
ff - A factory for RandomAccessFile objects. This factory decides the capabilities of the returned object.
mode - The mode for opening.
Returns:
An open FileChannel. The caller is responsible for closing the channel.
Throws:
ReadOnlyException - If a read-only file is opened for writing.
ReadLockRequiredException - If the file is opened with mode r and the client does not have a read lock for the file.
WriteLockRequiredException - If the file is opened for writing and the client does not have a write lock for the file.
AccessDeniedException - If the client does not have sufficient access rights to the entity.
Locks_required:
A read lock for the file if it is opened for reading. A write lock on the file if it is opened for reading and writing.
Permissions_required:
Read access if the file is opened for reading. Read and write access if it is opened for reading and writing.

openFileChannelForRead

FileChannel openFileChannelForRead(RandomAccessFileFactory ff)
                                   throws AccessDeniedException,
                                          ReadLockRequiredException
Open the file for reading and return a FileChannel. The caller is responsible for closing the channel.

Parameters:
ff - A factory for RandomAccessFile objects. This factory decides the capabilities of the returned channel.
Returns:
An open FileChannel.
Throws:
AccessDeniedException - If the client does not have read access to the entity.
ReadLockRequiredException - If the client does not have a read lock for the file.
Locks_required:
A read lock on the file.
Permissions_required:
Read access.

openFileChannelForWrite

FileChannel openFileChannelForWrite(RandomAccessFileFactory ff)
                                    throws ReadOnlyException,
                                           AccessDeniedException,
                                           WriteLockRequiredException
Open the file for writing and return a FileChannel. The previous contents of the file will be discarded. The caller is responsible for closing the channel.

Parameters:
ff - A factory for RandomAccessFile objects. This factory decides the capabilities of the returned channel.
Returns:
An open FileChannel.
Throws:
ReadOnlyException - If the file is read only.
WriteLockRequiredException - If the client does not have a write lock for the file.
AccessDeniedException - If the client does not have write access to the entity.
Locks_required:
A write lock on the file.
Permissions_required:
Write access.

openFileChannelForAppend

FileChannel openFileChannelForAppend(RandomAccessFileFactory ff)
                                     throws ReadOnlyException,
                                            AccessDeniedException,
                                            WriteLockRequiredException
Open the file for writing and return a FileChannel. Data written to the channel will be appended to the previous contents of the file. The caller is responsible for closing the channel.

Parameters:
ff - A factory for RandomAccessFile objects. This factory decides the capabilities of the returned channel.
Returns:
An open FileChannel.
Throws:
ReadOnlyException - If the file is read only.
WriteLockRequiredException - If the client does not have a write lock for the file.
AccessDeniedException - If the client does not have write access to the entity.
Locks_required:
A write lock on the file.
Permissions_required:
Write access.