org.apache.turbine.util.security
Class SecuritySet<T>

java.lang.Object
  extended by org.apache.turbine.util.security.SecuritySet<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>
Direct Known Subclasses:
GroupSet, PermissionSet, RoleSet

public abstract class SecuritySet<T>
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<T>

This class represents a set of Security Entities. It makes it easy to build a UI. It wraps a TreeSet object to enforce that only relevant methods are available. TreeSet's contain only unique Objects (no duplicates).

Version:
$Id: SecuritySet.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
protected  java.util.Map<java.lang.Integer,T> idMap
          Map for "id" -> "security object"
protected  java.util.Map<java.lang.String,T> nameMap
          Map for "name" -> "security object"
 
Constructor Summary
SecuritySet()
          Constructs an empty Set
 
Method Summary
 void clear()
          Removes all Objects from this Set.
 boolean containsId(int id)
          Searches if an Object with a given Id is in the Set
 boolean containsName(java.lang.String name)
          Searches if an Object with a given name is in the Set
 java.util.Set<java.lang.Integer> getIds()
          Returns a set of Id values in this Object.
 java.util.Set<java.lang.String> getNames()
          Returns a set of Names in this Object.
 java.util.Set<? extends T> getSet()
          Returns a set of security objects in this object.
 java.util.Iterator<T> iterator()
          Returns an Iterator for Objects in this Set.
 int size()
          Returns size (cardinality) of this set.
 java.lang.String toString()
          list of role names in this set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nameMap

protected java.util.Map<java.lang.String,T> nameMap
Map for "name" -> "security object"


idMap

protected java.util.Map<java.lang.Integer,T> idMap
Map for "id" -> "security object"

Constructor Detail

SecuritySet

public SecuritySet()
Constructs an empty Set

Method Detail

getSet

public java.util.Set<? extends T> getSet()
Returns a set of security objects in this object.

Returns:
A Set Object

getNames

public java.util.Set<java.lang.String> getNames()
Returns a set of Names in this Object.

Returns:
The Set of Names in this Object, backed by the actual data.

getIds

public java.util.Set<java.lang.Integer> getIds()
Returns a set of Id values in this Object.

Returns:
The Set of Ids in this Object, backed by the actual data.

clear

public void clear()
Removes all Objects from this Set.


containsName

public boolean containsName(java.lang.String name)
Searches if an Object with a given name is in the Set

Parameters:
roleName - Name of the Security Object.
Returns:
True if argument matched an Object in this Set; false if no match.

containsId

public boolean containsId(int id)
Searches if an Object with a given Id is in the Set

Parameters:
id - Id of the Security Object.
Returns:
True if argument matched an Object in this Set; false if no match.

iterator

public java.util.Iterator<T> iterator()
Returns an Iterator for Objects in this Set.

Specified by:
iterator in interface java.lang.Iterable<T>
Returns:
An iterator for the Set

size

public int size()
Returns size (cardinality) of this set.

Returns:
The cardinality of this Set.

toString

public java.lang.String toString()
list of role names in this set

Overrides:
toString in class java.lang.Object
Returns:
The string representation of this Set.


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