jSyncManager

org.jSyncManager.API.Tools
Class UnsignedByte

java.lang.Object
  |
  +--org.jSyncManager.API.Tools.UnsignedByte

public final class UnsignedByte
extends java.lang.Object

A simple class for manipulating standard Java signed bytes as if they were Unsigned bytes. This class is populated with static methods, and thus cannot be instantiated.

Version:
$Revision: 1.7 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/04/22 20:49:30 $.

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 java.lang.String toString(byte[] b)
          Returns an array of bytes as a human-readable String.
static java.lang.String toString(byte[] b, int length)
          Returns an array of bytes as a human-readable String.
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 four 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 four 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.

toString

public static java.lang.String toString(byte[] b,
                                        int length)
Returns an array of bytes as a human-readable String. This method will return a String, containing 16 hex digits per row, followed by their ASCII representation if an alpha-numeric or punctuation character, or a period ('.') if a non-printable character.
Parameters:
b - an array of bytes.
length - the number of bytes to dump.
Returns:
a String containing the array of bytes as a human-readable String.

toString

public static java.lang.String toString(byte[] b)
Returns an array of bytes as a human-readable String. This method will return a String, containing 16 hex digits per row, followed by their ASCII representation if an alpha-numeric or punctuation character, or a period ('.') if a non-printable character.
Parameters:
b - an array of bytes.
Returns:
a String containing the array of bytes as a human-readable String.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.