|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.util.base.AbstractReadableFile
org.entityfs.util.ByteArrayReadableFile
public class ByteArrayReadableFile
This is a read only ReadableFile
implementation that is backed by a
byte array.
Locking instances of this class returns a NoObjectDummyLock
.
Constructor Summary | |
---|---|
ByteArrayReadableFile(byte[] buf)
Create a read only, byte array-backed ReadableFile . |
Method Summary | |
---|---|
long |
getSize()
Get the size of the file (in bytes). |
EntityLock |
getWriteLock()
Returns a dummy lock. |
boolean |
isWriteLockedByCurrentThread()
Always returns true . |
EntityLock |
lockForWriting()
Returns a dummy lock. |
ReadableByteChannel |
openChannelForRead()
This opens a byte channel on the InputStream returned from
openForRead . |
RandomAccess |
openForRandomAccess(RandomAccessMode ram)
Open the file for random access in the specified mode. |
InputStream |
openForRead()
Opens the file for reading. |
Methods inherited from class org.entityfs.util.base.AbstractReadableFile |
---|
getDataSize, getReadLock, isReadLockedByCurrentThread, lockForReading |
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 |
---|
getDataSize |
Methods inherited from interface org.entityfs.lock.ReadLockable |
---|
getReadLock, isReadLockedByCurrentThread, lockForReading |
Constructor Detail |
---|
public ByteArrayReadableFile(byte[] buf)
ReadableFile
.
buf
- The byte array.Method Detail |
---|
public EntityLock getWriteLock()
getWriteLock
in interface WriteLockable
public EntityLock lockForWriting()
lockForWriting
in interface WriteLockable
public boolean isWriteLockedByCurrentThread()
true
.
isWriteLockedByCurrentThread
in interface WriteLockable
true
if the lockable object is write locked by the
current thread.public RandomAccess openForRandomAccess(RandomAccessMode ram)
RandomlyAccessibleFile
Although a read or write lock on the file is required for the execution
thread opening the RandomAccess
, the RandomAccess
object
itself is not protected from access by other threads. It can be protected
by wrapping it in a LockAwareRandomAccess
object.
openForRandomAccess
in interface RandomlyAccessibleFile
ram
- The mode to open the file in.
RandomAccess
object. It must be closed by the
caller.public InputStream openForRead()
ReadableFile
Although a read lock on the file is required for the execution thread
opening the stream, the stream itself is not protected from access by
other threads. It can be protected by wrapping it in a
LockAwareInputStream
.
openForRead
in interface ReadableFile
InputStream
on the file. The stream must be closed by
the caller.public ReadableByteChannel openChannelForRead()
AbstractReadableFile
InputStream
returned from
openForRead
.
openChannelForRead
in interface ReadableFile
openChannelForRead
in class AbstractReadableFile
ReadableFile.openForRead()
public long getSize()
ReadableFile
Note: Most, but not all, implementations know their sizes. If an implementation does not know its size beforehand, this method will be slow since it has to calculate the file size when it is called.
Implementation note: If the size of the backing file is not known,
the
StreamUtil.getSizeOfDataInStream(InputStream, int)
method can be used to calculate it.
getSize
in interface ReadableFile
ReadableFile.getDataSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |