sbrt.shell.io
Class SerializedOutputFile<E>

java.lang.Object
  extended by sbrt.shell.io.SerializedOutputFile<E>
Type Parameters:
E - the object type.
All Implemented Interfaces:
ResultsManager<E>, OutputFile<E>, SbrtFile
Direct Known Subclasses:
SmoFile

public class SerializedOutputFile<E>
extends java.lang.Object
implements OutputFile<E>

This class is used to write serialized objects to output files.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
SerializedOutputFile(java.lang.String fileName, FileFormat fileFormat)
          Constructs a new serialized output file from the provided arguments.
 
Method Summary
<S extends E>
void
addData(S results)
          Adds data to this output file.
 void breakPoint()
          Does nothing.
 void close()
          Closes this file.
protected  void finalize()
          Disposes of system resources associated with this file when called by the garbage collector.
 java.lang.String getCanonicalName()
          Returns the canonical name of this file.
 FileFormat getFileFormat()
          Returns the format of this file.
 java.lang.String getName()
          Returns the canonical name of this file.
 java.lang.String getOriginalName()
          Returns the name of this file.
 boolean isClosed()
          Indicates if this file has already been closed.
static boolean isEof(java.lang.Object obj)
          Indicates if the provided object is a valid end-of-file marker.
static boolean isValidFormat(FileFormat fileFormat)
          Indicates if the provided file format is valid for a serialized output file.
protected  void writeObject(java.lang.Object obj)
          Serializes the provided object and writes it to this file.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializedOutputFile

public SerializedOutputFile(java.lang.String fileName,
                            FileFormat fileFormat)
Constructs a new serialized output file from the provided arguments.

Parameters:
fileName - the name of the file to be created.
fileFormat - the format of the file to be created.
Method Detail

isEof

public static boolean isEof(java.lang.Object obj)
Indicates if the provided object is a valid end-of-file marker.

Parameters:
obj - the object to test.
Returns:
true if the provided object is an instance of EndOfFile; false otherwise.

isValidFormat

public static boolean isValidFormat(FileFormat fileFormat)
Indicates if the provided file format is valid for a serialized output file.

Parameters:
fileFormat - the file format to test.
Returns:
true if the provided file format is valid for a serialized output file; false otherwise.

getFileFormat

public FileFormat getFileFormat()
Returns the format of this file.

Returns:
the format of this file.

getName

public final java.lang.String getName()
Returns the canonical name of this file.

Specified by:
getName in interface ResultsManager<E>
Returns:
the canonical name of this file.

getOriginalName

public final java.lang.String getOriginalName()
Returns the name of this file.

Specified by:
getOriginalName in interface SbrtFile
Returns:
the name of this file.

getCanonicalName

public final java.lang.String getCanonicalName()
Returns the canonical name of this file.

Specified by:
getCanonicalName in interface SbrtFile
Returns:
the canonical name of this file.
See Also:
File.getCanonicalPath()

addData

public <S extends E> void addData(S results)
Adds data to this output file. The provided data is serialized and written to this file.

Specified by:
addData in interface ResultsManager<E>
Type Parameters:
S - a type extending the primary data type contained in this output file.
Parameters:
results - the results, or data, to be added to this output file.
Throws:
ApplicationException - if an I/O error occurs while writing data to this file.
java.lang.IllegalStateException - if close() has already been called.
java.lang.NullPointerException - if the provided argument is null.

writeObject

protected final void writeObject(java.lang.Object obj)
Serializes the provided object and writes it to this file.

Parameters:
obj - the object to be serialized and written to this file.
Throws:
ApplicationException - if an I/O error occurs while writing to file.
java.io#InvalidClassException - if something is wrong with a class used by serialization.
java.io#NotSerializableException - if some object to be serialized does not implement the java.io.Serializable interface.

breakPoint

public void breakPoint()
Does nothing.

Specified by:
breakPoint in interface ResultsManager<E>
Throws:
java.lang.IllegalStateException - if close() has already been called.

close

public void close()
Closes this file. If this file is already closed, then invoking this method has no effect.

Specified by:
close in interface ResultsManager<E>
Specified by:
close in interface SbrtFile
Throws:
ApplicationException - if an I/O error occurred while closing this file.

isClosed

public final boolean isClosed()
Indicates if this file has already been closed.

Specified by:
isClosed in interface ResultsManager<E>
Specified by:
isClosed in interface SbrtFile
Returns:
true if this file is closed; false othewise.
See Also:
ResultsManager.close()

finalize

protected void finalize()
                 throws java.lang.Throwable
Disposes of system resources associated with this file when called by the garbage collector.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - the Exception raised by this method.
See Also:
Object.finalize()