001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.statistics.impl;
018:
019: import java.net.InetAddress;
020: import java.net.UnknownHostException;
021:
022: import org.apache.jetspeed.statistics.UserStats;
023:
024: /**
025: * UserStatsImpl
026: *
027: * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
028: * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
029: * @version $Id: $
030: */
031: public class UserStatsImpl implements UserStats {
032:
033: private String username;
034:
035: private int numberOfSessions;
036:
037: private InetAddress inetAddress;
038:
039: /*
040: * (non-Javadoc)
041: *
042: * @see org.apache.jetspeed.statistics.UserStats#getNumberOfSessions()
043: */
044: public int getNumberOfSessions() {
045: return numberOfSessions;
046: }
047:
048: /*
049: * (non-Javadoc)
050: *
051: * @see org.apache.jetspeed.statistics.UserStats#getUsername()
052: */
053: public String getUsername() {
054:
055: return username;
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see org.apache.jetspeed.statistics.UserStats#setNumberOfSession(int)
062: */
063: public void setNumberOfSession(int number) {
064: numberOfSessions = number;
065:
066: }
067:
068: /*
069: * (non-Javadoc)
070: *
071: * @see org.apache.jetspeed.statistics.UserStats#setUsername(java.lang.String)
072: */
073: public void setUsername(String username) {
074: this .username = username;
075:
076: }
077:
078: /* (non-Javadoc)
079: * @see org.apache.jetspeed.statistics.UserStats#getInetAddress()
080: */
081: public InetAddress getInetAddress() {
082: return inetAddress;
083: }
084:
085: /* (non-Javadoc)
086: * @see org.apache.jetspeed.statistics.UserStats#setInetAddress(java.net.InetAddress)
087: */
088: public void setInetAddress(InetAddress inetAddress) {
089: this .inetAddress = inetAddress;
090: }
091:
092: /* (non-Javadoc)
093: * @see org.apache.jetspeed.statistics.UserStats#setInetAddressFromIp(java.lang.String)
094: */
095: public void setInetAddressFromIp(String ip)
096: throws UnknownHostException {
097: this .inetAddress = InetAddress.getByName(ip);
098: }
099:
100: /**
101: * Checks whether these two object match. Simple check for
102: * just the ipaddresse and username.
103: *
104: * @param Object instanceof UserStats
105: */
106: public boolean equals(Object obj) {
107:
108: if (!(obj instanceof UserStats))
109: return false;
110:
111: UserStats userstat = (UserStats) obj;
112: return this.inetAddress.equals(userstat.getInetAddress())
113: && this.username.equals(userstat.getUsername());
114: }
115: }
|