FileDocCategorySizeDatePackage
PropertyPermission.javaAPI DocAndroid 1.5 API6662Wed May 06 22:41:04 BST 2009java.util

PropertyPermission

public final class PropertyPermission extends BasicPermission
{@code PropertyPermission} objects represent a permission to access system properties.

A permission is one of the possible permission strings like "user.name" or "java.version". It's also possible to use a wildcard to define the permission to several properties at once. For example "user.*" will define the permission for "user.home", "user.name", "user.dir", ... "*" defines the permission for all available properties.

There are two possible permission action types: read and write. Possible actions are "read", "write", or "read,write"/"write,read".

since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private transient boolean
read
private transient boolean
write
private static final ObjectStreamField[]
serialPersistentFields
Constructors Summary
public PropertyPermission(String name, String actions)
Constructs a new instance of this class.

param
name the (possibly wildcarded) name of the property.
param
actions the actions which are applicable to it. Possible actions are "read", "write", or "read,write"/"write,read". Anything else will result in an {@code IllegalArgumentException}.
since
Android 1.0


                                                                                                 
         
        super(name);
        decodeActions(actions);
    
Methods Summary
private voiddecodeActions(java.lang.String actions)

        StringTokenizer tokenizer = new StringTokenizer(Util.toASCIILowerCase(actions),
                " \t\n\r,"); //$NON-NLS-1$
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            if (token.equals("read")) { //$NON-NLS-1$
                read = true;
            } else if (token.equals("write")) { //$NON-NLS-1$
                write = true;
            } else {
                throw new IllegalArgumentException();
            }
        }
        if (!read && !write) {
            throw new IllegalArgumentException();
        }
    
public booleanequals(java.lang.Object o)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. In this case, the receiver must be a {@code PropertyPermission} for the same property as the argument, and must have the same actions. If {@code o} is a permission that is not a {@code PropertyPermission}, this method may throw a {@code ClassCastException}.

param
o the {@code Object} to compare with this {@code Object}.
return
{@code true} if the {@code Object} is the same as this {@code Object}, {@code false} if it is different from this {@code Object}.
see
#hashCode
since
Android 1.0

        if (super.equals(o)) {
            PropertyPermission pp = (PropertyPermission) o;
            return read == pp.read && write == pp.write;
        }
        return false;
    
public java.lang.StringgetActions()
Returns the actions associated with the receiver. The result will be either "read", "write", or "read,write".

return
the actions associated with the receiver.
since
Android 1.0

        return read ? (write ? "read,write" : "read") : "write"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
    
public inthashCode()
Returns an integer hash code for the receiver. Any two objects which return {@code true} when passed to {@code equals} must return the same value for this method.

return
the receiver's hash.
see
#equals
since
Android 1.0

        return super.hashCode();
    
public booleanimplies(java.security.Permission permission)
Indicates whether the argument permission is implied by the receiver.

return
boolean {@code true} if the argument permission is implied by the receiver, and {@code false} if it is not.
param
permission the permission to check.
since
Android 1.0

        if (super.implies(permission)) {
            PropertyPermission pp = (PropertyPermission) permission;
            return (read || !pp.read) && (write || !pp.write);
        }
        return false;
    
public java.security.PermissionCollectionnewPermissionCollection()
Returns a new {@code PermissionCollection} for holding permissions of this class. Returns {@code null} if any {@code PermissionCollection} can be used.

return
a new {@code PermissionCollection} or {@code null}.
see
java.security.PermissionCollection
since
Android 1.0

        return new PropertyPermissionCollection();
    
private voidreadObject(java.io.ObjectInputStream stream)

        ObjectInputStream.GetField fields = stream.readFields();
        String actions = (String) fields.get("actions", ""); //$NON-NLS-1$ //$NON-NLS-2$
        decodeActions(actions);
    
private voidwriteObject(java.io.ObjectOutputStream stream)

 //$NON-NLS-1$

          
        ObjectOutputStream.PutField fields = stream.putFields();
        fields.put("actions", getActions()); //$NON-NLS-1$
        stream.writeFields();