org.entityfs.ram
Class RamFileAdapter

java.lang.Object
  extended by org.entityfs.impl.impl.adapter.AbstractRWEntityAdapter<RamFileSystemAdapter,RamDirectoryAdapter>
      extended by org.entityfs.ram.AbstractRamEntityAdapter
          extended by org.entityfs.ram.RamFileAdapter
All Implemented Interfaces:
EntityAdapter, FileAdapter

public final class RamFileAdapter
extends AbstractRamEntityAdapter
implements FileAdapter

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
RamFileAdapter(RamFileSystemAdapter fs, RamDirectoryAdapter parent, String name)
           
 
Method Summary
 void copyTo(OutputStream os)
           
 void copyTo(WritableByteChannel wbc)
           
 void delete()
          Override to leave back segments to the size guard
 long getDataSize()
           
 EntityType getEntityType()
           
 long getSize()
           
 ScatteringByteChannel openChannelForRead()
           
 GatheringByteChannel openChannelForWrite(boolean append)
           
 RandomAccess openForRandomAccess(RandomAccessMode mode)
           
 InputStream openForRead()
           
 OutputStream openForWrite(boolean append)
           
 int read(long pos)
           
 int read(long pos, byte[] barr)
           
 int read(long pos, byte[] barr, int off, int len)
          Same behavior as InputStream.read
 int read(long pos, ByteBuffer bb)
           
 void replaceContents(FileAdapter fa)
           
 void setLength(long l)
           
 String toString()
           
 void write(byte[] barr)
           
 void write(byte[] barr, int off, int len)
          Same contract as OutputStream.write
 int write(ByteBuffer src)
           
 void write(int b)
           
 void writeAt(long pos, byte[] barr)
           
 void writeAt(long pos, byte[] barr, int off, int len)
           
 int writeAt(long pos, ByteBuffer src)
           
 void writeAt(long pos, int b)
           
 
Methods inherited from class org.entityfs.ram.AbstractRamEntityAdapter
canRead, canWrite, create, exists, getLastModified, rename, setLastModified
 
Methods inherited from class org.entityfs.impl.impl.adapter.AbstractRWEntityAdapter
getName, getParent, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.entityfs.impl.adapter.EntityAdapter
canRead, canWrite, create, exists, getFileSystemAdapter, getLastModified, getName, getParent, init, rename, setLastModified
 

Constructor Detail

RamFileAdapter

public RamFileAdapter(RamFileSystemAdapter fs,
                      RamDirectoryAdapter parent,
                      String name)
Method Detail

getSize

public long getSize()
Specified by:
getSize in interface FileAdapter

getDataSize

public long getDataSize()
Specified by:
getDataSize in interface FileAdapter

openForRead

public InputStream openForRead()
Specified by:
openForRead in interface FileAdapter

openForWrite

public OutputStream openForWrite(boolean append)
Specified by:
openForWrite in interface FileAdapter

openChannelForRead

public ScatteringByteChannel openChannelForRead()
Specified by:
openChannelForRead in interface FileAdapter

openChannelForWrite

public GatheringByteChannel openChannelForWrite(boolean append)
Specified by:
openChannelForWrite in interface FileAdapter

openForRandomAccess

public RandomAccess openForRandomAccess(RandomAccessMode mode)
Specified by:
openForRandomAccess in interface FileAdapter

copyTo

public void copyTo(OutputStream os)
Specified by:
copyTo in interface FileAdapter

copyTo

public void copyTo(WritableByteChannel wbc)
Specified by:
copyTo in interface FileAdapter

getEntityType

public EntityType getEntityType()
Specified by:
getEntityType in interface EntityAdapter

read

public int read(long pos)

read

public int read(long pos,
                byte[] barr,
                int off,
                int len)
Same behavior as InputStream.read


read

public int read(long pos,
                byte[] barr)

read

public int read(long pos,
                ByteBuffer bb)

write

public void write(int b)

write

public void write(byte[] barr,
                  int off,
                  int len)
Same contract as OutputStream.write

Parameters:
barr -
off -
len -

write

public void write(byte[] barr)

writeAt

public void writeAt(long pos,
                    int b)

writeAt

public void writeAt(long pos,
                    byte[] barr,
                    int off,
                    int len)

writeAt

public void writeAt(long pos,
                    byte[] barr)

write

public int write(ByteBuffer src)

writeAt

public int writeAt(long pos,
                   ByteBuffer src)

setLength

public void setLength(long l)

delete

public void delete()
Override to leave back segments to the size guard

Specified by:
delete in interface EntityAdapter
Overrides:
delete in class AbstractRamEntityAdapter

replaceContents

public void replaceContents(FileAdapter fa)
Specified by:
replaceContents in interface FileAdapter

toString

public String toString()
Overrides:
toString in class Object