org.apache.turbine.util.security
Class PermissionSet

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

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

This class represents a set of Permissions. It makes it easy to build a UI that would allow someone to add a group of Permissions to a Role. It wraps a TreeSet object to enforce that only Permission objects are allowed in the set and only relevant methods are available. TreeSet's contain only unique Objects (no duplicates).

Version:
$Id$
Author:
John D. McNally, Brett McLaughlin
See Also:
Serialized Form

Field Summary
private  java.util.TreeSet set
          Set to hold the Permission Set
 
Constructor Summary
PermissionSet()
          Constructs an empty PermissionSet
PermissionSet(java.util.Collection permissions)
          Constructs a new PermissionSet with specifed contents.
 
Method Summary
 boolean add(java.util.Collection permissions)
          Adds the Permissions in a Collection to this PermissionSet.
 boolean add(Permission permission)
          Adds a Permission to this PermissionSet.
 boolean add(PermissionSet permissionSet)
          Adds the Permissions in another PermissionSet to this PermissionSet.
 void clear()
          Removes all Permissions from this PermissionSet.
 boolean contains(Permission permission)
          Checks whether this PermissionSet contains a Permission.
 boolean contains(java.lang.String permissionName)
          Compares by name a Permission with the Permissions contained in this PermissionSet.
 java.util.Iterator elements()
          Returns an Iterator for Permissions in this PermissionSet.
 Permission getPermission(java.lang.String permissionName)
          Returns a Permission with the given name, if it is contained in this PermissionSet.
 Permission[] getPermissionsArray()
          Returns an Permissions[] of Permissions in this PermissionSet.
 boolean remove(Permission permission)
          Removes a Permission from this PermissionSet.
 int size()
          Returns size (cardinality) of this set.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

set

private java.util.TreeSet set
Set to hold the Permission Set
Constructor Detail

PermissionSet

public PermissionSet()
Constructs an empty PermissionSet

PermissionSet

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

add

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

add

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

add

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

remove

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

clear

public void clear()
Removes all Permissions from this PermissionSet.

contains

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

contains

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

getPermission

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

getPermissionsArray

public Permission[] getPermissionsArray()
Returns an Permissions[] of Permissions in this PermissionSet.
Returns:
A Permission[].

elements

public java.util.Iterator elements()
Returns an Iterator for Permissions in this PermissionSet.

size

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


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.