net.kolls.railworld.io
Class RWGReader

java.lang.Object
  extended by net.kolls.railworld.io.RWGReader

public class RWGReader
extends java.lang.Object

Reads Rail World Games (RWG) files and updates segments, visual appearance, and trains

Author:
Steve Kollmansberger

Constructor Summary
RWGReader()
           
 
Method Summary
static void read(java.io.File f, PlayFrame rf, java.util.List<Script> scripts)
          Reads a Rail World Game (RWG) file and populates/updates a given rail canvas and train list.
static java.lang.String readForRWM(java.io.File f)
          Reads a Rail World Game (RWG) file just to find out the map name associated with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RWGReader

public RWGReader()
Method Detail

readForRWM

public static java.lang.String readForRWM(java.io.File f)
                                   throws org.xml.sax.SAXException,
                                          java.io.IOException
Reads a Rail World Game (RWG) file just to find out the map name associated with it. No other data is acquired.

Parameters:
f - The File containing the RWG data
Returns:
A String indicating the file name (without path) of the associated RWM file
Throws:
org.xml.sax.SAXException - If the parser encounters an error.
java.io.IOException - If the file cannot be read.

read

public static void read(java.io.File f,
                        PlayFrame rf,
                        java.util.List<Script> scripts)
                 throws org.xml.sax.SAXException,
                        java.io.IOException
Reads a Rail World Game (RWG) file and populates/updates a given rail canvas and train list. The rail canvas must already be initialized with the appropriate map. The train list is assumed to be empty. In order to have the canvas initialized, you should use readForRWM(File) first and load the given RWM file. The frame's script list will be updated based on the available scripts. Every scripts used in the save game must be in the available list.

Parameters:
f - The File containing the RWG data
rf - The PlayFrame to update.
scripts - A list of available Scripts. Every script used in the saved game must be available.
Throws:
org.xml.sax.SAXException - If the parser encounters an error, or if there is a problem with the map/game line-up.
java.io.IOException - If the file cannot be read.