Coverage details for base.user.NAddress

LineHitsSource
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  
330    private String city = "";
34  
350    private String nation = "";
36  
370    private String street = "";
38  
390    private String region = "";
40  
410    private String postalCode = "";
42  
430    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) {
610        super();
62         // TODO Auto-generated constructor stub
630        this.id = id;
640        this.city = city;
650        this.nation = nation;
660        this.street = street;
670        this.region = region;
680        this.postalCode = postalCode;
690        this.description = description;
700    }
71  
720    public NAddress() {
73         // TODO Auto-generated constructor stub
740    }
75  
76     /*
77      * (non-Javadoc)
78      *
79      * @see java.lang.Object#toString()
80      */
81     @Override
82     public String toString() {
830        return street + ", " + city + ", " + nation + ", " + region + ", "
840                + postalCode;
85     }
86  
87     /**
88      * @return Returns the city.
89      */
90     public String getCity() {
910        return city;
92     }
93  
94     /**
95      * @param city
96      * The city to set.
97      */
98     public void setCity(String city) {
990        this.city = city;
1000    }
101  
102     /**
103      * @return Returns the nation.
104      */
105     public String getNation() {
1060        return nation;
107     }
108  
109     /**
110      * @param nation
111      * The nation to set.
112      */
113     public void setNation(String nation) {
1140        this.nation = nation;
1150    }
116  
117     /**
118      * @return Returns the postalCode.
119      */
120     public String getPostalCode() {
1210        return postalCode;
122     }
123  
124     /**
125      * @param postalCode
126      * The postalCode to set.
127      */
128     public void setPostalCode(String postalCode) {
1290        this.postalCode = postalCode;
1300    }
131  
132     /**
133      * @return Returns the region.
134      */
135     public String getRegion() {
1360        return region;
137     }
138  
139     /**
140      * @param region
141      * The region to set.
142      */
143     public void setRegion(String region) {
1440        this.region = region;
1450    }
146  
147     /**
148      * @return Returns the description.
149      */
150     public String getDescription() {
1510        return description;
152     }
153  
154     /**
155      * @param description
156      * The description to set.
157      */
158     public void setDescription(String description) {
1590        this.description = description;
1600    }
161  
162     /**
163      * @return Returns the street.
164      */
165     public String getStreet() {
1660        return street;
167     }
168  
169     /**
170      * @param street
171      * The street to set.
172      */
173     public void setStreet(String street) {
1740        this.street = street;
1750    }
176  
177     /**
178      * @return Returns the id.
179      */
180     public int getId() {
1810        return id;
182     }
183  
184     /**
185      * @param id
186      * The id to set.
187      */
188     protected void setId(int id) {
1890        this.id = id;
1900    }
191  
192     public Node toXml(Document document) {
1930        Element nAddressElement = document
1940                .createElement(ICXmlTags.IC_NADDRESS_TAG);
1950        nAddressElement.setAttribute(ICXmlTags.IC_NADDRESS_ID_ATTRIBUTE, ""
1960                + this.id);
197  
1980        Element cityElement = document
1990                .createElement(ICXmlTags.IC_NADDRESS_CITY_TAG);
2000        cityElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.city);
2010        nAddressElement.appendChild(cityElement);
202  
2030        Element nationElement = document
2040                .createElement(ICXmlTags.IC_NADDRESS_NATION_TAG);
2050        nationElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.nation);
2060        nAddressElement.appendChild(nationElement);
207  
2080        Element streetElement = document
2090                .createElement(ICXmlTags.IC_NADDRESS_STREET_TAG);
2100        streetElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.street);
2110        nAddressElement.appendChild(streetElement);
212  
2130        Element regionElement = document
2140                .createElement(ICXmlTags.IC_NADDRESS_REGION_TAG);
2150        regionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.region);
2160        nAddressElement.appendChild(regionElement);
217  
2180        Element postalCodeElement = document
2190                .createElement(ICXmlTags.IC_NADDRESS_POSTAL_CODE_TAG);
2200        postalCodeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2210                this.postalCode);
2220        nAddressElement.appendChild(postalCodeElement);
223  
2240        Element descriptionElement = document
2250                .createElement(ICXmlTags.IC_NADDRESS_DESCRIPTION_TAG);
2260        descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2270                this.description);
2280        nAddressElement.appendChild(descriptionElement);
229  
2300        return nAddressElement;
231     }
232  
233     public NAddress fromXml(Node node) {
234         
2350        int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_NADDRESS_ID_ATTRIBUTE).getNodeValue());
236  
2370        String city = "";
2380        String nation = "";
2390        String street = "";
2400        String region = "";
2410        String postalCode = "";
2420        String description = "";
243         
2440        for(int i=0;i<node.getChildNodes().getLength(); i++){
2450            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_CITY_TAG))
2460                city = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2470            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_NATION_TAG))
2480                nation = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2490            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_STREET_TAG))
2500                street = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2510            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_REGION_TAG))
2520                region = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2530            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_POSTAL_CODE_TAG))
2540                postalCode = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2550            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_NADDRESS_DESCRIPTION_TAG))
2560                description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
257             
258         }
259  
2600        return new NAddress(id, city, nation, street,
2610                 region, postalCode, description);
262     }
263  
264 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.