CH.ifa.draw.util
Class StandardStorageFormat
- java.lang.Object
-
- CH.ifa.draw.util.StandardStorageFormat
-
- All Implemented Interfaces:
- StorageFormat
- Direct Known Subclasses:
- SerializationStorageFormat
public class StandardStorageFormat extends java.lang.Object implements StorageFormat
A StandardStorageFormat is an internal file format to store and restore Drawings. It uses its own descriptive syntax ands write classes and attributes as plain text in a text file. The StandardStorageFormat has the file extension "draw" (e.g. my_picasso.draw).
-
-
Constructor Summary
Constructors Constructor and Description StandardStorageFormat()Create a StandardStorageFormat for storing and restoring Drawings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.StringcreateFileDescription()Factory method to create a file description for the file type when displaying the associated FileFilter.booleanequals(java.lang.Object compareObject)Test, whether two StorageFormats are the same.java.lang.StringgetFileDescription()Return the file description for the file type of the storage formatjava.lang.StringgetFileExtension()Return the file extension for the storage formatjavax.swing.filechooser.FileFiltergetFileFilter()Return the FileFilter used to identify Drawing files with the correct file extension for this StorageFormat.Drawingrestore(java.lang.String fileName)Restore a Drawing from a file with a given name.voidsetFileDescription(java.lang.String newFileDescription)Set the file description for the file type of the storage formatvoidsetFileExtension(java.lang.String newFileExtension)Set the file extension for the storage formatvoidsetFileFilter(javax.swing.filechooser.FileFilter newFileFilter)Set the FileFilter used to identify Drawing files with the correct file extension for this StorageFormat.java.lang.Stringstore(java.lang.String fileName, Drawing saveDrawing)Store a Drawing under a given name.
-
-
-
Constructor Detail
-
StandardStorageFormat
public StandardStorageFormat()
Create a StandardStorageFormat for storing and restoring Drawings.
-
-
Method Detail
-
setFileExtension
public void setFileExtension(java.lang.String newFileExtension)
Set the file extension for the storage format- Parameters:
file- extension
-
getFileExtension
public java.lang.String getFileExtension()
Return the file extension for the storage format- Returns:
- file extension
-
createFileDescription
public java.lang.String createFileDescription()
Factory method to create a file description for the file type when displaying the associated FileFilter.- Returns:
- new file description
-
setFileDescription
public void setFileDescription(java.lang.String newFileDescription)
Set the file description for the file type of the storage format- Parameters:
newFileDescription- description of the file type
-
getFileDescription
public java.lang.String getFileDescription()
Return the file description for the file type of the storage format- Returns:
- description of the file type
-
setFileFilter
public void setFileFilter(javax.swing.filechooser.FileFilter newFileFilter)
Set the FileFilter used to identify Drawing files with the correct file extension for this StorageFormat.- Parameters:
newFileFilter- FileFilter for this StorageFormat
-
getFileFilter
public javax.swing.filechooser.FileFilter getFileFilter()
Return the FileFilter used to identify Drawing files with the correct file extension for this StorageFormat.- Specified by:
getFileFilterin interfaceStorageFormat- Returns:
- FileFilter for this StorageFormat
-
store
public java.lang.String store(java.lang.String fileName, Drawing saveDrawing) throws java.io.IOExceptionStore a Drawing under a given name. If the file name does not have the correct file extension, then the file extension is added.- Specified by:
storein interfaceStorageFormat- Parameters:
fileName- file name of the Drawing under which it should be storedsaveDrawing- 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.- Specified by:
restorein interfaceStorageFormat- Parameters:
name- of the file in which the Drawing has been saved- Returns:
- restored Drawing
- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object compareObject)
Test, whether two StorageFormats are the same. They are the same if they both support the same file extension.- Overrides:
equalsin classjava.lang.Object- Returns:
- true, if both StorageFormats have the same file extension, false otherwise
-
-
DataMelt 3.0 © DataMelt by jWork.ORG