com.imagero.uio.bio
Class BufferedRandomAccessIO

java.lang.Object
  extended byjava.io.InputStream
      extended bycom.imagero.uio.impl.AbstractRandomAccessInput
          extended bycom.imagero.uio.impl.AbstractRandomAccessIO
              extended bycom.imagero.uio.bio.BufferedRandomAccessIO
All Implemented Interfaces:
AdvancedDataInput, AdvancedDataOutput, java.io.DataInput, java.io.DataOutput, Input, ISeekable, OSeekable, RandomAccessInput, RandomAccessIO, RandomAccessOutput

public class BufferedRandomAccessIO
extends AbstractRandomAccessIO

BufferedRandomAccessIO - buffered readable and writable stream with random access.


Field Summary
 
Fields inherited from class com.imagero.uio.impl.AbstractRandomAccessInput
byteOrder
 
Fields inherited from interface com.imagero.uio.ISeekable
BIG_ENDIAN, LITTLE_ENDIAN
 
Constructor Summary
BufferedRandomAccessIO(IOController controller)
           
BufferedRandomAccessIO(IOController controller, long offset)
           
 
Method Summary
 int available()
           
 void close()
           
 RandomAccessInput createInputChild(long offset, int byteOrder, boolean syncPointer)
           
 java.io.InputStream createInputStream(long offset)
           
 RandomAccessIO createIOChild(long offset, int byteOrder, boolean syncPointer)
           
 RandomAccessOutput createOutputChild(long offset, int byteOrder, boolean syncPointer)
           
 java.io.OutputStream createOutputStream(long offset)
           
 void flush()
           
 long flushBefore(long pos)
           
 int getByteOrder()
          get byte order
 long getFilePointer()
          Since this is an interface and is not restricted to files, "getFilePointer" is wrong name for this method.
 boolean isBuffered()
           
 long length()
          get length of data
protected  void prepareBufferForReading(com.imagero.uio.bio.BufferIndex index)
           
protected  void prepareBufferForWriting(com.imagero.uio.bio.BufferIndex index)
           
 int read()
           
 int read(byte[] b, int offset, int length)
           
 int read(char[] dest, int offset, int length, int byteOrder)
           
 int read(double[] dest, int offset, int length, int byteOrder)
           
 int read(float[] dest, int offset, int length, int byteOrder)
           
 int read(int[] dest, int offset, int length, int byteOrder)
           
 int read(long[] dest, int offset, int length, int byteOrder)
           
 int read(short[] dest, int offset, int length, int byteOrder)
           
 void readFully(byte[] b, int offset, int length)
           
 void seek(long pos)
          set current cursor position to specified offset
 void setByteOrder(int byteOrder)
          set byte order
 void setLength(long newLength)
          Set length of stream.
 long skip(long n)
           
 void write(byte[] b, int offset, int length)
           
 void write(char[] data, int offset, int length, int byteOrder)
           
 void write(double[] data, int offset, int length, int byteOrder)
           
 void write(float[] data, int offset, int length, int byteOrder)
           
 void write(int b)
           
 void write(int[] data, int offset, int length, int byteOrder)
           
 void write(long[] data, int offset, int length, int byteOrder)
           
 void write(short[] data, int offset, int length, int byteOrder)
           
 void writeBuffer(java.io.DataOutput out)
          write buffer contents to DataOutput
 void writeBuffer(java.io.OutputStream out)
          write buffer contents to given OutputStream
 
Methods inherited from class com.imagero.uio.impl.AbstractRandomAccessIO
transform, transform, transform, transform, transform, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChar, writeChars, writeDouble, writeDouble, writeFloat, writeFloat, writeInt, writeInt, writeLong, writeLong, writeShort, writeShort, writeUTF
 
Methods inherited from class com.imagero.uio.impl.AbstractRandomAccessInput
read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readBoolean, readByte, readByteLine, readByteLine, readChar, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readInt, readLine, readLong, readLong, readShort, readShort, readUnsignedByte, readUnsignedShort, readUnsignedShort, readUTF, skipBytes
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.imagero.uio.Input
read
 
