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

Revision 2, 4.0 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 * IncidentInquiryWitnesses extends from IncidentInquiryLogEntry
11 * to provide a model object containing information used to display a Witness
12 * entry on the IncidentInquiry CAD screen. Data for a witness includes the
13 * reporting party's name, phone number, and address.<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 *    <REPORT_PARTY/><br/>
19 *    <PHONE_NUM>/<br/>
20 *    <ADDRESS/><br/>
21 *    <POSITION_INFO/><br/>
22 *    <TIMESTAMP/><br/>
23 * </ROOT><br/>
24 *
25 * @author Matthew Cechini
26 * @version
27 */
28@SuppressWarnings("serial")
29public class IncidentInquiryWitnesses extends IncidentInquiryLogEntry
30    implements Serializable {
31   
32    /**
33     * Enumeration with XML tag names.
34     * @author Matthew Cechini
35     */
36    private static enum XML_TAGS {
37        /** Witness' name. */
38        REPORT_PARTY  ("REPORT_PARTY"),     
39        /** Witness' phone number. */
40        PHONE_NUM     ("PHONE_NUM"),   
41        /** Witness' address. */
42        ADDRESS       ("ADDRESS");
43       
44        public String tag;
45       
46        private XML_TAGS(String t) {
47            tag = t;
48        }       
49    }
50   
51    /** Witness' name. */
52    public String reportingParty;
53   
54    /** Witness' phone number. */
55    public String telephoneNum;
56   
57    /** Witness' address. */
58    public String address;     
59
60
61    /**
62     * Constructor.  Initialize all Witness data to empty strings.
63     *
64     *  @param newPosInfo String containing position info for this log entry
65     */
66    public IncidentInquiryWitnesses(String newPosInfo) {
67        super(newPosInfo, "0000");
68
69        reportingParty = "";
70        telephoneNum   = "";
71        address        = "";   
72    }
73   
74
75    /**
76     * Constructor.  Set local data and base data from parameters.
77     *
78     * @param newPositionInfo Position info for this log entry.
79     * @param name            Witness' name
80     * @param num             Witness' phone number
81     * @param add             Witness' address
82     * @param timestamp       Timestamp for this log entry
83     */
84    public IncidentInquiryWitnesses(String newPositionInfo, String name, 
85            String num, String add, String timeStamp) {
86        super(newPositionInfo, timeStamp);
87
88        reportingParty = name;
89        telephoneNum   = num;
90        address        = add;   
91    }       
92   
93    /**
94     * Constructor.  Parse parameter node for Witness log entry data.
95     *
96     * @param theNode Node containing data for this Witness log entry
97     */
98    public IncidentInquiryWitnesses(Node theNode) { 
99        fromXML(theNode);   
100    }
101   
102
103    public void toXML(Element currElem) {
104       
105        Document theDoc    = currElem.getOwnerDocument();
106        Element  tempElem  = null;
107       
108        tempElem = theDoc.createElement(XML_TAGS.REPORT_PARTY.tag);
109        tempElem.appendChild(theDoc.createTextNode(reportingParty));
110        currElem.appendChild(tempElem);
111       
112        tempElem = theDoc.createElement(XML_TAGS.PHONE_NUM.tag);
113        tempElem.appendChild(theDoc.createTextNode(telephoneNum));
114        currElem.appendChild(tempElem);
115       
116        tempElem = theDoc.createElement(XML_TAGS.ADDRESS.tag);
117        tempElem.appendChild(theDoc.createTextNode(address));
118        currElem.appendChild(tempElem);
119
120        super.toXML(currElem);
121    }   
122   
123    public void fromXML(Node modelNode) {   
124       
125        Node childNode = null;
126       
127        childNode = modelNode.getFirstChild();
128        reportingParty = childNode.getTextContent();
129       
130        childNode = childNode.getNextSibling();
131        telephoneNum = childNode.getTextContent();
132       
133        childNode = childNode.getNextSibling();
134        address = childNode.getTextContent();
135
136        childNode = childNode.getNextSibling();
137        super.fromXML(childNode);
138       
139    }
140   
141}
Note: See TracBrowser for help on using the repository browser.