com.huguesjohnson.tiamat
Class GameDataManager

java.lang.Object
  extended by com.huguesjohnson.tiamat.GameDataManager
All Implemented Interfaces:
Storable

public class GameDataManager
extends java.lang.Object
implements Storable

GameDataManager.java - manages global data for a game

Author:
Hugues Johnson

Field Summary
protected  java.lang.String absoluteDir
          Absolute path to the directory where objects are saved.
 
Constructor Summary
GameDataManager()
          Creates a new instance of GameDataManager.
 
Method Summary
 void addCharacter(java.lang.String name, java.lang.String absoluteCharacterPath)
          Add a Character to the game data.
 void addItem(java.lang.String name, java.lang.String absoluteItemPath)
          Add an Item to the game data.
 void addLocation(java.lang.String name, java.lang.String absoluteLocationPath)
          Add a Location to the game data.
 void addSequence(java.lang.String name, java.lang.String absoluteLocationPath)
          Add a Sequence to the game data.
 Character getCharacter(java.lang.String name, Formatter formatter)
          Retrieve (deserialize) a Character by name.
 Item getItem(java.lang.String name, Formatter formatter)
          Retrieve an Item by name.
 Location getLocation(java.lang.String name, Formatter formatter)
          Retrieve a Location by name.
 Sequence getSequence(java.lang.String name, Formatter formatter)
          Retrieve a Sequence by name.
 void onDeserialize(Formatter formatter, java.lang.String absoluteDir)
          The onDeserialize event should be fired after an object is de-serialized.
 void saveCharacter(java.lang.String name, Character character, Formatter formatter)
          Save (serialize) a character.
 void saveItem(java.lang.String name, Item item, Formatter formatter)
          Save (serialize) an Item.
 void saveLocation(java.lang.String name, Location location, Formatter formatter)
          Save (serialize) a Location.
 void saveSequence(java.lang.String name, Sequence sequence, Formatter formatter)
          Save (serialize) a Sequence.
 void setAbsoluteDir(java.lang.String absoluteDir)
          Sets the absolute path to the directory where objects are saved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

absoluteDir

protected transient java.lang.String absoluteDir
Absolute path to the directory where objects are saved.

Constructor Detail

GameDataManager

public GameDataManager()
Creates a new instance of GameDataManager.

Method Detail

setAbsoluteDir

public void setAbsoluteDir(java.lang.String absoluteDir)
Sets the absolute path to the directory where objects are saved.

Parameters:
absoluteDir - The absolute path to the directory where characters are saved.

addCharacter

public void addCharacter(java.lang.String name,
                         java.lang.String absoluteCharacterPath)
Add a Character to the game data.

Parameters:
name - The name of the Character to add.
absoluteCharacterPath - The absolute path to the Character file.

getCharacter

public Character getCharacter(java.lang.String name,
                              Formatter formatter)
Retrieve (deserialize) a Character by name.

Parameters:
name - The name of the Character to retrieve.
formatter - The formatter to use to load the Character.
Returns:
A concrete Character.

saveCharacter

public void saveCharacter(java.lang.String name,
                          Character character,
                          Formatter formatter)
Save (serialize) a character.

Parameters:
name - The name of the Character to save.
character - The actual Character object to save.
formatter - The formatter to use to save the Character.

addItem

public void addItem(java.lang.String name,
                    java.lang.String absoluteItemPath)
Add an Item to the game data.

Parameters:
name - The name of the Item to add.
absoluteItemPath - The absolute path to the Item file.

getItem

public Item getItem(java.lang.String name,
                    Formatter formatter)
Retrieve an Item by name.

Parameters:
name - The name of the Item to retrieve.
formatter - The formatter to use to load the Item.
Returns:
A concrete Item.

saveItem

public void saveItem(java.lang.String name,
                     Item item,
                     Formatter formatter)
Save (serialize) an Item.

Parameters:
name - The name of the Item to save.
item - The actual Item object to save.
formatter - The formatter to use to save the Item.

addLocation

public void addLocation(java.lang.String name,
                        java.lang.String absoluteLocationPath)
Add a Location to the game data.

Parameters:
name - The name of the Location to add.
absoluteLocationPath - The absolute path to the Location file.

getLocation

public Location getLocation(java.lang.String name,
                            Formatter formatter)
Retrieve a Location by name.

Parameters:
name - The name of the Location to retrieve.
formatter - The formatter to use to load the Location.
Returns:
A concrete Location.

saveLocation

public void saveLocation(java.lang.String name,
                         Location location,
                         Formatter formatter)
Save (serialize) a Location.

Parameters:
name - The name of the Location to save.
location - The actual Location object to save.
formatter - The formatter to use to save the Location.

addSequence

public void addSequence(java.lang.String name,
                        java.lang.String absoluteLocationPath)
Add a Sequence to the game data.

Parameters:
name - The name of the Sequence to add.
absoluteLocationPath - The absolute path to the Sequence file.

getSequence

public Sequence getSequence(java.lang.String name,
                            Formatter formatter)
Retrieve a Sequence by name.

Parameters:
name - The name of the Sequence to retrieve.
formatter - The formatter to use to load the Sequence.
Returns:
A concrete Sequence.

saveSequence

public void saveSequence(java.lang.String name,
                         Sequence sequence,
                         Formatter formatter)
Save (serialize) a Sequence.

Parameters:
name - The name of the Sequence to save.
sequence - The actual Sequence object to save.
formatter - The formatter to use to save the Sequence.

onDeserialize

public void onDeserialize(Formatter formatter,
                          java.lang.String absoluteDir)
Description copied from interface: Storable
The onDeserialize event should be fired after an object is de-serialized. This allows objects to load transient members, set their working directory, and load Storable members if needed.

Specified by:
onDeserialize in interface Storable
Parameters:
formatter - the formatter to use to load any storable members
absoluteDir - the working directory since all paths stored in the object should be relative


Copyright © 2004-2006 Hugues Johnson