Package host.fai.lib.faiNumber
Class HexUtil
- java.lang.Object
-
- host.fai.lib.faiNumber.HexUtil
-
public final class HexUtil extends Object
The
HexUtilclass is a final class that provides static methods for converting hexadecimal values in string representation as bits to a Java's Primitive Data Type.Currently this class supports converting hexadecimal values in string representation to integer int values and integer long values.
This class treats hexadecimal strings as bit values represented by hexadecimal digits and not real numbers. Thus, hexadecimal strings parse by this class will be converted to the suppored data types as if they were real bit values represented by hexadecimal digits.
To treats hexadecimal values as signed or unsigned real base 16 numbers use
Base16Util.- Since:
- 1.0.0.f
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static inttoInt(String input)Parse theinputstring as bits represented by hexadecimal digits to an integer int value.static longtoLong(String input)Parse theinputstring as bits represented by hexadecimal digits to an integer long value.
-
-
-
Method Detail
-
toInt
public static int toInt(String input)
Parse theinputstring as bits represented by hexadecimal digits to an integer int value.- Parameters:
input- A string to be parsed as hexadecimal digits to an interger int value.- Returns:
- An integer int value of the hexadecimal
inputstring. - Throws:
NumberFormatException- If theinputstring contains invalid hexadecimal digits, or if theinputstring contains a value that is beyond 32 bits. Leading zeroes do not count.EmptyStringException- If theinputstring is empty.- Since:
- 1.0.0.f
-
toLong
public static long toLong(String input)
Parse theinputstring as bits represented by hexadecimal digits to an integer long value.- Parameters:
input- A string to be parsed as hexadecimal digits to an interger long value.- Returns:
- An integer long value of the hexadecimal
inputstring. - Throws:
NumberFormatException- If theinputstring contains invalid hexadecimal digits, or if theinputstring contains a value that is beyond 64 bits. Leading zeroes do not count.EmptyStringException- If theinputstring is empty.- Since:
- 1.0.0.f
-
-