gov.sandia.cognition.io.serialization
Class AbstractFileSerializationHandler<SerializedType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.io.serialization.AbstractFileSerializationHandler<SerializedType>
Type Parameters:
SerializedType - The type of object that can be serialized.
All Implemented Interfaces:
FileSerializationHandler<SerializedType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
AbstractStreamSerializationHandler

public abstract class AbstractFileSerializationHandler<SerializedType>
extends AbstractCloneableSerializable
implements FileSerializationHandler<SerializedType>

An abstract implementation of FileSerializationHandler. Takes care of converting a file name to a File object.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Constructor Summary
AbstractFileSerializationHandler()
          Creates a new AbstractFileSerializationHandler.
 
Method Summary
 Object readFromFile(String fileName)
          Reads an object from the given file.
 void writeToFile(String fileName, SerializedType object)
          Writes an object to a given file.
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.io.serialization.FileSerializationHandler
readFromFile, writeToFile
 

Constructor Detail

AbstractFileSerializationHandler

public AbstractFileSerializationHandler()
Creates a new AbstractFileSerializationHandler.

Method Detail

writeToFile

public void writeToFile(String fileName,
                        SerializedType object)
                 throws IOException
Description copied from interface: FileSerializationHandler
Writes an object to a given file.

Specified by:
writeToFile in interface FileSerializationHandler<SerializedType>
Parameters:
fileName - The name of the file to write the object to.
object - The object to write.
Throws:
IOException - If there is an i/o error.

readFromFile

public Object readFromFile(String fileName)
                    throws IOException,
                           ClassNotFoundException
Description copied from interface: FileSerializationHandler
Reads an object from the given file.

Specified by:
readFromFile in interface FileSerializationHandler<SerializedType>
Parameters:
fileName - The name of the file to read an object from.
Returns:
The object read from the file.
Throws:
IOException - If there is an i/o error.
ClassNotFoundException - If a class cannot be found.