org.jivesoftware.spark
Class UserManager

java.lang.Object
  extended by org.jivesoftware.spark.UserManager

public class UserManager
extends java.lang.Object

Handles all users in the agent application. Each user or chatting user can be referenced from the User Manager. You would use the UserManager to get visitors in a chat room or secondary agents.


Constructor Summary
UserManager()
           
 
Method Summary
static java.lang.String escapeJID(java.lang.String jid)
          Escapes a complete JID by examing the Node itself and escaping when neccessary.
 java.util.Collection getAllParticipantsInRoom(ChatRoom chatRoom)
          Returns a Collection of all ChatUsers in a ChatRoom.
 java.lang.String getFullJID(java.lang.String jid)
          Returns the full jid (with resource) based on the user's jid.
 java.lang.String getJIDFromNickname(java.lang.String nickname)
          Returns the full jid w/ resource of a user by their nickname in the ContactList.
 java.lang.String getNickname()
           
 org.jivesoftware.smackx.muc.Occupant getOccupant(GroupChatRoom groupChatRoom, java.lang.String nickname)
          Returns the occupant of the room identified by their nickname.
 javax.swing.Icon getTabIconForPresence(org.jivesoftware.smack.packet.Presence presence)
          Returns the Icon associated with the presence.
 java.util.Collection getUserJidsInRoom(java.lang.String room, boolean fullJID)
          Return a Collection of all user jids found in the specified room.
 java.lang.String getUserNicknameFromJID(java.lang.String jid)
           
 boolean hasVoice(GroupChatRoom groupChatRoom, java.lang.String nickname)
           
 boolean isAdmin(GroupChatRoom groupChatRoom, java.lang.String nickname)
          Checks the nickname of a user in a room and determines if they are an administrator of the room.
 boolean isModerator(GroupChatRoom groupChatRoom, java.lang.String nickname)
          Checks to see if the Occupant is a moderator.
 boolean isModerator(org.jivesoftware.smackx.muc.Occupant occupant)
          Checks to see if the Occupant is a moderator.
 boolean isOwner(GroupChatRoom groupChatRoom, java.lang.String nickname)
          Checks to see if the user is an owner of the specified room.
 boolean isOwner(org.jivesoftware.smackx.muc.Occupant occupant)
          Checks to see if the Occupant is the owner of the room.
 boolean isOwnerOrAdmin(GroupChatRoom groupChatRoom, java.lang.String nickname)
          Checks to see if the user is either an owner or admin of a room.
 boolean isOwnerOrAdmin(org.jivesoftware.smackx.muc.Occupant occupant)
          Checks to see if the user is either an owner or admin of the given room.
 void searchContacts(java.lang.String contact, javax.swing.JFrame parent)
           
static java.lang.String unescapeJID(java.lang.String jid)
          Unescapes a complete JID by examing the node itself and unescaping when necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserManager

public UserManager()
Method Detail

getNickname

public java.lang.String getNickname()

getUserJidsInRoom

public java.util.Collection getUserJidsInRoom(java.lang.String room,
                                              boolean fullJID)
Return a Collection of all user jids found in the specified room.

Parameters:
room - the name of the chatroom
fullJID - set to true if you wish to have the full jid with resource, otherwise false for the bare jid.
Returns:
a Collection of jids found in the room.

isOwner

public boolean isOwner(GroupChatRoom groupChatRoom,
                       java.lang.String nickname)
Checks to see if the user is an owner of the specified room.

Parameters:
groupChatRoom - the group chat room.
nickname - the user's nickname.
Returns:
true if the user is an owner.

isOwner

public boolean isOwner(org.jivesoftware.smackx.muc.Occupant occupant)
Checks to see if the Occupant is the owner of the room.

Parameters:
occupant - the occupant of a room.
Returns:
true if the user is an owner.

isModerator

public boolean isModerator(GroupChatRoom groupChatRoom,
                           java.lang.String nickname)
Checks to see if the Occupant is a moderator.

Parameters:
groupChatRoom - the group chat room.
nickname - the nickname of the user.
Returns:
true if the user is a moderator.

isModerator

public boolean isModerator(org.jivesoftware.smackx.muc.Occupant occupant)
Checks to see if the Occupant is a moderator.

Parameters:
occupant - the Occupant of a room.
Returns:
true if the user is a moderator.

isOwnerOrAdmin

public boolean isOwnerOrAdmin(GroupChatRoom groupChatRoom,
                              java.lang.String nickname)
Checks to see if the user is either an owner or admin of a room.

Parameters:
groupChatRoom - the group chat room.
nickname - the user's nickname.
Returns:
true if the user is either an owner or admin of the room.

isOwnerOrAdmin

public boolean isOwnerOrAdmin(org.jivesoftware.smackx.muc.Occupant occupant)
Checks to see if the user is either an owner or admin of the given room.

Parameters:
occupant - the Occupant to check.
Returns:
true if the user is either an owner or admin of the room.

getOccupant

public org.jivesoftware.smackx.muc.Occupant getOccupant(GroupChatRoom groupChatRoom,
                                                        java.lang.String nickname)
Returns the occupant of the room identified by their nickname.

Parameters:
groupChatRoom - the GroupChatRoom.
nickname - the users nickname.
Returns:
the Occupant found.

isAdmin

public boolean isAdmin(GroupChatRoom groupChatRoom,
                       java.lang.String nickname)
Checks the nickname of a user in a room and determines if they are an administrator of the room.

Parameters:
groupChatRoom - the GroupChatRoom.
nickname - the nickname of the user. Note: In MultiUserChats, users nicknames are defined by the resource(ex.theroom@conference.jivesoftware.com/derek) would have derek as a nickname.
Returns:
true if the user is an admin.

hasVoice

public boolean hasVoice(GroupChatRoom groupChatRoom,
                        java.lang.String nickname)

getAllParticipantsInRoom

public java.util.Collection getAllParticipantsInRoom(ChatRoom chatRoom)
Returns a Collection of all ChatUsers in a ChatRoom.

Parameters:
chatRoom - the ChatRoom to inspect.
Returns:
the Collection of all ChatUsers.
See Also:
ChatUser

getUserNicknameFromJID

public java.lang.String getUserNicknameFromJID(java.lang.String jid)

escapeJID

public static java.lang.String escapeJID(java.lang.String jid)
Escapes a complete JID by examing the Node itself and escaping when neccessary.

Parameters:
jid - the users JID
Returns:
the escaped JID.

unescapeJID

public static java.lang.String unescapeJID(java.lang.String jid)
Unescapes a complete JID by examing the node itself and unescaping when necessary.

Parameters:
jid - the users jid.
Returns:
the unescaped JID.

getJIDFromNickname

public java.lang.String getJIDFromNickname(java.lang.String nickname)
Returns the full jid w/ resource of a user by their nickname in the ContactList.

Parameters:
nickname - the nickname of the user.
Returns:
the full jid w/ resource of the user.

getFullJID

public java.lang.String getFullJID(java.lang.String jid)
Returns the full jid (with resource) based on the user's jid.

Parameters:
jid - the users bare jid.
Returns:
the full jid with resource.

getTabIconForPresence

public javax.swing.Icon getTabIconForPresence(org.jivesoftware.smack.packet.Presence presence)
Returns the Icon associated with the presence.

Parameters:
presence - the presence.
Returns:
the icon.

searchContacts

public void searchContacts(java.lang.String contact,
                           javax.swing.JFrame parent)