| 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 EAddress implements IXMLSaveable { | |
| 30 | ||
| 31 | private int id; | |
| 32 | ||
| 33 | private String userName; | |
| 34 | ||
| 35 | private String hostName; | |
| 36 | ||
| 37 | private String domainName; | |
| 38 | ||
| 39 | 0 | private String description = ""; |
| 40 | ||
| 41 | 0 | public EAddress(int id, String address) { |
| 42 | 0 | this.id = id; |
| 43 | 0 | this.userName = address.substring(0, address.indexOf("@")); |
| 44 | 0 | this.hostName = address.substring(address.indexOf("@") + 1, address |
| 45 | 0 | .lastIndexOf(".")); |
| 46 | 0 | this.domainName = address.substring(address.lastIndexOf(".") + 1, |
| 47 | 0 | address.length()); |
| 48 | 0 | } |
| 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) { | |
| 59 | 0 | super(); |
| 60 | // TODO Auto-generated constructor stub | |
| 61 | 0 | this.id = id; |
| 62 | 0 | this.userName = userName; |
| 63 | 0 | this.hostName = hostName; |
| 64 | 0 | this.domainName = domainName; |
| 65 | 0 | this.description = description; |
| 66 | 0 | } |
| 67 | ||
| 68 | 0 | public EAddress() { |
| 69 | // TODO Auto-generated constructor stub | |
| 70 | 0 | } |
| 71 | ||
| 72 | /** | |
| 73 | * @return Returns the description. | |
| 74 | */ | |
| 75 | public String getDescription() { | |
| 76 | 0 | return description; |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * @return Returns the domainName. | |
| 81 | */ | |
| 82 | public String getDomainName() { | |
| 83 | 0 | return domainName; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * @return Returns the hostName. | |
| 88 | */ | |
| 89 | public String getHostName() { | |
| 90 | 0 | return hostName; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * @return Returns the userName. | |
| 95 | */ | |
| 96 | public String getUserName() { | |
| 97 | 0 | return userName; |
| 98 | } | |
| 99 | ||
| 100 | /* | |
| 101 | * (non-Javadoc) | |
| 102 | * | |
| 103 | * @see java.lang.Object#toString() | |
| 104 | */ | |
| 105 | @Override | |
| 106 | public String toString() { | |
| 107 | 0 | return this.getUserName() + "@" + this.getHostName() + "." |
| 108 | 0 | + this.getDomainName(); |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * @return Returns the id. | |
| 113 | */ | |
| 114 | public int getId() { | |
| 115 | 0 | return id; |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * @param id | |
| 120 | * The id to set. | |
| 121 | */ | |
| 122 | protected void setId(int id) { | |
| 123 | 0 | this.id = id; |
| 124 | 0 | } |
| 125 | ||
| 126 | /** | |
| 127 | * @param description | |
| 128 | * The description to set. | |
| 129 | */ | |
| 130 | public void setDescription(String description) { | |
| 131 | 0 | this.description = description; |
| 132 | 0 | } |
| 133 | ||
| 134 | /** | |
| 135 | * @param domainName | |
| 136 | * The domainName to set. | |
| 137 | */ | |
| 138 | protected void setDomainName(String domainName) { | |
| 139 | 0 | this.domainName = domainName; |
| 140 | 0 | } |
| 141 | ||
| 142 | /** | |
| 143 | * @param hostName | |
| 144 | * The hostName to set. | |
| 145 | */ | |
| 146 | protected void setHostName(String hostName) { | |
| 147 | 0 | this.hostName = hostName; |
| 148 | 0 | } |
| 149 | ||
| 150 | /** | |
| 151 | * @param userName | |
| 152 | * The userName to set. | |
| 153 | */ | |
| 154 | protected void setUserName(String userName) { | |
| 155 | 0 | this.userName = userName; |
| 156 | 0 | } |
| 157 | ||
| 158 | public Node toXml(Document document) { | |
| 159 | 0 | Element eAddressElement = document |
| 160 | 0 | .createElement(ICXmlTags.IC_EADDRESS_TAG); |
| 161 | 0 | eAddressElement.setAttribute(ICXmlTags.IC_EADDRESS_ID_ATTRIBUTE, "" |
| 162 | 0 | + this.id); |
| 163 | 0 | eAddressElement.setAttribute( |
| 164 | 0 | ICXmlTags.IC_EADDRESS_FULL_ADDRESS_ATTRIBUTE, this.toString()); |
| 165 | ||
| 166 | 0 | Element descriptionElement = document |
| 167 | 0 | .createElement(ICXmlTags.IC_EADDRESS_DESCRIPTION_TAG); |
| 168 | 0 | descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
| 169 | 0 | this.description); |
| 170 | 0 | eAddressElement.appendChild(descriptionElement); |
| 171 | ||
| 172 | 0 | return eAddressElement; |
| 173 | } | |
| 174 | ||
| 175 | public EAddress fromXml(Node node) { | |
| 176 | ||
| 177 | 0 | int id = Integer.parseInt(node.getAttributes().getNamedItem(ICXmlTags.IC_EADDRESS_ID_ATTRIBUTE).getNodeValue()); |
| 178 | ||
| 179 | 0 | String fullAddress = node.getChildNodes().item(0).getAttributes().getNamedItem(ICXmlTags.IC_EADDRESS_FULL_ADDRESS_ATTRIBUTE).getNodeValue(); |
| 180 | ||
| 181 | 0 | return new EAddress(id,fullAddress); |
| 182 | } | |
| 183 | ||
| 184 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |