CLDC 1.1.1

javax.microedition.io
Class FileProtocolPermission

java.lang.Object
  extended byjava.security.Permission
      extended byjavax.microedition.io.GCFPermission
          extended byjavax.microedition.io.FileProtocolPermission

public final class FileProtocolPermission
extends GCFPermission

This class represents access rights to connections via the "file" protocol. A FileProtocolPermission consists of a URI string indicating a fully-qualified, absolute pathname and a set of actions desired for that pathname.

The URI string takes the following general form:

 file:{pathname} | file://[localhost]{pathname}
 
(The exact syntax is given by RFCs 1738 & 2396.) In addition, a pathname that ends in "/*" indicates all the files and directories contained in that directory. A pathname that ends with "/-" indicates (recursively) all files and subdirectories contained in that directory.

The actions to be granted are passed to the constructor in a string containing a list of one or more comma-separated keywords. The possible keywords are "read" and "write". The actions string is converted to lowercase before processing.

See Also:
Connector.open(java.lang.String), "javax.microedition.io.file.FileConnection" in FileConnection Optional Package Specification

Constructor Summary
FileProtocolPermission(String uri, String actions)
          Creates a new FileProtocolPermission with the specified actions.
 
Method Summary
 boolean equals(Object obj)
          Checks two FileProtocolPermission objects for equality.
 String getActions()
          Returns the canonical string representation of the actions.
 int hashCode()
          Returns the hash code value for this object.
 boolean implies(Permission p)
          Checks if this FileProtocolPermission object "implies" the specified permission.
 PermissionCollection newPermissionCollection()
          Returns a new PermissionCollection for storing FileProtocolPermission objects.
 
Methods inherited from class javax.microedition.io.GCFPermission
getProtocol, getURI
 
Methods inherited from class java.security.Permission
getName, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileProtocolPermission

public FileProtocolPermission(String uri,
                              String actions)
Creates a new FileProtocolPermission with the specified actions. The specified URI becomes the name of the FileProtocolPermission. The URI string must conform to the specification given above, and is normalized to facilitate subsequent comparisons.

Parameters:
uri - the URI string
actions - comma-separated list of desired actions
Throws:
IllegalArgumentException - if uri or actions is malformed.
NullPointerException - if uri or actions is null.
See Also:
Permission.getName(), getActions()
Method Detail

implies

public boolean implies(Permission p)
Checks if this FileProtocolPermission object "implies" the specified permission.

More specifically, this method returns true if:

Specified by:
implies in class Permission
Parameters:
p - the permission to check against
Returns:
true if the specified permission is implied by this object, false if not.

equals

public boolean equals(Object obj)
Checks two FileProtocolPermission objects for equality.

Specified by:
equals in class Permission
Parameters:
obj - the object we are testing for equality with this object.
Returns:
true if obj is a FileProtocolPermission, and has the same URI string and actions as this FileProtocolPermission object.

hashCode

public int hashCode()
Returns the hash code value for this object.

Specified by:
hashCode in class Permission
Returns:
a hash code value for this object.

getActions

public String getActions()
Returns the canonical string representation of the actions. If both read and write actions are allowed, this method returns the string "read,write".

Specified by:
getActions in class Permission
Returns:
the canonical string representation of the actions.

newPermissionCollection

public PermissionCollection newPermissionCollection()
Returns a new PermissionCollection for storing FileProtocolPermission objects.

FileProtocolPermission objects must be stored in a manner that allows them to be inserted into the collection in any order, but that also enables the PermissionCollection implies method to be implemented in an efficient (and consistent) manner.

Overrides:
newPermissionCollection in class Permission
Returns:
a new PermissionCollection suitable for storing FileProtocolPermission objects.

CLDC 1.1.1

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