|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.buildforge.services.common.text.Hex
public class Hex
Fast hex encode/decode
Method Summary | |
---|---|
static byte[] |
bytesToHex(byte[] in)
Converts a sequence of bytes into a sequence of hex digits representing them. |
static byte[] |
bytesToHex(byte[] in,
int offset,
int length)
Converts a sequence of bytes into a sequence of hex digits representing them. |
static byte[] |
bytesToHex(java.nio.ByteBuffer bbuf)
Converts a sequence of bytes into a sequence of hex digits representing them. |
static int |
decode(int code)
Reverses the escaping of an arbitrary UTF-16 character value. |
static int |
encode(char c)
Given a character, returns an integer value that would represent the character as a hex string suitable for use in a "\\u"-style escape sequence. |
static byte |
hexDigit(int b)
Maps hex values to the ASCII values that represent them. |
static byte[] |
hexToBytes(byte[] in)
Converts a sequence of hex digit bytes into the sequence of bytes that they represent. |
static byte[] |
hexToBytes(byte[] in,
int offset,
int length)
Converts a sequence of hex digit bytes into the sequence of bytes that they represent. |
static byte[] |
hexToBytes(java.nio.ByteBuffer bbuf)
Converts a sequence of hex digit bytes into the sequence of bytes that they represent. |
static java.lang.String |
hexToString(java.lang.String hex)
Converts a hexadecimal string of the UTF-8 bytes that encode the original string's characters back to the original string. |
static java.lang.String[] |
hexToString(java.lang.String[] hex)
Converts an array of hexadecimal strings of the UTF-8 bytes that encode the original strings' characters back to the original array of strings. |
static byte |
hexValue(int b)
Maps ASCII character values to their corresponding hex values. |
static java.lang.String |
stringToHex(java.lang.String text)
Converts a string to a hexadecimal string of the UTF-8 bytes that encode the original string's characters. |
static java.lang.String[] |
stringToHex(java.lang.String[] text)
Converts an array of strings to an array of hexadecimal strings of the UTF-8 bytes that encode the characters of the original array's strings. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static byte hexDigit(int b)
b
- the value to map
java.lang.IndexOutOfBoundsException
- if b is either negative
or larger than 0xF.public static byte hexValue(int b)
b
- the hex character for which to return the numeric value
java.lang.IndexOutOfBoundsException
- if b is negativepublic static int encode(char c)
AbstractProtocolImpl.write4(int)
method, which can be used to
write the hex value to the output stream after '\\' and 'u' have
been written.
c
- the char to be escaped
AbstractProtocolImpl.write4(int)
public static int decode(int code)
encode(char)
.
code
- the 4-byte sequence of ASCII codes for the hexadecimal
representation of the char value that was escaped, expressed as
a single integer value (in big endian)
public static java.lang.String stringToHex(java.lang.String text)
text
- the string to encode as hex
public static java.lang.String[] stringToHex(java.lang.String[] text)
text
- the array of strings to encode as hex
public static java.lang.String hexToString(java.lang.String hex)
hex
- the string to decode as hex
public static java.lang.String[] hexToString(java.lang.String[] hex)
hex
- the array of strings to decode as hex
public static byte[] bytesToHex(byte[] in)
bytesToHex(in,0,in.length)
.
in
- the byte array to encode as hex digits
public static byte[] bytesToHex(java.nio.ByteBuffer bbuf)
bytesToHex(byte[],int,int)
, but uses
a byte buffer instead of a byte array as the source of the
bytes to encode as hex.
bbuf
- the byte buffer to encode as hex digits
public static byte[] bytesToHex(byte[] in, int offset, int length)
in
- the byte array to encode as hex digitsoffset
- the offset into the array of the bytes to encodelength
- the length (in bytes) of the data to encode
public static byte[] hexToBytes(byte[] in)
hexToBytes(in,0,in.length)
.
in
- the byte array to decode as hex digits
public static byte[] hexToBytes(java.nio.ByteBuffer bbuf)
hexToBytes(byte[],int,int)
, but uses
a byte buffer instead of a byte array as the source of the
bytes to decode as hex.
bbuf
- the byte buffer to decode as hex digits
public static byte[] hexToBytes(byte[] in, int offset, int length)
in
- the byte array to decode as hex digitsoffset
- the offset into the array of the bytes to decodelength
- the length (in bytes) of the data to decode
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |