|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.codec.binary.Hex
public class Hex
Hex encoder and decoder. The charset used for certain operation can be set, the default is set in
DEFAULT_CHARSET_NAME
| Field Summary | |
|---|---|
private java.lang.String |
charsetName
|
static java.lang.String |
DEFAULT_CHARSET_NAME
Default charset name is CharEncoding.UTF_8 |
private static char[] |
DIGITS_LOWER
Used to build output as Hex |
private static char[] |
DIGITS_UPPER
Used to build output as Hex |
| Constructor Summary | |
|---|---|
Hex()
Creates a new codec with the default charset name DEFAULT_CHARSET_NAME |
|
Hex(java.lang.String csName)
Creates a new codec with the given charset name. |
|
| Method Summary | |
|---|---|
byte[] |
decode(byte[] array)
Converts an array of character bytes representing hexadecimal values into an array of bytes of those same values. |
java.lang.Object |
decode(java.lang.Object object)
Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those same values. |
static byte[] |
decodeHex(char[] data)
Converts an array of characters representing hexadecimal values into an array of bytes of those same values. |
byte[] |
encode(byte[] array)
Converts an array of bytes into an array of bytes for the characters representing the hexadecimal values of each byte in order. |
java.lang.Object |
encode(java.lang.Object object)
Converts a String or an array of bytes into an array of characters representing the hexadecimal values of each byte in order. |
static char[] |
encodeHex(byte[] data)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. |
static char[] |
encodeHex(byte[] data,
boolean toLowerCase)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. |
protected static char[] |
encodeHex(byte[] data,
char[] toDigits)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. |
static java.lang.String |
encodeHexString(byte[] data)
Converts an array of bytes into a String representing the hexadecimal values of each byte in order. |
java.lang.String |
getCharsetName()
Gets the charset name. |
protected static int |
toDigit(char ch,
int index)
Converts a hexadecimal character to an integer. |
java.lang.String |
toString()
Returns a string representation of the object, which includes the charset name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_CHARSET_NAME
CharEncoding.UTF_8
private static final char[] DIGITS_LOWER
private static final char[] DIGITS_UPPER
private final java.lang.String charsetName
| Constructor Detail |
|---|
public Hex()
DEFAULT_CHARSET_NAME
public Hex(java.lang.String csName)
csName - the charset name.| Method Detail |
|---|
public static byte[] decodeHex(char[] data)
throws DecoderException
data - An array of characters containing hexadecimal digits
DecoderException - Thrown if an odd number or illegal of characters is suppliedpublic static char[] encodeHex(byte[] data)
data - a byte[] to convert to Hex characters
public static char[] encodeHex(byte[] data,
boolean toLowerCase)
data - a byte[] to convert to Hex characterstoLowerCase - true converts to lowercase, false to uppercase
protected static char[] encodeHex(byte[] data,
char[] toDigits)
data - a byte[] to convert to Hex characterstoDigits - the output alphabet
public static java.lang.String encodeHexString(byte[] data)
data - a byte[] to convert to Hex characters
protected static int toDigit(char ch,
int index)
throws DecoderException
ch - A character to convert to an integer digitindex - The index of the character in the source
DecoderException - Thrown if ch is an illegal hex character
public byte[] decode(byte[] array)
throws DecoderException
decode in interface BinaryDecoderarray - An array of character bytes containing hexadecimal digits
DecoderException - Thrown if an odd number of characters is supplied to this functiondecodeHex(char[])
public java.lang.Object decode(java.lang.Object object)
throws DecoderException
decode in interface Decoderobject - A String or, an array of character bytes containing hexadecimal digits
DecoderException - Thrown if an odd number of characters is supplied to this function or the object is not a String or
char[]decodeHex(char[])public byte[] encode(byte[] array)
The conversion from hexadecimal characters to the returned bytes is performed with the charset named by
getCharsetName().
encode in interface BinaryEncoderarray - a byte[] to convert to Hex characters
java.lang.IllegalStateException - if the charsetName is invalid. This API throws IllegalStateException instead of
UnsupportedEncodingException for backward compatibility.encodeHex(byte[])
public java.lang.Object encode(java.lang.Object object)
throws EncoderException
The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by
getCharsetName().
encode in interface Encoderobject - a String, or byte[] to convert to Hex characters
EncoderException - Thrown if the given object is not a String or byte[]encodeHex(byte[])public java.lang.String getCharsetName()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||