Coverage details for base.user.EAddress

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 EAddress implements IXMLSaveable {
30  
31     private int id;
32  
33     private String userName;
34  
35     private String hostName;
36  
37     private String domainName;
38  
390    private String description = "";
40  
410    public EAddress(int id, String address) {
420        this.id = id;
430        this.userName = address.substring(0, address.indexOf("@"));
440        this.hostName = address.substring(address.indexOf("@") + 1, address
450                .lastIndexOf("."));
460        this.domainName = address.substring(address.lastIndexOf(".") + 1,
470                address.length());
480    }
49  
50     /**
51      * @param id
52      * @param userName
53      * @param hostName
54      * @param domainName
55      * @param description
56      */
57     public EAddress(int id, String userName, String hostName,
58             String domainName, String description) {
590        super();
60         // TODO Auto-generated constructor stub
610        this.id = id;
620        this.userName = userName;
630        this.hostName = hostName;
640        this.domainName = domainName;
650        this.description = description;
660    }
67  
680    public EAddress() {
69         // TODO Auto-generated constructor stub
700    }
71  
72     /**
73      * @return Returns the description.
74      */
75     public String getDescription() {
760        return description;
77     }
78  
79     /**
80      * @return Returns the domainName.
81      */
82     public String getDomainName() {
830        return domainName;
84     }
85  
86     /**
87      * @return Returns the hostName.
88      */
89     public String getHostName() {
900        return hostName;
91     }
92  
93     /**
94      * @return Returns the userName.
95      */
96     public String getUserName() {
970        return userName;
98     }
99  
100     /*
101      * (non-Javadoc)
102      *
103      * @see java.lang.Object#toString()
104      */
105     @Override
106     public String toString() {
1070        return this.getUserName() + "@" + this.getHostName() + "."
1080                + this.getDomainName();
109     }
110  
111     /**
112      * @return Returns the id.
113      */
114     public int getId() {
1150        return id;
116     }
117  
118     /**
119      * @param id
120      * The id to set.
121      */
122     protected void setId(int id) {
1230        this.id = id;
1240    }
125  
126     /**
127      * @param description
128      * The description to set.
129      */
130     public void setDescription(String description) {
1310        this.description = description;
1320    }
133  
134     /**
135      * @param domainName
136      * The domainName to set.
137      */
138     protected void setDomainName(String domainName) {
1390        this.domainName = domainName;
1400    }
141  
142     /**
143      * @param hostName
144      * The hostName to set.
145      */
146     protected void setHostName(String hostName) {
1470        this.hostName = hostName;
1480    }
149  
150     /**
151      * @param userName
152      * The userName to set.
153      */
154     protected void setUserName(String userName) {
1550        this.userName = userName;
1560    }
157  
158     public Node toXml(Document document) {
1590        Element eAddressElement = document
1600                .createElement(ICXmlTags.IC_EADDRESS_TAG);
1610        eAddressElement.setAttribute(ICXmlTags.IC_EADDRESS_ID_ATTRIBUTE, ""
1620                + this.id);
1630        eAddressElement.setAttribute(
1640                ICXmlTags.IC_EADDRESS_FULL_ADDRESS_ATTRIBUTE, this.toString());
165  
1660        Element descriptionElement = document
1670                .createElement(ICXmlTags.IC_EADDRESS_DESCRIPTION_TAG);
1680        descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
1690                this.description);
1700        eAddressElement.appendChild(descriptionElement);
171  
1720        return eAddressElement;
173     }
174  
175     public EAddress fromXml(Node node) {
176         
1770        int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_EADDRESS_ID_ATTRIBUTE).getNodeValue());
178  
1790        String fullAddress = node.getChildNodes().item(0).getAttributes().getNamedItem(ICXmlTags.IC_EADDRESS_FULL_ADDRESS_ATTRIBUTE).getNodeValue();
180         
1810        return new EAddress(id,fullAddress);
182     }
183  
184 }

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.