source: tmcsimulator/trunk/src/tmcsim/client/cadclientgui/GUIScriptReader.java @ 3

Revision 3, 1.1 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files - cadclientgui

Line 
1package tmcsim.client.cadclientgui;
2
3import java.io.File;
4import java.rmi.RemoteException;
5
6import javax.xml.parsers.SAXParserFactory;
7
8import tmcsim.client.cadclientgui.data.CADData;
9
10/**
11 * This class loads the XML script and parses through it in the ScriptHandler. Finally it stores the data from the XML
12 * into the CADData.
13 * @author Nicholas
14 *
15 */
16public class GUIScriptReader {
17   
18    public GUIScriptReader(String fp, CADData cadData) throws RemoteException
19    {
20        loadScriptFile(new File(fp),cadData);
21    }
22   
23    /*
24     * loads the script from the XML and stores the data in the CADData class.
25     */
26    public static void loadScriptFile(File scriptFile,CADData cadData) throws RemoteException {     
27        try {
28               
29            ScriptHandler sh = new ScriptHandler();
30            SAXParserFactory.newInstance().newSAXParser().parse(scriptFile, sh);
31            //cadData.setUnitsFromXML(sh.getUnits());
32            cadData.setIncidentsFromXML(sh.getIncidents());
33               
34        }
35        catch (Exception e) {e.printStackTrace();}
36    }   
37}
Note: See TracBrowser for help on using the repository browser.