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