org.ejdb.bson.io
Class InputBuffer

java.lang.Object
  extended by org.ejdb.bson.io.InputBuffer

public class InputBuffer
extends java.lang.Object

Utility class for reading BSON object data from byte array

Version:
$Id$
Author:
Tyutyunkov Vyacheslav (tve@softmotions.com)

Method Summary
static InputBuffer createFromByteArray(byte[] data)
          Creates InputBuffer from byte array
protected  void ensure(int size)
          Checks is buffer contains needed bytes
 boolean isAvailable()
          Returns true if any bytes available to read from buffer or false otherwise
 byte read()
          Reads one byte from buffer
 byte[] readBytes(int count)
          Reads bytes from buffer
 int readInt()
          Reads 4 bytes from buffer as integer value
 long readLong()
          Reads 8 bytes from buffer as long value
 java.lang.String readString()
          Reads c-string (null-terminated) from buffer
 java.lang.String readString(int length)
          Reads c-string from buffer with specified length
 InputBuffer subBuffer(int limit)
          Get sub buffer with specified length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public byte read()
Reads one byte from buffer


readInt

public int readInt()
Reads 4 bytes from buffer as integer value


readLong

public long readLong()
Reads 8 bytes from buffer as long value


readBytes

public byte[] readBytes(int count)
Reads bytes from buffer

Parameters:
count - count of bytes to read

readString

public java.lang.String readString()
Reads c-string (null-terminated) from buffer


readString

public java.lang.String readString(int length)
Reads c-string from buffer with specified length


isAvailable

public boolean isAvailable()
Returns true if any bytes available to read from buffer or false otherwise

Returns:
true if any bytes available to read from buffer or false otherwise

subBuffer

public InputBuffer subBuffer(int limit)
Get sub buffer with specified length


ensure

protected void ensure(int size)
Checks is buffer contains needed bytes


createFromByteArray

public static InputBuffer createFromByteArray(byte[] data)
Creates InputBuffer from byte array