Class Base64Encoder
java.lang.Object
org.simpleframework.common.encode.Base64Encoder
The
Base64Encoder
is used to encode and decode base64
content. The implementation used here provides a reasonably fast
memory efficient encoder for use with input and output streams. It
is possible to achieve higher performance, however, ease of use
and convenience are the priorities with this implementation. This
can only decode complete blocks.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
decode
(char[] text) This is used to decode the provide base64 data back in to an array of binary data.static byte[]
decode
(char[] text, int off, int len) This is used to decode the provide base64 data back in to an array of binary data.static char[]
encode
(byte[] buf) This method is used to encode the specified byte array of binary data in to base64 data.static char[]
encode
(byte[] buf, int off, int len) This method is used to encode the specified byte array of binary data in to base64 data.
-
Field Details
-
REFERENCE
private static final int[] REFERENCEThis maintains reference data used to fast decoding. -
ALPHABET
private static final char[] ALPHABETThis contains the base64 alphabet used for encoding.
-
-
Constructor Details
-
Base64Encoder
public Base64Encoder()
-
-
Method Details
-
encode
public static char[] encode(byte[] buf) This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.- Parameters:
buf
- this is the binary data to be encoded- Returns:
- this is the base64 encoded value of the data
-
encode
public static char[] encode(byte[] buf, int off, int len) This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.- Parameters:
buf
- this is the binary data to be encodedoff
- this is the offset to read the binary data fromlen
- this is the length of data to encode from the array- Returns:
- this is the base64 encoded value of the data
-
decode
public static byte[] decode(char[] text) This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.- Parameters:
text
- this is the base64 text to be decoded- Returns:
- this returns the resulting byte array
-
decode
public static byte[] decode(char[] text, int off, int len) This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.- Parameters:
text
- this is the base64 text to be decodedoff
- this is the offset to read the text data fromlen
- this is the length of data to decode from the text- Returns:
- this returns the resulting byte array
-