Jive Messenger 2.2.2 Javadoc

org.jivesoftware.messenger.group
Class GroupManager

java.lang.Object
  extended by org.jivesoftware.messenger.group.GroupManager

public class GroupManager
extends Object

Manages groups.

Author:
Matt Tucker
See Also:
Group

Method Summary
 Group createGroup(String name)
          Factory method for creating a new Group.
 void deleteGroup(Group group)
          Deletes a group from the system.
 void deleteUser(User user)
          Deletes a user from all the groups where he/she belongs.
 Group getGroup(String name)
          Returns a Group by name.
 int getGroupCount()
          Returns the total number of groups in the system.
 Collection<Group> getGroups()
          Returns an unmodifiable Collection of all groups in the system.
 Collection<Group> getGroups(int startIndex, int numResults)
          Returns an iterator for all groups according to a filter.
 Collection<Group> getGroups(User user)
          Returns an iterator for all groups that a user is a member of.
static GroupManager getInstance()
          Returns a singleton instance of GroupManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static GroupManager getInstance()
Returns a singleton instance of GroupManager.

Returns:
a GroupManager instance.

createGroup

public Group createGroup(String name)
                  throws GroupAlreadyExistsException
Factory method for creating a new Group. A unique name is the only required field.

Parameters:
name - the new and unique name for the group.
Returns:
a new Group.
Throws:
GroupAlreadyExistsException - if the group name already exists in the system.

getGroup

public Group getGroup(String name)
               throws GroupNotFoundException
Returns a Group by name.

Parameters:
name - The name of the group to retrieve
Returns:
The group corresponding to that name
Throws:
GroupNotFoundException - if the group does not exist.

deleteGroup

public void deleteGroup(Group group)
Deletes a group from the system.

Parameters:
group - the group to delete.

deleteUser

public void deleteUser(User user)
Deletes a user from all the groups where he/she belongs. The most probable cause for this request is that the user has been deleted from the system. TODO: remove this method and use events isntead.

Parameters:
user - the deleted user from the system.

getGroupCount

public int getGroupCount()
Returns the total number of groups in the system.

Returns:
the total number of groups.

getGroups

public Collection<Group> getGroups()
Returns an unmodifiable Collection of all groups in the system.

Returns:
an unmodifiable Collection of all groups.

getGroups

public Collection<Group> getGroups(int startIndex,
                                   int numResults)
Returns an iterator for all groups according to a filter.

This is useful to support pagination in a GUI where you may only want to display a certain number of results per page. It is possible that the number of results returned will be less than that specified by numResults if numResults is greater than the number of records left in the system to display.

Parameters:
startIndex - start index in results.
numResults - number of results to return.
Returns:
an Iterator for all groups in the specified range.

getGroups

public Collection<Group> getGroups(User user)
Returns an iterator for all groups that a user is a member of.

Parameters:
user - the user to get a list of groups for.
Returns:
all groups that a user belongs to.

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.