org.apache.commons.codec.net
Class BCodec
- Decoder, Encoder, StringDecoder, StringEncoder
Identical to the Base64 encoding defined by
RFC
1521 and allows a character set to be specified.
RFC 1522 describes techniques to allow the encoding of non-ASCII
text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message
handling software.
$Id: BCodec.java,v 1.5 2004/04/13 22:46:37 ggregory Exp $- Apache Software Foundation
private String | charset - The default charset used for string decoding and encoding.
|
BCodec() - Default constructor.
|
BCodec(String charset) - Constructor which allows for the selection of a default charset
|
Object | decode(Object value) - Decodes a Base64 object into its original form.
|
String | decode(String value) - Decodes a Base64 string into its original form.
|
protected byte[] | doDecoding(byte[] bytes) - Decodes an array of bytes using the defined encoding scheme
|
protected byte[] | doEncoding(byte[] bytes) - Encodes an array of bytes using the defined encoding scheme
|
Object | encode(Object value) - Encodes an object into its Base64 form using the default charset.
|
String | encode(String value) - Encodes a string into its Base64 form using the default charset.
|
String | encode(String value, String charset) - Encodes a string into its Base64 form using the specified charset.
|
String | getDefaultCharset() - The default charset used for string decoding and encoding.
|
protected String | getEncoding() - Returns the codec name (referred to as encoding in the RFC 1522)
|
charset
private String charset
The default charset used for string decoding and encoding.
BCodec
public BCodec()
Default constructor.
BCodec
public BCodec(String charset)
Constructor which allows for the selection of a default charset
charset
- the default string charset to use.
decode
public Object decode(Object value)
throws DecoderException
Decodes a Base64 object into its original form. Escaped characters are converted back to their original
representation.
- decode in interface Decoder
value
- Base64 object to convert into its original form
DecoderException
- A decoder exception is thrown if a failure condition is encountered during the decode process.
decode
public String decode(String value)
throws DecoderException
Decodes a Base64 string into its original form. Escaped characters are converted back to their original
representation.
- decode in interface StringDecoder
value
- Base64 string to convert into its original form
DecoderException
- A decoder exception is thrown if a failure condition is encountered during the decode process.
doDecoding
protected byte[] doDecoding(byte[] bytes)
throws DecoderException
Decodes an array of bytes using the defined encoding scheme
- doDecoding in interface RFC1522Codec
bytes
- Data to be decoded
- a byte array that contains decoded data
DecoderException
- A decoder exception is thrown if a Decoder encounters a
failure condition during the decode process.
doEncoding
protected byte[] doEncoding(byte[] bytes)
throws EncoderException
Encodes an array of bytes using the defined encoding scheme
- doEncoding in interface RFC1522Codec
bytes
- Data to be encoded
- A byte array containing the encoded data
EncoderException
- thrown if the Encoder encounters a failure condition
during the encoding process.
encode
public Object encode(Object value)
throws EncoderException
Encodes an object into its Base64 form using the default charset. Unsafe characters are escaped.
- encode in interface Encoder
value
- object to convert to Base64 form
EncoderException
- thrown if a failure condition is encountered during the encoding process.
encode
public String encode(String value)
throws EncoderException
Encodes a string into its Base64 form using the default charset. Unsafe characters are escaped.
- encode in interface StringEncoder
value
- string to convert to Base64 form
EncoderException
- thrown if a failure condition is encountered during the encoding process.
encode
public String encode(String value,
String charset)
throws EncoderException
Encodes a string into its Base64 form using the specified charset. Unsafe characters are escaped.
value
- string to convert to Base64 formcharset
- the charset for pString
EncoderException
- thrown if a failure condition is encountered during the encoding process.
getDefaultCharset
public String getDefaultCharset()
The default charset used for string decoding and encoding.
- the default string charset.
getEncoding
protected String getEncoding()
Returns the codec name (referred to as encoding in the RFC 1522)
- getEncoding in interface RFC1522Codec
commons-codec version 1.3 - Copyright © 2002-2004 - Apache Software Foundation