org.safehaus.triplesec.guardian
Class Roles

java.lang.Object
  extended by org.safehaus.triplesec.guardian.Roles
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Roles
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Represnets an immutable set of Roles.

Version:
$Rev: 52 $, $Date: 2005-08-19 23:03:36 -0400 (Fri, 19 Aug 2005) $
Author:
Trustin Lee
See Also:
Serialized Form

Constructor Summary
Roles(java.lang.String applicationName, Role[] roles)
          Creates a new instance.
 
Method Summary
 Roles addAll(Roles roles)
          Creates a new set of Roles which contains all elements of both this set and the specified set (OR operation).
 java.lang.Object clone()
           
 boolean contains(Role role)
          Returns true if and only if this set contains the specified role.
 boolean contains(java.lang.String roleName)
          Returns true if and only if this set contains the Role with the specified roleName.
 boolean containsAll(Roles roles)
          Returns true if and only if this set contains all elements of the specified roles.
 boolean equals(java.lang.Object that)
           
 Role get(java.lang.String roleName)
          Returns the Role with the specified roleName.
 java.lang.String getApplicationName()
          Returns the name of the application this roles belong to
 Roles getDependentRoles(Permission perm)
           
 Roles getDependentRoles(java.lang.String permName)
           
 int hashCode()
           
 boolean isEmpty()
          Returns true if this set is empty.
 java.util.Iterator iterator()
          Returns an Iterator that iterates all Roles this set contains.
 Roles removeAll(Roles roles)
          Creates a new set of Roles which contains elements of this set excluding what exists in the specified set (NAND operation).
 Roles retainAll(Roles roles)
          Creates a new set of Roles which contains elements which exists in both this set and the specified set (AND operation).
 int size()
          Returns the number of elements this set contains.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Roles

public Roles(java.lang.String applicationName,
             Role[] roles)
Creates a new instance.

Parameters:
applicationName - the name of the application this roles belong to
roles - the array of Roles that will belong to this role set
Method Detail

getApplicationName

public java.lang.String getApplicationName()
Returns the name of the application this roles belong to

Returns:
the name of the application this roles belong to

contains

public boolean contains(Role role)
Returns true if and only if this set contains the specified role.

Parameters:
role - the role to find
Returns:
true if and only if this set contains the specified role

contains

public boolean contains(java.lang.String roleName)
Returns true if and only if this set contains the Role with the specified roleName.

Parameters:
roleName - the name of the role to find
Returns:
true if and only if this set contains the specified roleName

containsAll

public boolean containsAll(Roles roles)
Returns true if and only if this set contains all elements of the specified roles.

Parameters:
roles - another set of roles
Returns:
true if and only if this set contains all elements of the specified roles

get

public Role get(java.lang.String roleName)
Returns the Role with the specified roleName.

Parameters:
roleName - the name of the role to find
Returns:
null if there's no role with the specified name

isEmpty

public boolean isEmpty()
Returns true if this set is empty.

Returns:
true if this set is empty

size

public int size()
Returns the number of elements this set contains.

Returns:
the number of elements this set contains

iterator

public java.util.Iterator iterator()
Returns an Iterator that iterates all Roles this set contains.

Returns:
an Iterator that iterates all Roles this set contains

addAll

public Roles addAll(Roles roles)
Creates a new set of Roles which contains all elements of both this set and the specified set (OR operation). This operation never modifies this set.

Parameters:
roles - a set of roles to add
Returns:
a new set

removeAll

public Roles removeAll(Roles roles)
Creates a new set of Roles which contains elements of this set excluding what exists in the specified set (NAND operation). This operation never modifies this set.

Parameters:
roles - a set of roles to remove
Returns:
a new set

retainAll

public Roles retainAll(Roles roles)
Creates a new set of Roles which contains elements which exists in both this set and the specified set (AND operation). This operation never modifies this set.

Parameters:
roles - a set of roles to retain.
Returns:
a new set

getDependentRoles

public Roles getDependentRoles(java.lang.String permName)

getDependentRoles

public Roles getDependentRoles(Permission perm)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object that)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object