Coverage details for base.user.PhoneNumber

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 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) {
490        super();
50         // TODO Auto-generated constructor stub
510        this.id = id;
520        this.areaCode = areaCode;
530        this.exchange = exchange;
540        this.number = number;
550    }
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) {
660        super();
67         // TODO Auto-generated constructor stub
680        this.id = id;
690        this.areaCode = areaCode;
700        this.exchange = exchange;
710        this.number = number;
720        this.description = description;
730    }
74  
750    public PhoneNumber() {
76         // TODO Auto-generated constructor stub
770    }
78  
79     /**
80      * @return Returns the areaCode.
81      */
82     public String getAreaCode() {
830        return areaCode;
84     }
85  
86     /**
87      * @param areaCode
88      * The areaCode to set.
89      */
90     public void setAreaCode(String areaCode) {
910        this.areaCode = areaCode;
920    }
93  
94     /**
95      * @return Returns the description.
96      */
97     public String getDescription() {
980        return description;
99     }
100  
101     /**
102      * @param description
103      * The description to set.
104      */
105     public void setDescription(String description) {
1060        this.description = description;
1070    }
108  
109     /**
110      * @return Returns the exchange.
111      */
112     public String getExchange() {
1130        return exchange;
114     }
115  
116     /**
117      * @param exchange
118      * The exchange to set.
119      */
120     public void setExchange(String exchange) {
1210        this.exchange = exchange;
1220    }
123  
124     /**
125      * @return Returns the number.
126      */
127     public String getNumber() {
1280        return number;
129     }
130  
131     /**
132      * @param number
133      * The number to set.
134      */
135     public void setNumber(String number) {
1360        this.number = number;
1370    }
138  
139     /**
140      * @return Returns the id.
141      */
142     public int getId() {
1430        return id;
144     }
145  
146     /**
147      * @param id
148      * The id to set.
149      */
150     protected void setId(int id) {
1510        this.id = id;
1520    }
153  
154     public Node toXml(Document document) {
1550        Element phoneNumberElement = document
1560                .createElement(ICXmlTags.IC_PHONE_NUMBER_TAG);
1570        phoneNumberElement.setAttribute(ICXmlTags.IC_PHONE_NUMBER_ID_ATTRIBUTE,
1580                "" + this.id);
159  
1600        Element areaCodeElement = document
1610                .createElement(ICXmlTags.IC_PHONE_AREA_CODE_TAG);
1620        areaCodeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
1630                this.areaCode);
1640        phoneNumberElement.appendChild(areaCodeElement);
165  
1660        Element exchangeElement = document
1670                .createElement(ICXmlTags.IC_PHONE_NUMBER_EXCHANGE_TAG);
1680        exchangeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
1690                this.exchange);
1700        phoneNumberElement.appendChild(exchangeElement);
171  
1720        Element numberElement = document
1730                .createElement(ICXmlTags.IC_PHONE_NUMBER_NUMBER_TAG);
1740        numberElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.number);
1750        phoneNumberElement.appendChild(numberElement);
176  
1770        Element descriptionElement = document
1780                .createElement(ICXmlTags.IC_PHONE_NUMBER_DESCRIPTION_TAG);
1790        descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
1800                this.description);
1810        phoneNumberElement.appendChild(descriptionElement);
182  
1830        return phoneNumberElement;
184     }
185  
186     public PhoneNumber fromXml(Node node) {
1870        int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_PHONE_NUMBER_ID_ATTRIBUTE).getNodeValue());
188  
1890        String areaCode="";
1900        String exchange="";
1910        String number="";
1920        String description="";
193         
1940        for(int i=0;i<node.getChildNodes().getLength();i++){
1950            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_AREA_CODE_TAG))
1960                areaCode = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
1970            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_EXCHANGE_TAG))
1980                exchange = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
1990            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_NUMBER_TAG))
2000                number = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2010            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_PHONE_NUMBER_DESCRIPTION_TAG))
2020                description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
203             
204         }
205         
2060        return new PhoneNumber(id, areaCode, exchange, number,description);
207     }
208  
209 }

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.