|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.entityfs.util.base.AbstractReadWritableFile
public abstract class AbstractReadWritableFile
This class can be used as a starting point for ReadWritableFile
implementations.
The locking methods of this class uses DummyLock:s.
| Field Summary | |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size, in bytes, of internal buffers if no buffer size is set when creating an instance. |
| Constructor Summary | |
|---|---|
protected |
AbstractReadWritableFile()
Create a ReadWritableFile object. |
protected |
AbstractReadWritableFile(int bufferSize)
Create a ReadWritableFile object. |
| Method Summary | |
|---|---|
long |
copy(OutputStream os)
Dump the file contents to the stream. |
long |
copy(WritableByteChannel oc)
Copy the file's contents to the WritableByteChannel. |
long |
getDataSize()
This default implementation returns the result from the ReadableFile.getSize() method. |
EntityLock |
getReadLock()
This returns a dummy lock. |
long |
getSizeNoLocking()
This default implementation returns the result from the ReadableFile.getSize() method. |
EntityLock |
getWriteLock()
This returns a dummy lock. |
boolean |
isReadLockedByCurrentThread()
This method always returns true. |
boolean |
isWriteLockedByCurrentThread()
This method always returns true. |
EntityLock |
lockForReading()
This returns a dummy lock. |
EntityLock |
lockForWriting()
This returns a dummy lock. |
void |
replaceContents(ReadWritableFile f)
Replace the contents of this file with the contents of the supplied file and then delete the supplied file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.entityfs.ReadableFile |
|---|
getSize, openChannelForRead, openForRead |
| Methods inherited from interface org.entityfs.WritableFile |
|---|
openChannelForAppend, openChannelForWrite, openForAppend, openForWrite |
| Methods inherited from interface org.entityfs.RandomlyAccessibleFile |
|---|
openForRandomAccess |
| Methods inherited from interface org.entityfs.Deletable |
|---|
delete, isDeleted |
| Field Detail |
|---|
public static final int DEFAULT_BUFFER_SIZE
| Constructor Detail |
|---|
protected AbstractReadWritableFile()
ReadWritableFile object.
If this object has to create a temporary buffer for storing data in, it
will use a buffer of the default size, DEFAULT_BUFFER_SIZE.
AbstractReadWritableFile(int)
protected AbstractReadWritableFile(int bufferSize)
throws IllegalArgumentException
ReadWritableFile object.
If this object has to create a temporary buffer for storing data in, it will use a buffer of the supplied size.
bufferSize - The size of internal buffers.
IllegalArgumentException - If the buffer size is not greater than
zero.AbstractReadWritableFile()| Method Detail |
|---|
public EntityLock getReadLock()
getReadLock in interface ReadLockableDummyLock instance.public EntityLock lockForReading()
lockForReading in interface ReadLockableDummyLock instance.public boolean isReadLockedByCurrentThread()
true.
isReadLockedByCurrentThread in interface ReadLockabletrue.public EntityLock getWriteLock()
getWriteLock in interface WriteLockableDummyLock instance.public EntityLock lockForWriting()
lockForWriting in interface WriteLockableDummyLock instance.public boolean isWriteLockedByCurrentThread()
true.
isWriteLockedByCurrentThread in interface WriteLockabletrue.public void replaceContents(ReadWritableFile f)
ReadWritableFilef over to this file, which makes the entire operation quick and not
requiring any extra disk space.
If both files support metadata, this file's metadata is replaced with
that of f.
replaceContents in interface ReadWritableFilef - The file whose contents are to be moved to this file. f
is deleted by this method.public long getDataSize()
ReadableFile.getSize() method.
getDataSize in interface ReadableFileReadableFile.getSize()public long getSizeNoLocking()
ReadableFile.getSize() method.
getSizeNoLocking in interface ReadWritableFile0 is returned.ReadableFile.getSize()public long copy(OutputStream os)
ReadWritableFile
copy in interface ReadWritableFileos - The stream the file contents are written to. The stream is not
closed after writing, that must be done by the caller.
public long copy(WritableByteChannel oc)
ReadWritableFileWritableByteChannel.
copy in interface ReadWritableFileoc - The WritableByteChannel. The channel is not closed by
this method.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||