bcds.phison.io
Class DemandTypesReader

java.lang.Object
  extended by bcds.phison.io.DemandTypesReader

public class DemandTypesReader
extends java.lang.Object

Demand types file (.dtypes) reader.

A demand types file specifies certain properties that are common to groups of connections, for example, in what proportion each group contributes to the total traffic (to be used by traffic generators), or which routing algorithm should be used with each one (to be used by simulators).

One (ficticious) example of a .dtypes file is:

  d1  proportion=20,ra=mincost,costtype=unavail_and_edge_bc,w_alpha=0.3
  d2  proportion=80,ra=minhop,costtype=hop
 

The format is line-oriented. Each line has the following format:

id tag
where An internal map is kept that associated a demand id with a dictionary of the key=value pairs. A reference to this map is returned by getTypes().

Author:
Juan Segovia S.

Nested Class Summary
 class DemandTypesReader.DemandType
          DemandType associates a collection of key-value pairs to a demand id.
 
Field Summary
static java.lang.String DEFAULT_TYPE
          A default demand type.
 
Constructor Summary
DemandTypesReader()
          Creates a new instance and automatically inserts a "default" type whose id is "*", with an empty tag.
DemandTypesReader(java.lang.String fname)
          Creates a new instance just like DemandTypesReader(java.lang.String), and prepares for reading from the file fname.
 
Method Summary
 void addDefaultType()
          Inserts the "default" demand type.
 java.util.Map<java.lang.String,DemandTypesReader.DemandType> getTypes()
          Returns a reference to the demand types map.
 void read()
          Reads the whole file and populates the internal map.
 void setInputStream(java.io.Reader ips)
          Changes the input stream to ips.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TYPE

public static final java.lang.String DEFAULT_TYPE
A default demand type. See DemandTypesReader().

See Also:
Constant Field Values
Constructor Detail

DemandTypesReader

public DemandTypesReader()
Creates a new instance and automatically inserts a "default" type whose id is "*", with an empty tag.


DemandTypesReader

public DemandTypesReader(java.lang.String fname)
Creates a new instance just like DemandTypesReader(java.lang.String), and prepares for reading from the file fname.

Throws:
AnyException - wrapping an IOException if any IO error occurs while instantiating the DataFileReader object.
Method Detail

setInputStream

public void setInputStream(java.io.Reader ips)
Changes the input stream to ips. The interal DataFileReader object created in the constructor is replace with a new one pointing to ips.

Throws:
AnyException - wrapping an IOException if any IO error occurs while instantiating the DataFileReader object.

getTypes

public java.util.Map<java.lang.String,DemandTypesReader.DemandType> getTypes()
Returns a reference to the demand types map.


read

public void read()
Reads the whole file and populates the internal map.

The current demand types are removed prior to the read.

Throws:
BadFormatException - if there is a syntax error or if the demand ids are duplicated.
AnyException - wrapping an IOException if any error is encountered while reading.

addDefaultType

public void addDefaultType()
Inserts the "default" demand type.