FileDocCategorySizeDatePackage
FilePermissionCollection.javaAPI DocAndroid 1.5 API3572Wed May 06 22:41:04 BST 2009java.io

FilePermissionCollection

public final class FilePermissionCollection extends PermissionCollection implements Serializable
Collects {@link FilePermission} objects and allows to query whether a particular permission is implied by it.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
Vector
permissions
Constructors Summary
public FilePermissionCollection()
Construct a new FilePermissionCollection


             
      
        super();
    
Methods Summary
public voidadd(java.security.Permission permission)
Add a permission object to the permission collection.

param
permission the FilePermission object to add to the collection.
throws
IllegalArgumentException if {@code permission} is not an instance of {@code FilePermission}.
throws
IllegalStateException if this collection is read-only.
see
java.security.PermissionCollection#add(java.security.Permission)

        if (isReadOnly()) {
            throw new IllegalStateException();
        }
        if (permission instanceof FilePermission) {
            permissions.addElement(permission);
        } else {
            throw new IllegalArgumentException(permission.toString());
        }
    
public java.util.Enumerationelements()
Returns an enumeration for the collection of permissions.

return
a permission enumeration for this permission collection.
see
java.security.PermissionCollection#elements()

        return permissions.elements();
    
public booleanimplies(java.security.Permission permission)
Indicates whether this permissions collection implies a specific {@code permission}.

param
permission the permission to check.
see
java.security.PermissionCollection#implies(java.security.Permission)

        if (permission instanceof FilePermission) {
            FilePermission fp = (FilePermission) permission;
            int matchedMask = 0;
            int i = 0;
            while (i < permissions.size()
                    && ((matchedMask & fp.mask) != fp.mask)) {
                // Cast will not fail since we added it
                matchedMask |= ((FilePermission) permissions.elementAt(i))
                        .impliesMask(permission);
                i++;
            }
            return ((matchedMask & fp.mask) == fp.mask);
        }
        return false;