Class Base64
A class for encoding and decoding to and from Base64. Also contains Binary identifiers which are used to indicate what type a message is when transferred in Base64. This is done by adding a one byte prefix to the start of the encoded message.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
The binary indentifier for a byte.static final char
The binary indentifier for a double.static final char
The binary indentifier for a float.static final char
The binary indentifier for a int.static final char
The binary indentifier for a lgon.static final char
The binary indentifier for an opaque type.static final char
The binary indentifier for a short.static final char
The binary indentifier for a string.static final char
The binary indentifier for an unsigned byte.static final char
The binary indentifier for an unsigned int.static final char
The binary indentifier for an unsigned long.static final char
The binary indentifier for an unsigned short. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
encode
(byte b) Base64 encodes a byte value.static byte[]
encode
(byte[] bytes) Base64 encodes an opaque type.static byte[]
encode
(double d) Base64 encodes a double value.static byte[]
encode
(float f) Base64 encodes a float value.static byte[]
encode
(int i) Base64 encodes an int value.static byte[]
encode
(long l) Base64 encodes a long value.static byte[]
encode
(short s) Base64 encodes a short value.static byte
Decodes a Base64 encodedString
and converts it into a byte value.static double
Decodes a Base64 encodedString
and converts it into a double value.static float
Decodes a Base64 encodedString
and converts it into a float value.static int
Decodes a Base64 encodedString
and converts it into an int value.static long
Decodes a Base64 encodedString
and converts it into a long value.static byte[]
Decodes a Base64 encodedString
and converts it into an opaque value.static short
Decodes a Base64 encodedString
and converts it into a short value.static String
Decodes a Base64 encodedString
and converts it into aString
value.
-
Field Details
-
FLOAT
public static final char FLOATThe binary indentifier for a float.
- See Also:
-
DOUBLE
public static final char DOUBLEThe binary indentifier for a double.
- See Also:
-
BYTE
public static final char BYTEThe binary indentifier for a byte.
- See Also:
-
SHORT
public static final char SHORTThe binary indentifier for a short.
- See Also:
-
INT
public static final char INTThe binary indentifier for a int.
- See Also:
-
LONG
public static final char LONGThe binary indentifier for a lgon.
- See Also:
-
U_BYTE
public static final char U_BYTEThe binary indentifier for an unsigned byte.
- See Also:
-
U_SHORT
public static final char U_SHORTThe binary indentifier for an unsigned short.
- See Also:
-
U_INT
public static final char U_INTThe binary indentifier for an unsigned int.
- See Also:
-
U_LONG
public static final char U_LONGThe binary indentifier for an unsigned long.
- See Also:
-
STRING
public static final char STRINGThe binary indentifier for a string.
- See Also:
-
OPAQUE
public static final char OPAQUEThe binary indentifier for an opaque type.
- See Also:
-
-
Constructor Details
-
Base64
public Base64()
-
-
Method Details
-
getDouble
Decodes a Base64 encoded
String
and converts it into a double value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded double value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getFloat
Decodes a Base64 encoded
String
and converts it into a float value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded float value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getByte
Decodes a Base64 encoded
String
and converts it into a byte value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded byte value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getShort
Decodes a Base64 encoded
String
and converts it into a short value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded short value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getInt
Decodes a Base64 encoded
String
and converts it into an int value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded int value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getLong
Decodes a Base64 encoded
String
and converts it into a long value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded long value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getString
Decodes a Base64 encoded
String
and converts it into aString
value.- Parameters:
str
- the string to be decoded.- Returns:
- the decoded String value.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
getOpaque
Decodes a Base64 encoded
String
and converts it into an opaque value.- Parameters:
str
- the string to be decoded.- Returns:
- a Base64 decoded byte array.
- Throws:
InvalidBase64DataException
- if the String was incomplete.
-
encode
public static byte[] encode(byte b) Base64 encodes a byte value.
- Parameters:
b
- the byte to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(short s) Base64 encodes a short value.
- Parameters:
s
- the short to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(int i) Base64 encodes an int value.
- Parameters:
i
- the int to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(long l) Base64 encodes a long value.
- Parameters:
l
- the long to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(double d) Base64 encodes a double value.
- Parameters:
d
- the double to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(float f) Base64 encodes a float value.
- Parameters:
f
- the float to be encoded.- Returns:
- an encoded byte array.
-
encode
public static byte[] encode(byte[] bytes) Base64 encodes an opaque type.
- Parameters:
bytes
- the opaque type to be encoded.- Returns:
- an encoded byte array.
-