Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.turbine.util.security
Class RoleSet

    java.lang.Object
      org.apache.turbine.util.security.SecuritySet<Role>
          org.apache.turbine.util.security.RoleSet

All Implemented Interfaces:
  Serializable, Iterable<Role>

    public class RoleSet

extends SecuritySet<Role>

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 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
`RoleSet()` Constructs an empty RoleSet
`RoleSet(Collection<Role> roles)` Constructs a new RoleSet with specified contents.

Method Summary
`boolean` | `add(Collection<Role> 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` | `getRoleById(int roleId)` Returns a Role with the given id, if it is contained in this RoleSet.
`Role` | `getRoleByName(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.
`String` | `toString()` Print out a RoleSet 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

### RoleSet

    public RoleSet()

  Constructs an empty RoleSet

### RoleSet

    public RoleSet(Collection<Role> 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(Collection<Role> 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.

### getRoleByName

    public Role getRoleByName(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 String toString()

  Print out a RoleSet as a String

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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