org.entityfs.util.base
Class AbstractWritableFile

java.lang.Object
  extended by org.entityfs.util.base.AbstractWritableFile
All Implemented Interfaces:
Lockable, WriteLockable, WritableFile
Direct Known Subclasses:
ByteArrayWritableFile, FileWritableFile

public abstract class AbstractWritableFile
extends Object
implements WritableFile

This class can be used as a starting point for WritableFile implementations.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
AbstractWritableFile()
           
 
Method Summary
 EntityLock getWriteLock()
          This method returns a NoObjectDummyLock.
 boolean isWriteLockedByCurrentThread()
          This method always returns true.
 EntityLock lockForWriting()
          This method returns a NoObjectDummyLock.
 WritableByteChannel openChannelForAppend()
          This method opens a byte channel on the OutputStream returned from openForAppend.
 WritableByteChannel openChannelForWrite()
          This method opens a byte channel on the OutputStream returned from openForWrite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.entityfs.WritableFile
openForAppend, openForWrite
 

Constructor Detail

AbstractWritableFile

public AbstractWritableFile()
Method Detail

getWriteLock

public EntityLock getWriteLock()
This method returns a NoObjectDummyLock.

Specified by:
getWriteLock in interface WriteLockable
Returns:
The lockable's write lock. This might be unlocked or locked by someone else.

lockForWriting

public EntityLock lockForWriting()
This method returns a NoObjectDummyLock.

Specified by:
lockForWriting in interface WriteLockable
Returns:
A locked write lock.

isWriteLockedByCurrentThread

public boolean isWriteLockedByCurrentThread()
This method always returns true. Override it to change that behavior.

Specified by:
isWriteLockedByCurrentThread in interface WriteLockable
Returns:
true, always.

openChannelForAppend

public WritableByteChannel openChannelForAppend()
This method opens a byte channel on the OutputStream returned from openForAppend.

Specified by:
openChannelForAppend in interface WritableFile
Returns:
An open WritableByteChannel. The channel must be closed by the caller. The returned channel may be a GatheringByteChannel, but that is not required.

openChannelForWrite

public WritableByteChannel openChannelForWrite()
This method opens a byte channel on the OutputStream returned from openForWrite.

Specified by:
openChannelForWrite in interface WritableFile
Returns:
An open WritableByteChannel. The channel must be closed by the caller. The returned channel may be a GatheringByteChannel, but that is not required.
See Also:
WritableFile.openForWrite(), WritableFile.openChannelForAppend()