org.entityfs.util.base
Class AbstractReadableFile

java.lang.Object
  extended by org.entityfs.util.base.AbstractReadableFile
All Implemented Interfaces:
Lockable, ReadLockable, ReadableFile
Direct Known Subclasses:
ByteArrayReadableFile, CharSequenceReadableFile, FileReadableFile, UrlReadableFile

public abstract class AbstractReadableFile
extends Object
implements ReadableFile

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

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
AbstractReadableFile()
           
 
Method Summary
 long getDataSize()
          This calls getSize() to get the size.
 EntityLock getReadLock()
          This method returns a NoObjectDummyLock.
 boolean isReadLockedByCurrentThread()
          This method always returns true.
 EntityLock lockForReading()
          This method returns a NoObjectDummyLock.
 ReadableByteChannel openChannelForRead()
          This opens a byte channel on the InputStream returned from openForRead.
 
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, openForRead
 

Constructor Detail

AbstractReadableFile

public AbstractReadableFile()
Method Detail

getReadLock

public EntityLock getReadLock()
This method returns a NoObjectDummyLock.

Specified by:
getReadLock in interface ReadLockable
Returns:
The lockable's read lock. This might be unlocked or locked by someone else.

lockForReading

public EntityLock lockForReading()
This method returns a NoObjectDummyLock.

Specified by:
lockForReading in interface ReadLockable
Returns:
A locked read lock.

isReadLockedByCurrentThread

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

Specified by:
isReadLockedByCurrentThread in interface ReadLockable
Returns:
true if the lockable object is read or write locked by the current thread.

openChannelForRead

public ReadableByteChannel openChannelForRead()
This opens a byte channel on the InputStream returned from openForRead.

Specified by:
openChannelForRead in interface ReadableFile
Returns:
An open byte channel.
See Also:
ReadableFile.openForRead()

getDataSize

public long getDataSize()
This calls getSize() to get the size. Subclasses may override this method if the data size is different from the file size.

Specified by:
getDataSize in interface ReadableFile
Returns:
The size of data in the file.
See Also:
ReadableFile.getSize()