edu.colorado.cs.ns2.sys
Class GenerateScript

java.lang.Object
  extended by edu.colorado.cs.ns2.sys.GenerateScript

public class GenerateScript
extends java.lang.Object

This class is responsible for handling all file I/O operations necessary for writing the TCL script to disk.

Author:
Kevin Bauer, Pushkar Sambhoos.

Field Summary
private  java.io.BufferedWriter out
          A buffered file writer.
private  java.lang.String templateString
          The TCL script in memory.
 
Constructor Summary
GenerateScript()
          Default constructor.
 
Method Summary
 java.lang.String getTemplateString()
          Returns the TCL code as a String.
 void insertBlankLine()
          Insert a new endline character in the TCL script.
 void insertBlankLine(int n)
          Inserts n blank lines into the TCL script.
 void readTemplate()
          Read the generic NS2 initialization TCL code.
 void setTemplateString(java.lang.String templateString)
          Sets the TCL code String.
 java.lang.String toString()
          Returns the TCL script.
 void writeAgent(Agent agent, NsNode node)
          Write an Agent declaration to the TCL script.
 void writeApplication(NsNode node, int agentElement, Application app)
          Write an Application declaration to the TCL script.
 void writeConnectAgents(Agent agent1, Agent agent2)
          Write a new Agent connection to the TCL script.
 void writeCreateFlowColors()
          Create color scheme for flows 1, 2, and 3
 void writeCreateLink(Link link)
          Write a link declaration to the TCL script.
 void writeCreateNode(NsNode node)
          Write a node variable declaration to the TCL script.
 void writeEvent(java.lang.String s)
          Write a simulation event to the TCL script.
 void writeRouting(java.lang.String routingProto)
          Write routing information to the TCL script.
 void writeScript(java.lang.String fileName)
          Write the script to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

out

private java.io.BufferedWriter out
A buffered file writer.


templateString

private java.lang.String templateString
The TCL script in memory.

Constructor Detail

GenerateScript

public GenerateScript()
Default constructor.

Method Detail

toString

public java.lang.String toString()
Returns the TCL script.

Overrides:
toString in class java.lang.Object

writeCreateFlowColors

public void writeCreateFlowColors()
Create color scheme for flows 1, 2, and 3


writeCreateNode

public void writeCreateNode(NsNode node)
Write a node variable declaration to the TCL script.

Parameters:
node - A new node to append to the TCL script.

writeCreateLink

public void writeCreateLink(Link link)
Write a link declaration to the TCL script.

Parameters:
link - The link to add to the TCL script.

writeAgent

public void writeAgent(Agent agent,
                       NsNode node)
Write an Agent declaration to the TCL script.

Parameters:
agent - The Agent to add to the script.
node - The Node on which the Agent resides.

writeApplication

public void writeApplication(NsNode node,
                             int agentElement,
                             Application app)
Write an Application declaration to the TCL script.

Parameters:
node - The node on which the Application exists.
agentElement - The index of the agent in the Application Object's Agent list.
app - A reference to the Application to append.

writeConnectAgents

public void writeConnectAgents(Agent agent1,
                               Agent agent2)
Write a new Agent connection to the TCL script.

Parameters:
agent1 - The first agent in the connection.
agent2 - The second agent in the connection.

writeEvent

public void writeEvent(java.lang.String s)
Write a simulation event to the TCL script.

Parameters:
s - The TCL code for the new event.

writeScript

public void writeScript(java.lang.String fileName)
Write the script to disk.

Parameters:
fileName - The name of the TCL output file.

readTemplate

public void readTemplate()
Read the generic NS2 initialization TCL code.


getTemplateString

public java.lang.String getTemplateString()
Returns the TCL code as a String.

Returns:
The TCL code as a String.

setTemplateString

public void setTemplateString(java.lang.String templateString)
Sets the TCL code String.

Parameters:
templateString - A new TCL code String.

insertBlankLine

public void insertBlankLine()
Insert a new endline character in the TCL script.


insertBlankLine

public void insertBlankLine(int n)
Inserts n blank lines into the TCL script.

Parameters:
n - The number of blank lines to append to the TCL script.

writeRouting

public void writeRouting(java.lang.String routingProto)
Write routing information to the TCL script.

Parameters:
routingProto - The desired routing protocol.