Index: trunk/src/tmcsim/application.properties
===================================================================
--- trunk/src/tmcsim/application.properties	(revision 79)
+++ trunk/src/tmcsim/application.properties	(revision 87)
@@ -1,5 +1,5 @@
-#Thu, 05 Oct 2017 10:44:21 -0700
+#Tue, 10 Oct 2017 02:07:01 -0700
 
-Application.revision=67
+Application.revision=84
 
-Application.buildnumber=46
+Application.buildnumber=48
Index: trunk/src/atmsdriver/ATMSDriver.java
===================================================================
--- trunk/src/atmsdriver/ATMSDriver.java	(revision 79)
+++ trunk/src/atmsdriver/ATMSDriver.java	(revision 87)
@@ -1,7 +1,9 @@
 package atmsdriver;
 
-import atmsdriver.model.Network;
+import atmsdriver.model.Highways;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
 import java.util.Properties;
 import java.util.logging.Level;
@@ -9,4 +11,8 @@
 
 /**
+ * ATMS Driver reads the current simulation traffic conditions from the
+ * EXCHANGE.XML file and constructs the Highway Network status info in the
+ * format required by the FEP. It then sends this XML data over a socket to the
+ * FEP Simulator.
  *
  * @author John A. Torres
@@ -15,10 +21,14 @@
 public class ATMSDriver implements Runnable {
 
-    /** ATMSDriver Error logger. */
+    /**
+     * ATMSDriver Error logger.
+     */
     private static Logger ATMSDriverLogger = Logger.getLogger("atmsdriver");
 
     private static final String CONFIG_FILE_NAME = "atms_driver_config.properties";
 
-    /** Properties object for the CADClient class. */
+    /**
+     * Properties object for the CADClient class.
+     */
     private Properties ATMSDriverProperties;
 
@@ -31,9 +41,10 @@
      */
     private static enum PROPERTIES {
-
         LDS_FILE_NAME("LDSFileName"),
-        LOOP_FILE_NAME("LoopFileName"),
-        NETWORK_FILE_NAME("NetworkFileName"),
-        EXCHANGE_FILE_NAME("ExchangeFileName");
+        LOOPS_FILE_NAME("LoopsFileName"),
+        HIGHWAY_META_FILE("HighwayMetaFileName"),
+        EXCHANGE_FILE_NAME("ExchangeFileName"),
+        FEP_WRITER_HOST("FEPWriterHost"),
+        FEP_WRITER_PORT("FEPWriterPort");
 
         public String name;
@@ -44,31 +55,40 @@
     }
 
-    /** Network model. */
-    final private Network network;
-    
-    /** Sleep Time (10 seconds). **/
-    private static final int SLEEP_TIME = 10000;
-    
-    /** Exchange Reader */
+    /**
+     * Highways in traffic network
+     */
+    final private Highways highways;
+
+    /**
+     * Sleep Time (30 seconds). *
+     */
+    private static final int SLEEP_TIME = 30000;
+
+    /**
+     * Exchange Reader
+     */
     private ExchangeReader exchangeReader;
-    
+
     @Override
     public void run() {
         // Check for packets and update the simulator
-        for (;;) {
+        while (true) {
             // Flush the input file
             ExchangeInfo exInfo = exchangeReader.parse(ATMSDriverProperties
                     .getProperty(PROPERTIES.EXCHANGE_FILE_NAME.name));
-            network.toXML();
-            // Update if packet is recieved
+
+            System.out.println(highways.toXML());
+            highways.writeToFEP();
+            // Update if exchangeInfo is recieved
             if (exInfo != null) {
-                System.out.println("Grabbed");
+                // TODO: handle this condition
+                Logger.getLogger("ATMSDriver").log(Level.INFO, "exInfo is not null");
             }
 
-            // Sleep
+            // Wait for FEP Sim to process the data we just sent
             try {
                 Thread.sleep(SLEEP_TIME);
             } catch (InterruptedException ie) {
-                
+                ie.printStackTrace();
             }
         }
@@ -81,12 +101,15 @@
         }
 
-        network = new Network(
-                new File(ATMSDriverProperties.getProperty(
-                                PROPERTIES.LDS_FILE_NAME.name)),
-                new File(ATMSDriverProperties.getProperty(
-                                PROPERTIES.LOOP_FILE_NAME.name)),
-                new File(ATMSDriverProperties.getProperty(
-                                PROPERTIES.NETWORK_FILE_NAME.name)));
-        network.toXML();
+        highways = new Highways(
+                ATMSDriverProperties.getProperty(
+                                PROPERTIES.LDS_FILE_NAME.name),
+                ATMSDriverProperties.getProperty(
+                                PROPERTIES.LOOPS_FILE_NAME.name),
+                ATMSDriverProperties.getProperty(
+                                PROPERTIES.HIGHWAY_META_FILE.name),
+                ATMSDriverProperties.getProperty(PROPERTIES.FEP_WRITER_HOST.name),
+                Integer.parseInt(ATMSDriverProperties.getProperty(
+                                PROPERTIES.FEP_WRITER_PORT.name)));
+        
         exchangeReader = new ExchangeReader();
     }
