source: tmcsimulator/trunk/src/tmcsim/cadmodels/IncidentInquiryTows.java @ 2

Revision 2, 4.4 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

Line 
1package tmcsim.cadmodels;
2
3import java.io.Serializable;
4
5import org.w3c.dom.Document;
6import org.w3c.dom.Element;
7import org.w3c.dom.Node;
8
9/**
10 * IncidentInquiryTows extends from IncidentInquiryLogEntry to provide a model
11 * object containing information used to display an assigned tow unit.
12 * Data for a tow includes the Tow Company's name, the confidential and public
13 * phone numbers, assigned beat, and current status.<br/>
14 * <br/>
15 * This element parses and creates the following XML schema in its toXML() and
16 * fromXML() methods.  The ROOT element is the parameter for those methods.<br/>
17 * <ROOT><br/>
18 *    <COMPANY/><br/>
19 *    <CONF_PHONE_NUM/>/<br/>
20 *    <PUB_PHONE_NUM/><br/>
21 *    <BEAT/><br/>
22 *    <STATUS/><br/>
23 *    <POSITION_INFO/><br/>
24 *    <TIMESTAMP/><br/>
25 * </ROOT><br/>
26 *
27 * @author Matthew Cechini
28 * @version
29 */
30@SuppressWarnings("serial")
31public class IncidentInquiryTows extends IncidentInquiryLogEntry
32    implements Serializable {
33   
34    /**
35     * Enumeration with XML tag names.
36     * @author Matthew Cechini
37     */
38    private static enum XML_TAGS { 
39        /** Tow company's name. */
40        COMPANY        ("COMPANY"),
41        /** Tow company's confidential phone number. */
42        CONF_PHONE_NUM ("CONF_PHONE_NUM"),     
43        /** Tow company's public phone number. */
44        PUB_PHONE_NUM  ("PUB_PHONE_NUM"),       
45        /** Tow vehicle's assigned beat. */
46        BEAT           ("BEAT"),   
47        /** Tow vehicle's status. */
48        STATUS         ("STATUS");
49       
50        public String tag;
51       
52        private XML_TAGS(String t) {
53            tag = t;
54        }
55    }
56   
57    /** Tow's company name */
58    public String towCompany;
59   
60    /** Tow's confidential phone number */
61    public String confPhoneNum;
62   
63    /** Tow's public phone number */
64    public String publicPhoneNum;
65   
66    /** Tow's assigned beat */
67    public String beat;
68   
69    /** Tow's status */
70    public String statusInfo;
71       
72    /**
73     * Constructor.  Initialize all Tow data to empty strings.
74     *
75     *  @param newPosInfo String containing position info for this log entry
76     */
77    public IncidentInquiryTows(String newPosInfo) {
78        super(newPosInfo, "0000");
79       
80        towCompany     = "";
81        confPhoneNum   = "";
82        publicPhoneNum = "";
83        beat           = "";
84        statusInfo     = "";       
85    }
86   
87    /**
88     * Constructor.  Parse parameter node for Tow log entry data.
89     *
90     * @param theNode Node containing data for this Tow log entry
91     */
92    public IncidentInquiryTows(Node theNode) { 
93        fromXML(theNode);
94    }
95   
96    public void toXML(Element currElem) {
97       
98        Document theDoc    = currElem.getOwnerDocument();
99        Element  tempElem  = null;
100       
101        tempElem = theDoc.createElement(XML_TAGS.COMPANY.tag);
102        tempElem.appendChild(theDoc.createTextNode(towCompany));
103        currElem.appendChild(tempElem);
104       
105        tempElem = theDoc.createElement(XML_TAGS.CONF_PHONE_NUM.tag);
106        tempElem.appendChild(theDoc.createTextNode(confPhoneNum));
107        currElem.appendChild(tempElem);
108       
109        tempElem = theDoc.createElement(XML_TAGS.PUB_PHONE_NUM.tag);
110        tempElem.appendChild(theDoc.createTextNode(publicPhoneNum));
111        currElem.appendChild(tempElem);
112       
113        tempElem = theDoc.createElement(XML_TAGS.BEAT.tag);
114        tempElem.appendChild(theDoc.createTextNode(beat));
115        currElem.appendChild(tempElem);
116       
117        tempElem = theDoc.createElement(XML_TAGS.STATUS.tag);
118        tempElem.appendChild(theDoc.createTextNode(statusInfo));
119        currElem.appendChild(tempElem);
120
121        super.toXML(currElem);
122    }   
123   
124    public void fromXML(Node modelNode) {   
125       
126        Node childNode = null;
127       
128        childNode = modelNode.getFirstChild();
129        towCompany      = childNode.getTextContent();
130       
131        childNode = childNode.getNextSibling();
132        confPhoneNum = childNode.getTextContent();
133       
134        childNode = childNode.getNextSibling();
135        publicPhoneNum = childNode.getTextContent();
136       
137        childNode = childNode.getNextSibling();
138        beat = childNode.getTextContent();
139       
140        childNode = childNode.getNextSibling();
141        statusInfo = childNode.getTextContent();
142
143        childNode = childNode.getNextSibling();
144        super.fromXML(childNode);
145       
146    } 
147}
Note: See TracBrowser for help on using the repository browser.