|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openadaptor.util.base64.Base64
public class Base64
Helper class for encoding byte arrays into base64 Strings and vice-versa. Base64 is the MIME / RFC1521 standard for turning binary byte streams into meaningless "printable" (i.e. a-z A-Z 0-9 etc.) strings for safe shipping around by text-based utilities.
Field Summary | |
---|---|
(package private) static java.lang.StringBuffer |
encoded
|
static int |
INVALID_CHAR
Magic number representing the invalid chars when decoding base64. |
static int |
PAD_CHAR
Magic number representing the padding char when decoding base64. |
static int |
WHITESPACE_CHAR
Magic number representing the whitespace chars when decoding base64. |
Constructor Summary | |
---|---|
Base64()
|
Method Summary | |
---|---|
(package private) static boolean |
compareByteArrays(byte[] a1,
byte[] a2)
|
static byte[] |
decode(java.lang.String base64)
Decodes a Base64 String into a byte array. |
static java.lang.String |
encode(byte[] raw)
Encodes a byte array as a Base64 String. |
static java.lang.String |
encode(byte[] raw,
int maxLineLength)
Encodes a byte array as a Base64 String with line breaks. |
protected static char[] |
encodeBlock(byte[] raw,
int offset)
Encodes three characters at offset + [0,1,2] in raw |
protected static char |
getChar(int sixBit)
Given a six bit value, returns the corresponding base64 character |
protected static int |
getValue(char c)
Decodes a single Base64 charater, and returns it as a six bit value. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PAD_CHAR
public static final int WHITESPACE_CHAR
public static final int INVALID_CHAR
static java.lang.StringBuffer encoded
Constructor Detail |
---|
public Base64()
Method Detail |
---|
public static java.lang.String encode(byte[] raw)
raw
- Byte Array to be encoded.
raw
public static java.lang.String encode(byte[] raw, int maxLineLength)
raw
- Byte Array to be encoded.lineLength
- maximum length of line.
raw
protected static char[] encodeBlock(byte[] raw, int offset)
raw into base64 characters.
Note this is ripe for optimisation!
protected static char getChar(int sixBit)
sixBit
- Six bit integer value.
public static byte[] decode(java.lang.String base64) throws Base64Exception
base64
- Base64 String to be decoded.
Base64Exception
- If base64
contains an invalid
base64 message, i.e. illegal charaters, too many padding chars etc.protected static int getValue(char c)
c
or PAD_CHAR, WHITESPACE_CHAR
or INVALID_CHAR.public static void main(java.lang.String[] args)
static boolean compareByteArrays(byte[] a1, byte[] a2)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |