org.apache.turbine.util.security
Class GroupSet

java.lang.Object
  |
  +--org.apache.turbine.util.security.GroupSet
All Implemented Interfaces:
java.io.Serializable

public class GroupSet
extends java.lang.Object
implements java.io.Serializable

This class represents a set of Groups. It's useful for building administration UI. It wraps a TreeSet object to enforce that only Group objects are allowed in the set and only relevant methods are available. TreeSet's contain only unique Objects (no duplicates).

Version:
$Id: GroupSet.java,v 1.3 2002/07/16 12:15:30 henning Exp $
Author:
John D. McNally, Brett McLaughlin
See Also:
Serialized Form

Constructor Summary
GroupSet()
          Constructs an empty GroupSet
GroupSet(java.util.Collection groups)
          Constructs a new GroupSet with specifed contents.
 
Method Summary
 boolean add(java.util.Collection groups)
          Adds the Groups in a Collection to this GroupSet.
 boolean add(Group group)
          Adds a Group to this GroupSet.
 boolean add(GroupSet groupSet)
          Adds the Groups in another GroupSet to this GroupSet.
 void clear()
          Removes all Groups from this GroupSet.
 boolean contains(Group group)
          Checks whether this GroupSet contains a Group.
 boolean contains(java.lang.String groupName)
          Compares by name a Group with the Groups contained in this GroupSet.
 java.util.Iterator elements()
          Returns an Iterator for Groups in this GroupSet.
 Group getGroup(java.lang.String groupName)
          Returns a Group with the given name, if it is contained in this GroupSet.
 Group[] getGroupsArray()
          Returns an Groups[] of Groups in this GroupSet.
 boolean remove(Group group)
          Removes a Group from this GroupSet.
 int size()
          Returns size (cardinality) of this set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupSet

public GroupSet()
Constructs an empty GroupSet

GroupSet

public GroupSet(java.util.Collection groups)
Constructs a new GroupSet with specifed contents. If the given collection contains multiple objects that are identical WRT equals() method, some objects will be overwriten.
Parameters:
groups - A collection of groups to be contained in the set.
Method Detail

add

public boolean add(Group group)
Adds a Group to this GroupSet.
Parameters:
group - A Group.
Returns:
True if Group was added; false if GroupSet already contained the Group.

add

public boolean add(java.util.Collection groups)
Adds the Groups in a Collection to this GroupSet.
Parameters:
groups - A Collection of Groups.
Returns:
True if this GroupSet changed as a result; false if no change to this GroupSet occurred (this GroupSet already contained all members of the added GroupSet).

add

public boolean add(GroupSet groupSet)
Adds the Groups in another GroupSet to this GroupSet.
Parameters:
groupSet - A GroupSet.
Returns:
True if this GroupSet changed as a result; false if no change to this GroupSet occurred (this GroupSet already contained all members of the added GroupSet).

remove

public boolean remove(Group group)
Removes a Group from this GroupSet.
Parameters:
group - A Group.
Returns:
True if this GroupSet contained the Group before it was removed.

clear

public void clear()
Removes all Groups from this GroupSet.

contains

public boolean contains(Group group)
Checks whether this GroupSet contains a Group.
Parameters:
group - A Group.
Returns:
True if this GroupSet contains the Group, false otherwise.

contains

public boolean contains(java.lang.String groupName)
Compares by name a Group with the Groups contained in this GroupSet.
Parameters:
groupName - Name of Group.
Returns:
True if argument matched a Group in this GroupSet; false if no match.

getGroup

public Group getGroup(java.lang.String groupName)
Returns a Group with the given name, if it is contained in this GroupSet.
Parameters:
groupName - Name of Group.
Returns:
Group if argument matched a Group in this GroupSet; null if no match.

getGroupsArray

public Group[] getGroupsArray()
Returns an Groups[] of Groups in this GroupSet.
Returns:
A Group[].

elements

public java.util.Iterator elements()
Returns an Iterator for Groups in this GroupSet.

size

public int size()
Returns size (cardinality) of this set.
Returns:
The cardinality of this GroupSet.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.