com.bristle.javalib.util
Class Base64

java.lang.Object
  extended by com.bristle.javalib.util.Base64

public class Base64
extends Object

This class contains support for Base64 encoding and decoding.

Usage:
   - The typical scenario for using this class is:
     - To encode a string as Base64:
               String strEncoded = Base64.encode(strDecoded);
     - To decode a Base64 string:
               String strDecoded = Base64.decode(strEncoded);

   - See the source code of the inner Tester class for more examples.
  
Assumptions:
Effects:
       - None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
Revision History:
   $Log$


Nested Class Summary
static class Base64.InvalidBase64DigitException
          This exception is thrown when an invalid character is found as a digit in a Base64 encoded string that is being decoded.
static class Base64.Tester
          Each class contains a Tester inner class with a main() for easier unit testing.
static class Base64.TruncatedBase64EncodingException
          This exception is thrown when a Base64 encoded string that is being decoded has an invalid length, or has a trailing Base64 digit that implies that there should be more digits.
 
Constructor Summary
Base64()
           
 
Method Summary
static String decode(String strIn)
          Return the decoded string value of the specified Base64 encoded string.
static String encode(String strIn)
          Return the Base64 encoded string value of the specified string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64

public Base64()
Method Detail

encode

public static String encode(String strIn)
                     throws UnsupportedEncodingException
Return the Base64 encoded string value of the specified string. The specified string is assumed to use the ISO-8859-1 (Latin-1) encoding.

Parameters:
strIn - String to be encoded.
Returns:
Encoded string.
Throws:
UnsupportedEncodingException - When the incoming string does not use the ISO-8859-1 (Latin-1) encoding.

decode

public static String decode(String strIn)
                     throws UnsupportedEncodingException,
                            Base64.InvalidBase64DigitException,
                            Base64.TruncatedBase64EncodingException
Return the decoded string value of the specified Base64 encoded string. The specified string is assumed to use the ISO-8859-1 (Latin-1) encoding.

Parameters:
strIn - String to be decoded.
Returns:
Decoded string.
Throws:
UnsupportedEncodingException - When the incoming string does not use the ISO-8859-1 (Latin-1) encoding.
Base64.InvalidBase64DigitException - When the string to be decoded contains a character that is not a valid Base64 digit char.
Base64.TruncatedBase64EncodingException - When the string to be decoded has an invalid length.