|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.util.cap.entity.FCFileBackedUtil
public final class FCFileBackedUtil
A utility class with static methods for working with FCFileBacked
file entity capabilities.
The methods in this class will use the locking strategy for utility classes
described in EntityLock
.
FCFileBacked
Method Summary | |
---|---|
static FCFileBacked |
getCapability(EFile f)
Get the FCFileBacked capability for a file entity. |
static FileChannel |
openFileChannelForAppend(EFile f)
Open the file for appending and return a FileChannel . |
static FileChannel |
openFileChannelForAppend(EFile f,
EntityLock writeLock)
Open the file for appending and return a FileChannel . |
static FileChannel |
openFileChannelForRandomAccess(EFile f,
RandomAccessMode mode)
Open the file for random access using the random access file factory RandomAccessFileFactoryImpl and return an open FileChannel . |
static FileChannel |
openFileChannelForRandomAccess(EFile f,
RandomAccessMode mode,
EntityLock lock)
Open the file for random access using the random access file factory LockAwareRandomAccessFileFactoryImpl and return an open FileChannel . |
static FileChannel |
openFileChannelForRead(EFile f)
Open the file for reading and return a FileChannel . |
static FileChannel |
openFileChannelForRead(EFile f,
EntityLock readLock)
Open the file for reading and return a FileChannel . |
static FileChannel |
openFileChannelForWrite(EFile f)
Open the file for writing and return a FileChannel . |
static FileChannel |
openFileChannelForWrite(EFile f,
EntityLock writeLock)
Open the file for writing and return a FileChannel . |
static FileOutputStream |
openFileForAppend(EFile f)
Open the file for appending and return a FileOutputStream . |
static FileOutputStream |
openFileForAppend(EFile f,
EntityLock writeLock)
Open the file for appending and return a FileOutputStream . |
static RandomAccessFile |
openFileForRandomAccess(EFile f,
RandomAccessMode mode)
Open the file for random access using the random access file factory RandomAccessFileFactoryImpl . |
static RandomAccessFile |
openFileForRandomAccess(EFile f,
RandomAccessMode mode,
EntityLock lock)
Open the file for random access using the random access file factory LockAwareRandomAccessFileFactoryImpl . |
static FileInputStream |
openFileForRead(EFile f)
Open the file for reading and return a FileInputStream . |
static FileInputStream |
openFileForRead(EFile f,
EntityLock readLock)
Open the file for reading and return a FileInputStream . |
static FileOutputStream |
openFileForWrite(EFile f)
Open the file for writing and return a FileOutputStream . |
static FileOutputStream |
openFileForWrite(EFile f,
EntityLock writeLock)
Open the file for writing and return a FileOutputStream . |
static boolean |
supportsCapability(EFile f)
Check if the supplied file entity supports the FCFileBacked
capability. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static FCFileBacked getCapability(EFile f) throws UnsupportedCapabilityException
FCFileBacked
capability for a file entity.
f
- The file entity to get the capability for.
UnsupportedCapabilityException
- If the entity does not support the
FCFileBacked
capability.public static boolean supportsCapability(EFile f)
FCFileBacked
capability.
f
- The file entity to investigate.
true
if the entity supports the capability, false
if not.public static RandomAccessFile openFileForRandomAccess(EFile f, RandomAccessMode mode) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, ReadLockRequiredException, WriteLockRequiredException
RandomAccessFileFactoryImpl
. The caller is responsible for
closing the file. The caller is also responsible for having a locked
entity lock for the file while it is open.
f
- The file to open.mode
- The mode for opening.
RandomAccessFile
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static RandomAccessFile openFileForRandomAccess(EFile f, RandomAccessMode mode, EntityLock lock) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, ReadLockRequiredException, WriteLockRequiredException
LockAwareRandomAccessFileFactoryImpl
. The caller is responsible
for closing the file. When the file is closed, the supplied
EntityLock
is unlocked by the file.
f
- The file to open.mode
- The mode for opening.lock
- A locked entity lock for the file. The lock will be unlocked
when the file is closed. If this method fails, the lock is unlocked.
RandomAccessFile
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileChannel openFileChannelForRandomAccess(EFile f, RandomAccessMode mode) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, ReadLockRequiredException, WriteLockRequiredException
RandomAccessFileFactoryImpl
and return an open FileChannel
. The caller is responsible for closing the channel. The
caller is also responsible for having a locked entity lock for the file
while it is open.
f
- The file to open.mode
- The mode for opening.
FileChannel
for random access to the file.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileChannel openFileChannelForRandomAccess(EFile f, RandomAccessMode mode, EntityLock lock) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, ReadLockRequiredException, WriteLockRequiredException
LockAwareRandomAccessFileFactoryImpl
and return an open FileChannel
. The caller is responsible for closing the channel. When the
file is closed, the supplied EntityLock
is unlocked by the file.
f
- The file to open.mode
- The mode for opening.lock
- A locked entity lock for the file. The lock will be unlocked
when the file is closed. If this method fails, the lock is unlocked.
FileChannel
for random access to the file.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileOutputStream openFileForWrite(EFile f) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, WriteLockRequiredException
FileOutputStream
. The
previous contents of the file will be discarded.
The caller is responsible for closing the stream. The caller is also responsible for having a locked write lock on the opened file entity while it is open.
f
- The file to open for writing.
FileOutputStream
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileOutputStream openFileForWrite(EFile f, EntityLock writeLock) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileOutputStream
. The
previous contents of the file will be discarded.
The caller is responsible for closing the stream. When the stream is
closed, the supplied EntityLock
is unlocked by the stream.
f
- The file to open for writing.writeLock
- A locked write lock for the file entity. The lock will
be unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileOutputStream
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.writeLock
argument.public static FileChannel openFileChannelForWrite(EFile f) throws UnsupportedCapabilityException, ReadOnlyException, AccessDeniedException, WriteLockRequiredException
FileChannel
. The previous
contents of the file will be discarded.
The caller is responsible for closing the channel. The caller is also responsible for having a locked write lock on the opened file entity while it is open.
f
- The file to open for writing.
FileChannel
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileChannel openFileChannelForWrite(EFile f, EntityLock writeLock) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileChannel
. The previous
contents of the file will be discarded.
The caller is responsible for closing the channel. When it is closed, the
supplied EntityLock
is unlocked by the stream.
f
- The file to open for writing.writeLock
- A locked write lock for the file entity. The lock will
be unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileOutputStream
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.writeLock
argument.public static FileOutputStream openFileForAppend(EFile f) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileOutputStream
. Data
written to the returned stream will be added at the end of the file.
The caller is responsible for closing the stream. The caller is also responsible for having a locked write lock on the opened file entity while it is open.
f
- The file to open for appending.
FileOutputStream
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileOutputStream openFileForAppend(EFile f, EntityLock writeLock) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileOutputStream
. Data
written to the returned stream will be added at the end of the file.
The caller is responsible for closing the stream. When the stream is
closed, the supplied EntityLock
is unlocked by the stream.
f
- The file to open for appending.writeLock
- A locked write lock for the file entity. The lock will
be unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileOutputStream
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.writeLock
argument.public static FileChannel openFileChannelForAppend(EFile f) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileChannel
. Data
written to the returned channel will be added at the end of the file.
The caller is responsible for closing the channel. The caller is also responsible for having a locked write lock on the opened file entity while it is open.
f
- The file to open for appending.
FileChannel
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileChannel openFileChannelForAppend(EFile f, EntityLock writeLock) throws UnsupportedCapabilityException, ReadOnlyException, WriteLockRequiredException, AccessDeniedException
FileChannel
. Data
written to the returned channel will be added at the end of the file.
The caller is responsible for closing the channel. When the stream is
closed, the supplied EntityLock
is unlocked by the stream.
f
- The file to open for appending.writeLock
- A locked write lock for the file entity. The lock will
be unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileChannel
.
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.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.writeLock
argument.public static FileInputStream openFileForRead(EFile f) throws UnsupportedCapabilityException, ReadLockRequiredException, AccessDeniedException
FileInputStream
.
The caller is responsible for closing the stream. The caller is also responsible for having a locked read lock on the opened file entity while it is open.
f
- The file to open for reading.
FileInputStream
.
ReadLockRequiredException
- If the client does not have a read lock
for the file.
AccessDeniedException
- If the client does not have read access to
the entity.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileInputStream openFileForRead(EFile f, EntityLock readLock) throws UnsupportedCapabilityException, ReadLockRequiredException, AccessDeniedException
FileInputStream
.
The caller is responsible for closing the stream. When the stream is
closed, the supplied EntityLock
is unlocked by the stream.
f
- The file to open for reading.readLock
- A locked read lock for the file entity. The lock will be
unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileInputStream
.
ReadLockRequiredException
- If the client does not have a read lock
for the file.
AccessDeniedException
- If the client does not have read access to
the entity.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.readLock
argument.public static FileChannel openFileChannelForRead(EFile f) throws UnsupportedCapabilityException, ReadLockRequiredException, AccessDeniedException
FileChannel
.
The caller is responsible for closing the channel. The caller is also responsible for having a locked read lock on the opened file entity while it is open.
f
- The file to open for reading.
FileChannel
.
ReadLockRequiredException
- If the client does not have a read lock
for the file.
AccessDeniedException
- If the client does not have read access to
the entity.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.public static FileChannel openFileChannelForRead(EFile f, EntityLock readLock) throws UnsupportedCapabilityException, ReadLockRequiredException, AccessDeniedException
FileChannel
.
The caller is responsible for closing the channel. When it is closed, the
supplied EntityLock
is also unlocked.
f
- The file to open for reading.readLock
- A locked read lock for the file entity. The lock will be
unlocked when the stream is closed. If this method fails, the lock is
unlocked.
FileChannel
.
ReadLockRequiredException
- If the client does not have a read lock
for the file.
AccessDeniedException
- If the client does not have read access to
the entity.
UnsupportedCapabilityException
- If the file entity does not
support the FCFileBacked
capability.readLock
argument.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |