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.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 | ||
46 | 0 | 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 | */ | |
64 | 0 | protected Session(final int id, User user, Workstation workstation, |
65 | 0 | String description, Date startTime, Date endTime, Service service) { |
66 | 0 | this.id = id; |
67 | 0 | this.user = user; |
68 | 0 | this.workstation = workstation; |
69 | 0 | this.description = description; |
70 | 0 | this.startTime = startTime; |
71 | 0 | this.endTime = endTime; |
72 | 0 | this.service = service; |
73 | 0 | } |
74 | ||
75 | /** | |
76 | * @return Returns the description. | |
77 | */ | |
78 | public String getDescription() { | |
79 | 0 | return description; |
80 | } | |
81 | ||
82 | /** | |
83 | * @param description | |
84 | * The description to set. | |
85 | */ | |
86 | public void setDescription(String description) { | |
87 | 0 | this.description = description; |
88 | 0 | } |
89 | ||
90 | /** | |
91 | * @return Returns the endTime. | |
92 | */ | |
93 | public Date getEndTime() { | |
94 | 0 | return endTime; |
95 | } | |
96 | ||
97 | /** | |
98 | * @param endTime | |
99 | * The endTime to set. | |
100 | */ | |
101 | public void setEndTime(Date endTime) { | |
102 | 0 | this.endTime = endTime; |
103 | 0 | } |
104 | ||
105 | /** | |
106 | * @return Returns the startTime. | |
107 | */ | |
108 | public Date getStartTime() { | |
109 | 0 | return startTime; |
110 | } | |
111 | ||
112 | /** | |
113 | * @param startTime | |
114 | * The startTime to set. | |
115 | */ | |
116 | public void setStartTime(Date startTime) { | |
117 | 0 | this.startTime = startTime; |
118 | 0 | } |
119 | ||
120 | /** | |
121 | * @return Returns the user. | |
122 | */ | |
123 | public User getUser() { | |
124 | 0 | return user; |
125 | } | |
126 | ||
127 | /** | |
128 | * @return Returns the workstation. | |
129 | */ | |
130 | public Workstation getWorkstation() { | |
131 | 0 | return workstation; |
132 | } | |
133 | ||
134 | /* | |
135 | * (non-Javadoc) | |
136 | * | |
137 | * @see java.lang.Object#toString() | |
138 | */ | |
139 | @Override | |
140 | public String toString() { | |
141 | 0 | StringBuffer sb = new StringBuffer(); |
142 | 0 | sb.append("SESSION"); |
143 | 0 | sb.append("\n"); |
144 | 0 | sb.append("id: " + id); |
145 | 0 | sb.append("\n"); |
146 | 0 | sb.append("user: \n" + user); |
147 | 0 | sb.append("\n"); |
148 | 0 | sb.append("workstation: \n" + workstation); |
149 | 0 | sb.append("\n"); |
150 | 0 | sb.append("description: " + description); |
151 | 0 | sb.append("\n"); |
152 | 0 | sb.append("startTime: " + startTime); |
153 | 0 | sb.append("\n"); |
154 | 0 | sb.append("endTime: " + endTime); |
155 | 0 | return sb.toString(); |
156 | } | |
157 | ||
158 | /** | |
159 | * @return Returns the id. | |
160 | */ | |
161 | public int getId() { | |
162 | 0 | return id; |
163 | } | |
164 | ||
165 | /** | |
166 | * @return Returns the service. | |
167 | */ | |
168 | public Service getService() { | |
169 | 0 | 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() { | |
180 | 0 | 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) { | |
189 | 0 | Element sessionElement = document |
190 | 0 | .createElement(ICXmlTags.IC_SESSION_TAG); |
191 | 0 | sessionElement.setAttribute(ICXmlTags.IC_SESSION_ID_ATTRIBUTE, "" |
192 | 0 | + this.id); |
193 | 0 | sessionElement.setAttribute(ICXmlTags.IC_SESSION_START_TIME_ATTRIBUTE, |
194 | 0 | this.startTime.toString()); |
195 | 0 | sessionElement.setAttribute(ICXmlTags.IC_SESSION_END_TIME_ATTRIBUTE, |
196 | 0 | this.endTime.toString()); |
197 | ||
198 | 0 | sessionElement.appendChild(this.user.toXml(document)); |
199 | 0 | sessionElement.appendChild(this.workstation.toXml(document)); |
200 | 0 | sessionElement.appendChild(this.service.toXml(document)); |
201 | ||
202 | 0 | Element descriptionElement = document |
203 | 0 | .createElement(ICXmlTags.IC_SESSION_DESCRIPTION_TAG); |
204 | 0 | descriptionElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, |
205 | 0 | this.description); |
206 | 0 | sessionElement.appendChild(descriptionElement); |
207 | ||
208 | 0 | return sessionElement; |
209 | } | |
210 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |