JHotDraw 6.0b1

org.jhotdraw.util
Interface StorageFormat

All Known Implementing Classes:
SerializationStorageFormat, StandardStorageFormat, SVGStorageFormat

public interface StorageFormat

Interface to define a storage format. A StorageFormat is a strategy that knows how to store and restore a Drawing according to a specific encoding. Typically it can be recognized by a file extension. To identify a valid file format for a Drawing an appropriate FileFilter for a javax.swing.JFileChooser component can be requested.

See Also:
Drawing, StorageFormatManager

Method Summary
 javax.swing.filechooser.FileFilter getFileFilter()
          Return a FileFilter that can be used to identify files which can be stored and restored with this Storage Format.
 boolean isRestoreFormat()
          Every format has to identify itself as able to store and/or restore from the format it represents.
 boolean isStoreFormat()
          Every format has to identify itself as able to store and/or restore from the format it represents.
 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.
 

Method Detail

getFileFilter

javax.swing.filechooser.FileFilter getFileFilter()
Return a FileFilter that can be used to identify files which can be stored and restored with this Storage Format. Typically, each storage format has its own recognizable file extension.

Returns:
FileFilter to be used with a javax.swing.JFileChooser

isStoreFormat

boolean isStoreFormat()
Every format has to identify itself as able to store and/or restore from the format it represents. If the storage format can save to the format, it should return true in this method.

Returns:
boolean true if the format can save

isRestoreFormat

boolean isRestoreFormat()
Every format has to identify itself as able to store and/or restore from the format it represents. If the storage format can load from the format, it should return true in this method.

Returns:
boolean true if the format can load

store

java.lang.String store(java.lang.String fileName,
                       Drawing saveDrawing)
                       throws java.io.IOException
Store a Drawing under a given name.

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

Drawing restore(java.lang.String fileName)
                throws java.io.IOException
Restore a Drawing from a file with a given name.

Parameters:
fileName - of the file in which the Drawing has been saved
Returns:
restored Drawing
Throws:
java.io.IOException

JHotDraw 6.0b1