Coverage details for base.user.Document

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 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  
320    private String type = DocumentType.DOCUMENT_TYPE[0];
33  
340    private String number = "";
35  
360    private String description = "";
37  
380    private Date release = new Date();
39  
400    private Date expiration = new Date();
41  
420    private String imagePath = null;
43  
440    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      */
630    public Document(String type, String number, String releaseAuthority,
640            String description, Date release, Date expiration, String imagePath) {
650        this.releaseAuthority = releaseAuthority;
660        this.description = description;
670        this.release = release;
680        this.number = number;
690        this.expiration = expiration;
700        this.type = type;
710        this.imagePath = imagePath;
720    }
73  
740    public Document() {
75         // TODO Auto-generated constructor stub
760    }
77  
78     /**
79      * @return Returns the description.
80      */
81     public String getDescription() {
820        return description;
83     }
84  
85     /**
86      * @param description
87      * The description to set.
88      */
89     public void setDescription(String description) {
900        this.description = description;
910    }
92  
93     /**
94      * @return Returns the expiration.
95      */
96     public Date getExpiration() {
970        return expiration;
98     }
99  
100     /**
101      * @param expiration
102      * The expiration to set.
103      */
104     public void setExpiration(Date expiration) {
1050        this.expiration = expiration;
1060    }
107  
108     /**
109      * @return Returns the imagePath.
110      */
111     public String getImagePath() {
1120        return imagePath;
113     }
114  
115     /**
116      * @param imagePath
117      * The imagePath to set.
118      */
119     public void setImagePath(String imagePath) {
1200        this.imagePath = imagePath;
1210    }
122  
123     /**
124      * @return Returns the release.
125      */
126     public Date getRelease() {
1270        return release;
128     }
129  
130     /**
131      * @param release
132      * The release to set.
133      */
134     public void setRelease(Date release) {
1350        this.release = release;
1360    }
137  
138     /**
139      * @return Returns the releaseAuthority.
140      */
141     public String getReleaseAuthority() {
1420        return releaseAuthority;
143     }
144  
145     /**
146      * @return Returns the number.
147      */
148     public String getNumber() {
1490        return number;
150     }
151  
152     /**
153      * @return Returns the type.
154      */
155     public String getType() {
1560        return type;
157     }
158  
159     /*
160      * (non-Javadoc)
161      *
162      * @see java.lang.Object#toString()
163      */
164     @Override
165     public String toString() {
1660        StringBuffer sb = new StringBuffer();
1670        sb.append("DOCUMENT");
1680        sb.append("\n");
1690        sb.append("type:" + type);
1700        sb.append("\n");
1710        sb.append("number: " + number);
1720        sb.append("\n");
1730        sb.append("description: " + description);
1740        sb.append("\n");
1750        sb.append("release: " + release);
1760        sb.append("\n");
1770        sb.append("expiration: " + expiration);
1780        sb.append("\n");
1790        sb.append("image: " + imagePath);
1800        sb.append("\n");
1810        sb.append("authority: " + releaseAuthority);
1820        return sb.toString();
183     }
184  
185     /**
186      * @param releaseAuthority
187      * The authority to set.
188      */
189     public void setAuthority(String releaseAuthority) {
1900        this.releaseAuthority = releaseAuthority;
1910    }
192  
193     /**
194      * @param number
195      * The number to set.
196      */
197     public void setNumber(String number) {
1980        this.number = number;
1990    }
200  
201     /**
202      * @param type
203      * The type to set.
204      */
205     public void setType(String type) {
2060        this.type = type;
2070    }
208  
209     public Node toXml(org.w3c.dom.Document document) {
2100        Element documentElement = document
2110                .createElement(ICXmlTags.IC_DOCUMENT_TAG);
212  
2130        Element typeElement = document
2140                .createElement(ICXmlTags.IC_DOCUMENT_TYPE_TAG);
2150        typeElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.type);
2160        documentElement.appendChild(typeElement);
217  
2180        Element numberElement = document
2190                .createElement(ICXmlTags.IC_DOCUMENT_NUMBER_TAG);
2200        numberElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.number);
2210        documentElement.appendChild(numberElement);
222  
2230        Element descriptionElement = document
2240                .createElement(ICXmlTags.IC_DOCUMENT_DESCRIPTION_TAG);
2250        descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2260                this.description);
2270        documentElement.appendChild(descriptionElement);
228  
2290        Element releaseAuthorityElement = document
2300                .createElement(ICXmlTags.IC_DOCUMENT_RELEASE_AUTHORITY_TAG);
2310        releaseAuthorityElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2320                this.releaseAuthority.toString());
2330        documentElement.appendChild(releaseAuthorityElement);
234  
2350        Element releaseElement = document
2360                .createElement(ICXmlTags.IC_DOCUMENT_RELEASE_TAG);
2370        releaseElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.release
2380                .toString());
2390        releaseElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""+this.release.getTime());
2400        documentElement.appendChild(releaseElement);
241  
2420        Element expirationElement = document
2430                .createElement(ICXmlTags.IC_DOCUMENT_EXPIRATION_TAG);
2440        expirationElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2450                this.expiration.toString());
2460        expirationElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""+this.expiration.getTime());
247         
2480        documentElement.appendChild(expirationElement);
249  
2500        Element imagePathElement = document
2510                .createElement(ICXmlTags.IC_DOCUMENT_IMAGE_PATH_TAG);
2520        imagePathElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2530                this.imagePath);
2540        documentElement.appendChild(imagePathElement);
255  
2560        return documentElement;
257     }
258  
259     public base.user.Document fromXml(Node node) {
260         
2610        String type="";
2620        String number="";
2630        String description="";
2640        Date release=null;;
2650        Date expiration=null;;
2660        String imagePath="";
2670        String releaseAuthority="";
268         
2690        for(int i=0;i<node.getChildNodes().getLength();i++){
2700            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_TYPE_TAG))
2710                type = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2720            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_NUMBER_TAG))
2730                number = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2740            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_DESCRIPTION_TAG))
2750                description = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2760            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_RELEASE_AUTHORITY_TAG))
2770                releaseAuthority = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
2780            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_RELEASE_TAG))
2790                release = new Date(Long.parseLong(node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE).getNodeValue()));
2800            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_EXPIRATION_TAG))
2810                expiration = new Date(Long.parseLong(node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE).getNodeValue()));
2820            if(node.getChildNodes().item(i).getNodeName().equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_IMAGE_PATH_TAG))
2830                imagePath = node.getChildNodes().item(i).getAttributes().getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE).getNodeValue();
284         }
285         
2860        return new Document(type, number, releaseAuthority, description, release, expiration, imagePath);
287     }
288 }

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.