JHotDraw 6.0b1

org.jhotdraw.util
Class StorageFormatManager

java.lang.Object
  extended by org.jhotdraw.util.StorageFormatManager

public class StorageFormatManager
extends java.lang.Object

The StorageFormatManager is a contains StorageFormats. It is not a Singleton because it could be necessary to deal with different format managers, e.g. one for importing Drawings, one for exporting Drawings. If one StorageFormat matches the file extension of the Drawing file, then this StorageFormat can be used to store or restore the Drawing.

See Also:
StorageFormat

Constructor Summary
StorageFormatManager()
          Create a new StorageFormatManager.
 
Method Summary
 void addStorageFormat(StorageFormat newStorageFormat)
          Add a StorageFormat that should be supported by this StorageFormatManager.
 boolean containsStorageFormat(StorageFormat checkStorageFormat)
          Test, whether a StorageFormat is supported by this StorageFormat
 StorageFormat findStorageFormat(java.io.File file)
          Find a StorageFormat that can be used according to a file object to store a Drawing in a file or restore it from a file respectively.
 StorageFormat findStorageFormat(javax.swing.filechooser.FileFilter findFileFilter)
          Find a StorageFormat that can be used according to a FileFilter to store a Drawing in a file or restore it from a file respectively.
 StorageFormat getDefaultStorageFormat()
          Return the StorageFormat which is used as selected file format in a javax.swing.JFileChooser
 void registerFileFilters(javax.swing.JFileChooser fileChooser)
          Register all FileFilters supported by StorageFormats
 void removeStorageFormat(StorageFormat oldStorageFormat)
          Remove a StorageFormat that should no longer be supported by this StorageFormatManager.
 void setDefaultStorageFormat(StorageFormat newDefaultStorageFormat)
          Set a StorageFormat as the default storage format which is selected in a javax.swing.JFileChooser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageFormatManager

public StorageFormatManager()
Create a new StorageFormatManager.

Method Detail

addStorageFormat

public void addStorageFormat(StorageFormat newStorageFormat)
Add a StorageFormat that should be supported by this StorageFormatManager.

Parameters:
newStorageFormat - new StorageFormat to be supported

removeStorageFormat

public void removeStorageFormat(StorageFormat oldStorageFormat)
Remove a StorageFormat that should no longer be supported by this StorageFormatManager. The StorageFormat is excluded in when search for a StorageFormat.

Parameters:
oldStorageFormat - old StorageFormat no longer to be supported

containsStorageFormat

public boolean containsStorageFormat(StorageFormat checkStorageFormat)
Test, whether a StorageFormat is supported by this StorageFormat


setDefaultStorageFormat

public void setDefaultStorageFormat(StorageFormat newDefaultStorageFormat)
Set a StorageFormat as the default storage format which is selected in a javax.swing.JFileChooser. The default storage format must be already added with addStorageFormat. Setting the default storage format to null does not automatically remove the StorageFormat from the list of supported StorageFormats.

Parameters:
newDefaultStorageFormat - StorageFormat that should be selected in a JFileChooser

getDefaultStorageFormat

public StorageFormat getDefaultStorageFormat()
Return the StorageFormat which is used as selected file format in a javax.swing.JFileChooser

Returns:
default storage format

registerFileFilters

public void registerFileFilters(javax.swing.JFileChooser fileChooser)
Register all FileFilters supported by StorageFormats

Parameters:
fileChooser - javax.swing.JFileChooser to which FileFilters are added

findStorageFormat

public StorageFormat findStorageFormat(javax.swing.filechooser.FileFilter findFileFilter)
Find a StorageFormat that can be used according to a FileFilter to store a Drawing in a file or restore it from a file respectively.

Parameters:
findFileFilter - FileFilter used to identify a StorageFormat
Returns:
StorageFormat, if a matching file extension could be found, false otherwise

findStorageFormat

public StorageFormat findStorageFormat(java.io.File file)
Find a StorageFormat that can be used according to a file object to store a Drawing in a file or restore it from a file respectively.

Parameters:
file - a File object to be matched
Returns:
StorageFormat, if a matching file extension could be found, null otherwise

JHotDraw 6.0b1