1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.statistics.impl;
18
19 import java.net.InetAddress;
20 import java.net.UnknownHostException;
21
22 import org.apache.jetspeed.statistics.UserStats;
23
24 /***
25 * UserStatsImpl
26 *
27 * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
28 * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
29 * @version $Id: $
30 */
31 public class UserStatsImpl implements UserStats
32 {
33
34 private String username;
35
36 private int numberOfSessions;
37
38 private InetAddress inetAddress;
39
40
41
42
43
44
45 public int getNumberOfSessions()
46 {
47 return numberOfSessions;
48 }
49
50
51
52
53
54
55 public String getUsername()
56 {
57
58 return username;
59 }
60
61
62
63
64
65
66 public void setNumberOfSession(int number)
67 {
68 numberOfSessions = number;
69
70 }
71
72
73
74
75
76
77 public void setUsername(String username)
78 {
79 this.username = username;
80
81 }
82
83
84
85
86 public InetAddress getInetAddress() {
87 return inetAddress;
88 }
89
90
91
92
93 public void setInetAddress(InetAddress inetAddress) {
94 this.inetAddress = inetAddress;
95 }
96
97
98
99
100 public void setInetAddressFromIp(String ip) throws UnknownHostException {
101 this.inetAddress = InetAddress.getByName(ip);
102 }
103
104 /***
105 * Checks whether these two object match. Simple check for
106 * just the ipaddresse and username.
107 *
108 * @param Object instanceof UserStats
109 */
110 public boolean equals(Object obj) {
111
112 if(!(obj instanceof UserStats))
113 return false;
114
115 UserStats userstat = (UserStats)obj;
116 return this.inetAddress.equals(userstat.getInetAddress()) && this.username.equals(userstat.getUsername());
117 }
118 }