dsto.dfc.swing.persistence
Class Deserializer

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

public final class Deserializer
extends Object

Support for deserializing objects in various formats.

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

Method Summary
static InputStream openAutoDetect(InputStream stream, SerializedFormat format)
          Open a data stream, auto detecting format and adding a decompressor if stream is compressed.
static Object read(File file)
           
static Object read(File file, SerializedFormat format)
           
static Object read(InputStream stream)
           
static Object read(InputStream stream, SerializedFormat format)
          Read an object from an input stream.
static Object read(String fileName)
           
static Object read(String fileName, SerializedFormat format)
          Read a serialized object from a file, autodetecting serialized format.
static Object readObject(InputStream input, SerializedFormat format)
          Read an object from an input stream using the correct reader for the given format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public static Object read(File file)
                   throws FileNotFoundException,
                          ClassNotFoundException,
                          IOException
Throws:
FileNotFoundException
ClassNotFoundException
IOException

read

public static Object read(File file,
                          SerializedFormat format)
                   throws FileNotFoundException,
                          ClassNotFoundException,
                          IOException
Throws:
FileNotFoundException
ClassNotFoundException
IOException

read

public static Object read(String fileName)
                   throws FileNotFoundException,
                          ClassNotFoundException,
                          IOException
Throws:
FileNotFoundException
ClassNotFoundException
IOException

read

public static Object read(String fileName,
                          SerializedFormat format)
                   throws FileNotFoundException,
                          ClassNotFoundException,
                          IOException
Read a serialized object from a file, autodetecting serialized format.

Parameters:
fileName - The file to read from.
format - The detected format is stored here if non-null.
Returns:
The deserialized object.
Throws:
FileNotFoundException
ClassNotFoundException
IOException

read

public static Object read(InputStream stream)
                   throws IOException,
                          ClassNotFoundException
Throws:
IOException
ClassNotFoundException

read

public static Object read(InputStream stream,
                          SerializedFormat format)
                   throws IOException,
                          ClassNotFoundException
Read an object from an input stream. Autodetects format for XML (KBML) and Java object serialized object streams, with optional compression.

Parameters:
stream - The stream to read from.
format - The detected format of the stream will be recorded in this if it is not null.
Returns:
The deserialized object.
Throws:
IOException - if an error occurs
ClassNotFoundException - if an error occurs

readObject

public static Object readObject(InputStream input,
                                SerializedFormat format)
                         throws IOException,
                                ClassNotFoundException
Read an object from an input stream using the correct reader for the given format. To read with stream format autodetection, use read(InputStream,SerializedFormat).

Parameters:
input - The stream to read from. Note that if using binary mode, and input is already an ObjectInput instance, it is used directly.
format - The format of the stream.
Returns:
The deserialized object.
Throws:
IOException - if an error occurs
ClassNotFoundException - if an error occurs

openAutoDetect

public static InputStream openAutoDetect(InputStream stream,
                                         SerializedFormat format)
                                  throws IOException
Open a data stream, auto detecting format and adding a decompressor if stream is compressed.

Parameters:
format - Auto detected format is stored here.
Returns:
A stream ready for data reading. Stream is guaranteed to be buffered and support mark ()/reset ().
Throws:
IOException


Copyright © 2008 Commonwealth of Australia