bcds.phison.io
Class GraphWriter<V,E>

java.lang.Object
  extended by bcds.phison.io.GraphWriter<V,E>
Direct Known Subclasses:
GraphMLWriter, SgfGraphWriter

public abstract class GraphWriter<V,E>
extends java.lang.Object

Base class for all topology file writers; it defines both an interface and useful methods and data for derived classes. For a SimGraph to be writable, its nodes must implement GraphIONode.

Author:
Juan Segovia S.

Constructor Summary
GraphWriter(java.lang.String fname, SimGraph<V,E> g)
           
GraphWriter(java.io.Writer wr, SimGraph<V,E> g)
          Creates a GraphWriter for g and prepares a buffered writer around wr.
 
Method Summary
 void printf(java.lang.String fmt, java.lang.Object... args)
          Writes a formatted string to the output stream.
 void setCapacityMap(java.util.Map<E,java.lang.Integer> cap)
          Saves a reference to the capacity map that will be written out by writeAll().
 void setCostMap(java.util.Map<E,? extends java.lang.Number> cost)
          Saves a reference to the cost map that will be written out by writeAll().
 void setHeadingComment(java.lang.String comment)
          Sets a comment that is typically written at the beginning of the output file (for example, a time stamp).
 void setNetName(java.lang.String netname)
          Sets a name/identification of the topology to be written.
 void setTrafficMatrix(java.util.Map<SimplePair<V,V>,java.lang.Double> trf)
          Saves a reference to the traffic matrix that will be written out by writeAll().
 void write(java.lang.String netname, java.lang.String heading_comment, java.util.Map<E,java.lang.Integer> capacity_map, java.util.Map<E,? extends java.lang.Number> cost_map, java.util.Map<SimplePair<V,V>,java.lang.Double> trf)
          Calls the appropriate setters (setCapacityMap(), setCostMap(), etc.), and finally invokes writeAll().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphWriter

public GraphWriter(java.io.Writer wr,
                   SimGraph<V,E> g)
Creates a GraphWriter for g and prepares a buffered writer around wr.


GraphWriter

public GraphWriter(java.lang.String fname,
                   SimGraph<V,E> g)
Method Detail

write

public void write(java.lang.String netname,
                  java.lang.String heading_comment,
                  java.util.Map<E,java.lang.Integer> capacity_map,
                  java.util.Map<E,? extends java.lang.Number> cost_map,
                  java.util.Map<SimplePair<V,V>,java.lang.Double> trf)
Calls the appropriate setters (setCapacityMap(), setCostMap(), etc.), and finally invokes writeAll().


setNetName

public void setNetName(java.lang.String netname)
Sets a name/identification of the topology to be written. If never called, the netname is the empty string.


setHeadingComment

public void setHeadingComment(java.lang.String comment)
Sets a comment that is typically written at the beginning of the output file (for example, a time stamp). The contents of comment must be consistent with the format of the output.


setCostMap

public void setCostMap(java.util.Map<E,? extends java.lang.Number> cost)
Saves a reference to the cost map that will be written out by writeAll(). cost can be null.


setCapacityMap

public void setCapacityMap(java.util.Map<E,java.lang.Integer> cap)
Saves a reference to the capacity map that will be written out by writeAll().


setTrafficMatrix

public void setTrafficMatrix(java.util.Map<SimplePair<V,V>,java.lang.Double> trf)
Saves a reference to the traffic matrix that will be written out by writeAll(). trf can be null.


printf

public void printf(java.lang.String fmt,
                   java.lang.Object... args)
Writes a formatted string to the output stream.

Throws:
AnyException - wrapping an IOException if an IO error occurs.