Package org.castor.core.util
Class HexDecoder
- java.lang.Object
-
- org.castor.core.util.HexDecoder
-
public final class HexDecoder extends java.lang.Object
Hex encoder/decoder implementation (borrowed from BouncyCastle=.- Since:
- 1.1.1
- Version:
- $Revision$
- Author:
- Johan Lindquist
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DATA_TYPE
Identifies the data type supported by this decoder.protected static byte[]
DECODING_TABLE
Decoding table.protected static byte[]
ENCODING_TABLE
Encoding table.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
decode(byte[] data, int off, int length, java.io.OutputStream out)
Decodes the Hex encoded byte data writing it to the given output stream, whitespace characters will be ignored.static byte[]
decode(java.lang.String data)
Decodes the HEX input data producing a output stream.static int
decode(java.lang.String data, java.io.OutputStream out)
Decodes the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.static java.lang.String
encode(byte[] data)
Encodes the input data producing a Hex output stream.static int
encode(byte[] data, int off, int length, java.io.OutputStream out)
Encodes the input data producing a Hex output stream.protected static void
initialiseDecodingTable()
Initialize the decoding table.
-
-
-
Field Detail
-
DATA_TYPE
public static final java.lang.String DATA_TYPE
Identifies the data type supported by this decoder.- See Also:
- Constant Field Values
-
ENCODING_TABLE
protected static final byte[] ENCODING_TABLE
Encoding table.
-
DECODING_TABLE
protected static final byte[] DECODING_TABLE
Decoding table.
-
-
Method Detail
-
initialiseDecodingTable
protected static void initialiseDecodingTable()
Initialize the decoding table.
-
encode
public static int encode(byte[] data, int off, int length, java.io.OutputStream out) throws java.io.IOException
Encodes the input data producing a Hex output stream.- Parameters:
data
- The input data to be HEX encodedoff
- Initiak offsetlength
- Initial length of the input data arrayout
- TheOutputStream
instance holding the encoded input data.- Returns:
- the number of bytes produced.
- Throws:
java.io.IOException
- If encoding fails.
-
decode
public static int decode(byte[] data, int off, int length, java.io.OutputStream out) throws java.io.IOException
Decodes the Hex encoded byte data writing it to the given output stream, whitespace characters will be ignored.- Parameters:
data
- The data to be encodedoff
- Initial offset.length
- Initial lengthout
- TheOutputStream
instance- Returns:
- the number of bytes produced.
- Throws:
java.io.IOException
- If encoding failed.
-
decode
public static int decode(java.lang.String data, java.io.OutputStream out) throws java.io.IOException
Decodes the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.- Parameters:
data
- The data to be encodedout
- TheOutputStream
instance- Returns:
- the number of bytes produced.
- Throws:
java.io.IOException
- If encoding failed.
-
encode
public static java.lang.String encode(byte[] data)
Encodes the input data producing a Hex output stream.- Parameters:
data
- Input data to encode.- Returns:
- the number of bytes produced.
-
decode
public static byte[] decode(java.lang.String data)
Decodes the HEX input data producing a output stream.- Parameters:
data
- Input data to be decoded.- Returns:
- A byte array representing the decoded input data.
-
-