java.util.prefs
Class Base64

java.lang.Object
  extended byjava.util.prefs.Base64

class Base64
extends Object

Static methods for translating Base64 encoded strings to byte arrays and vice-versa.

Since:
1.4
Author:
Josh Bloch
See Also:
Preferences

Field Summary
private static byte[] altBase64ToInt
          This array is the analogue of base64ToInt, but for the nonstandard variant that avoids the use of uppercase alphabetic characters.
private static byte[] base64ToInt
          This array is a lookup table that translates unicode characters drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit positive integer equivalents.
private static char[] intToAltBase64
          This array is a lookup table that translates 6-bit positive integer index values into their "Alternate Base64 Alphabet" equivalents.
private static char[] intToBase64
          This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in Table 1 of RFC 2045.
 
Constructor Summary
(package private) Base64()
           
 
Method Summary
(package private) static byte[] altBase64ToByteArray(String s)
          Translates the specified "aternate representation" Base64 string into a byte array.
(package private) static byte[] base64ToByteArray(String s)
          Translates the specified Base64 string (as per Preferences.get(byte[])) into a byte array.
private static byte[] base64ToByteArray(String s, boolean alternate)
           
private static int base64toInt(char c, byte[] alphaToInt)
          Translates the specified character, which is assumed to be in the "Base 64 Alphabet" into its equivalent 6-bit positive integer.
(package private) static String byteArrayToAltBase64(byte[] a)
          Translates the specified byte array into an "aternate representation" Base64 string.
(package private) static String byteArrayToBase64(byte[] a)
          Translates the specified byte array into a Base64 string as per Preferences.put(byte[]).
private static String byteArrayToBase64(byte[] a, boolean alternate)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intToBase64

private static final char[] intToBase64
This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in Table 1 of RFC 2045.


intToAltBase64

private static final char[] intToAltBase64
This array is a lookup table that translates 6-bit positive integer index values into their "Alternate Base64 Alphabet" equivalents. This is NOT the real Base64 Alphabet as per in Table 1 of RFC 2045. This alternate alphabet does not use the capital letters. It is designed for use in environments where "case folding" occurs.


base64ToInt

private static final byte[] base64ToInt
This array is a lookup table that translates unicode characters drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 alphabet but fall within the bounds of the array are translated to -1.


altBase64ToInt

private static final byte[] altBase64ToInt
This array is the analogue of base64ToInt, but for the nonstandard variant that avoids the use of uppercase alphabetic characters.

Constructor Detail

Base64

Base64()
Method Detail

byteArrayToBase64

static String byteArrayToBase64(byte[] a)
Translates the specified byte array into a Base64 string as per Preferences.put(byte[]).


byteArrayToAltBase64

static String byteArrayToAltBase64(byte[] a)
Translates the specified byte array into an "aternate representation" Base64 string. This non-standard variant uses an alphabet that does not contain the uppercase alphabetic characters, which makes it suitable for use in situations where case-folding occurs.


byteArrayToBase64

private static String byteArrayToBase64(byte[] a,
                                        boolean alternate)

base64ToByteArray

static byte[] base64ToByteArray(String s)
Translates the specified Base64 string (as per Preferences.get(byte[])) into a byte array.


altBase64ToByteArray

static byte[] altBase64ToByteArray(String s)
Translates the specified "aternate representation" Base64 string into a byte array.


base64ToByteArray

private static byte[] base64ToByteArray(String s,
                                        boolean alternate)

base64toInt

private static int base64toInt(char c,
                               byte[] alphaToInt)
Translates the specified character, which is assumed to be in the "Base 64 Alphabet" into its equivalent 6-bit positive integer.


main

public static void main(String[] args)