dsto.dfc.swing.persistence
Class Serializer

java.lang.Object
  extended by dsto.dfc.swing.persistence.Serializer

public final class Serializer
extends Object

Support for serializing objects in various formats. Includes support XML (KBML) and Java object serialization and adds optional compression.

Version:
$Revision$
Author:
Matthew.
See Also:
Deserializer

Method Summary
static void finishOutput(OutputStream output)
          Call this to finalize compressed output streams.
static OutputStream openCompressedOutput(OutputStream output)
          Open a compressed output stream.
static void save(Object object, String file, SerializedFormat format)
          Serialize an object using a given format.
static void saveAsBinary(Object object, OutputStream stream)
           
static void saveAsBinary(Object object, OutputStream stream, boolean compress)
           
static void saveAsBinary(Object object, String fileName)
           
static void saveAsBinary(Object object, String fileName, boolean compress)
           
static void saveAsKBML(Object object, OutputStream stream)
           
static void saveAsKBML(Object object, OutputStream stream, boolean compress)
           
static void saveAsKBML(Object object, String fileName)
           
static void saveAsKBML(Object object, String fileName, boolean compress)
           
static void writeObject(Object object, OutputStream output, SerializedFormat format)
          Write an object to an output stream using the appropriate writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

save

public static void save(Object object,
                        String file,
                        SerializedFormat format)
                 throws FileNotFoundException,
                        IOException
Serialize an object using a given format.

Parameters:
object - The object to serialize.
file - The file to serialize to.
format - The format to use.
Throws:
FileNotFoundException
IOException

saveAsBinary

public static void saveAsBinary(Object object,
                                String fileName)
                         throws FileNotFoundException,
                                IOException
Throws:
FileNotFoundException
IOException

saveAsBinary

public static void saveAsBinary(Object object,
                                String fileName,
                                boolean compress)
                         throws FileNotFoundException,
                                IOException
Throws:
FileNotFoundException
IOException

saveAsBinary

public static void saveAsBinary(Object object,
                                OutputStream stream)
                         throws IOException
Throws:
IOException

saveAsBinary

public static void saveAsBinary(Object object,
                                OutputStream stream,
                                boolean compress)
                         throws IOException
Throws:
IOException

saveAsKBML

public static void saveAsKBML(Object object,
                              String fileName)
                       throws FileNotFoundException,
                              IOException
Throws:
FileNotFoundException
IOException

saveAsKBML

public static void saveAsKBML(Object object,
                              String fileName,
                              boolean compress)
                       throws FileNotFoundException,
                              IOException
Throws:
FileNotFoundException
IOException

saveAsKBML

public static void saveAsKBML(Object object,
                              OutputStream stream)
                       throws IOException
Throws:
IOException

saveAsKBML

public static void saveAsKBML(Object object,
                              OutputStream stream,
                              boolean compress)
                       throws IOException
Throws:
IOException

openCompressedOutput

public static OutputStream openCompressedOutput(OutputStream output)
                                         throws IOException
Open a compressed output stream. Ensure a call to finishOutput(java.io.OutputStream) is made before closing or the stream will be invalid.

Throws:
IOException

finishOutput

public static void finishOutput(OutputStream output)
                         throws IOException
Call this to finalize compressed output streams. Has no effect on normal streams.

Throws:
IOException

writeObject

public static void writeObject(Object object,
                               OutputStream output,
                               SerializedFormat format)
                        throws IOException
Write an object to an output stream using the appropriate writer.

Parameters:
object - The object to write.
output - The stream.
format - The format. Only the type is used.
Throws:
IOException - if an error occurs


Copyright © 2008 Commonwealth of Australia