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 NAddress implements IXMLSaveable { | |
30 | ||
31 | private int id; | |
32 | ||
33 | 0 | private String city = ""; |
34 | ||
35 | 0 | private String nation = ""; |
36 | ||
37 | 0 | private String street = ""; |
38 | ||
39 | 0 | private String region = ""; |
40 | ||
41 | 0 | private String postalCode = ""; |
42 | ||
43 | 0 | private String description = ""; |
44 | ||
45 | /** | |
46 | * @param city | |
47 | * The Address'sCity. | |
48 | * @param nation | |
49 | * The Address's Nation. | |
50 | * @param street | |
51 | * The Address's Street. | |
52 | * @param region | |
53 | * The Address's Region. | |
54 | * @param postalCode | |
55 | * The Address's Postal Code. | |
56 | * @param description | |
57 | * The Address's Description. | |
58 | */ | |
59 | protected NAddress(int id, String city, String nation, String street, | |
60 | String region, String postalCode, String description) { | |
61 | 0 | super(); |
62 | // TODO Auto-generated constructor stub | |
63 | 0 | this.id = id; |
64 | 0 | this.city = city; |
65 | 0 | this.nation = nation; |
66 | 0 | this.street = street; |
67 | 0 | this.region = region; |
68 | 0 | this.postalCode = postalCode; |
69 | 0 | this.description = description; |
70 | 0 | } |
71 | ||
72 | 0 | public NAddress() { |
73 | // TODO Auto-generated constructor stub | |
74 | 0 | } |
75 | ||
76 | /* | |
77 | * (non-Javadoc) | |
78 | * | |
79 | * @see java.lang.Object#toString() | |
80 | */ | |
81 | @Override | |
82 | public String toString() { | |
83 | 0 | return street + ", " + city + ", " + nation + ", " + region + ", " |
84 | 0 | + postalCode; |
85 | } | |
86 | ||
87 | /** | |
88 | * @return Returns the city. | |
89 | */ | |
90 | public String getCity() { | |
91 | 0 | return city; |
92 | } | |
93 | ||
94 | /** | |
95 | * @param city | |
96 | * The city to set. | |
97 | */ | |
98 | public void setCity(String city) { | |
99 | 0 | this.city = city; |
100 | 0 | } |
101 | ||
102 | /** | |
103 | * @return Returns the nation. | |
104 | */ | |
105 | public String getNation() { | |
106 | 0 | return nation; |
107 | } | |
108 | ||
109 | /** | |
110 | * @param nation | |
111 | * The nation to set. | |
112 | */ | |
113 | public void setNation(String nation) { | |
114 | 0 | this.nation = nation; |
115 | 0 | } |
116 | ||
117 | /** | |
118 | * @return Returns the postalCode. | |
119 | */ | |
120 | public String getPostalCode() { | |
121 | 0 | return postalCode; |
122 | } | |
123 | ||
124 | /** | |
125 | * @param postalCode | |
126 | * The postalCode to set. | |
127 | */ | |
128 | public void setPostalCode(String postalCode) { | |
129 | 0 | this.postalCode = postalCode; |
130 | 0 | } |
131 | ||
132 | /** | |
133 | * @return Returns the region. | |
134 | */ | |
135 | public String getRegion() { | |
136 | 0 | return region; |
137 | } | |
138 | ||
139 | /** | |
140 | * @param region | |
141 | * The region to set. | |
142 | */ | |
143 | public void setRegion(String region) { | |
144 | 0 | this.region = region; |
145 | 0 | } |
146 | ||
147 | /** | |
148 | * @return Returns the description. | |
149 | */ | |
150 | public String getDescription() { | |
151 | 0 | return description; |
152 | } | |
153 | ||
154 | /** | |
155 | * @param description | |
156 | * The description to set. | |
157 | */ | |
158 | public void setDescription(String description) { | |
159 | 0 | this.description = description; |
160 | 0 | } |
161 | ||
162 | /** | |
163 | * @return Returns the street. | |
164 | */ | |
165 | public String getStreet() { | |
166 | 0 | return street; |
167 | } | |
168 | ||
169 | /** | |
170 | * @param street | |
171 | * The street to set. | |
172 | */ | |
173 | public void setStreet(String street) { | |
174 | 0 | this.street = street; |
175 | 0 | } |
176 | ||
177 | /** | |
178 | * @return Returns the id. | |
179 | */ | |
180 | public int getId() { | |
181 | 0 | return id; |
182 | } | |
183 | ||
184 | /** | |
185 | * @param id | |
186 | * The id to set. | |
187 | */ | |
188 | protected void setId(int id) { | |
189 | 0 | this.id = id; |
190 | 0 | } |
191 | ||
192 | public Node toXml(Document document) { | |
193 | 0 | Element nAddressElement = document |
194 | 0 | .createElement(ICXmlTags.IC_NADDRESS_TAG); |
195 | 0 | nAddressElement.setAttribute(ICXmlTags.IC_NADDRESS_ID_ATTRIBUTE, "" |
196 | 0 | + this.id); |
197 | ||
198 | 0 | Element cityElement = document |
199 | 0 | .createElement(ICXmlTags.IC_NADDRESS_CITY_TAG); |
200 | 0 | cityElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.city); |
201 | 0 | nAddressElement.appendChild(cityElement); |
202 | ||
203 | 0 | Element nationElement = document |
204 | 0 | .createElement(ICXmlTags.IC_NADDRESS_NATION_TAG); |
205 | 0 | nationElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.nation); |
206 | 0 | nAddressElement.appendChild(nationElement); |
207 | ||
208 | 0 | Element streetElement = document |
209 | 0 | .createElement(ICXmlTags.IC_NADDRESS_STREET_TAG); |
210 | 0 | streetElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.street); |
211 | 0 | nAddressElement.appendChild(streetElement); |
212 | ||
213 | 0 | Element regionElement = document |
214 | 0 | .createElement(ICXmlTags.IC_NADDRESS_REGION_TAG); |
215 | 0 | regionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.region); |
216 | 0 | nAddressElement.appendChild(regionElement); |
217 | ||
218 | 0 | Element postalCodeElement = document |
219 | 0 | .createElement(ICXmlTags.IC_NADDRESS_POSTAL_CODE_TAG); |
220 | 0 | postalCodeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
221 | 0 | this.postalCode); |
222 | 0 | nAddressElement.appendChild(postalCodeElement); |
223 | ||
224 | 0 | Element descriptionElement = document |
225 | 0 | .createElement(ICXmlTags.IC_NADDRESS_DESCRIPTION_TAG); |
226 | 0 | descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
227 | 0 | this.description); |
228 | 0 | nAddressElement.appendChild(descriptionElement); |
229 | ||
230 | 0 | return nAddressElement; |
231 | } | |
232 | ||
233 | public NAddress fromXml(Node node) { | |
234 | ||
235 | 0 | int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_NADDRESS_ID_ATTRIBUTE).getNodeValue()); |
236 | ||
237 | 0 | String city = ""; |
238 | 0 | String nation = ""; |
239 | 0 | String street = ""; |
240 | 0 | String region = ""; |
241 | 0 | String postalCode = ""; |
242 | 0 | String description = ""; |
243 | ||
244 | 0 | for(int i=0;i<node.getChildNodes().getLength(); i++){ |
245 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_CITY_TAG)) |
246 | 0 | city = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
247 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_NATION_TAG)) |
248 | 0 | nation = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
249 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_STREET_TAG)) |
250 | 0 | street = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
251 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_REGION_TAG)) |
252 | 0 | region = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
253 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_POSTAL_CODE_TAG)) |
254 | 0 | postalCode = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
255 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_DESCRIPTION_TAG)) |
256 | 0 | description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
257 | ||
258 | } | |
259 | ||
260 | 0 | return new NAddress(id, city, nation, street, |
261 | 0 | region, postalCode, description); |
262 | } | |
263 | ||
264 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |