com.jakewharton.pingdom.util
Class Base64

java.lang.Object
  extended by com.jakewharton.pingdom.util.Base64

public class Base64
extends Object

Provides serialization and deserialization between a regular string and a base-64 encoded string.

This class was taken from Nabeel Mukhtar's github-java-sdk.


Nested Class Summary
static class Base64.InputStream
          The Class InputStream.
static class Base64.OutputStream
          The Class OutputStream.
 
Field Summary
static int DECODE
          The Constant DECODE.
static int DO_BREAK_LINES
          The Constant DO_BREAK_LINES.
static int DONT_GUNZIP
          The Constant DONT_GUNZIP.
static int ENCODE
          The Constant ENCODE.
static int GZIP
          The Constant GZIP.
static int NO_OPTIONS
          The Constant NO_OPTIONS.
static int ORDERED
          The Constant ORDERED.
static int URL_SAFE
          The Constant URL_SAFE.
 
Method Summary
static byte[] decode(byte[] source)
          Decode.
static byte[] decode(byte[] source, int off, int len, int options)
          Decode.
static byte[] decode(String s)
          Decode.
static byte[] decode(String s, int options)
          Decode.
static void decodeFileToFile(String infile, String outfile)
          Decode file to file.
static byte[] decodeFromFile(String filename)
          Decode from file.
static void decodeToFile(String dataToDecode, String filename)
          Decode to file.
static Object decodeToObject(String encodedObject)
          Decode to object.
static Object decodeToObject(String encodedObject, int options, ClassLoader loader)
          Decode to object.
static void encode(ByteBuffer raw, ByteBuffer encoded)
          Encode.
static void encode(ByteBuffer raw, CharBuffer encoded)
          Encode.
static String encodeBytes(byte[] source)
          Encode bytes.
static String encodeBytes(byte[] source, int options)
          Encode bytes.
static String encodeBytes(byte[] source, int off, int len)
          Encode bytes.
static String encodeBytes(byte[] source, int off, int len, int options)
          Encode bytes.
static byte[] encodeBytesToBytes(byte[] source)
          Encode bytes to bytes.
static byte[] encodeBytesToBytes(byte[] source, int off, int len, int options)
          Encode bytes to bytes.
static void encodeFileToFile(String infile, String outfile)
          Encode file to file.
static String encodeFromFile(String filename)
          Encode from file.
static String encodeObject(Serializable serializableObject)
          Encode object.
static String encodeObject(Serializable serializableObject, int options)
          Encode object.
static void encodeToFile(byte[] dataToEncode, String filename)
          Encode to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_OPTIONS

public static final int NO_OPTIONS
The Constant NO_OPTIONS.

See Also:
Constant Field Values

ENCODE

public static final int ENCODE
The Constant ENCODE.

See Also:
Constant Field Values

DECODE

public static final int DECODE
The Constant DECODE.

See Also:
Constant Field Values

GZIP

public static final int GZIP
The Constant GZIP.

See Also:
Constant Field Values

DONT_GUNZIP

public static final int DONT_GUNZIP
The Constant DONT_GUNZIP.

See Also:
Constant Field Values

DO_BREAK_LINES

public static final int DO_BREAK_LINES
The Constant DO_BREAK_LINES.

See Also:
Constant Field Values

URL_SAFE

public static final int URL_SAFE
The Constant URL_SAFE.

See Also:
Constant Field Values

ORDERED

public static final int ORDERED
The Constant ORDERED.

See Also:
Constant Field Values
Method Detail

encode

public static void encode(ByteBuffer raw,
                          ByteBuffer encoded)
Encode.

Parameters:
raw - the raw
encoded - the encoded

encode

public static void encode(ByteBuffer raw,
                          CharBuffer encoded)
Encode.

Parameters:
raw - the raw
encoded - the encoded

encodeObject

public static String encodeObject(Serializable serializableObject)
                           throws IOException
Encode object.

Parameters:
serializableObject - the serializable object
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.

