org.simantics.databoard.util.binary
Class FileReadable

java.lang.Object
  extended by org.simantics.databoard.util.binary.FileReadable
All Implemented Interfaces:
BinaryReadable, Seekable

public class FileReadable
extends java.lang.Object
implements BinaryReadable, Seekable

This class is a Random Access File implementation to Binary Readable. The implementation is buffered. The implementation is not multi-thread safe. Although file pointer of the backend RandomAccessFile is allowed to move between read operations of this class.

Author:
Toni Kalajainen

Constructor Summary
FileReadable(java.io.RandomAccessFile file)
           
 
Method Summary
 void clearBuffer()
          Flushes internal buffer
 void close()
          Closes the object.
 byte get()
           
 void get(byte[] dst)
           
 void get(byte[] dst, int offset, int length)
           
 void get(java.nio.ByteBuffer buf)
          Get buf fully
 void get(java.nio.ByteBuffer buf, int length)
          Get fully length bytes
 double getDouble()
           
 java.io.RandomAccessFile getFile()
           
 float getFloat()
           
 int getInt()
           
 long getLong()
           
 short getShort()
           
 long length()
           
 java.nio.ByteOrder order()
           
 void order(java.nio.ByteOrder order)
           
 long position()
          Get position
 void position(long newPosition)
          Seek new position.
 void skip(long bytes)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReadable

public FileReadable(java.io.RandomAccessFile file)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Closes the object. Not this will not close the wrapped random access file.

Throws:
java.io.IOException

getFile

public java.io.RandomAccessFile getFile()

order

public java.nio.ByteOrder order()
Specified by:
order in interface BinaryReadable

order

public void order(java.nio.ByteOrder order)
Specified by:
order in interface BinaryReadable

get

public byte get()
         throws java.io.IOException
Specified by:
get in interface BinaryReadable
Throws:
java.io.IOException

get

public void get(byte[] dst,
                int offset,
                int length)
         throws java.io.IOException
Specified by:
get in interface BinaryReadable
Throws:
java.io.IOException

get

public void get(byte[] dst)
         throws java.io.IOException
Specified by:
get in interface BinaryReadable
Throws:
java.io.IOException

get

public void get(java.nio.ByteBuffer buf)
         throws java.io.IOException
Description copied from interface: BinaryReadable
Get buf fully

Specified by:
get in interface BinaryReadable
Throws:
java.io.IOException

get

public void get(java.nio.ByteBuffer buf,
                int length)
         throws java.io.IOException
Description copied from interface: BinaryReadable
Get fully length bytes

Specified by:
get in interface BinaryReadable
Throws:
java.io.IOException

getDouble

public double getDouble()
                 throws java.io.IOException
Specified by:
getDouble in interface BinaryReadable
Throws:
java.io.IOException

getFloat

public float getFloat()
               throws java.io.IOException
Specified by:
getFloat in interface BinaryReadable
Throws:
java.io.IOException

getInt

public int getInt()
           throws java.io.IOException
Specified by:
getInt in interface BinaryReadable
Throws:
java.io.IOException

getLong

public long getLong()
             throws java.io.IOException
Specified by:
getLong in interface BinaryReadable
Throws:
java.io.IOException

getShort

public short getShort()
               throws java.io.IOException
Specified by:
getShort in interface BinaryReadable
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
Specified by:
length in interface BinaryReadable
Throws:
java.io.IOException

position

public long position()
              throws java.io.IOException
Description copied from interface: Seekable
Get position

Specified by:
position in interface BinaryReadable
Specified by:
position in interface Seekable
Returns:
position
Throws:
java.io.IOException

position

public void position(long newPosition)
              throws java.io.IOException
Description copied from interface: Seekable
Seek new position. The next value will be written after the index of the given pointer.

Specified by:
position in interface Seekable
Parameters:
newPosition - new position
Throws:
java.io.IOException

clearBuffer

public void clearBuffer()
Flushes internal buffer


skip

public void skip(long bytes)
          throws java.io.IOException
Specified by:
skip in interface BinaryReadable
Throws:
java.io.IOException