com.web_visage.ichat
Class IChatUserList

java.lang.Object
  extended by com.web_visage.ichat.IChatUserList

public class IChatUserList
extends java.lang.Object

Provides a set of operations on the user list.

Provides the following main operations on the user list:

This implementation is thread safe.

Author:
K.Baturytski

Constructor Summary
IChatUserList()
          Constructor.
 
Method Summary
 void addUser(IChatSender sender, IChatUserInfo userInfo)
          Adds new user to the list.
 void addUser(IChatSender aSender, java.lang.String aNickName, EnumStatus aStatus)
          Adds a new user to the list.
 boolean contains(IChatSender aSender)
          Checks whether the given user already exists in the user list.
 java.util.Map<IChatSender,IChatUserInfo> getSnapshot()
          Returns a momentary snapshot of the user map.
 IChatUserInfo getUser(IChatSender aSender)
          Returns a user information associated with the given sender.
 boolean isActive(IChatSender aUser)
          Checks whether the given user is active.
 void removeAll()
          Clears the user list.
 void removeInactive()
          Removes inactive users from the list.
 void removeUser(IChatSender aSender)
          Removes given user from the list.
 int size()
          Returns the number of users in the list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IChatUserList

public IChatUserList()
Constructor.

Method Detail

addUser

public void addUser(IChatSender aSender,
                    java.lang.String aNickName,
                    EnumStatus aStatus)
Adds a new user to the list.

Parameters:
aSender - - sender object
aStatus - - user status
aNickName - - user nickname

addUser

public void addUser(IChatSender sender,
                    IChatUserInfo userInfo)
Adds new user to the list.

Parameters:
userInfo - - user info object.

removeUser

public void removeUser(IChatSender aSender)
Removes given user from the list.

Parameters:
aSender -

getUser

public IChatUserInfo getUser(IChatSender aSender)
                      throws IChatUserNotFoundException
Returns a user information associated with the given sender.

Parameters:
aSender - - sender object
Returns:
Throws:
IChatUserNotFoundException

getSnapshot

public java.util.Map<IChatSender,IChatUserInfo> getSnapshot()
Returns a momentary snapshot of the user map.

Modifying the resulting map won't affect the original.

Note that this operation is rather expensive, try to avoid its intensive usage.

Returns:

removeInactive

public void removeInactive()
Removes inactive users from the list.


isActive

public boolean isActive(IChatSender aUser)
                 throws java.lang.RuntimeException
Checks whether the given user is active.

Parameters:
aUser -
Returns:
Throws:
java.lang.RuntimeException

removeAll

public void removeAll()
Clears the user list.


contains

public boolean contains(IChatSender aSender)
Checks whether the given user already exists in the user list.

Parameters:
aSender -
Returns:

size

public int size()
Returns the number of users in the list.

Returns: