JHotDraw 6.0b1

org.jhotdraw.util
Class SerializationStorageFormat

java.lang.Object
  extended by org.jhotdraw.util.StandardStorageFormat
      extended by org.jhotdraw.util.SerializationStorageFormat
All Implemented Interfaces:
StorageFormat

public class SerializationStorageFormat
extends StandardStorageFormat

A SerializationStorageFormat is a straight-forward file format to store and restore Drawings. It uses Java's serialization mechanism to store Drawings. The SerializationStorageFormat has the file extension "ser" (e.g. my_picasso.ser).


Constructor Summary
SerializationStorageFormat()
          Create a SerialzationStorageFormat for storing and restoring Drawings.
 
Method Summary
 java.lang.String createFileDescription()
          Factory method to create a file description for the file type when displaying the associated FileFilter.
protected  java.lang.String createFileExtension()
          Factory method to create the file extension recognized by the FileFilter for this SerializationStorageFormat.
 Drawing restore(java.lang.String fileName)
          Restore a Drawing from a file with a given name.
 java.lang.String store(java.lang.String fileName, Drawing saveDrawing)
          Store a Drawing under a given name.
 
Methods inherited from class org.jhotdraw.util.StandardStorageFormat
adjustFileName, createFileFilter, equals, getFileDescription, getFileExtension, getFileFilter, hasCorrectFileExtension, isRestoreFormat, isStoreFormat, setFileDescription, setFileExtension, setFileFilter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializationStorageFormat

public SerializationStorageFormat()
Create a SerialzationStorageFormat for storing and restoring Drawings.

Method Detail

createFileExtension

protected java.lang.String createFileExtension()
Factory method to create the file extension recognized by the FileFilter for this SerializationStorageFormat. The SerializationStorageFormat has the file extension "ser" (e.g. my_picasso.ser).

Overrides:
createFileExtension in class StandardStorageFormat
Returns:
new file extension

createFileDescription

public java.lang.String createFileDescription()
Factory method to create a file description for the file type when displaying the associated FileFilter.

Overrides:
createFileDescription in class StandardStorageFormat
Returns:
new file description

store

public java.lang.String store(java.lang.String fileName,
                              Drawing saveDrawing)
                       throws java.io.IOException
Store a Drawing under a given name. The name should be valid with regard to the FileFilter that means, it should already contain the appropriate file extension.

Specified by:
store in interface StorageFormat
Overrides:
store in class StandardStorageFormat
Parameters:
fileName - file name of the Drawing under which it should be stored
saveDrawing - drawing to be saved
Returns:
file name with correct file extension
Throws:
java.io.IOException

restore

public Drawing restore(java.lang.String fileName)
                throws java.io.IOException
Restore a Drawing from a file with a given name. The name must be should with regard to the FileFilter that means, it should have the appropriate file extension.

Specified by:
restore in interface StorageFormat
Overrides:
restore in class StandardStorageFormat
Parameters:
fileName - of the file in which the Drawing has been saved
Returns:
restored Drawing
Throws:
java.io.IOException

JHotDraw 6.0b1