uk.co.keang.sudoku
Class Storage

java.lang.Object
  extended by uk.co.keang.sudoku.Storage

public class Storage
extends java.lang.Object

Provides persistent storage and recovery of sudoku puzzles

Author:
A.G.Docherty

Field Summary
protected static java.lang.String SUDOKU_EXT
           
 
Constructor Summary
Storage()
           
 
Method Summary
static Puzzle load(java.awt.Component owner)
          Loads a puzzle, displaying a file chooser dialog defaulting to the users default directory
static Puzzle load(java.awt.Component owner, java.io.File dir)
          Loads a puzzle, displaying a file chooser dialog defaulting to the given directory
static Puzzle load(java.io.File file)
          Loads the puzzle from this file.
static java.io.File save(Puzzle p, java.awt.Component owner)
          Saves this puzzle displaying a file chooser dialog defaulting to the users default directory
static java.io.File save(Puzzle p, java.awt.Component owner, java.io.File dir)
          Saves this puzzle displaying a file chooser dialog defaulting to the given directory
static void save(Puzzle p, java.io.File file)
          Saves this puzzle to this file.
static java.io.File selectFile(java.awt.Component owner, java.io.File dir, java.lang.String btnText)
          Displays a file chooser dialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUDOKU_EXT

protected static final java.lang.String SUDOKU_EXT
See Also:
Constant Field Values
Constructor Detail

Storage

public Storage()
Method Detail

save

public static java.io.File save(Puzzle p,
                                java.awt.Component owner)
                         throws java.io.IOException
Saves this puzzle displaying a file chooser dialog defaulting to the users default directory

Parameters:
p - the puzzle to save
owner - the gui owner or null
Returns:
the file the puzzle was saved to or null if it wasn't saved
Throws:
java.io.IOException

save

public static java.io.File save(Puzzle p,
                                java.awt.Component owner,
                                java.io.File dir)
                         throws java.io.IOException
Saves this puzzle displaying a file chooser dialog defaulting to the given directory

Parameters:
p - the puzzle to save
owner - the gui owner or null
dir - the directory or null. If a file is given, the files parent directory is used.
Returns:
the file the puzzle was saved to or null if it wasn't saved
Throws:
java.io.IOException

save

public static void save(Puzzle p,
                        java.io.File file)
                 throws java.io.IOException
Saves this puzzle to this file. If the file exists it will be overwritten.

Parameters:
p - the puzzle to save
file - the file to save to
Throws:
java.io.IOException

load

public static Puzzle load(java.awt.Component owner)
                   throws java.io.IOException,
                          IllegalGridException
Loads a puzzle, displaying a file chooser dialog defaulting to the users default directory

Parameters:
owner - the gui owner or null
Returns:
the puzzle
Throws:
java.io.IOException
IllegalGridException

load

public static Puzzle load(java.awt.Component owner,
                          java.io.File dir)
                   throws java.io.IOException,
                          IllegalGridException
Loads a puzzle, displaying a file chooser dialog defaulting to the given directory

Parameters:
owner - the gui owner or null
dir - the directory or null. If a file is given, the files parent directory is used.
Returns:
the puzzle
Throws:
java.io.IOException
IllegalGridException

load

public static Puzzle load(java.io.File file)
                   throws java.io.IOException,
                          IllegalGridException
Loads the puzzle from this file.

Parameters:
file - the file to load from
Returns:
the puzzle
Throws:
java.io.IOException
IllegalGridException

selectFile

public static java.io.File selectFile(java.awt.Component owner,
                                      java.io.File dir,
                                      java.lang.String btnText)
Displays a file chooser dialog

Parameters:
owner -
dir -
Returns: