futils
Class SerialUtils

java.lang.Object
  extended by futils.SerialUtils

public class SerialUtils
extends java.lang.Object


Constructor Summary
SerialUtils()
           
 
Method Summary
static byte[] getBytes(java.io.Serializable obj)
          Convert an object that is Serializable into an array of byte
static byte[] getGzBytes(java.io.Serializable obj)
          This is the inverse of the getGZObject method
static java.lang.Object getGzObject(byte[] b)
          A means of implementing persistance using gzipped byte arrays
static java.lang.Object getObject(byte[] b)
          The inverse of the getBytes method, this reconstitutes and object
static void main(java.lang.String[] args)
           
static void print(Customer[] c)
          This will print all the customers in a list.
static java.lang.Object readGzippedObject()
           
static java.lang.String readGzipString()
          Takes file input that is compressed and uncompresses it.
static java.lang.Object readObjectUncompressed()
           
static void saveGzipObject(java.lang.Object o)
           
static void saveObjectUncompressed(java.lang.Object o)
           
static void saveReadGzipObjectTest()
           
static void testReadGzipObject()
           
static void testReadWriteGzipString()
           
static void testSaveGzipString()
           
static void testTheTest()
           
static void writeGzipString(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialUtils

public SerialUtils()
Method Detail

testReadGzipObject

public static void testReadGzipObject()

readGzippedObject

public static java.lang.Object readGzippedObject()
                                          throws java.io.IOException,
                                                 java.io.FileNotFoundException,
                                                 java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.io.FileNotFoundException
java.lang.ClassNotFoundException

readObjectUncompressed

public static java.lang.Object readObjectUncompressed()
                                               throws java.io.IOException,
                                                      java.io.FileNotFoundException,
                                                      java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.io.FileNotFoundException
java.lang.ClassNotFoundException

saveGzipObject

public static void saveGzipObject(java.lang.Object o)
                           throws java.io.IOException
Throws:
java.io.IOException

saveReadGzipObjectTest

public static void saveReadGzipObjectTest()

testSaveGzipString

public static void testSaveGzipString()

testReadWriteGzipString

public static void testReadWriteGzipString()

readGzipString

public static java.lang.String readGzipString()
                                       throws java.io.IOException
Takes file input that is compressed and uncompresses it.

Returns:
a uncompressed string from a file
Throws:
java.io.IOException

writeGzipString

public static void writeGzipString(java.lang.String s)
                            throws java.io.IOException
Throws:
java.io.IOException

saveObjectUncompressed

public static void saveObjectUncompressed(java.lang.Object o)
                                   throws java.io.IOException
Throws:
java.io.IOException

print

public static void print(Customer[] c)
This will print all the customers in a list. Customers rule

Parameters:
c - a customer array

testTheTest

public static void testTheTest()

getGzBytes

public static byte[] getGzBytes(java.io.Serializable obj)
                         throws java.io.IOException
This is the inverse of the getGZObject method

Parameters:
obj - must be serializable
Returns:
and array of bytes, compressed using gzip.
Throws:
java.io.IOException - this should never happen

getGzObject

public static java.lang.Object getGzObject(byte[] b)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
A means of implementing persistance using gzipped byte arrays

Parameters:
b - a byte array of a serializable, gzipped instance
Returns:
an instance that is serializable
Throws:
java.io.IOException - this should not happen
java.lang.ClassNotFoundException - this will happen if the class changes.

getBytes

public static byte[] getBytes(java.io.Serializable obj)
                       throws java.io.IOException
Convert an object that is Serializable into an array of byte

Parameters:
obj - must be serializable
Returns:
array of bytes
Throws:
java.io.IOException - this should never happen

getObject

public static java.lang.Object getObject(byte[] b)
                                  throws java.io.IOException,
                                         java.lang.ClassNotFoundException
The inverse of the getBytes method, this reconstitutes and object

Parameters:
b - the array of bytes containing an instance of a known class.
Returns:
an instance that is serializable
Throws:
java.io.IOException - this should never happen
java.lang.ClassNotFoundException - this will happen if the class is unknown

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException