org.apache.turbine.util.security
Class RoleSet

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

public class RoleSet
extends SecuritySet

This class represents a set of Roles. It makes it easy to build a UI that would allow someone to add a group of Roles to a User. It enforces that only Role objects are allowed in the set and only relevant methods are available.

Version:
$Id: RoleSet.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
RoleSet()
          Constructs an empty RoleSet
RoleSet(java.util.Collection roles)
          Constructs a new RoleSet with specified contents.
 
Method Summary
 boolean add(java.util.Collection roles)
          Adds the Roles in a Collection to this RoleSet.
 boolean add(Role role)
          Adds a Role to this RoleSet.
 boolean add(RoleSet roleSet)
          Adds the Roles in another RoleSet to this RoleSet.
 boolean contains(Role role)
          Checks whether this RoleSet contains a Role.
 Role getRole(java.lang.String roleName)
          Deprecated. Use getRoleByName instead.
 Role getRoleById(int roleId)
          Returns a Role with the given id, if it is contained in this RoleSet.
 Role getRoleByName(java.lang.String roleName)
          Returns a Role with the given name, if it is contained in this RoleSet.
 Role[] getRolesArray()
          Returns an Array of Roles in this RoleSet.
 boolean remove(Role role)
          Removes a Role from this RoleSet.
 java.lang.String toString()
          Print out a RoleSet 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

RoleSet

public RoleSet()
Constructs an empty RoleSet


RoleSet

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

Parameters:
roles - A collection of roles to be contained in the set.
Method Detail

add

public boolean add(Role role)
Adds a Role to this RoleSet.

Parameters:
role - A Role.
Returns:
True if Role was added; false if RoleSet already contained the Role.

add

public boolean add(java.util.Collection roles)
Adds the Roles in a Collection to this RoleSet.

Parameters:
roles - A Collection of Roles.
Returns:
True if this RoleSet changed as a result; false if no change to this RoleSet occurred (this RoleSet already contained all members of the added RoleSet).

add

public boolean add(RoleSet roleSet)
Adds the Roles in another RoleSet to this RoleSet.

Parameters:
roleSet - A RoleSet.
Returns:
True if this RoleSet changed as a result; false if no change to this RoleSet occurred (this RoleSet already contained all members of the added RoleSet).

remove

public boolean remove(Role role)
Removes a Role from this RoleSet.

Parameters:
role - A Role.
Returns:
True if this RoleSet contained the Role before it was removed.

contains

public boolean contains(Role role)
Checks whether this RoleSet contains a Role.

Parameters:
role - A Role.
Returns:
True if this RoleSet contains the Role, false otherwise.

getRole

public Role getRole(java.lang.String roleName)
Deprecated. Use getRoleByName instead.

Returns a Role with the given name, if it is contained in this RoleSet.

Parameters:
roleName - Name of Role.
Returns:
Role if argument matched a Role in this RoleSet; null if no match.

getRoleByName

public Role getRoleByName(java.lang.String roleName)
Returns a Role with the given name, if it is contained in this RoleSet.

Parameters:
roleName - Name of Role.
Returns:
Role if argument matched a Role in this RoleSet; null if no match.

getRoleById

public Role getRoleById(int roleId)
Returns a Role with the given id, if it is contained in this RoleSet.

Parameters:
roleId - id of the Role.
Returns:
Role if argument matched a Role in this RoleSet; null if no match.

getRolesArray

public Role[] getRolesArray()
Returns an Array of Roles in this RoleSet.

Returns:
An Array of Role objects.

toString

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

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


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