@@ -106,5 +129,5 @@
 
     /**
-     * Runs the Paramics simulator.
+     * Runs the ATMS Driver.
      */
     public static void main(String[] args) {
Index: trunk/src/atmsdriver/model/Highway.java
===================================================================
--- trunk/src/atmsdriver/model/Highway.java	(revision 87)
+++ trunk/src/atmsdriver/model/Highway.java	(revision 87)
@@ -0,0 +1,23 @@
+package atmsdriver.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ *
+ * @author jtorres
+ */
+class Highway {
+    final private ArrayList<Station> stations;
+    
+    public Highway(ArrayList<FEPLine> lines, int highway)
+    {
+        stations = new ArrayList<Station>();
+        loadHighwayStations(lines);
+    }
+    
+    private void loadHighwayStations(ArrayList<FEPLine> lines)
+    {
+        Collections.sort(stations);
+    }
+}
Index: trunk/src/atmsdriver/model/Station.java
===================================================================
--- trunk/src/atmsdriver/model/Station.java	(revision 84)
+++ trunk/src/atmsdriver/model/Station.java	(revision 87)
@@ -5,12 +5,12 @@
 import org.w3c.dom.Element;
 
-/** A Station is a simulation of a station in a traffic network.
- *  
- *  A Station (LDS) contains static meta data about the station, and
-  two dynamic attributes, MLTotVol and OppTotVol. 
- 
-  A single LDS contains multiple LoopDetectors, which
-  contain data for a single lane on one direction of the freeway. A LDS
-  is specific to a single freeway, direction, and postmile.
+/**
+ * A Station is a simulation of a station in a traffic network.
+ *
+ * A Station (LDS) contains static meta data about the station, and two dynamic
+ * attributes, MLTotVol and OppTotVol.  *
+ * A single LDS contains multiple LoopDetectors, which contain data for a single
+ * lane on one direction of the freeway. A LDS is specific to a single freeway,
+ * direction, and postmile.
  *
  * @author John A. Torres
@@ -19,4 +19,5 @@
 public class Station implements Comparable {
     /* Static Station meta data */
+
     final private int lineNum;
     final private int ldsID; // double check
@@ -27,14 +28,13 @@
     final private double postmile;
     final private DIRECTION direction;
-    
+
     /* Dynamic Station data */
     private int MLTotVol;
     private int OppTotVol;
-    
+
     /* Constructor */
     public Station(int lineNum, int ldsID, int drop,
-            String location, List<LoopDetector> loops, int fwy, 
-            DIRECTION direction, double postmile)
-    {
+            String location, List<LoopDetector> loops, int fwy,
+            DIRECTION direction, double postmile) {
         this.lineNum = lineNum;
         this.ldsID = ldsID;
@@ -45,16 +45,66 @@
         this.direction = direction;
         this.freeway = fwy;
-        
+
         this.MLTotVol = 0;
         this.OppTotVol = 0;
     }
 
+    /**
+     * Returns the station metadata in condensed form. This is just a quick
+     * script function to make a proper highway metadata configuration file, so
+     * that we can read the network faster.
+     *
+     * @return station metadata
+     */
+    public String getStationMeta() {
+        StringBuilder build = new StringBuilder();
+        build.append(Integer.toString(this.ldsID));
+        build.append(" ");
+        build.append(Integer.toString(this.drop));
+        build.append(" ");
+        build.append(Integer.toString(this.freeway));
+        build.append(" ");
+        build.append(this.direction.name);
+        build.append(" ");
+        build.append(Double.toString(this.postmile));
+        build.append(" ");
+        build.append(Integer.toString(loops.size()));
+        build.append(" ");
+        build.append(this.location);
+        build.append("\n");
+        for (LoopDetector loop : loops) {
+            build.append(loop.getLoopMeta());
+        }
+        return build.toString();
+    }
+
+    public double getPostmile() {
+        return postmile;
+    }
+
     @Override
-    public int compareTo(Object o) {
-        
-    }
-    
-    private static enum XML_TAGS
-    {
+    public int compareTo(Object otherStation) {
+        // check that Object is of type Station, if not throw exception
+        if (!(otherStation instanceof Station)) {
+            throw new ClassCastException("A Station object expected.");
+        }
+
+        // get difference of values
+        double otherStationPostmile = ((Station) otherStation).getPostmile();
+        double val = this.postmile - otherStationPostmile;
+
+        // set appropriate comparable return value
+        int retval = 0;
+        if (val > 0) {
+            retval = 1;
+        } else if (val < 0) {
+            retval = -1;
+        }
+
+        return retval;
+    }
+
+    private static enum XML_TAGS {
+
         STATION("Station"),
         LDS_ID("LDS_ID"),
@@ -68,94 +118,89 @@
         ML_TOT_VOL("ML_Tot_Vol"),
         OPP_TOT_VOL("Opp_Tot_Vol");
-        
+
         String tag;
-        
-        private XML_TAGS(String n)
-        {
+
+        private XML_TAGS(String n) {
             tag = n;
         }
     }
-    
-    public void toXML(Element currElem)
-    {
+
+    public void toXML(Element currElem) {
         Document theDoc = currElem.getOwnerDocument();
-        
+
         Element stationElement = theDoc.createElement(XML_TAGS.STATION.tag);
         currElem.appendChild(stationElement);
-        
+
         Element ldsIDElement = theDoc.createElement(XML_TAGS.LDS_ID.tag);
         ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.ldsID)));
         stationElement.appendChild(ldsIDElement);
-        
+
         Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag);
         lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineNum)));
         stationElement.appendChild(lineNumElement);
