net.sf.colossus.server
Class GameLoading

java.lang.Object
  extended by net.sf.colossus.server.GameLoading

public class GameLoading
extends java.lang.Object


Field Summary
private static java.util.logging.Logger LOGGER
           
private  org.jdom.Element root
           
private  Variant variant
           
 
Constructor Summary
GameLoading()
           
 
Method Summary
 org.jdom.Element getRoot()
           
 Variant getVariant()
           
private  java.lang.String latestSaveFilename(java.lang.String[] filenames)
          Find from the list of savegame filenames the one with the highest numerical value (1000000000_xxx.xml comes after 999999999_xxx.xml)
 boolean loadGame(java.lang.String filename)
          Try to load a game from saveDirName/filename.
 boolean loadGameFromFile(java.io.File file)
          Load contents of the file, get variant name, load the right variant and get the root element.
private  long numberValue(java.lang.String filename)
          Extract and return the numeric part of a filename.
private  java.io.File resolveFileNameToFile(java.lang.String filename)
          For a given filename, open the file with that name from save game directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

variant

private Variant variant

root

private org.jdom.Element root
Constructor Detail

GameLoading

public GameLoading()
Method Detail

getVariant

public Variant getVariant()

getRoot

public org.jdom.Element getRoot()

loadGame

public boolean loadGame(java.lang.String filename)
Try to load a game from saveDirName/filename. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.


resolveFileNameToFile

private java.io.File resolveFileNameToFile(java.lang.String filename)
For a given filename, open the file with that name from save game directory. If no such file, try also whether with adding ".xml" it would become a valid/existing file. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.

Parameters:
filename - The name of the file to load, or "--latest" for looking for latest save game (snapshot) file.
Returns:
The File object for that filename, or null if no such file can't be found

loadGameFromFile

public boolean loadGameFromFile(java.io.File file)
Load contents of the file, get variant name, load the right variant and get the root element. Currently also gets all variant data files and puts them to file cache but that is going to be removed one day. Soon ;-)

Parameters:
file - The file from which to load the game
Returns:
True if load was successful, otherwise false

latestSaveFilename

private java.lang.String latestSaveFilename(java.lang.String[] filenames)
Find from the list of savegame filenames the one with the highest numerical value (1000000000_xxx.xml comes after 999999999_xxx.xml)

Parameters:
filenames - An array of strings which represent filenames
Returns:
Latest savegame from the list

numberValue

private long numberValue(java.lang.String filename)
Extract and return the numeric part of a filename.