org.safehaus.triplesec.guardian
Class Permissions

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

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

Represnets an immutable set of Permissions.

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

Constructor Summary
Permissions(java.lang.String applicationName, Permission[] permissions)
          Creates a new instance.
 
Method Summary
 Permissions addAll(Permissions permissions)
          Creates a new set of Permissions which contains all elements of both this set and the specified set (OR operation).
 java.lang.Object clone()
           
 boolean contains(Permission permission)
          Returns true if and only if this set contains the specified permission.
 boolean contains(java.lang.String permissionName)
          Returns true if and only if this set contains the Permission with the specified permissionName.
 boolean containsAll(Permissions permissions)
          Returns true if and only if this set contains all elements of the specified permissions.
 boolean equals(java.lang.Object that)
           
 Permission get(java.lang.String permissionName)
          Returns the Permission with the specified permissionName.
 java.lang.String getApplicationName()
          Returns the name of the application this permissions belong to
 int hashCode()
           
 boolean isEmpty()
          Returns true if this set is empty.
 java.util.Iterator iterator()
          Returns an Iterator that iterates all Permissions this set contains.
 Permissions removeAll(Permissions permissions)
          Creates a new set of Permissions which contains elements of this set excluding what exists in the specified set (NAND operation).
 Permissions retainAll(Permissions permissions)
          Creates a new set of Permissions 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

Permissions

public Permissions(java.lang.String applicationName,
                   Permission[] permissions)
Creates a new instance.

Parameters:
applicationName - The name of the application this permissions belong to
permissions - The array of Permissions that will belong to this permission set
Method Detail

getApplicationName

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

Returns:
the name of the application this permissions belong to

contains

public boolean contains(Permission permission)
Returns true if and only if this set contains the specified permission.

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

contains

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

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

containsAll

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

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

get

public Permission get(java.lang.String permissionName)
Returns the Permission with the specified permissionName.

Parameters:
permissionName - the name of the permission to find
Returns:
null if there's no permission 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 Permissions this set contains.

Returns:
an Iterator that iterates all Permissions this set contains

addAll

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

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

removeAll

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

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

retainAll

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

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

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