com.ibm.awb.misc
Class Hexadecimal

java.lang.Object
  |
  +--com.ibm.awb.misc.Hexadecimal

public class Hexadecimal
extends java.lang.Object

The Hexadecimal class

Version:
1.00 $Date: 2001/07/28 06:33:13 $
Author:
ONO Kouichi

Constructor Summary
Hexadecimal(byte num)
          Constructs a hexadecimal number with a byte.
Hexadecimal(int num)
          Constructs a hexadecimal number with a integer.
Hexadecimal(short num)
          Constructs a hexadecimal number with a short integer.
 
Method Summary
 byte byteValue()
          Gets a byte value.
 java.lang.String hexadecimalValue()
          Gets a string in hexadecimal notation.
 int intValue()
          Gets a integer value.
static void main(java.lang.String[] args)
           
static int octetValue(char c0, char c1)
          Converts a pair of characters as an octet in hexadecimal notation into integer.
static byte parseByte(java.lang.String hex)
          Converts a string in hexadecimal notation into byte.
static int parseInt(java.lang.String hex)
          Converts a string in hexadecimal notation into integer.
static byte[] parseSeq(java.lang.String str)
          Converts a string in hexadecimal notation into byte sequence.
static byte[] parseSeq(java.lang.String str, java.lang.String delimiters)
          Converts a string in hexadecimal notation into byte sequence.
static short parseShort(java.lang.String hex)
          Converts a string in hexadecimal notation into short integer.
 short shortValue()
          Gets a short integer value.
static java.lang.String valueOf(byte num)
          Converts a byte into its hexadecimal notation.
static java.lang.String valueOf(byte[] seq)
          Converts a byte sequence into its hexadecimal notation.
static java.lang.String valueOf(byte[] seq, char separator)
          Converts a byte sequence into its hexadecimal notation.
static java.lang.String valueOf(byte num, boolean padding)
          Converts a byte into its hexadecimal notation.
static java.lang.String valueOf(int num)
          Converts a integer into its hexadecimal notation.
static java.lang.String valueOf(int num, boolean padding)
          Converts a integer into its hexadecimal notation.
static java.lang.String valueOf(long num)
          Converts a long integer into its hexadecimal notation.
static java.lang.String valueOf(long num, boolean padding)
          Converts a long integer into its hexadecimal notation.
static java.lang.String valueOf(short num)
          Converts a short integer into its hexadecimal notation.
static java.lang.String valueOf(short num, boolean padding)
          Converts a short integer into its hexadecimal notation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hexadecimal

public Hexadecimal(byte num)
Constructs a hexadecimal number with a byte.
Parameters:
num - a byte

Hexadecimal

public Hexadecimal(int num)
Constructs a hexadecimal number with a integer.
Parameters:
num - a integer

Hexadecimal

public Hexadecimal(short num)
Constructs a hexadecimal number with a short integer.
Parameters:
num - a short integer
Method Detail

byteValue

public byte byteValue()
               throws java.lang.NumberFormatException
Gets a byte value.
Returns:
a byte of the hexadecimal number

hexadecimalValue

public java.lang.String hexadecimalValue()
Gets a string in hexadecimal notation.
Returns:
string in hexadecimal notation of the number

intValue

public int intValue()
             throws java.lang.NumberFormatException
Gets a integer value.
Returns:
a integer of the hexadecimal number

main

public static void main(java.lang.String[] args)

octetValue

public static int octetValue(char c0,
                             char c1)
                      throws java.lang.NumberFormatException
Converts a pair of characters as an octet in hexadecimal notation into integer.
Parameters:
c0 - higher character of given octet in hexadecimal notation
c1 - lower character of given octet in hexadecimal notation
Returns:
a integer value of the octet

parseByte

public static byte parseByte(java.lang.String hex)
                      throws java.lang.NumberFormatException
Converts a string in hexadecimal notation into byte.
Parameters:
hex - string in hexadecimal notation
Returns:
a byte (1bytes)

parseInt

public static int parseInt(java.lang.String hex)
                    throws java.lang.NumberFormatException
Converts a string in hexadecimal notation into integer.
Parameters:
hex - string in hexadecimal notation
Returns:
a integer (4bytes)

parseSeq

public static byte[] parseSeq(java.lang.String str)
                       throws java.lang.NumberFormatException
Converts a string in hexadecimal notation into byte sequence.
Parameters:
str - a string in hexadecimal notation
Returns:
byte sequence

parseSeq

public static byte[] parseSeq(java.lang.String str,
                              java.lang.String delimiters)
                       throws java.lang.NumberFormatException
Converts a string in hexadecimal notation into byte sequence.
Parameters:
str - a string in hexadecimal notation
delimiters - a set of delimiters
Returns:
byte sequence

parseShort

public static short parseShort(java.lang.String hex)
                        throws java.lang.NumberFormatException
Converts a string in hexadecimal notation into short integer.
Parameters:
hex - string in hexadecimal notation
Returns:
a short integer (2bytes)

shortValue

public short shortValue()
                 throws java.lang.NumberFormatException
Gets a short integer value.
Returns:
a short integer of the hexadecimal number

valueOf

public static java.lang.String valueOf(byte[] seq)
Converts a byte sequence into its hexadecimal notation.
Parameters:
seq - a byte sequence
Returns:
hexadecimal notation of the byte sequence

valueOf

public static java.lang.String valueOf(byte[] seq,
                                       char separator)
Converts a byte sequence into its hexadecimal notation.
Parameters:
seq - a byte sequence
separator - separator between bytes
Returns:
hexadecimal notation of the byte sequence

valueOf

public static java.lang.String valueOf(byte num)
Converts a byte into its hexadecimal notation.
Parameters:
num - a byte (1bytes)
Returns:
hexadecimal notation of the byte

valueOf

public static java.lang.String valueOf(byte num,
                                       boolean padding)
Converts a byte into its hexadecimal notation.
Parameters:
num - a byte (1bytes)
padding - fit the length to 2 by filling with '0' when padding is true
Returns:
hexadecimal notation of the byte

valueOf

public static java.lang.String valueOf(int num)
Converts a integer into its hexadecimal notation.
Parameters:
num - a integer (4bytes)
Returns:
hexadecimal notation of the integer

valueOf

public static java.lang.String valueOf(int num,
                                       boolean padding)
Converts a integer into its hexadecimal notation.
Parameters:
num - a integer (4bytes)
padding - fit the length to 8 by filling with '0' when padding is true
Returns:
hexadecimal notation of the integer

valueOf

public static java.lang.String valueOf(long num)
Converts a long integer into its hexadecimal notation.
Parameters:
num - a long integer (8bytes)
Returns:
hexadecimal notation of the long integer

valueOf

public static java.lang.String valueOf(long num,
                                       boolean padding)
Converts a long integer into its hexadecimal notation.
Parameters:
num - a long integer (8bytes)
padding - fit the length to 16 by filling with '0' when padding is true
Returns:
hexadecimal notation of the long integer

valueOf

public static java.lang.String valueOf(short num)
Converts a short integer into its hexadecimal notation.
Parameters:
num - a short integer (2bytes)
Returns:
hexadecimal notation of the short integer

valueOf

public static java.lang.String valueOf(short num,
                                       boolean padding)
Converts a short integer into its hexadecimal notation.
Parameters:
num - a short integer (2bytes)
padding - fit the length to 8 by filling with '0' when padding is true
Returns:
hexadecimal notation of the short integer