kaapo.filemanager
Class FileManager

java.lang.Object
  extended by kaapo.filemanager.FileManager

public class FileManager
extends Object

Class that implements FileManager interface. Includes file system operations like saving, loading and exporting projects and is to be used by the GUI subsystem.

This class doesn't handle exceptions but throws them up to GUI to handle and inform user about.

Author:
paltamaa
See Also:
Project

Constructor Summary
FileManager()
          Creates a new FileManager.
 
Method Summary
 void exportProject(Project project, DiagramWrapper visibleDiagram, ExportPlugin exportPlugin, File file, Component component)
          Exports a Project object to disk using the export plugin given as a parameter.
 List<ExportPlugin> getExportPlugins()
          Not implemented yet.
 Project readProject(File file)
          Reads a Project object from a file.
 void writeProject(Project project, File file)
          Writes a Project object to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManager

public FileManager()
Creates a new FileManager.

Method Detail

writeProject

public void writeProject(Project project,
                         File file)
                  throws IOException
Writes a Project object to a file.

Parameters:
project - the project to save
file - the file to be opened for writing
Throws:
IOException - if an I/O error occurs

readProject

public Project readProject(File file)
                    throws IOException,
                           ClassNotFoundException,
                           ClassCastException
Reads a Project object from a file.

Parameters:
file - the file to be opened for reading
Returns:
project object from the file
Throws:
IOException - if an I/O error occurs
ClassNotFoundException - if some of the classes used in project is missing from system
ClassCastException - if the object contained in file is not a Project object

exportProject

public void exportProject(Project project,
                          DiagramWrapper visibleDiagram,
                          ExportPlugin exportPlugin,
                          File file,
                          Component component)
                   throws IOException,
                          ComponentNotSupportedException
Exports a Project object to disk using the export plugin given as a parameter.

Throws an IOException if writing fails. The ExportPlugin may choose to throw a ComponentNotSupportedException if it cannot handle a project component in the given project.

Parameters:
project - the project to export
visibleDiagram - the current visible diagram
exportPlugin - the export plugin used for exporting
file - the file to be opened for writing
component - the component to show message dialogs on
Throws:
IOException - if an I/O error occurs
ComponentNotSupportedException - ExportPlugin may throw this exception if it cannot handle some object included in the project

getExportPlugins

public List<ExportPlugin> getExportPlugins()
Not implemented yet. Should return a list of all the available export plugins installed on the system. Should dynamically read the classes from disk so that user can add them after compiling.

Returns:
null