net.sourceforge.worldsaver.rp
Class Loader

java.lang.Object
  |
  +--net.sourceforge.worldsaver.rp.Loader
All Implemented Interfaces:
MiscUtils, java.lang.Runnable

public class Loader
extends java.lang.Object
implements MiscUtils, java.lang.Runnable

This class is designed to load a world and all objects around it from a reader and to do all the connecting world. If you want to use this one, you should generally use the following way:

For interested developers, here is the way the whole thing works: first of all, this one implements the Runnable Interface (as explained above). This means, that the constructor just initializes the StreamTokenizer and the run() method does all the work. I splitted the parsing work the following way: the run() method invokes, dependant on the parsed keyword, a method called parseFoo() where Foo stands for the `end'-classes like Adventure, City etc. This method does call the superclass-like-method, for example, parseAdventure calls parseAction and parseRpBase. These methods just proove, if the current token belongs to the class-specific fields. If yes, it parses the field. Parsing of the fields goes over some data-type-like methods like parseString, parseIntIntLong etc. That results in quite a lot of methods, but provides a better overview, I think. Note that the methods that parse fields defined in abstract classes do nothing than parsing the current token and that e.g. parseAction does NOT call parseRpBase! Further, there are the prooveFoo methods which proove, if the necessary fields of the current object have been there or not.

Version:
Feb 17 2001
Author:
Andreas Schmitz

Fields inherited from interface net.sourceforge.worldsaver.util.MiscUtils
CONSOLE_WIDTH, NEWLINE, RANDOM
 
Constructor Summary
Loader(java.io.Reader r)
          Reads the data from the given Reader.
 
Method Summary
 java.lang.Throwable getException()
          Returns the exception that occured during the running Thread, or null if none occured.
 long getLengthOfTask()
          Returns the length of the task.
 java.lang.String getMessage()
          Returns the message what the Thread is doing right now.
 long getStatus()
          Returns the status of the current running thread.
 World getWorld()
          Returns a reference of the just loaded World, or null, if none has been loaded.
 boolean isReady()
          Returns whether the running thread is ready or not.
 void run()
          This method does the large part of the work.
 java.lang.String versionRequired()
          Returns the version string that the file specified, or '0' if none specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Loader

public Loader(java.io.Reader r)
       throws java.io.IOException
Reads the data from the given Reader. See introduction for details on the usage for this class. Note that the isReady() method will return false until the run() method has been called and finished.
Parameters:
r - the Reader which contains the data
See Also:
Loader
Method Detail

run

public void run()
This method does the large part of the work. It should not be invoked directly; see introduction for details.
Specified by:
run in interface java.lang.Runnable
See Also:
Loader

isReady

public boolean isReady()
Returns whether the running thread is ready or not.
Returns:
true if the thread is ready

getStatus

public long getStatus()
Returns the status of the current running thread.
Returns:
the status

getLengthOfTask

public long getLengthOfTask()
Returns the length of the task.
Returns:
the length

getWorld

public World getWorld()
Returns a reference of the just loaded World, or null, if none has been loaded.
Returns:
the reference

versionRequired

public java.lang.String versionRequired()
Returns the version string that the file specified, or '0' if none specified. The version String can be used to determine which version of the ws is required to use all the features of this file.
Returns:
the version string

getException

public java.lang.Throwable getException()
Returns the exception that occured during the running Thread, or null if none occured.
Returns:
the Exception

getMessage

public java.lang.String getMessage()
Returns the message what the Thread is doing right now.
Returns:
the String (guaranteed not to be null)