planet.simulate
Class EventParser

java.lang.Object
  extended byplanet.simulate.EventParser

public class EventParser
extends java.lang.Object

This class permits to parser the events file with a concrete text format. This format is the following:

 at {stepNumber} JOIN {sourceNodeId} {destinationNodeId} {numberOfTimes}
 at {stepNumber} {LEAVE|FAIL} {sourceNodeId} {numberOfTimes}
 
as for example:
 at 3 JOIN 0 0 1
 at 65 FAIL 6 1
 at 24 LEAVE 4 1
 
If the {sourceNodeId} field is exactly ID the parser will randomly build a new Id.

This last implementation is generic and permits the use of any implemented Id to load the specified values into the {sourceNodeId} and {destinationNodeId} fields.

Author:
Pedro Garcia, Carles Pairot, Ruben Mondejar, Jordi Pujol 08-jul-2005

Constructor Summary
EventParser()
           
 
Method Summary
static java.util.Vector parseEvents(java.lang.String fileName)
          Parse the specified fileName.
static java.util.Vector parseLeaveFail(java.util.StringTokenizer st, int type, int time)
          Parse a LEAVE or FAIL event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventParser

public EventParser()
Method Detail

parseEvents

public static java.util.Vector parseEvents(java.lang.String fileName)
                                    throws java.io.FileNotFoundException,
                                           java.io.IOException
Parse the specified fileName.

Parameters:
fileName - Path to the file with the events to load.
Returns:
A Vector with all loaded events.
Throws:
java.io.FileNotFoundException - if the file is not found.
java.io.IOException - if occurs any problem loading the file.

parseLeaveFail

public static java.util.Vector parseLeaveFail(java.util.StringTokenizer st,
                                              int type,
                                              int time)
Parse a LEAVE or FAIL event.

Parameters:
st - StringTokenizer with the rest of the line to process.
type - The current int value for the LEAVE or FAIL event.
time - Begining event step.
Returns:
The vector with all LEAVE or FAIL events.