Package org.castor.core.util
Class Base64Decoder
java.lang.Object
org.castor.core.util.Base64Decoder
Class decodes a Base64 encoded string back into the original byte representation
that can be read as byte array.
- Since:
- 0.9.9
- Version:
- $Revision: 6907 $ $Date: 2005-08-05 13:58:36 -0600 (Fri, 05 Aug 2005) $
- Author:
- Ralf Joachim
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a default Base64Decoder waiting on calls to its translate() method. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Decode given string into a decoded byte array.byte[]
Get all decoded octets as byte array.void
Translate every base64 character from given string into a sextet byte value by using above translation array.
-
Constructor Details
-
Base64Decoder
public Base64Decoder()Construct a default Base64Decoder waiting on calls to its translate() method.
-
-
Method Details
-
decode
Decode given string into a decoded byte array.- Parameters:
str
- Base64 String to be decoded.- Returns:
- All decoded octets as byte array.
-
translate
Translate every base64 character from given string into a sextet byte value by using above translation array. The sextets are then shiftet into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all characters of given string are evaluated. If there are remaing sextets in the buffer they also will be converted into octets at the end. All the converted octets are added to the list for later read.- Parameters:
string
- Base64 String to be decoded.
-
getByteArray
public byte[] getByteArray()Get all decoded octets as byte array.- Returns:
- All decoded octets as byte array.
-