com.amx.duet.tools.text
Class HexUtil

java.lang.Object
  extended bycom.amx.duet.tools.text.HexUtil

public class HexUtil
extends java.lang.Object

A utility class for converting String hex values to integers and integer to String hex values.


Constructor Summary
HexUtil()
           
 
Method Summary
static char HEXTOA(byte cZa, byte cZb)
          Changes two ascii bytes into one ascii character.
static int HEXTOI(byte cZa, byte cZb)
          Changes two ascii bytes into one integer value.
static int HEXTOI(char cZa, char cZb)
          Changes two ascii chars into one integer value.
static int hextoi(java.lang.String hex)
          Converts an ASCII string containing the hexadecimal representation of a number to an integer.
static int hextoi(java.lang.String hex, boolean big)
           
static java.lang.String itohex(int value)
          Converts an integer to an ASCII string containing the hexadecimal representation of the number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HexUtil

public HexUtil()
Method Detail

hextoi

public static final int hextoi(java.lang.String hex)
Converts an ASCII string containing the hexadecimal representation of a number to an integer.

Returns:
An integer representing the converted string. Any non-hexadecimal characters in the string are ignored. hextoi returns a value representing the first complete set of characters that represents an integer. Valid characters are "0" through "9", "A" through "F" and "a" through "f". If no valid characters are found, zero is returned as a result.

hextoi

public static final int hextoi(java.lang.String hex,
                               boolean big)

itohex

public static final java.lang.String itohex(int value)
Converts an integer to an ASCII string containing the hexadecimal representation of the number.

Parameters:
value - integer to be converted to a hexadecimal string.
Returns:
A character string that contains the hexadecimal representation of the specified integer.

HEXTOI

public static int HEXTOI(byte cZa,
                         byte cZb)
Changes two ascii bytes into one integer value. Ex: 0x37,0x43 -> 0x7C = 124

Parameters:
cZa - [0x30..0x39,0x41..0x46]
cZb - [0x30..0x39,0x41..0x46]
Returns:
integer

HEXTOI

public static int HEXTOI(char cZa,
                         char cZb)
Changes two ascii chars into one integer value. Ex: 0x37,0x43 -> 0x7C = 124

Parameters:
cZa - ['0'..'9','A'..'F']
cZb - ['0'..'9','A'..'F']
Returns:
integer

HEXTOA

public static char HEXTOA(byte cZa,
                          byte cZb)
Changes two ascii bytes into one ascii character. Ex: 0x34,0x31 -> 0x41 = 'A'

Parameters:
cZa -
cZb -
Returns:
char


Copyright © 2008 AMX LLC. All Rights Reserved.