|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.shlublu.javax.data.Base64
RFC 2045 compliant Base 64 encoder/decoder.
Field Summary | |
static char[] |
ENCODING_TABLE
The encoding table, according to the RFC. |
static char |
PAD
Metachar, known as PAD in the RFC |
Constructor Summary | |
Base64()
|
Method Summary | |
byte[] |
decode(char chA,
char chB,
char chC,
char chD)
Decoder : take four base 64 digits to produce 1 to 3 bytes, depending the padding chars. |
byte[] |
decode(java.lang.String strBase64Code)
Decoder : take a base 64 string to produce the binary equivalent. |
char[] |
encode(byte byA)
Encoder : take one byte to produce four base 64 digits, the two last ones padded |
java.lang.String |
encode(byte[] abyData)
Encoder : convert the binary given data to a base 64 String. |
char[] |
encode(byte byA,
byte byB)
Encoder : take two bytes to produce four base 64 digits, the last one padded |
char[] |
encode(byte byA,
byte byB,
byte byC)
Encoder : take three bytes to produce four base 64 digits |
static int |
getBinaryLength(int iCodeLength,
int iPadNumber)
Return the length of the binary produced for the given base 64 code specs. |
static int |
getBinaryLength(java.lang.String strCode)
Return the length of the binary produced for the given base 64 code. |
static int |
getCodeLength(byte[] abyToEncode)
Return the length of the code produced for the given binary. |
static int |
getCodeLength(int iBinaryLength)
Return the length of the code produced for the given binary length. |
static int |
getDigitIndex(char ch)
Get the given char's correponding index |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char[] ENCODING_TABLE
'A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','+','/'
public static final char PAD
Constructor Detail |
public Base64()
Method Detail |
public static final int getCodeLength(byte[] abyToEncode)
abyToEncode
- The binary to encodepublic static final int getCodeLength(int iBinaryLength)
abyToEncode
- The binary to encodepublic static final int getBinaryLength(java.lang.String strCode) throws TruncatedBase64CodeException, UnexpectedPadException
strCode
- The base 64 codeTruncatedBase64CodeException
- if the code length is not a multiple of 4UnexpectedPadException
- if ththis code contains more than 2 PADspublic static int getBinaryLength(int iCodeLength, int iPadNumber) throws TruncatedBase64CodeException, UnexpectedPadException
iCodeLength
- A code length, without CR/LFsiPadNumber
- The number of padding char in this code E [0;2]TruncatedBase64CodeException
- if the code length is not a multiple of 4UnexpectedPadException
- if the pad number is not E [0;2]public final java.lang.String encode(byte[] abyData)
byte
- [] abyData The binary data to encodeString.String(char[])
public final char[] encode(byte byA, byte byB, byte byC)
byte
- The bytes to encodepublic final char[] encode(byte byA, byte byB)
byte
- The bytes to encodepublic final char[] encode(byte byA)
byte
- The byte to encodepublic final byte[] decode(java.lang.String strBase64Code) throws UnknownBase64DigitException, UnexpectedPadException, TruncatedBase64CodeException
strBase64Code
- The digits to decodeUnknownBase64DigitException
- if one at least of the given chars is not PAD and is unknown in the encoding table.UnexpectedPadException
- if a padding char is found at an unexpected position.TruncatedBase64CodeException
- if the given code is not multiple of 4 charspublic final byte[] decode(char chA, char chB, char chC, char chD) throws UnknownBase64DigitException, UnexpectedPadException
char
- The digits to decodeUnknownBase64DigitException
- if one at least of the given chars is not PAD and is unknown in the encoding table.UnexpectedPadException
- if a padding char is found in the two firsts digits, or in third position without having a padding fourth digit.public static final int getDigitIndex(char ch) throws UnknownBase64DigitException
char
- ch A base 64 digit, or PADUnknownBase64DigitException
- if the given char is not PAD and unknown in the encoding table.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |