|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ca.commons.cbutil.CBBase64
Converts back and forth between binary and base 64 (rfc 1521). There are almost certainly java classes that already do this, but it will take longer to find them than to write this :-)
Not fully optimised for speed - might be made faster if necessary...
Maybe should rewrite sometime as a stream?
| Nested Class Summary | |
protected static class |
CBBase64.Base64EncodingException
|
| Method Summary | |
static java.lang.String |
binaryToString(byte[] byteArray)
Takes a binary byte array and converts it to base64 mime encoded data. |
static java.lang.String |
binaryToString(byte[] byteArray,
int offset)
Takes a binary byte array and converts it to base64 mime encoded data. |
static byte[] |
decode(byte[] rawData)
Decodes a byte array containing base64 encoded data. |
static byte[] |
encode(byte[] byteArray)
Encodes an arbitrary byte array into an array of base64 encoded bytes (i.e. bytes that have values corresponding to the ascii values of base 64 data, and can be type cast to those chars). |
static byte[] |
encodeFormatted(byte[] byteArray,
int start,
int colSize)
Encodes an arbitrary byte array into an array of base64 encoded bytes (i.e. bytes that have values corresponding to the ascii values of base 64 data, and can be type cast to those chars). |
static java.lang.String |
format(byte[] base64Data,
int offset)
This returns a formatted string representing the base64 data. |
static byte[] |
stringToBinary(java.lang.String chars)
Takes a base 64 encoded string and converts it to a binary byte array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static java.lang.String binaryToString(byte[] byteArray)
byteArray - an array of 8 bit bytes to be converted
public static java.lang.String binaryToString(byte[] byteArray,
int offset)
byteArray - an array of 8 bit bytes to be convertedoffset - The first line of the string may be offset by
by this many characters for nice formatting (e.g. in
an ldif file, the first line may include 'att value = ...'
at the beginning of the base 64 encoded block).
public static java.lang.String format(byte[] base64Data,
int offset)
base64Data - a byte array of base64 encoded data.offset - the string is formatted to fit inside column 76.
The offset number provides for the first line to be
foreshortened (basically for pretty formatting in ldif
files).public static byte[] encode(byte[] byteArray)
byteArray - the raw data to encode
public static byte[] encodeFormatted(byte[] byteArray,
int start,
int colSize)
throws CBBase64.Base64EncodingException
byteArray - the raw data to encodestart - the number of padding spaces to have at the start (must be less than colSize)colSize - the length of each line of text (i.e. the right hand margin). Must
be a multiple of 4.
CBBase64.Base64EncodingExceptionpublic static byte[] stringToBinary(java.lang.String chars)
chars - a string of base64 encoded characters to be converted
public static byte[] decode(byte[] rawData)
rawData - a byte array, each byte of which is a seven-bit ASCII value.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||