FileDocCategorySizeDatePackage
PermissionCollection.javaAPI DocAndroid 1.5 API4659Wed May 06 22:41:06 BST 2009java.security

PermissionCollection

public abstract class PermissionCollection extends Object implements Serializable
{@code PermissionCollection} is the common base class for all collections that provide a convenient method for determining whether or not a given permission is implied by any of the permissions present in this collection.

A {@code PermissionCollection} is typically created by using the {@link Permission#newPermissionCollection()} factory method. If the mentioned method returns {@code null}, then a {@code PermissionCollection} of any type can be used. If a collection is returned, it must be used for holding several permissions of the particular type.

Subclasses must be implemented thread save.

since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private boolean
readOnly
Constructors Summary
Methods Summary
public abstract voidadd(java.security.Permission permission)
Adds the specified {@code Permission} to this collection.

param
permission the {@code Permission} to add.
throws
IllegalStateException if the collection is read only.
since
Android 1.0

public abstract java.util.Enumerationelements()
Returns an enumeration over all {@link Permission}s encapsulated by this {@code PermissionCollection}.

return
an enumeration over all {@link Permission}s.
since
Android 1.0

public abstract booleanimplies(java.security.Permission permission)
Indicates whether the specified permission is implied by this {@code PermissionCollection}.

param
permission the permission to check.
return
{@code true} if the given permission is implied by the permissions in this collection, {@code false} otherwise.
since
Android 1.0

public booleanisReadOnly()
Indicates whether new permissions can be added to this {@code PermissionCollection}.

return
{@code true} if the receiver is read only, {@code false} if new elements can still be added to this {@code PermissionCollection}.
since
Android 1.0

 // = false;

                                                           
        

                                
       

                                                                   
        

                                                      
       
        return readOnly;
    
public voidsetReadOnly()
Marks this {@code PermissionCollection} as read only, so that no new permissions can be added to it.

since
Android 1.0

        readOnly = true;
    
public java.lang.StringtoString()
Returns a string containing a concise, human-readable description of this {@code PermissionCollection}.

return
a printable representation for this {@code PermissionCollection}.
since
Android 1.0

        List elist = new ArrayList(100);
        Enumeration elenum = elements();
        String superStr = super.toString();
        int totalLength = superStr.length() + 5;
        if (elenum != null) {
            while (elenum.hasMoreElements()) {
                String el = elenum.nextElement().toString();
                totalLength += el.length();
                elist.add(el);
            }
        }
        int esize = elist.size();
        totalLength += esize * 4;
        //FIXME StringBuffer --> StringBuilder
        StringBuffer result = new StringBuffer(totalLength).append(superStr)
            .append(" ("); //$NON-NLS-1$
        for (int i = 0; i < esize; i++) {
            result.append("\n  ").append(elist.get(i).toString()); //$NON-NLS-1$
        }
        return result.append("\n)").toString(); //$NON-NLS-1$