org.fusesource.hawtbuf
Class AbstractVarIntSupport

java.lang.Object
  extended by org.fusesource.hawtbuf.AbstractVarIntSupport
Direct Known Subclasses:
BufferEditor

public abstract class AbstractVarIntSupport
extends Object

Author:
Hiram Chirino

Constructor Summary
AbstractVarIntSupport()
           
 
Method Summary
static int computeVarIntSize(int value)
          Compute the number of bytes that would be needed to encode a varint.
static int computeVarLongSize(long value)
          Compute the number of bytes that would be needed to encode a varint.
static int computeVarSignedIntSize(int value)
          Compute the number of bytes that would be needed to encode a signed varint.
static int computeVarSignedLongSize(long value)
          Compute the number of bytes that would be needed to encode a signed varint.
protected abstract  byte readByte()
           
 int readVarInt()
          Read a raw Varint from the stream.
 long readVarLong()
          Read a raw Varint from the stream.
 int readVarSignedInt()
          Read an sint32 field value from the stream.
 long readVarSignedLong()
          Read an sint64 field value from the stream.
protected abstract  void writeByte(int value)
           
 void writeVarInt(int value)
          Encode and write a varint.
 void writeVarLong(long value)
          Encode and write a varint.
 void writeVarSignedInt(int value)
           
 void writeVarSignedLong(long value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractVarIntSupport

public AbstractVarIntSupport()
Method Detail

readByte

protected abstract byte readByte()
                          throws IOException
Throws:
IOException

writeByte

protected abstract void writeByte(int value)
                           throws IOException
Throws:
IOException

readVarInt

public int readVarInt()
               throws IOException
Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits.

Throws:
IOException

readVarLong

public long readVarLong()
                 throws IOException
Read a raw Varint from the stream.

Throws:
IOException

readVarSignedInt

public int readVarSignedInt()
                     throws IOException
Read an sint32 field value from the stream.

Throws:
IOException

readVarSignedLong

public long readVarSignedLong()
                       throws IOException
Read an sint64 field value from the stream.

Throws:
IOException

writeVarInt

public void writeVarInt(int value)
                 throws IOException
Encode and write a varint. value is treated as unsigned, so it won't be sign-extended if negative.

Throws:
IOException

writeVarLong

public void writeVarLong(long value)
                  throws IOException
Encode and write a varint.

Throws:
IOException

writeVarSignedInt

public void writeVarSignedInt(int value)
                       throws IOException
Throws:
IOException

writeVarSignedLong

public void writeVarSignedLong(long value)
                        throws IOException
Throws:
IOException

computeVarIntSize

public static int computeVarIntSize(int value)
Compute the number of bytes that would be needed to encode a varint. value is treated as unsigned, so it won't be sign-extended if negative.


computeVarLongSize

public static int computeVarLongSize(long value)
Compute the number of bytes that would be needed to encode a varint.


computeVarSignedIntSize

public static int computeVarSignedIntSize(int value)
Compute the number of bytes that would be needed to encode a signed varint.


computeVarSignedLongSize

public static int computeVarSignedLongSize(long value)
Compute the number of bytes that would be needed to encode a signed varint.



Copyright © 2010-2014 FuseSource, Corp.. All Rights Reserved.