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

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

public abstract class SecuritySet<T>
extends Object
implements Serializable, 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  Map<Integer,T> idMap
          Map for "id" -> "security object"
protected  Map<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(String name)
          Searches if an Object with a given name is in the Set
 Set<Integer> getIds()
          Returns a set of Id values in this Object.
 Set<String> getNames()
          Returns a set of Names in this Object.
 Set<? extends T> getSet()
          Returns a set of security objects in this object.
 Iterator<T> iterator()
          Returns an Iterator for Objects in this Set.
 int size()
          Returns size (cardinality) of this set.
 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 Map<String,T> nameMap
Map for "name" -> "security object"


idMap

protected Map<Integer,T> idMap
Map for "id" -> "security object"

Constructor Detail

SecuritySet

public SecuritySet()
Constructs an empty Set

Method Detail

getSet

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

Returns:
A Set Object

getNames

public Set<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 Set<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(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 Iterator<T> iterator()
Returns an Iterator for Objects in this Set.

Specified by:
iterator in interface 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 String toString()
list of role names in this set

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


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