-        
+
         Element dropElement = theDoc.createElement(XML_TAGS.DROP.tag);
         dropElement.appendChild(theDoc.createTextNode(String.valueOf(this.drop)));
         stationElement.appendChild(dropElement);
-        
+
         Element locationElement = theDoc.createElement(XML_TAGS.LOCATION.tag);
         locationElement.appendChild(theDoc.createTextNode(this.location));
         stationElement.appendChild(locationElement);
-        
+
         Element postMileElement = theDoc.createElement(XML_TAGS.POST_MILE.tag);
         postMileElement.appendChild(theDoc.createTextNode(String.valueOf(this.postmile)));
         stationElement.appendChild(postMileElement);
-        
+
         Element directionElement = theDoc.createElement(XML_TAGS.DIRECTION.tag);
         directionElement.appendChild(theDoc.createTextNode(this.direction.name));
         stationElement.appendChild(directionElement);
-        
+
         Element freewayElement = theDoc.createElement(XML_TAGS.FREEWAY.tag);
         freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.freeway)));
         stationElement.appendChild(freewayElement);
-        
+
         Element mlElement = theDoc.createElement(XML_TAGS.ML_TOT_VOL.tag);
         mlElement.appendChild(theDoc.createTextNode(String.valueOf(this.MLTotVol)));
         stationElement.appendChild(mlElement);
-        
+
         Element oppElement = theDoc.createElement(XML_TAGS.OPP_TOT_VOL.tag);
         oppElement.appendChild(theDoc.createTextNode(String.valueOf(this.OppTotVol)));
         stationElement.appendChild(oppElement);
