All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kpalin.alabra.FileIO

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Dialog
                                   |
                                   +----java.awt.FileDialog
                                           |
                                           +----kpalin.alabra.FileIO

public class FileIO
extends FileDialog
implements FilenameFilter
Here we control all saving and loading of game. The game is saved brutaly by saving the ChessPlay object, but this class is writen for general object so we can change the implementation easily.

Author:
Kimmo Palin

Variable Index

 o fileSuffix
Identification suffix of the files.
 o LOADTITLE
 o savefile
Name of the file where current game has been saved.
 o saveObject
Object that this object controls.
 o SAVETITLE

Constructor Index

 o FileIO(Frame)
Creates new object for handling game saving and loading.
 o FileIO(Frame, Object)
Creates new object for handling game saving and loading.

Method Index

 o accept(File, String)
Controls what files to show on dialog and what not.
 o getFileName()
 o getLoadName()
Asks the name of the game to be load.
 o getObject()
Returns the target of this object.
 o getSaveName()
 o loadData()
Loads the object from the savefile.
 o loadFile()
Asks the name of the game to be load and loads it.
 o saveData()
Saves game with a given name.
 o saveFile()
 o saveFileAs()
 o setFileName(String)
 o setObject(Object)
Sets new object for this FileIO to handle.

Variables

 o fileSuffix
 private final String fileSuffix
Identification suffix of the files.

 o SAVETITLE
 private final String SAVETITLE
 o LOADTITLE
 private final String LOADTITLE
 o saveObject
 private Object saveObject
Object that this object controls.

 o savefile
 private String savefile
Name of the file where current game has been saved.

Constructors

 o FileIO
 FileIO(Frame parent)
Creates new object for handling game saving and loading.

Parameters:
parent - Parent frame of the possible FileDialog
 o FileIO
 FileIO(Frame parent,
        Object save)
Creates new object for handling game saving and loading.

Parameters:
parent - Parent frame of the possible FileDialog
save - The object to be saved.

Methods

 o setObject
 public void setObject(Object target)
Sets new object for this FileIO to handle.

 o setFileName
 public void setFileName(String name)
 o getFileName
 public String getFileName()
 o getObject
 public Object getObject()
Returns the target of this object.

 o accept
 public boolean accept(File dir,
                       String name)
Controls what files to show on dialog and what not.

 o saveFileAs
 public boolean saveFileAs()
 o saveFile
 public boolean saveFile()
 o getSaveName
 private void getSaveName()
 o saveData
 public boolean saveData()
Saves game with a given name.

Returns:
true if save was succesful, otherwise false.
 o loadFile
 public boolean loadFile()
Asks the name of the game to be load and loads it.

 o getLoadName
 private void getLoadName()
Asks the name of the game to be load.

 o loadData
 public boolean loadData()
Loads the object from the savefile.


All Packages  Class Hierarchy  This Package  Previous  Next  Index