de.caff.maze
Class FileDataStorage

java.lang.Object
  extended by de.caff.maze.TemporaryDataStorage
      extended by de.caff.maze.FileDataStorage
All Implemented Interfaces:
DataStorage

public class FileDataStorage
extends TemporaryDataStorage

Data storage using a system access.

 

Field Summary
 
Fields inherited from class de.caff.maze.TemporaryDataStorage
persistentData
 
Constructor Summary
FileDataStorage(SystemAccess systemAccess)
          Constructor.
 
Method Summary
(package private)  boolean load()
          Load data.
(package private)  boolean save()
          Save data.
(package private)  boolean saveImage(java.awt.image.RenderedImage image)
          Save an image.
(package private)  boolean saveToPainter(Maze maze, MazePaintPropertiesProvider properties, SystemAccess.FileType fileType, OutputMazePainterCreator painterCreator)
          Save using a generic output painter.
 void storePersistentData()
          Store all persistent data.
 
Methods inherited from class de.caff.maze.TemporaryDataStorage
getBoolean, getColor, getDouble, getInt, getLong, getString, hasKey, setBoolean, setColor, setDouble, setInt, setLong, setString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDataStorage

public FileDataStorage(SystemAccess systemAccess)
Constructor.

Parameters:
systemAccess - system access used for access of the underlying file system
Method Detail

load

boolean load()
       throws java.lang.Exception
Load data.

Throws:
java.lang.Exception - on access and i/o errors
Returns:
true if data could be loaded successfully, otherwise false

save

boolean save()
       throws java.lang.Exception
Save data.

Throws:
java.lang.Exception - on access and i/o errors
Returns:
true if data could be saved successfully, otherwise false

saveImage

boolean saveImage(java.awt.image.RenderedImage image)
            throws java.lang.Exception
Save an image.

Throws:
java.lang.Exception - on access and i/o errors
Parameters:
image - image to save
Returns:
true if the image could be saved successfully, otherwise false

saveToPainter

boolean saveToPainter(Maze maze,
                      MazePaintPropertiesProvider properties,
                      SystemAccess.FileType fileType,
                      OutputMazePainterCreator painterCreator)
                throws java.lang.Exception
Save using a generic output painter.

Throws:
java.lang.Exception - on access and i/o errors
Parameters:
maze - maze to save
properties - paint properties to use
fileType - file type to save to
painterCreator - creator for the output maze painter
Returns:
true if the created file could be saved successfully, otherwise false

storePersistentData

public void storePersistentData()
Store all persistent data. This is called when the process is about to shutdown.

Specified by:
storePersistentData in interface DataStorage
Overrides:
storePersistentData in class TemporaryDataStorage