Package org.castor.core.util
Class HexDecoder
java.lang.Object
org.castor.core.util.HexDecoder
Hex encoder/decoder implementation (borrowed from BouncyCastle=.
- Since:
- 1.1.1
- Version:
- $Revision$
- Author:
- Johan Lindquist
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Identifies the data type supported by this decoder.protected static final byte[]
Decoding table.protected static final byte[]
Encoding table. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
decode
(byte[] data, int off, int length, OutputStream out) Decodes the Hex encoded byte data writing it to the given output stream, whitespace characters will be ignored.static byte[]
Decodes the HEX input data producing a output stream.static int
decode
(String data, OutputStream out) Decodes the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.static String
encode
(byte[] data) Encodes the input data producing a Hex output stream.static int
encode
(byte[] data, int off, int length, OutputStream out) Encodes the input data producing a Hex output stream.protected static void
Initialize the decoding table.
-
Field Details
-
DATA_TYPE
Identifies the data type supported by this decoder.- See Also:
-
ENCODING_TABLE
protected static final byte[] ENCODING_TABLEEncoding table. -
DECODING_TABLE
protected static final byte[] DECODING_TABLEDecoding table.
-
-
Method Details
-
initialiseDecodingTable
protected static void initialiseDecodingTable()Initialize the decoding table. -
encode
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:
IOException
- If encoding fails.
-
decode
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:
IOException
- If encoding failed.
-
decode
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:
IOException
- If encoding failed.
-
encode
Encodes the input data producing a Hex output stream.- Parameters:
data
- Input data to encode.- Returns:
- the number of bytes produced.
-
decode
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.
-