com.compoze.collab.util
Class HexByteBuffer

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

public class HexByteBuffer
extends Object

This class allows the creation of a byte array from primitives, Strings and byte arrays that can be converted to a hex string and back.


Constructor Summary
HexByteBuffer()
          Constructor.
HexByteBuffer(byte[] initial)
          Constructor.
HexByteBuffer(String sHex)
          Constructor.
 
Method Summary
 boolean getBoolean()
          Gets a boolean.
 byte getByte()
          Gets a byte.
 byte[] getByteArray()
          Gets a byte array encoded with a length.
 byte[] getBytes(int iLen)
          Gets a number of bytes.
 String getHexString()
          Gets a hex string.
 int getInt()
          Gets an int.
 long getLong()
          Gets a long.
 short getShort()
          Gets a short.
 int getSmallInt()
          Gets an int that is typically small, encoded in a special way to minimize the number of bytes created.
 String getString()
          Gets a string.
static void main(String[] args)
          Exerciser.
 void put(boolean b)
          Appends a boolean.
 void put(byte b)
          Appends a byte.
 void put(byte[] bytes)
          Appends a byte array to the buffer.
 void put(int i)
          Appends an integer.
 void put(long l)
          Appends a long.
 void put(short s)
          Appends a short.
 void put(String s)
          Appends a string to the buffer and precedes it with its length.
 void putByteArray(byte[] bytes)
          Appends a byte array to the buffer and precedes it with its length.
 void putHexString(String s)
          Appends a string (in hex) to the buffer and precedes it with a length.
 void putSmallInt(int i)
          Puts an int that is typically small, encoded in a special way to minimize the number of bytes created.
 String toString()
          Creates a string representation of the byte array in hex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HexByteBuffer

public HexByteBuffer()
Constructor.


HexByteBuffer

public HexByteBuffer(String sHex)
Constructor. Allows get methods to be called.

Parameters
sHex - a hex string (not null)

HexByteBuffer

public HexByteBuffer(byte[] initial)
Constructor. Allows get methods to be called.

Parameters
initial - the initial bytes (not null)
Method Detail

putHexString

public void putHexString(String s)
Appends a string (in hex) to the buffer and precedes it with a length.

Parameters
s - a string (not null)
See Also
getString()

put

public void put(String s)
Appends a string to the buffer and precedes it with its length.

Parameters
s - a string (not null)
See Also
getString()

put

public void put(byte[] bytes)
Appends a byte array to the buffer.

Parameters
bytes - the byte array (not null)
See Also
getBytes(int)

putByteArray

public void putByteArray(byte[] bytes)
Appends a byte array to the buffer and precedes it with its length.

Parameters
bytes - the byte array (not null)

put

public void put(int i)
Appends an integer.

Parameters
i - the int

put

public void put(long l)
Appends a long.

Parameters
l - the long

put

public void put(boolean b)
Appends a boolean.

Parameters
b - the boolean

put

public void put(byte b)
Appends a byte.

Parameters
b - the byte

put

public void put(short s)
Appends a short.

Parameters
s - the short

putSmallInt

public void putSmallInt(int i)
Puts an int that is typically small, encoded in a special way to minimize the number of bytes created.

Parameters
i - the int

getSmallInt

public int getSmallInt()
Gets an int that is typically small, encoded in a special way to minimize the number of bytes created.

Returns
the int

getString

public String getString()
Gets a string.

Returns
the string (not null)

getHexString

public String getHexString()
Gets a hex string.

Returns
the string (not null)

getBytes

public byte[] getBytes(int iLen)
Gets a number of bytes.

Returns
the byte array (not null)

getByteArray

public byte[] getByteArray()
Gets a byte array encoded with a length.

Returns
the byte array (not null)

getByte

public byte getByte()
Gets a byte.

Returns
the byte

getInt

public int getInt()
Gets an int.

Returns
the int

getShort

public short getShort()
Gets a short.

Returns
the short

getLong

public long getLong()
Gets a long.

Returns
the long

getBoolean

public boolean getBoolean()
Gets a boolean.

Returns
the boolean

toString

public String toString()
Creates a string representation of the byte array in hex.

Overrides:
toString in class Object
Returns
the hex string (not null)

main

public static void main(String[] args)
Exerciser.



Copyright © 2006 BEA Systems, Inc. All Rights Reserved