com.ibm.manplato.Tools
Class UnsignedByte

java.lang.Object
  |
  +--com.ibm.manplato.Tools.UnsignedByte

public class UnsignedByte
extends java.lang.Object

A simple class for manipulating standard Java signed bytes as if they were Unsigned bytes.

Version:
$Rev$-$Date: 2001/03/15 16:55:33 $$State: Exp $
Author:
File Created By: Brad BARCLAY <bbarclay@ca.ibm.com>, Last Modified By: $Author: Yaztromo $

Method Summary
static byte increment(byte b)
          Increments the given byte by one.
static int intValue(byte b)
          Returns the value of the specified byte in unsigned form as an integer.
static java.lang.String toString(byte b)
          Returns the string representation of the specified byte in unsigned form as a two-digit hex value.
static char unsignedBytes2Char(byte b1, byte b2)
          Converts two bytes into a single char value.
static int unsignedBytes2Int(byte b1, byte b2, byte b3, byte b4)
          Converts two bytes into a single int value.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

increment

public static byte increment(byte b)
Increments the given byte by one. Note that if b = 255 unsigned (-1 signed), incrementing it by one will return zero.
Parameters:
b - the byte to increment.
Returns:
b incremented by 1.

intValue

public static int intValue(byte b)
Returns the value of the specified byte in unsigned form as an integer.
Parameters:
b - the byte the unsign and return as an int.
Returns:
unsigned b represened as an integer.

toString

public static java.lang.String toString(byte b)
Returns the string representation of the specified byte in unsigned form as a two-digit hex value.
Parameters:
b - the byte to represent as a hex string
Returns:
b represented as a hex string.

unsignedBytes2Char

public static char unsignedBytes2Char(byte b1,
                                      byte b2)
Converts two bytes into a single char value.
Parameters:
b1 - the first (high order) byte.
b2 - the second (low-order) byte.
Returns:
b1 and b2 as a single char.

unsignedBytes2Int

public static int unsignedBytes2Int(byte b1,
                                    byte b2,
                                    byte b3,
                                    byte b4)
Converts two bytes into a single int value.
Parameters:
b1 - the first (high order) byte.
b2 - the second byte.
b3 - the third byte.
b4 - the fourth (low-order) byte.
Returns:
b1, b2, b3 and b4 as a single int.