org.egothor.io
Class MemoryInputStream

java.lang.Object
  extended by org.egothor.io.DataInputStream
      extended by org.egothor.io.MemoryInputStream
All Implemented Interfaces:
DataInput

public class MemoryInputStream
extends DataInputStream

Author:
galambos

Constructor Summary
MemoryInputStream(byte[] buffer)
          Creates a new instance of MemoryInputStream
MemoryInputStream(byte[] buffer, int begin)
          Creates a new instance of MemoryInputStream
MemoryInputStream(byte[] buffer, int begin, int end)
          Create an InputStream on top of a byte array.
MemoryInputStream(DataInput in, int size)
           
 
Method Summary
 int directRead(long from, byte[] arr)
          Read from the offset position without buffering.
 long getFilePointer()
          Gets the filePointer attribute of the DataInputStream object
 long getMarkPointer()
          Returns the offset of the mark if any, else returns 0.
 void jump()
           
 long length()
          Description of the Method
 void mark(long skip)
          Denote position at getFilePointer+skip for DataInput.jump().
 int read(byte[] arr, int offset, int max_len)
           
 byte readByte()
          Description of the Method
 int readFully(byte[] arr)
          Description of the Method
static int readInt(byte[] rd_buff, int i)
          Reads the integer value from the array at the offset.
static long readLong(byte[] rd_buff, int i)
          Reads the long-int value from the array at the offset.
 void seek(long pos)
          Description of the Method
 java.lang.String toString()
           
 
Methods inherited from class org.egothor.io.DataInputStream
close, readBoolean, readInt, readLong, readPack7, readPack7I, readShort, readString, readString, skipBytes, skipPack7, skipPack7I
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryInputStream

public MemoryInputStream(byte[] buffer)
Creates a new instance of MemoryInputStream


MemoryInputStream

public MemoryInputStream(DataInput in,
                         int size)
                  throws java.io.IOException
Throws:
java.io.IOException

MemoryInputStream

public MemoryInputStream(byte[] buffer,
                         int begin)
Creates a new instance of MemoryInputStream


MemoryInputStream

public MemoryInputStream(byte[] buffer,
                         int begin,
                         int end)
Create an InputStream on top of a byte array.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readFully

public int readFully(byte[] arr)
              throws java.io.IOException
Description copied from class: DataInputStream
Description of the Method

Specified by:
readFully in interface DataInput
Specified by:
readFully in class DataInputStream
Parameters:
arr - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

read

public int read(byte[] arr,
                int offset,
                int max_len)
         throws java.io.IOException
Specified by:
read in interface DataInput
Specified by:
read in class DataInputStream
Parameters:
arr - Description of the Parameter
max_len - Description of the Parameter
Returns:
number of bytes read
Throws:
java.io.IOException - Description of the Exception

readByte

public byte readByte()
              throws java.io.IOException
Description copied from class: DataInputStream
Description of the Method

Specified by:
readByte in interface DataInput
Specified by:
readByte in class DataInputStream
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

directRead

public int directRead(long from,
                      byte[] arr)
               throws java.io.IOException
Description copied from interface: DataInput
Read from the offset position without buffering. This operation moves the read head which may collide with buffered methods.

Specified by:
directRead in interface DataInput
Specified by:
directRead in class DataInputStream
Throws:
java.io.IOException

seek

public void seek(long pos)
          throws java.io.IOException
Description copied from class: DataInputStream
Description of the Method

Specified by:
seek in interface DataInput
Overrides:
seek in class DataInputStream
Parameters:
pos - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

length

public long length()
            throws java.io.IOException
Description copied from class: DataInputStream
Description of the Method

Specified by:
length in interface DataInput
Overrides:
length in class DataInputStream
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

getMarkPointer

public long getMarkPointer()
Description copied from interface: DataInput
Returns the offset of the mark if any, else returns 0.

Specified by:
getMarkPointer in interface DataInput
Overrides:
getMarkPointer in class DataInputStream

jump

public void jump()
          throws java.io.IOException
Specified by:
jump in interface DataInput
Overrides:
jump in class DataInputStream
Throws:
java.io.IOException

mark

public void mark(long skip)
Description copied from interface: DataInput
Denote position at getFilePointer+skip for DataInput.jump().

Specified by:
mark in interface DataInput
Overrides:
mark in class DataInputStream

getFilePointer

public long getFilePointer()
Description copied from class: DataInputStream
Gets the filePointer attribute of the DataInputStream object

Specified by:
getFilePointer in interface DataInput
Overrides:
getFilePointer in class DataInputStream
Returns:
The filePointer value

readLong

public static long readLong(byte[] rd_buff,
                            int i)
Reads the long-int value from the array at the offset.


readInt

public static int readInt(byte[] rd_buff,
                          int i)
Reads the integer value from the array at the offset.