APIdia Launch Partner
Top Description Fields Constructors Methods
java.util.prefs

pack-priv Class Base64

extends Object
Class Inheritance

Static methods for translating Base64 encoded strings to byte arrays and vice-versa.
Author
Josh Bloch
Since
1.4
See Also
Preferences

Field Summary

Modifier and TypeField and Description
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.

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.

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.

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.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static byte[]
altBase64ToByteArray(String s)

Translates the specified "alternate representation" Base64 string into a byte array.

pack-priv 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.

pack-priv static String
byteArrayToAltBase64(byte[] a)

Translates the specified byte array into an "alternate representation" Base64 string.

pack-priv 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)

public static void
main(String[] args)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

altBase64ToIntback to summary
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.

base64ToIntback to summary
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.

intToAltBase64back to summary
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.

intToBase64back to summary
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.

Constructor Detail

Base64back to summary
pack-priv Base64()

Method Detail

altBase64ToByteArrayback to summary
pack-priv static byte[] altBase64ToByteArray(String s)

Translates the specified "alternate representation" Base64 string into a byte array.

Exceptions
IllegalArgumentException:
or ArrayOutOfBoundsException if s is not a valid alternate representation Base64 string.
base64ToByteArrayback to summary
pack-priv static byte[] base64ToByteArray(String s)

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

Exceptions
IllegalArgumentException:
if s is not a valid Base64 string.
base64ToByteArrayback to summary
private static byte[] base64ToByteArray(String s, boolean alternate)
base64toIntback to summary
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.

Exceptions
IllegalArgumentException:
or ArrayOutOfBoundsException if c is not in the Base64 Alphabet.
byteArrayToAltBase64back to summary
pack-priv static String byteArrayToAltBase64(byte[] a)

Translates the specified byte array into an "alternate 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.

byteArrayToBase64back to summary
pack-priv static String byteArrayToBase64(byte[] a)

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

byteArrayToBase64back to summary
private static String byteArrayToBase64(byte[] a, boolean alternate)
mainback to summary
public static void main(String[] args)