org.apache.cassandra.utils.vint
Class EncodedDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.cassandra.io.util.AbstractDataInput
          extended by org.apache.cassandra.utils.vint.EncodedDataInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class EncodedDataInputStream
extends AbstractDataInput

Borrows idea from https://developers.google.com/protocol-buffers/docs/encoding#varints Should be used with EncodedDataOutputStream


Constructor Summary
EncodedDataInputStream(java.io.DataInput input)
           
 
Method Summary
protected  int getPosition()
           
 int read()
           
 int readInt()
          Reads a 32-bit integer from the current position in this file.
 long readLong()
          Reads a 64-bit long from the current position in this file.
 short readShort()
          Reads a 16-bit short from the current position in this file.
 int readUnsignedShort()
          Reads an unsigned 16-bit short from the current position in this file and returns it as an integer.
protected  void seekInternal(int position)
           
 int skipBytes(int n)
           
 
Methods inherited from class org.apache.cassandra.io.util.AbstractDataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readLine, readUnsignedByte, readUTF
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodedDataInputStream

public EncodedDataInputStream(java.io.DataInput input)
Method Detail

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

seekInternal

protected void seekInternal(int position)
Specified by:
seekInternal in class AbstractDataInput

getPosition

protected int getPosition()
Specified by:
getPosition in class AbstractDataInput

readInt

public int readInt()
            throws java.io.IOException
Description copied from class: AbstractDataInput
Reads a 32-bit integer from the current position in this file. Blocks until four bytes have been read, the end of the file is reached or an exception is thrown.

Specified by:
readInt in interface java.io.DataInput
Overrides:
readInt in class AbstractDataInput
Returns:
the next int value from this file.
Throws:
java.io.EOFException - if the end of this file is detected.
java.io.IOException - if this file is closed or another I/O error occurs.

readLong

public long readLong()
              throws java.io.IOException
Description copied from class: AbstractDataInput
Reads a 64-bit long from the current position in this file. Blocks until eight bytes have been read, the end of the file is reached or an exception is thrown.

Specified by:
readLong in interface java.io.DataInput
Overrides:
readLong in class AbstractDataInput
Returns:
the next long value from this file.
Throws:
java.io.EOFException - if the end of this file is detected.
java.io.IOException - if this file is closed or another I/O error occurs.

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException
Description copied from class: AbstractDataInput
Reads an unsigned 16-bit short from the current position in this file and returns it as an integer. Blocks until two bytes have been read, the end of the file is reached or an exception is thrown.

Specified by:
readUnsignedShort in interface java.io.DataInput
Overrides:
readUnsignedShort in class AbstractDataInput
Returns:
the next unsigned short value from this file as an int.
Throws:
java.io.EOFException - if the end of this file is detected.
java.io.IOException - if this file is closed or another I/O error occurs.

readShort

public short readShort()
                throws java.io.IOException
Description copied from class: AbstractDataInput
Reads a 16-bit short from the current position in this file. Blocks until two bytes have been read, the end of the file is reached or an exception is thrown.

Specified by:
readShort in interface java.io.DataInput
Overrides:
readShort in class AbstractDataInput
Returns:
the next short value from this file.
Throws:
java.io.EOFException - if the end of this file is detected.
java.io.IOException - if this file is closed or another I/O error occurs.


Copyright © 2012 The Apache Software Foundation