-        
+
         Element loopsElement = theDoc.createElement(XML_TAGS.LOOPS.tag);
         stationElement.appendChild(loopsElement);
-        
-        for(LoopDetector loop : loops)
-        {
+
+        for (LoopDetector loop : loops) {
             loop.toXML(loopsElement);
         }
     }
-    
+
     /**
      * Enum for freeway direction.
-     * 
+     *
      * @author John A. Torres
      * @version 9/10/2017
      */
-    public static enum DIRECTION
-    {
+    public static enum DIRECTION {
+
         NORTH("N"),
         SOUTH("S"),
         EAST("E"),
         WEST("W");
-        
+
         String name;
-        
-        DIRECTION(String name)
-        {
+
+        DIRECTION(String name) {
             this.name = name;
         }
-        
+
         /**
          * Returns the direction enum, given a string value.
+         *
          * @param name str value for enum
          * @return enum for given str value
          */
-        public static DIRECTION getEnum(String name)
-        {
-            switch(name)
-            {
+        public static DIRECTION getEnum(String name) {
+            switch (name) {
                 case "S":
                     return SOUTH;
Index: trunk/src/atmsdriver/model/FEPLine.java
===================================================================
--- trunk/src/atmsdriver/model/FEPLine.java	(revision 84)
+++ trunk/src/atmsdriver/model/FEPLine.java	(revision 87)
@@ -25,6 +25,6 @@
     final private int lineInfo;
     final private long systemKey;
-    final private long globalSeq;
-    final private long scheduleSeq;
+    private long globalSeq;
+    private long scheduleSeq;
     
     public FEPLine(int lineNum, List<Station> stations, int count,
@@ -40,4 +40,27 @@
         this.globalSeq = globalSeq;
         this.scheduleSeq = scheduleSeq;
+    }
+    
+    // NEED TO CHECK NUMBERS? DO WE EVEN NEED THIS?
+    public void updateSequences()
+    {        
+        this.scheduleSeq += 1;
+        this.globalSeq += 51;
+    }
+    
+    public String getLineMeta()
+    {
+        StringBuilder build = new StringBuilder();
+        build.append(Integer.toString(this.lineNum));
+        build.append(" ");
+        build.append(Integer.toString(this.count));
+        build.append(" ");
+        build.append(Integer.toString(this.stations.size()));
+        build.append("\n");
+        for(Station station : stations)
+        {
+            build.append(station.getStationMeta());
+        }
+        return build.toString();
     }
     
Index: trunk/src/atmsdriver/model/Highways.java
===================================================================
--- trunk/src/atmsdriver/model/Highways.java	(revision 87)
+++ trunk/src/atmsdriver/model/Highways.java	(revision 87)
@@ -0,0 +1,247 @@
+package atmsdriver.model;
+
+import atmsdriver.NetworkLoader;
+import atmsdriver.model.Station.DIRECTION;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Scanner;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author andrew
+ */
+public class Highways {
+
+    final private ArrayList<FEPLine> lines;
+    final private String FEPHostName;
+    final private int FEPPortNum;
+    
+    // NEED FINISH final private ArrayList<Highway> highways;
+    
+    public Highways(String ldsFileName, String loopsFileName, 
+            String highwayMetaFileName, String FEPHostName, int FEPPortNum) {
+        /*
+        lines = loadLines(highwayMetaFileName);
+        System.out.println("SIZE: " + toXML().toCharArray().length);
+        */
+        
+        NetworkLoader ldr = new NetworkLoader(new File(ldsFileName), new File(loopsFileName));
+        this.lines = (ArrayList<FEPLine>) ldr.getFEPLines();
+        this.FEPHostName = FEPHostName;
+        this.FEPPortNum = FEPPortNum;
+        // NEED FINISH this.highways = loadHighways();
+        //writeHighwaysMeta("hard.txt");
+    }
+    
+    // NEED FINISH
+    private void loadHighways()
+    {
+        
+        //highways.add(new Highway(lines, ));
+        
+    }
+/*
+    private ArrayList<FEPLine> loadLines(String highwayMetaFileName) {
+        ArrayList<FEPLine> lines = new ArrayList<>();
+        try {
+            Scanner sc = new Scanner(new File(highwayMetaFileName));
+            String firstLine = sc.nextLine();
+
+            Scanner linesc = new Scanner(firstLine);
+            int numLines = linesc.nextInt();
+            linesc.close();
+
+            for (int i = 0; i < numLines; i++) {
+                System.out.println("CURR: " + i);
+                lines.add(loadLine(sc));
+            }
+            sc.close();
+
+        } catch (FileNotFoundException ex) {
+            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return lines;
+    }
+
+    private FEPLine loadLine(Scanner sc) {
+        String line = sc.nextLine();
+        System.out.println(line);
+        Scanner scline = new Scanner(line);
+
+        int lineNum = scline.nextInt();
+        int count = scline.nextInt();
+        int numStations = scline.nextInt();
+        ArrayList<Station> stations = new ArrayList<>();
+        for (int i = 0; i < numStations; i++) {
+            stations.add(loadStation(sc, lineNum));
+        }
+
+        return new FEPLine(lineNum, stations, count);
+    }
+
+    private Station loadStation(Scanner sc, int lineNum) {
+        String line = sc.nextLine();
+        System.out.println(line);
+        Scanner scline = new Scanner(line);
+        int ldsID = scline.nextInt();
+        int drop = scline.nextInt();
+        int fwy = scline.nextInt();
+        DIRECTION dir = DIRECTION.getEnum(scline.next());
+        double postmile = scline.nextDouble();
+        int numLoops = scline.nextInt();
+        String location = getStationLoc(line);
+        ArrayList<LoopDetector> loops = new ArrayList<>();
+        for (int i = 0; i < numLoops; i++) {
+            loops.add(loadLoop(sc));
+        }
+
+        return new Station(lineNum, ldsID, drop, location, loops, fwy, dir, postmile);
+    }
+
+    private LoopDetector loadLoop(Scanner sc) {
+        String line = sc.nextLine();
+        Scanner scline = new Scanner(line);
+
+        int loopID = scline.nextInt();
+        int laneNum = scline.nextInt();
+        String loopLoc = getLoopLoc(line); // NEED GET LOOPLOC
+        scline.close();
+        return new LoopDetector(loopID, loopLoc, laneNum);
+    }
+
+    private String getLoopLoc(String line) {
+        Scanner sc = new Scanner(line);
+        sc.nextInt();
+        sc.nextInt();
+
+        // GRABS FROM CURRENT TO END OF LINE
+         
+        sc.useDelimiter("\\z");
+        String loc = sc.next().trim();
+        sc.close();
+        return loc;
+    }
+
+    // Returns the loction given the whole line from the lookup file
+    private String getStationLoc(String line) {
+        Scanner scline = new Scanner(line);
+        scline.nextInt();
+        scline.nextInt();
+        scline.nextInt();
+        scline.next();
+        scline.nextDouble();
+        scline.nextInt();
+
+        // GRABS FROM CURRENT TO END OF LINE
+        scline.useDelimiter("\\z");
+        String loc = scline.next().trim();
+        scline.close();
+        return loc;
+    }
+*/
+    public void writeToFEP() {
+        try {
+            Socket sock = new Socket(FEPHostName, FEPPortNum);
+            PrintWriter out = new PrintWriter(sock.getOutputStream(), true);
+            out.println(this.toXML());
+            sock.close();
+        } catch (IOException ex) {
+            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+    
+    // CHECK: DO WE EVEN NEED TO DO THIS?
+    private void updateSequences() {
+        for (FEPLine line : lines) {
+            line.updateSequences();
+        }
+    }
+
+    /**
+     * Returns the network metadata in condensed form. This is just a quick
+     * script function to make a proper highway metadata configuration file, so
+     * that we can read the network faster.
+     *
+     * @return Network metadata
+     */
+    public void writeHighwaysMeta(String fileName) {
+
+        try {
+            FileWriter fw = new FileWriter(new File(fileName));
+            StringBuilder build = new StringBuilder();
+            build.append(lines.size());
+            build.append("\n");
+            System.out.println(lines.size());
+            fw.write(build.toString());
+            int count = 1;
+            for (FEPLine line : lines) {
+                System.out.println("Writing num: " + count);
+                count++;
+                fw.write(line.getLineMeta());
+
+            }
+        } catch (IOException ex) {
+            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public String toXML() {
+        String xml = null;
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            Document theDoc = builder.newDocument();
+
+            Element networkElement = theDoc.createElement(XML_TAGS.NETWORK.tag);
+            theDoc.appendChild(networkElement);
+
+            for (FEPLine line : lines) {
+                line.toXML(networkElement);
+            }
+
+            Transformer tf = TransformerFactory.newInstance().newTransformer();
+
+            tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            tf.setOutputProperty(OutputKeys.INDENT, "yes");
+            tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+
+            Writer out = new StringWriter();
+            tf.transform(new DOMSource(theDoc), new StreamResult(out));
+            xml = out.toString();
+            out.close();
+        } catch (Exception ex) {
+            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return xml;
+
+    }
+
+    private static enum XML_TAGS {
+
+        NETWORK("Network");
+
+        String tag;
+
+        private XML_TAGS(String n) {
+            tag = n;
+        }
+    }
+}
Index: trunk/src/atmsdriver/model/LoopDetector.java
===================================================================
--- trunk/src/atmsdriver/model/LoopDetector.java	(revision 79)
+++ trunk/src/atmsdriver/model/LoopDetector.java	(revision 87)
@@ -57,4 +57,24 @@
     }
     
+    /**
+     * Returns the loop metadata in condensed form.
+     * This is just a quick script function to make a proper highway
+     * metadata configuration file, so that we can read the network
+     * faster.
+     * 
+     * @return loop metadata
+     */
+    public String getLoopMeta()
+    {
+        StringBuilder build = new StringBuilder();
+        build.append(Integer.toString(this.loopID));
+        build.append(" ");
+        build.append(Integer.toString(this.laneNum));
+        build.append(" ");
+        build.append(this.loopLocation);
+        build.append("\n");
+        return build.toString();
+    }
+    
     /** 
      * Updates loop detector dynamic attributes.
Index: trunk/src/atmsdriver/model/Network.java
===================================================================
--- trunk/src/atmsdriver/model/Network.java	(revision 79)
+++ 	(revision )
@@ -1,87 +1,0 @@
-package atmsdriver.model;
-
-import atmsdriver.NetworkLoader;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- *
- * @author andrew
- */
-public class Network {
-    final private ArrayList<FEPLine> lines;
-    final private File networkFile;
-    
-    public Network(File LDSFile, File loopFile, File networkFile)
-    {
-        lines = (ArrayList<FEPLine>) 
-                new NetworkLoader(LDSFile, loopFile).getFEPLines();
-        this.networkFile = networkFile;
-    }
-    
-    public void toXML()
-    {
-        try {
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            DocumentBuilder builder = factory.newDocumentBuilder();
-            Document theDoc = builder.newDocument();
-            
-            Element networkElement = theDoc.createElement(XML_TAGS.NETWORK.tag);
-            theDoc.appendChild(networkElement);
-            
-            for(FEPLine line : lines)
-            {
-                line.toXML(networkElement);
-            }
-            
-            Transformer tf = TransformerFactory.newInstance().newTransformer();
-            
-            tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            tf.setOutputProperty(OutputKeys.INDENT, "yes");
-            tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-            
-            Writer out = new StringWriter();
-            tf.transform(new DOMSource(theDoc), new StreamResult(out));
-            String xml = out.toString();
-            out.close();
-            
-            Writer fileWr = new FileWriter(networkFile);
-            fileWr.write(xml);
-            fileWr.close();
-            
-            
-        } catch (Exception ex) {
-            Logger.getLogger(Network.class.getName()).log(Level.SEVERE, null, ex);
-        }
-    }
-    
-    private static enum XML_TAGS
-    {
-        NETWORK("Network");
-        
-        String tag;
-        
-        private XML_TAGS(String n)
-        {
-            tag = n;
-        }
-    }
-}
