CLDC 1.1.1

java.security
Class PermissionCollection

java.lang.Object
  extended byjava.security.PermissionCollection

public abstract class PermissionCollection
extends Object

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.

See Also:
Permission

Constructor Summary
PermissionCollection()
           
 
Method Summary
abstract  void add(Permission permission)
          Adds a permission object to the current collection of permission objects.
abstract  Enumeration elements()
          Returns an enumeration of all the Permission objects in the collection.
abstract  boolean implies(Permission permission)
          Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.
 boolean isReadOnly()
          Returns true if this PermissionCollection object is marked as readonly.
 void setReadOnly()
          Marks this PermissionCollection object as "readonly".
 String toString()
          Returns a string describing this PermissionCollection object, providing information about all the permissions it contains.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, 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.
Throws:
SecurityException - - if this PermissionCollection object has been marked readonly

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.

setReadOnly

public void setReadOnly()
Marks this PermissionCollection object as "readonly". After a PermissionCollection object is marked as readonly, no new Permission objects can be added to it using add.


isReadOnly

public boolean isReadOnly()
Returns true if this PermissionCollection object is marked as readonly. If it is readonly, no new Permission objects can be added to it using add.

By default, the object is not readonly. It can be set to readonly by a call to setReadOnly.

Returns:
true if this PermissionCollection object is marked as readonly, false otherwise.

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.

Overrides:
toString in class Object
Returns:
information about this PermissionCollection object, as described above.

CLDC 1.1.1

Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. Use of this specification is subject to license terms.