org.apache.turbine.util.security
Class PermissionSet

java.lang.Object
  extended by org.apache.turbine.util.security.SecuritySet<Permission>
      extended by org.apache.turbine.util.security.PermissionSet
All Implemented Interfaces:
Serializable, Iterable<Permission>

public class PermissionSet
extends SecuritySet<Permission>

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 1073174 2011-02-21 22:18:45Z 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(Collection<Permission> permissions)
          Constructs a new PermissionSet with specified contents.
 
Method Summary
 boolean add(Collection<Permission> 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 getPermissionById(int permissionId)
          Returns a Permission with the given id, if it is contained in this PermissionSet.
 Permission getPermissionByName(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.
 String toString()
          Print out a PermissionSet as a String
 
Methods inherited from class org.apache.turbine.util.security.SecuritySet
clear, containsId, containsName, 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(Collection<Permission> 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(Collection<Permission> 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.

getPermissionByName

public Permission getPermissionByName(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 String toString()
Print out a PermissionSet as a String

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


Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.