Methods inherited from interface com.imagero.uio.AdvancedDataInput
read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readByteLine, readByteLine, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLong, readShort, readUnsignedShort
 
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
 

Constructor Detail

BufferedRandomAccessIO

public BufferedRandomAccessIO(IOController controller)

BufferedRandomAccessIO

public BufferedRandomAccessIO(IOController controller,
                              long offset)
Method Detail

setLength

public final void setLength(long newLength)
                     throws java.io.IOException
Description copied from interface: OSeekable
Set length of stream.

Parameters:
newLength - new stream length
Throws:
java.io.IOException

flushBefore

public long flushBefore(long pos)

prepareBufferForReading

protected void prepareBufferForReading(com.imagero.uio.bio.BufferIndex index)
                                throws java.io.IOException
Throws:
java.io.IOException

prepareBufferForWriting

protected void prepareBufferForWriting(com.imagero.uio.bio.BufferIndex index)
                                throws java.io.IOException
Throws:
java.io.IOException

write

public void write(short[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

write

public void write(char[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

write

public void write(int[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

write

public void write(float[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

write

public void write(long[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

write

public void write(double[] data,
                  int offset,
                  int length,
                  int byteOrder)
           throws java.io.IOException
Specified by:
write in interface AdvancedDataOutput
Overrides:
write in class AbstractRandomAccessIO
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()
Description copied from interface: ISeekable
Since this is an interface and is not restricted to files, "getFilePointer" is wrong name for this method. But I leaved it so for easier porting from RandomAccessFile

Returns:
current cursor position

length

public long length()
            throws java.io.IOException
Description copied from interface: ISeekable
get length of data

Returns:
data length (in bytes)
Throws:
java.io.IOException

seek

public void seek(long pos)
Description copied from interface: ISeekable
set current cursor position to specified offset

Parameters:
pos - new cursor position

available

public int available()
              throws java.io.IOException
Throws:
java.io.IOException

getByteOrder

public int getByteOrder()
Description copied from interface: ISeekable
get byte order

Specified by:
getByteOrder in interface ISeekable
Overrides:
getByteOrder in class AbstractRandomAccessInput

setByteOrder

public void setByteOrder(int byteOrder)
Description copied from interface: ISeekable
set byte order

Specified by:
setByteOrder in interface ISeekable
Overrides:
setByteOrder in class AbstractRandomAccessInput

write

public void write(int b)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int offset,
                  int length)
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

writeBuffer

public void writeBuffer(java.io.OutputStream out)
                 throws java.io.IOException
write buffer contents to given OutputStream

Parameters:
out - OutputStream
Throws:
java.io.IOException

writeBuffer

public void writeBuffer(java.io.DataOutput out)
                 throws java.io.IOException
write buffer contents to DataOutput

Parameters:
out - OutputStream
Throws:
java.io.IOException

read

public int read(short[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read(char[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read(int[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read(long[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read(float[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read(double[] dest,
                int offset,
                int length,
                int byteOrder)
         throws java.io.IOException
Specified by:
read in interface AdvancedDataInput
Overrides:
read in class AbstractRandomAccessInput
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Throws:
java.io.IOException

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException
Throws:
java.io.IOException

readFully

public void readFully(byte[] b,
                      int offset,
                      int length)
               throws java.io.IOException
Specified by:
readFully in interface java.io.DataInput
Overrides:
readFully in class AbstractRandomAccessInput
Throws:
java.io.IOException

createIOChild

public RandomAccessIO createIOChild(long offset,
                                    int byteOrder,
                                    boolean syncPointer)

createInputChild

public RandomAccessInput createInputChild(long offset,
                                          int byteOrder,
                                          boolean syncPointer)

createInputStream

public java.io.InputStream createInputStream(long offset)

createOutputChild

public RandomAccessOutput createOutputChild(long offset,
                                            int byteOrder,
                                            boolean syncPointer)

createOutputStream

public java.io.OutputStream createOutputStream(long offset)

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface RandomAccessOutput
Overrides:
flush in class AbstractRandomAccessIO
Throws:
java.io.IOException

isBuffered

public boolean isBuffered()
Specified by:
isBuffered in interface ISeekable
Overrides:
isBuffered in class AbstractRandomAccessInput