live.dto
Class Group

java.lang.Object
  extended bylive.dto.Group
All Implemented Interfaces:
Comparable

public class Group
extends Object
implements Comparable

Group is used by the cache to store information about a specific group.

Author:
Jason J. Herne

Field Summary
private  String groupName
           
private  LinkedList members
           
static String UNGROUPED_NAME
          A constant that defines a placeholder for a group that is actually (ungrouped).
 
Constructor Summary
Group(String groupName)
          Creates a Group and sets its name.
 
Method Summary
 void addMember(String guestNameToAdd)
          Adds the name of a guest to this group.
 int compareTo(Object o)
          This allows groups to be ordered by the guest name, so if you have a sorted collection (for instance, and this is by far the motivation) the groups will be in alphabetical order.
 int findMember(String guestNameToFind)
          Returns the index of guestNameToFind or -1 if it is not present
 String getGroupName()
          Gets the name of this group.
 LinkedList getMemberList()
          Returns the whole member list.
 ListIterator getMembers()
          Returns a ListIterator that can be used to get every guest name that is a member of this group.
 void removeMember(int indexOfMemberToRemove)
          Removes the member of the guest list given by the index.
 void removeMember(String guestNameToRemove)
          Removes the guest from this group given by the parameter.
 void setGroupName(String groupName)
          Sets the name of this group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNGROUPED_NAME

public static final String UNGROUPED_NAME
A constant that defines a placeholder for a group that is actually (ungrouped). The group that represents the ungrouped pseudogroup will have this as a name. This should be the only place you should get this string! There are a couple places where the "ungroupedness" is tested a name using == instead of equals. Always using this very string will allow this (substantially easier and faster) test to suffice, but if you use another string, even if it is "equal" to UNGROUPED_NAME, stuff will break.

See Also:
Constant Field Values

groupName

private String groupName

members

private LinkedList members
Constructor Detail

Group

public Group(String groupName)
Creates a Group and sets its name.

Parameters:
groupName - The name of this group
Method Detail

getGroupName

public String getGroupName()
Gets the name of this group.

Returns:
Name of this group.

setGroupName

public void setGroupName(String groupName)
Sets the name of this group.

Parameters:
groupName - The group name to use.

addMember

public void addMember(String guestNameToAdd)
Adds the name of a guest to this group.

Parameters:
guestNameToAdd - The name of the guest to add to this group.

findMember

public int findMember(String guestNameToFind)
Returns the index of guestNameToFind or -1 if it is not present

Parameters:
guestNameToFind - The name of the guest we are looking for in the list.
Returns:
The index of guestNameToFind or -1

removeMember

public void removeMember(String guestNameToRemove)
Removes the guest from this group given by the parameter.

Parameters:
guestNameToRemove - The guest to remove from this group.

removeMember

public void removeMember(int indexOfMemberToRemove)
Removes the member of the guest list given by the index. NOTE: If you plan on removing a guest from the groups list with this function, you MUST be careful! Another thread could have added/removed a guest between the time that you looked up the index you want to delete and the time that you called this function!! Be ABSOLUTELY SURE that your threads lock on this list object for the duration of any lookup/change events.

Parameters:
indexOfMemberToRemove - Index of the guest we wish to remove from the list.

getMembers

public ListIterator getMembers()
Returns a ListIterator that can be used to get every guest name that is a member of this group. Be careful of synchronization, especially as THIS CLASS DOESN'T.

Returns:
The ListIterator used to iterate over this list.

getMemberList

public LinkedList getMemberList()
Returns the whole member list. Again, careful of synchronization.

Returns:
The LinkedList of members.

compareTo

public int compareTo(Object o)
This allows groups to be ordered by the guest name, so if you have a sorted collection (for instance, and this is by far the motivation) the groups will be in alphabetical order.

Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(java.lang.Object)


Copyright © 2005