org.apache.turbine.util.security
Class PermissionSet

java.lang.Object
  extended byorg.apache.turbine.util.security.SecuritySet
      extended byorg.apache.turbine.util.security.PermissionSet
All Implemented Interfaces:
java.io.Serializable

public class PermissionSet
extends SecuritySet

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 enforces that only Permission objects are allowed in the set and only relevant methods are available.

Version:
$Id: PermissionSet.java 534527 2007-05-02 16:10:59Z tv $
Author:
John D. McNally, Brett McLaughlin, Marco Knüttel, Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.turbine.util.security.SecuritySet
idMap, nameMap
 
Constructor Summary
PermissionSet()
          Constructs an empty PermissionSet
PermissionSet(java.util.Collection permissions)
          Constructs a new PermissionSet with specified 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.
 boolean contains(Permission permission)
          Checks whether this PermissionSet contains a Permission.
 Permission getPermission(java.lang.String permissionName)
          Deprecated. Use getPermissionByName instead.
 Permission getPermissionById(int permissionId)
          Returns a Permission with the given id, if it is contained in this PermissionSet.
 Permission getPermissionByName(java.lang.String permissionName)
          Returns a Permission with the given name, if it is contained in this PermissionSet.
 Permission[] getPermissionsArray()
          Returns an Array of Permissions in this PermissionSet.
 boolean remove(Permission permission)
          Removes a Permission from this PermissionSet.
 java.lang.String toString()
          Print out a PermissionSet as a String
 
Methods inherited from class org.apache.turbine.util.security.SecuritySet
clear, contains, containsId, containsName, elements, getIds, getNames, getSet, iterator, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PermissionSet

public PermissionSet()
Constructs an empty PermissionSet


PermissionSet

public PermissionSet(java.util.Collection permissions)
Constructs a new PermissionSet with specified contents. If the given collection contains multiple objects that are identical WRT equals() method, some objects will be overwritten.

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:
permission - 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:
permissions - 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:
permissionSet - 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:
permission - A Permission.
Returns:
True if this PermissionSet contained the Permission before it was removed.

contains

public boolean contains(Permission permission)
Checks whether this PermissionSet contains a Permission.

Parameters:
permission - A Permission.
Returns:
True if this PermissionSet contains the Permission, false otherwise.

getPermission

public Permission getPermission(java.lang.String permissionName)
Deprecated. Use getPermissionByName instead.

Returns a Permission with the given name, if it is contained in this PermissionSet.

Parameters:
permissionName - Name of Permission.
Returns:
Permission if argument matched a Permission in this PermissionSet; null if no match.

getPermissionByName

public Permission getPermissionByName(java.lang.String permissionName)
Returns a Permission with the given name, if it is contained in this PermissionSet.

Parameters:
permissionName - Name of Permission.
Returns:
Permission if argument matched a Permission in this PermissionSet; null if no match.

getPermissionById

public Permission getPermissionById(int permissionId)
Returns a Permission with the given id, if it is contained in this PermissionSet.

Parameters:
permissionId - Id of the Permission.
Returns:
Permission if argument matched a Permission in this PermissionSet; null if no match.

getPermissionsArray

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

Returns:
An Array of Permission Objects.

toString

public java.lang.String toString()
Print out a PermissionSet as a String

Overrides:
toString in class SecuritySet
Returns:
The string representation of this Set.


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