encodeObject

public static String encodeObject(Serializable serializableObject,
                                  int options)
                           throws IOException
Encode object.

Parameters:
serializableObject - the serializable object
options - the options
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.

encodeBytes

public static String encodeBytes(byte[] source)
Encode bytes.

Parameters:
source - the source
Returns:
the string

encodeBytes

public static String encodeBytes(byte[] source,
                                 int options)
                          throws IOException
Encode bytes.

Parameters:
source - the source
options - the options
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.

encodeBytes

public static String encodeBytes(byte[] source,
                                 int off,
                                 int len)
Encode bytes.

Parameters:
source - the source
off - the off
len - the len
Returns:
the string

encodeBytes

public static String encodeBytes(byte[] source,
                                 int off,
                                 int len,
                                 int options)
                          throws IOException
Encode bytes.

Parameters:
source - the source
off - the off
len - the len
options - the options
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.

encodeBytesToBytes

public static byte[] encodeBytesToBytes(byte[] source)
Encode bytes to bytes.

Parameters:
source - the source
Returns:
the byte[]

encodeBytesToBytes

public static byte[] encodeBytesToBytes(byte[] source,
                                        int off,
                                        int len,
                                        int options)
                                 throws IOException
Encode bytes to bytes.

Parameters:
source - the source
off - the off
len - the len
options - the options
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

decode

public static byte[] decode(byte[] source)
                     throws IOException
Decode.

Parameters:
source - the source
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

decode

public static byte[] decode(byte[] source,
                            int off,
                            int len,
                            int options)
                     throws IOException
Decode.

Parameters:
source - the source
off - the off
len - the len
options - the options
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

decode

public static byte[] decode(String s)
                     throws IOException
Decode.

Parameters:
s - the s
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

decode

public static byte[] decode(String s,
                            int options)
                     throws IOException
Decode.

Parameters:
s - the s
options - the options
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

decodeToObject

public static Object decodeToObject(String encodedObject)
                             throws IOException,
                                    ClassNotFoundException
Decode to object.

Parameters:
encodedObject - the encoded object
Returns:
the object
Throws:
IOException - Signals that an I/O exception has occurred.
ClassNotFoundException - the class not found exception

decodeToObject

public static Object decodeToObject(String encodedObject,
                                    int options,
                                    ClassLoader loader)
                             throws IOException,
                                    ClassNotFoundException
Decode to object.

Parameters:
encodedObject - the encoded object
options - the options
loader - the loader
Returns:
the object
Throws:
IOException - Signals that an I/O exception has occurred.
ClassNotFoundException - the class not found exception

encodeToFile

public static void encodeToFile(byte[] dataToEncode,
                                String filename)
                         throws IOException
Encode to file.

Parameters:
dataToEncode - the data to encode
filename - the filename
Throws:
IOException - Signals that an I/O exception has occurred.

decodeToFile

public static void decodeToFile(String dataToDecode,
                                String filename)
                         throws IOException
Decode to file.

Parameters:
dataToDecode - the data to decode
filename - the filename
Throws:
IOException - Signals that an I/O exception has occurred.

decodeFromFile

public static byte[] decodeFromFile(String filename)
                             throws IOException
Decode from file.

Parameters:
filename - the filename
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

encodeFromFile

public static String encodeFromFile(String filename)
                             throws IOException
Encode from file.

Parameters:
filename - the filename
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.

encodeFileToFile

public static void encodeFileToFile(String infile,
                                    String outfile)
                             throws IOException
Encode file to file.

Parameters:
infile - the infile
outfile - the outfile
Throws:
IOException - Signals that an I/O exception has occurred.

decodeFileToFile

public static void decodeFileToFile(String infile,
                                    String outfile)
                             throws IOException
Decode file to file.

Parameters:
infile - the infile
outfile - the outfile
Throws:
IOException - Signals that an I/O exception has occurred.


Copyright © 2011 Jake Wharton. All Rights Reserved.