loci.formats
Class RandomAccessArray

java.lang.Object
  extended byjava.io.RandomAccessFile
      extended byloci.formats.RandomAccessArray
All Implemented Interfaces:
DataInput, DataOutput

public class RandomAccessArray
extends RandomAccessFile

An extension of RandomAccessFile providing random access into an array of bytes directly from memory. The implemention is very straightforward except for the copyArray methods, which replace readFully, and exist solely because readFully is declared final and thus cannot be overridden.


Constructor Summary
RandomAccessArray(String name, String mode)
           
 
Method Summary
 void close()
           
 void copyArray(byte[] b)
          This has the same functionality as RandomAccessFile's readFully.
 void copyArray(byte[] b, int off, int len)
           
 long getFilePointer()
           
 long length()
           
 int read()
          Reads a byte of data from the array.
 int read(byte[] b)
          Reads up to b.length bytes of data from the array.
 int read(byte[] b, int off, int len)
          Reads up to len bytes from the array.
 void seek(long pos)
          Sets the file pointer.
 void setLength(long newLength)
          Sets the array length.
 void setStream(byte[] b)
           
 int skipBytes(int n)
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.RandomAccessFile
getChannel, getFD, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessArray

public RandomAccessArray(String name,
                         String mode)
                  throws FileNotFoundException
Method Detail

setStream

public void setStream(byte[] b)

close

public void close()

getFilePointer

public long getFilePointer()

length

public long length()

seek

public void seek(long pos)
Sets the file pointer.


setLength

public void setLength(long newLength)
Sets the array length.


skipBytes

public int skipBytes(int n)

read

public int read()
Reads a byte of data from the array.


read

public int read(byte[] b)
         throws IOException
Reads up to b.length bytes of data from the array.

Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Reads up to len bytes from the array.

Throws:
IOException

copyArray

public void copyArray(byte[] b)
               throws IOException
This has the same functionality as RandomAccessFile's readFully. The readFully signature is not used because it's final in RandomAccessFile.

Throws:
IOException

copyArray

public void copyArray(byte[] b,
                      int off,
                      int len)
               throws IOException
Throws:
IOException

write

public void write(int b)

write

public void write(byte[] b)

write

public void write(byte[] b,
                  int off,
                  int len)