Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.security.PermissionCollection

java.lang.Object
    |
    +----java.security.PermissionCollection
Subclasses:
Permissions

public abstract class PermissionCollection
extends Object
implements Serializable
Abstract class representing a collection of Permission objects.

With a PermissionCollection, you can:

When it is desirable to group together a number of Permission objects of the same type, the newPermissionCollection method on that particular type of Permission object should first be called. The default behavior (from the Permission class) is to simply return null. Subclasses of class Permission override the method if they need to store their permissions in a particular PermissionCollection object in order to provide the correct semantics when the PermissionCollection.implies method is called. If a non-null value is returned, that PermissionCollection must be used. If null is returned, then the caller of newPermissionCollection is free to store permissions of the given type in any PermissionCollection they choose (one that uses a Hashtable, one that uses a Vector, etc).

The PermissionCollection returned by the Permission.newPermissionCollection method is a homogeneous collection, which stores only Permission objects for a given Permission type. A PermissionCollection may also be heterogenous. For example, Permissions is a PermissionCollection subclass that represents a collection of PermissionCollections. That is, its members are each a homogeneous PermissionCollection. For example, a Permissions object might have a FilePermissionCollection for all the FilePermission objects, a SocketPermissionCollection for all the SocketPermission objects, and so on. Its add method adds a permission to the appropriate collection.

Whenever a permission is added to a heterogeneous PermissionCollection such as Permissions, and the PermissionCollection doesn't yet contain a PermissionCollection of the specified permission's type, the PermissionCollection should call the newPermissionCollection method on the permission's class to see if it requires a special PermissionCollection. If newPermissionCollection returns null, the PermissionCollection is free to store the permission in any type of PermissionCollection it desires (one using a Hastable, one using a Vector, etc.). For example, the Permissions object uses a default PermissionCollection implementation that stores the permission objects in a Hashtable.

See Also:
Permission, Permissions

Constructor Summary
 PermissionCollection()
 
 

Method Summary
void  add(Permission permission)
Adds a permission object to the current collection of permission objects.
Enumeration  elements()
Returns an enumeration of all the Permission objects in the collection.
boolean  implies(Permission permission)
Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.
String  toString()
Returns a string describing this PermissionCollection object, providing information about all the permissions it contains.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionCollection

public PermissionCollection()
Method Detail

add

public abstract void add(Permission permission)
Adds a permission object to the current collection of permission objects.
Parameters:
permission - the Permission object to add.

implies

public abstract boolean implies(Permission permission)
Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.
Parameters:
permission - the Permission object to compare.
Returns:
true if "permission" is implied by the permissions in the collection, false if not.

elements

public abstract Enumeration elements()
Returns an enumeration of all the Permission objects in the collection.
Returns:
an enumeration of all the Permissions.

toString

public String toString()
Returns a string describing this PermissionCollection object, providing information about all the permissions it contains. The format is:
 super.toString() (
   // enumerate all the Permission
   // objects and call toString() on them,
   // one per line..
 )
super.toString is a call to the toString method of this object's superclass, which is Object. The result is this PermissionCollection's type name followed by this object's hashcode, thus enabling clients to differentiate different PermissionCollections object, even if they contain the same permissions.
Returns:
information about this PermissionCollection object, as described above.
Overrides:
toString in class Object

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.