com.compoze.collab.util
Class ByteBuffer

java.lang.Object
  extended by com.compoze.collab.util.ByteBuffer

public class ByteBuffer
extends Object

This is a utility class to write bytes into a buffer taking into account endianess.


Constructor Summary
ByteBuffer(boolean bLittleEndian)
          Constructs a buffer for writing.
ByteBuffer(boolean bLittleEndian, int iLength)
          Constructs a buffer for writing.
ByteBuffer(byte[] bytes)
          Constructs a buffer for reading.
ByteBuffer(int iLength)
          Constructs a buffer for writing.
 
Method Summary
 byte[] getBytes()
          Gets the bytes for the buffer.
static void main(String[] args)
          Exerciser
 byte readByte(int iOffset)
          Gets a byte from the offset of the byte array.
 byte[] readBytes(int iOffset, int iLen)
          Gets a series of bytes from the byte array
 int readInt(int iOffset, boolean bLittleEndian)
          Gets an integer from the offset of the byte array.
 long readLong(int iOffset, boolean bLittleEndian)
          Gets a long from the offset of the byte array.
 short readShort(int iOffset, boolean bLittleEndian)
          Gets a short from the offset of the byte array.
 int readShortAsInt(int iOffset, boolean bLittleEndian)
          Gets a short from the offset of the byte array.
 void writeByte(byte yValue)
          Writes a byte to the buffer
 void writeBytes(byte[] yBytes)
          Writes a series of bytes, in order.
 void writeInt(int iValue)
          Writes an integer to the buffer
 void writeLong(long lValue)
          Writes a long to the buffer
 void writeShort(short shValue)
          Writes a short to the buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBuffer

public ByteBuffer(boolean bLittleEndian)
Constructs a buffer for writing. The initial buffer size is zero bytes.

Parameters
bLittleEndian - true if the data should be written in little-endian order, false for big endian

ByteBuffer

public ByteBuffer(int iLength)
Constructs a buffer for writing. The buffer is constructed big-endian.

Parameters
iLength - the initial size of the buffer written in little-endian order, false for big endian

ByteBuffer

public ByteBuffer(boolean bLittleEndian,
                  int iLength)
Constructs a buffer for writing.

Parameters
bLittleEndian - true if the data should be written in little-endian order, false for big endian

ByteBuffer

public ByteBuffer(byte[] bytes)
Constructs a buffer for reading.

Method Detail

getBytes

public byte[] getBytes()
Gets the bytes for the buffer.


writeInt

public void writeInt(int iValue)
Writes an integer to the buffer

Parameters
iValue - the integer value

writeLong

public void writeLong(long lValue)
Writes a long to the buffer

Parameters
iValue - the integer value

writeByte

public void writeByte(byte yValue)
Writes a byte to the buffer


writeShort

public void writeShort(short shValue)
Writes a short to the buffer

Parameters
iValue - the integer value

readInt

public int readInt(int iOffset,
                   boolean bLittleEndian)
Gets an integer from the offset of the byte array.


readLong

public long readLong(int iOffset,
                     boolean bLittleEndian)
Gets a long from the offset of the byte array.


readShort

public short readShort(int iOffset,
                       boolean bLittleEndian)
Gets a short from the offset of the byte array.


readShortAsInt

public int readShortAsInt(int iOffset,
                          boolean bLittleEndian)
Gets a short from the offset of the byte array.


readByte

public byte readByte(int iOffset)
Gets a byte from the offset of the byte array.


readBytes

public byte[] readBytes(int iOffset,
                        int iLen)
Gets a series of bytes from the byte array


writeBytes

public void writeBytes(byte[] yBytes)
Writes a series of bytes, in order.

Parameters
yBytes - the bytes

main

public static void main(String[] args)
Exerciser



Copyright © 2006 BEA Systems, Inc. All Rights Reserved