Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | package base.user; | |
21 | ||
22 | import org.w3c.dom.Document; | |
23 | import org.w3c.dom.Element; | |
24 | import org.w3c.dom.Node; | |
25 | ||
26 | import base.ICXmlTags; | |
27 | import base.IXMLSaveable; | |
28 | ||
29 | public class PhoneNumber implements IXMLSaveable { | |
30 | ||
31 | private int id; | |
32 | ||
33 | private String areaCode; | |
34 | ||
35 | private String exchange; | |
36 | ||
37 | private String number; | |
38 | ||
39 | private String description; | |
40 | ||
41 | /** | |
42 | * @param id | |
43 | * @param areaCode | |
44 | * @param exchange | |
45 | * @param number | |
46 | */ | |
47 | protected PhoneNumber(int id, String areaCode, String exchange, | |
48 | String number) { | |
49 | 0 | super(); |
50 | // TODO Auto-generated constructor stub | |
51 | 0 | this.id = id; |
52 | 0 | this.areaCode = areaCode; |
53 | 0 | this.exchange = exchange; |
54 | 0 | this.number = number; |
55 | 0 | } |
56 | ||
57 | /** | |
58 | * @param id | |
59 | * @param areaCode | |
60 | * @param exchange | |
61 | * @param number | |
62 | * @param description | |
63 | */ | |
64 | protected PhoneNumber(int id, String areaCode, String exchange, | |
65 | String number, String description) { | |
66 | 0 | super(); |
67 | // TODO Auto-generated constructor stub | |
68 | 0 | this.id = id; |
69 | 0 | this.areaCode = areaCode; |
70 | 0 | this.exchange = exchange; |
71 | 0 | this.number = number; |
72 | 0 | this.description = description; |
73 | 0 | } |
74 | ||
75 | 0 | public PhoneNumber() { |
76 | // TODO Auto-generated constructor stub | |
77 | 0 | } |
78 | ||
79 | /** | |
80 | * @return Returns the areaCode. | |
81 | */ | |
82 | public String getAreaCode() { | |
83 | 0 | return areaCode; |
84 | } | |
85 | ||
86 | /** | |
87 | * @param areaCode | |
88 | * The areaCode to set. | |
89 | */ | |
90 | public void setAreaCode(String areaCode) { | |
91 | 0 | this.areaCode = areaCode; |
92 | 0 | } |
93 | ||
94 | /** | |
95 | * @return Returns the description. | |
96 | */ | |
97 | public String getDescription() { | |
98 | 0 | return description; |
99 | } | |
100 | ||
101 | /** | |
102 | * @param description | |
103 | * The description to set. | |
104 | */ | |
105 | public void setDescription(String description) { | |
106 | 0 | this.description = description; |
107 | 0 | } |
108 | ||
109 | /** | |
110 | * @return Returns the exchange. | |
111 | */ | |
112 | public String getExchange() { | |
113 | 0 | return exchange; |
114 | } | |
115 | ||
116 | /** | |
117 | * @param exchange | |
118 | * The exchange to set. | |
119 | */ | |
120 | public void setExchange(String exchange) { | |
121 | 0 | this.exchange = exchange; |
122 | 0 | } |
123 | ||
124 | /** | |
125 | * @return Returns the number. | |
126 | */ | |
127 | public String getNumber() { | |
128 | 0 | return number; |
129 | } | |
130 | ||
131 | /** | |
132 | * @param number | |
133 | * The number to set. | |
134 | */ | |
135 | public void setNumber(String number) { | |
136 | 0 | this.number = number; |
137 | 0 | } |
138 | ||
139 | /** | |
140 | * @return Returns the id. | |
141 | */ | |
142 | public int getId() { | |
143 | 0 | return id; |
144 | } | |
145 | ||
146 | /** | |
147 | * @param id | |
148 | * The id to set. | |
149 | */ | |
150 | protected void setId(int id) { | |
151 | 0 | this.id = id; |
152 | 0 | } |
153 | ||
154 | public Node toXml(Document document) { | |
155 | 0 | Element phoneNumberElement = document |
156 | 0 | .createElement(ICXmlTags.IC_PHONE_NUMBER_TAG); |
157 | 0 | phoneNumberElement.setAttribute(ICXmlTags.IC_PHONE_NUMBER_ID_ATTRIBUTE, |
158 | 0 | "" + this.id); |
159 | ||
160 | 0 | Element areaCodeElement = document |
161 | 0 | .createElement(ICXmlTags.IC_PHONE_AREA_CODE_TAG); |
162 | 0 | areaCodeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
163 | 0 | this.areaCode); |
164 | 0 | phoneNumberElement.appendChild(areaCodeElement); |
165 | ||
166 | 0 | Element exchangeElement = document |
167 | 0 | .createElement(ICXmlTags.IC_PHONE_NUMBER_EXCHANGE_TAG); |
168 | 0 | exchangeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
169 | 0 | this.exchange); |
170 | 0 | phoneNumberElement.appendChild(exchangeElement); |
171 | ||
172 | 0 | Element numberElement = document |
173 | 0 | .createElement(ICXmlTags.IC_PHONE_NUMBER_NUMBER_TAG); |
174 | 0 | numberElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.number); |
175 | 0 | phoneNumberElement.appendChild(numberElement); |
176 | ||
177 | 0 | Element descriptionElement = document |
178 | 0 | .createElement(ICXmlTags.IC_PHONE_NUMBER_DESCRIPTION_TAG); |
179 | 0 | descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
180 | 0 | this.description); |
181 | 0 | phoneNumberElement.appendChild(descriptionElement); |
182 | ||
183 | 0 | return phoneNumberElement; |
184 | } | |
185 | ||
186 | public PhoneNumber fromXml(Node node) { | |
187 | 0 | int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_PHONE_NUMBER_ID_ATTRIBUTE).getNodeValue()); |
188 | ||
189 | 0 | String areaCode=""; |
190 | 0 | String exchange=""; |
191 | 0 | String number=""; |
192 | 0 | String description=""; |
193 | ||
194 | 0 | for(int i=0;i<node.getChildNodes().getLength();i++){ |
195 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_AREA_CODE_TAG)) |
196 | 0 | areaCode = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
197 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_EXCHANGE_TAG)) |
198 | 0 | exchange = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
199 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_NUMBER_TAG)) |
200 | 0 | number = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
201 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_DESCRIPTION_TAG)) |
202 | 0 | description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
203 | ||
204 | } | |
205 | ||
206 | 0 | return new PhoneNumber(id, areaCode, exchange, number,description); |
207 | } | |
208 | ||
209 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |