de.novanic.eventservice.service.registry.user
Class UserInfo

java.lang.Object
  extended by de.novanic.eventservice.service.registry.user.UserInfo
All Implemented Interfaces:
java.lang.Comparable<UserInfo>

public class UserInfo
extends java.lang.Object
implements java.lang.Comparable<UserInfo>

UserInfo is a class to represent all users/clients and to manage all their information. It holds the events, the EventFilters (EventFilter) and the last activity time for the user.

Author:
sstrohschein
Date: 19.01.2009
Time: 23:59:58

Constructor Summary
UserInfo(java.lang.String aUserId)
          Creates a new UserInfo for the user id.
 
Method Summary
 void addEvent(Domain aDomain, Event anEvent)
          Adds an event for a domain to the user.
 int compareTo(UserInfo aUserInfo)
           
 boolean equals(java.lang.Object anObject)
           
 EventFilter getEventFilter(Domain aDomain)
          Returns the EventFilter for the domain.
 long getLastActivityTime()
          Returns the last activity time.
 UnlistenEvent getUnlistenEvent()
          Returns the registered UnlistenEvent.
 java.lang.String getUserId()
          Returns the user id.
 int hashCode()
           
 boolean isEventsEmpty()
          Checks if events are available.
 boolean removeEventFilter(Domain aDomain)
          Removes the EventFilter for a domain.
 java.util.List<DomainEvent> retrieveEvents()
          Returns and removes all recorded events.
 void setEventFilter(Domain aDomain, EventFilter anEventFilter)
          Sets an EventFilter to a domain.
 void setLastActivityTime(long aLastActivityTime)
          Sets the last activity time.
 void setUnlistenEvent(UnlistenEvent anUnlistenEvent)
          A custom UnlistenEvent can be set which is transferred to all registered UnlistenEventListener instances when an unlisten occurred (for example by a timeout or when a user/client leaves a domain).
 java.lang.String toString()
          The user id is used to represent the UserInfo.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserInfo

public UserInfo(java.lang.String aUserId)
Creates a new UserInfo for the user id.

Parameters:
aUserId - user
Method Detail

getUserId

public java.lang.String getUserId()
Returns the user id.

Returns:
user / user id

addEvent

public void addEvent(Domain aDomain,
                     Event anEvent)
Adds an event for a domain to the user.

Parameters:
aDomain - domain
anEvent - event

retrieveEvents

public java.util.List<DomainEvent> retrieveEvents()
Returns and removes all recorded events.

Returns:
all events according to the user

isEventsEmpty

public boolean isEventsEmpty()
Checks if events are available.

Returns:
true when no events recognized, otherwise false

setEventFilter

public void setEventFilter(Domain aDomain,
                           EventFilter anEventFilter)
Sets an EventFilter to a domain.

Parameters:
aDomain - domain where the EventFilter should be applied.
anEventFilter - EventFilter to filter the events for the domain

removeEventFilter

public boolean removeEventFilter(Domain aDomain)
Removes the EventFilter for a domain.

Parameters:
aDomain - domain where the EventFilter to remove is applied.
Returns:
true when the EventFilter is removed, otherwise false (for example the EventFilter was already removed before)

getEventFilter

public EventFilter getEventFilter(Domain aDomain)
Returns the EventFilter for the domain.

Parameters:
aDomain - domain
Returns:
EventFilter for the domain

getUnlistenEvent

public UnlistenEvent getUnlistenEvent()
Returns the registered UnlistenEvent. That can be a custom UnlistenEvent which can be set with setUnlistenEvent(de.novanic.eventservice.client.event.listener.unlisten.UnlistenEvent) or a default/generic UnlistenEvent when no custom UnlistenEvent is registered.

Returns:
UnlistenEvent to report a timeout or a user/client which left a domain.

setUnlistenEvent

public void setUnlistenEvent(UnlistenEvent anUnlistenEvent)
A custom UnlistenEvent can be set which is transferred to all registered UnlistenEventListener instances when an unlisten occurred (for example by a timeout or when a user/client leaves a domain). When no custom UnlistenEvent is registered, a default/generic UnlistenEvent will be processed and reported.

Parameters:
anUnlistenEvent - UnlistenEvent which should be triggered.

setLastActivityTime

public void setLastActivityTime(long aLastActivityTime)
Sets the last activity time. The last activity is used to recognize timeouts.

Parameters:
aLastActivityTime - last activity time

getLastActivityTime

public long getLastActivityTime()
Returns the last activity time. The last activity is used to recognize timeouts.

Returns:
last activity time

compareTo

public int compareTo(UserInfo aUserInfo)
Specified by:
compareTo in interface java.lang.Comparable<UserInfo>

equals

public boolean equals(java.lang.Object anObject)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
The user id is used to represent the UserInfo.

Overrides:
toString in class java.lang.Object
Returns:
String representation (user id) of the UserInfo.