Coverage details for base.session.Session

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.session;
21  
22 import java.util.Date;
23  
24 import org.w3c.dom.Document;
25 import org.w3c.dom.Element;
26 import org.w3c.dom.Node;
27  
28 import base.ICXmlTags;
29 import base.IXMLSaveable;
30 import base.network.Workstation;
31 import base.service.Service;
32 import base.user.User;
33  
34 public class Session implements IXMLSaveable {
35  
36     private final int id;
37  
38     private User user;
39  
40     private Workstation workstation;
41  
42     private String description;
43  
44     private Date startTime;
45  
460    private Date endTime = null;
47  
48     private Service service;
49  
50     /**
51      * @param id
52      * The session's id.
53      * @param user
54      * The session's user.
55      * @param workstation
56      * The session's envolved workstation.
57      * @param description
58      * The session's description.
59      * @param startTime
60      * The session's start time.
61      * @param endTime
62      * The session's end time.
63      */
640    protected Session(final int id, User user, Workstation workstation,
650            String description, Date startTime, Date endTime, Service service) {
660        this.id = id;
670        this.user = user;
680        this.workstation = workstation;
690        this.description = description;
700        this.startTime = startTime;
710        this.endTime = endTime;
720        this.service = service;
730    }
74  
75     /**
76      * @return Returns the description.
77      */
78     public String getDescription() {
790        return description;
80     }
81  
82     /**
83      * @param description
84      * The description to set.
85      */
86     public void setDescription(String description) {
870        this.description = description;
880    }
89  
90     /**
91      * @return Returns the endTime.
92      */
93     public Date getEndTime() {
940        return endTime;
95     }
96  
97     /**
98      * @param endTime
99      * The endTime to set.
100      */
101     public void setEndTime(Date endTime) {
1020        this.endTime = endTime;
1030    }
104  
105     /**
106      * @return Returns the startTime.
107      */
108     public Date getStartTime() {
1090        return startTime;
110     }
111  
112     /**
113      * @param startTime
114      * The startTime to set.
115      */
116     public void setStartTime(Date startTime) {
1170        this.startTime = startTime;
1180    }
119  
120     /**
121      * @return Returns the user.
122      */
123     public User getUser() {
1240        return user;
125     }
126  
127     /**
128      * @return Returns the workstation.
129      */
130     public Workstation getWorkstation() {
1310        return workstation;
132     }
133  
134     /*
135      * (non-Javadoc)
136      *
137      * @see java.lang.Object#toString()
138      */
139     @Override
140     public String toString() {
1410        StringBuffer sb = new StringBuffer();
1420        sb.append("SESSION");
1430        sb.append("\n");
1440        sb.append("id: " + id);
1450        sb.append("\n");
1460        sb.append("user: \n" + user);
1470        sb.append("\n");
1480        sb.append("workstation: \n" + workstation);
1490        sb.append("\n");
1500        sb.append("description: " + description);
1510        sb.append("\n");
1520        sb.append("startTime: " + startTime);
1530        sb.append("\n");
1540        sb.append("endTime: " + endTime);
1550        return sb.toString();
156     }
157  
158     /**
159      * @return Returns the id.
160      */
161     public int getId() {
1620        return id;
163     }
164  
165     /**
166      * @return Returns the service.
167      */
168     public Service getService() {
1690        return service;
170     }
171  
172     /**
173      * This method will be used in future releases and will be used to
174      * estabilish if the user associated to the session has logged out from the
175      * client workstation.
176      *
177      * @return Returns true if the endTime is not null, false otherwise.
178      */
179     public boolean isFinished() {
1800        return endTime != null;
181     }
182  
183     /*
184      * (non-Javadoc)
185      *
186      * @see test.base.IXMLSaveable#toXml(org.w3c.dom.Document)
187      */
188     public Node toXml(Document document) {
1890        Element sessionElement = document
1900                .createElement(ICXmlTags.IC_SESSION_TAG);
1910        sessionElement.setAttribute(ICXmlTags.IC_SESSION_ID_ATTRIBUTE, ""
1920                + this.id);
1930        sessionElement.setAttribute(ICXmlTags.IC_SESSION_START_TIME_ATTRIBUTE,
1940                this.startTime.toString());
1950        sessionElement.setAttribute(ICXmlTags.IC_SESSION_END_TIME_ATTRIBUTE,
1960                this.endTime.toString());
197  
1980        sessionElement.appendChild(this.user.toXml(document));
1990        sessionElement.appendChild(this.workstation.toXml(document));
2000        sessionElement.appendChild(this.service.toXml(document));
201  
2020        Element descriptionElement = document
2030                .createElement(ICXmlTags.IC_SESSION_DESCRIPTION_TAG);
2040        descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
2050                this.description);
2060        sessionElement.appendChild(descriptionElement);
207  
2080        return sessionElement;
209     }
210 }

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.