|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xins.logdoc.LogdocHexConverter
Utility class for converting numbers to unsigned hex strings and vice versa, specifically for Logdoc classes.
Method Summary | |
static boolean |
isHexDigit(char c)
Checks if the specified character is a hexadecimal digit. |
static int |
parseHexInt(String s)
Parses the specified 8-digit unsigned hex string. |
static int |
parseHexInt(String s,
int index)
Parses the 8-digit unsigned hex number in the specified string. |
static long |
parseHexLong(String s)
Parses the specified 16-digit unsigned hex string. |
static long |
parseHexLong(String s,
int index)
Parses the 16-digit unsigned hex number in the specified string. |
static String |
toHexString(int n)
Convert the specified int to an unsigned number hex
string. |
static void |
toHexString(LogdocStringBuffer buffer,
int n)
Converts the specified int to unsigned number and appends
it to the specified string buffer. |
static void |
toHexString(LogdocStringBuffer buffer,
long n)
Converts the specified long to unsigned number and appends
it to the specified string buffer. |
static String |
toHexString(long n)
Convert the specified long to an unsigned number hex
string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final boolean isHexDigit(char c)
'0'
to '9'
'a'
to 'f'
'A'
to 'F'
c
- the character to check.
true
if the specified character is a hexadecimal digit,
false
otherwise.public static String toHexString(int n)
int
to an unsigned number hex
string. The returned string will always consist of 8 hex characters,
zeroes will be prepended as necessary.
n
- the number to be converted to a hex string.
null
, the length is always 8
(i.e. return.
length()
== 8
).public static String toHexString(long n)
long
to an unsigned number hex
string. The returned string will always consist of 16 hex characters,
zeroes will be prepended as necessary.
n
- the number to be converted to a hex string.
null
, the length is always 16
(i.e. return.
length()
== 16
).public static void toHexString(LogdocStringBuffer buffer, int n) throws IllegalArgumentException
int
to unsigned number and appends
it to the specified string buffer. Exactly 8 characters will be
appended, all between '0'
to '9'
or between
'a'
and 'f'
.
buffer
- the string buffer to append to, cannot be null
.n
- the number to be converted to a hex string.
IllegalArgumentException
- if buffer == null
.public static void toHexString(LogdocStringBuffer buffer, long n) throws IllegalArgumentException
long
to unsigned number and appends
it to the specified string buffer. Exactly 16 characters will be
appended, all between '0'
to '9'
or between
'a'
and 'f'
.
buffer
- the string buffer to append to, cannot be null
.n
- the number to be converted to a hex string.
IllegalArgumentException
- if buffer == null
.public static long parseHexLong(String s, int index) throws IllegalArgumentException, NumberFormatException
s
- the hexadecimal string, cannot be null
.index
- the starting index in the string, must be >= 0.
IllegalArgumentException
- if s == null
|| index < 0
|| s.length()
< index + 16
).
NumberFormatException
- if any of the characters in the specified range of the string is not
a hex digit ('0'
to '9'
and
'a'
to 'f'
).public static long parseHexLong(String s) throws IllegalArgumentException, NumberFormatException
s
- the hexadecimal string, cannot be null
and must have
size 16
(i.e. s.
length()
== 16
).
IllegalArgumentException
- if s == null || s.
length()
!= 16
.
NumberFormatException
- if any of the characters in the specified string is not a hex digit
('0'
to '9'
and 'a'
to
'f'
).public static int parseHexInt(String s, int index) throws IllegalArgumentException, NumberFormatException
s
- the hexadecimal string, cannot be null
.index
- the starting index in the string, must be >= 0.
IllegalArgumentException
- if s == null
|| index < 0
|| s.length()
< index + 8
).
NumberFormatException
- if any of the characters in the specified range of the string is not
a hex digit ('0'
to '9'
and
'a'
to 'f'
).public static int parseHexInt(String s) throws IllegalArgumentException, NumberFormatException
s
- the hexadecimal string, cannot be null
and must have
size 8
(i.e. s.
length()
== 8
).
IllegalArgumentException
- if s == null || s.
length()
!= 8
.
NumberFormatException
- if any of the characters in the specified string is not a hex digit
('0'
to '9'
and 'a'
to
'f'
).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |