| 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 java.util.Date; | |
| 23 | ||
| 24 | import org.w3c.dom.Element; | |
| 25 | import org.w3c.dom.Node; | |
| 26 | ||
| 27 | import base.ICXmlTags; | |
| 28 | import base.IXMLSaveable; | |
| 29 | ||
| 30 | public class Document implements IXMLSaveable { | |
| 31 | ||
| 32 | 0 | private String type = DocumentType.DOCUMENT_TYPE[0]; |
| 33 | ||
| 34 | 0 | private String number = ""; |
| 35 | ||
| 36 | 0 | private String description = ""; |
| 37 | ||
| 38 | 0 | private Date release = new Date(); |
| 39 | ||
| 40 | 0 | private Date expiration = new Date(); |
| 41 | ||
| 42 | 0 | private String imagePath = null; |
| 43 | ||
| 44 | 0 | private String releaseAuthority = DocumentReleaseAuthority.DOCUMENT_RELEASE_AUTHORITY[0]; |
| 45 | ||
| 46 | /** | |
| 47 | * @param type | |
| 48 | * The document's type. | |
| 49 | * @param number | |
| 50 | * The document's number. | |
| 51 | * @param releaseAuthority | |
| 52 | * The document's release authority. | |
| 53 | * @param description | |
| 54 | * The document's description. | |
| 55 | * @param release | |
| 56 | * The document's release date. | |
| 57 | * @param expiration | |
| 58 | * The document's expiration date. | |
| 59 | * @param imagePath | |
| 60 | * The document's image path. | |
| 61 | * | |
| 62 | */ | |
| 63 | 0 | public Document(String type, String number, String releaseAuthority, |
| 64 | 0 | String description, Date release, Date expiration, String imagePath) { |
| 65 | 0 | this.releaseAuthority = releaseAuthority; |
| 66 | 0 | this.description = description; |
| 67 | 0 | this.release = release; |
| 68 | 0 | this.number = number; |
| 69 | 0 | this.expiration = expiration; |
| 70 | 0 | this.type = type; |
| 71 | 0 | this.imagePath = imagePath; |
| 72 | 0 | } |
| 73 | ||
| 74 | 0 | public Document() { |
| 75 | // TODO Auto-generated constructor stub | |
| 76 | 0 | } |
| 77 | ||
| 78 | /** | |
| 79 | * @return Returns the description. | |
| 80 | */ | |
| 81 | public String getDescription() { | |
| 82 | 0 | return description; |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * @param description | |
| 87 | * The description to set. | |
| 88 | */ | |
| 89 | public void setDescription(String description) { | |
| 90 | 0 | this.description = description; |
| 91 | 0 | } |
| 92 | ||
| 93 | /** | |
| 94 | * @return Returns the expiration. | |
| 95 | */ | |
| 96 | public Date getExpiration() { | |
| 97 | 0 | return expiration; |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * @param expiration | |
| 102 | * The expiration to set. | |
| 103 | */ | |
| 104 | public void setExpiration(Date expiration) { | |
| 105 | 0 | this.expiration = expiration; |
| 106 | 0 | } |
| 107 | ||
| 108 | /** | |
| 109 | * @return Returns the imagePath. | |
| 110 | */ | |
| 111 | public String getImagePath() { | |
| 112 | 0 | return imagePath; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * @param imagePath | |
| 117 | * The imagePath to set. | |
| 118 | */ | |
| 119 | public void setImagePath(String imagePath) { | |
| 120 | 0 | this.imagePath = imagePath; |
| 121 | 0 | } |
| 122 | ||
| 123 | /** | |
| 124 | * @return Returns the release. | |
| 125 | */ | |
| 126 | public Date getRelease() { | |
| 127 | 0 | return release; |
| 128 | } | |
| 129 | ||
| 130 | /** | |
| 131 | * @param release | |
| 132 | * The release to set. | |
| 133 | */ | |
| 134 | public void setRelease(Date release) { | |
| 135 | 0 | this.release = release; |
| 136 | 0 | } |
| 137 | ||
| 138 | /** | |
| 139 | * @return Returns the releaseAuthority. | |
| 140 | */ | |
| 141 | public String getReleaseAuthority() { | |
| 142 | 0 | return releaseAuthority; |
| 143 | } | |
| 144 | ||
| 145 | /** | |
| 146 | * @return Returns the number. | |
| 147 | */ | |
| 148 | public String getNumber() { | |
| 149 | 0 | return number; |
| 150 | } | |
| 151 | ||
| 152 | /** | |
| 153 | * @return Returns the type. | |
| 154 | */ | |
| 155 | public String getType() { | |
| 156 | 0 | return type; |
| 157 | } | |
| 158 | ||
| 159 | /* | |
| 160 | * (non-Javadoc) | |
| 161 | * | |
| 162 | * @see java.lang.Object#toString() | |
| 163 | */ | |
| 164 | @Override | |
| 165 | public String toString() { | |
| 166 | 0 | StringBuffer sb = new StringBuffer(); |
| 167 | 0 | sb.append("DOCUMENT"); |
| 168 | 0 | sb.append("\n"); |
| 169 | 0 | sb.append("type:" + type); |
| 170 | 0 | sb.append("\n"); |
| 171 | 0 | sb.append("number: " + number); |
| 172 | 0 | sb.append("\n"); |
| 173 | 0 | sb.append("description: " + description); |
| 174 | 0 | sb.append("\n"); |
| 175 | 0 | sb.append("release: " + release); |
| 176 | 0 | sb.append("\n"); |
| 177 | 0 | sb.append("expiration: " + expiration); |
| 178 | 0 | sb.append("\n"); |
| 179 | 0 | sb.append("image: " + imagePath); |
| 180 | 0 | sb.append("\n"); |
| 181 | 0 | sb.append("authority: " + releaseAuthority); |
| 182 | 0 | return sb.toString(); |
| 183 | } | |
| 184 | ||
| 185 | /** | |
| 186 | * @param releaseAuthority | |
| 187 | * The authority to set. | |
| 188 | */ | |
| 189 | public void setAuthority(String releaseAuthority) { | |
| 190 | 0 | this.releaseAuthority = releaseAuthority; |
| 191 | 0 | } |
| 192 | ||
| 193 | /** | |
| 194 | * @param number | |
| 195 | * The number to set. | |
| 196 | */ | |
| 197 | public void setNumber(String number) { | |
| 198 | 0 | this.number = number; |
| 199 | 0 | } |
| 200 | ||
| 201 | /** | |
| 202 | * @param type | |
| 203 | * The type to set. | |
| 204 | */ | |
| 205 | public void setType(String type) { | |
| 206 | 0 | this.type = type; |
| 207 | 0 | } |
| 208 | ||
| 209 | public Node toXml(org.w3c.dom.Document document) { | |
| 210 | 0 | Element documentElement = document |
| 211 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_TAG); |
| 212 | ||
| 213 | 0 | Element typeElement = document |
| 214 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_TYPE_TAG); |
| 215 | 0 | typeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.type); |
| 216 | 0 | documentElement.appendChild(typeElement); |
| 217 | ||
| 218 | 0 | Element numberElement = document |
| 219 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_NUMBER_TAG); |
| 220 | 0 | numberElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.number); |
| 221 | 0 | documentElement.appendChild(numberElement); |
| 222 | ||
| 223 | 0 | Element descriptionElement = document |
| 224 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_DESCRIPTION_TAG); |
| 225 | 0 | descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
| 226 | 0 | this.description); |
| 227 | 0 | documentElement.appendChild(descriptionElement); |
| 228 | ||
| 229 | 0 | Element releaseAuthorityElement = document |
| 230 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_RELEASE_AUTHORITY_TAG); |
| 231 | 0 | releaseAuthorityElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
| 232 | 0 | this.releaseAuthority.toString()); |
| 233 | 0 | documentElement.appendChild(releaseAuthorityElement); |
| 234 | ||
| 235 | 0 | Element releaseElement = document |
| 236 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_RELEASE_TAG); |
| 237 | 0 | releaseElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.release |
| 238 | 0 | .toString()); |
| 239 | 0 | releaseElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""+this.release.getTime()); |
| 240 | 0 | documentElement.appendChild(releaseElement); |
| 241 | ||
| 242 | 0 | Element expirationElement = document |
| 243 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_EXPIRATION_TAG); |
| 244 | 0 | expirationElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
| 245 | 0 | this.expiration.toString()); |
| 246 | 0 | expirationElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""+this.expiration.getTime()); |
| 247 | ||
| 248 | 0 | documentElement.appendChild(expirationElement); |
| 249 | ||
| 250 | 0 | Element imagePathElement = document |
| 251 | 0 | .createElement(ICXmlTags.IC_DOCUMENT_IMAGE_PATH_TAG); |
| 252 | 0 | imagePathElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
| 253 | 0 | this.imagePath); |
| 254 | 0 | documentElement.appendChild(imagePathElement); |
| 255 | ||
| 256 | 0 | return documentElement; |
| 257 | } | |
| 258 | ||
| 259 | public base.user.Document fromXml(Node node) { | |
| 260 | ||
| 261 | 0 | String type=""; |
| 262 | 0 | String number=""; |
| 263 | 0 | String description=""; |
| 264 | 0 | Date release=null;; |
| 265 | 0 | Date expiration=null;; |
| 266 | 0 | String imagePath=""; |
| 267 | 0 | String releaseAuthority=""; |
| 268 | ||
| 269 | 0 | for(int i=0;i<node.getChildNodes().getLength();i++){ |
| 270 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_TYPE_TAG)) |
| 271 | 0 | type = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
| 272 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_NUMBER_TAG)) |
| 273 | 0 | number = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
| 274 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_DESCRIPTION_TAG)) |
| 275 | 0 | description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
| 276 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_RELEASE_AUTHORITY_TAG)) |
| 277 | 0 | releaseAuthority = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
| 278 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_RELEASE_TAG)) |
| 279 | 0 | release = new Date(Long.parseLong(node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE).getNodeValue())); |
| 280 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_EXPIRATION_TAG)) |
| 281 | 0 | expiration = new Date(Long.parseLong(node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE).getNodeValue())); |
| 282 | 0 | if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_IMAGE_PATH_TAG)) |
| 283 | 0 | imagePath = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue(); |
| 284 | } | |
| 285 | ||
| 286 | 0 | return new Document(type, number, releaseAuthority, description, release, expiration, imagePath); |
| 287 | } | |
| 288 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |