Bees v0.5.0 API

bees.core.resource
Class File

java.lang.Object
  |
  +--bees.core.Capability
        |
        +--bees.core.resource.PathSpec
              |
              +--bees.core.resource.File
All Implemented Interfaces:
CapabilitySpec, edu.utah.janosvm.kit.comm.jsi.JSIHandler

public final class File
extends PathSpec
implements edu.utah.janosvm.kit.comm.jsi.JSIHandler

Capability to govern access to a disk file.


Field Summary
static PermissionSet DEFAULT_PERMISSIONS
          The default permissions for a new file capability.
static FilePermission FILE_APPEND_PERMISSION
          Permission to append to the file.
static Permission FILE_DELETE_PERMISSION
          Permission to delete the file.
static Permission FILE_LENGTH_PERMISSION
          Permission to get the file's length.
static Permission FILE_READ_LAST_MODIFIED_PERMISSION
          Permission to read the file's last modified time.
static Permission FILE_READ_PERMISSION
          Permission to read the file.
static Permission FILE_WRITE_LAST_MODIFIED_PERMISSION
          Permission to write the file's last modified time.
static Permission FILE_WRITE_PERMISSION
          Permission to write to the file.
 
Fields inherited from class bees.core.Capability
DELETE_PERMISSION, id, INVALID_ID
 
Constructor Summary
File()
          Construct an empty File capability.
 
Method Summary
 void delete()
          Delete the file on disk.
protected  void fromBytes(byte[] flattened, CapabilityEnvelope[] sub)
          Bind this capability to the given object.
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
 java.io.OutputStream getOutputStream(boolean append)
           
 void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
 void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc, edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
 long lastModified(Clock clock)
          Get the last modified time of the file.
 long length()
           
 edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm, edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
           
 void revoke()
          Revoke access to the capability.
 java.lang.String toString()
           
 
Methods inherited from class bees.core.resource.PathSpec
getFactory, specFromBytes, toBytes
 
Methods inherited from class bees.core.Capability
checkPermission, clear, clonePermission, deleteCapability, equals, fromBytes, revokedPermission, revokePermission, revokePermissions, valid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE_READ_PERMISSION

public static final Permission FILE_READ_PERMISSION
Permission to read the file.

FILE_WRITE_PERMISSION

public static final Permission FILE_WRITE_PERMISSION
Permission to write to the file.

FILE_APPEND_PERMISSION

public static final FilePermission FILE_APPEND_PERMISSION
Permission to append to the file.

FILE_LENGTH_PERMISSION

public static final Permission FILE_LENGTH_PERMISSION
Permission to get the file's length.

FILE_READ_LAST_MODIFIED_PERMISSION

public static final Permission FILE_READ_LAST_MODIFIED_PERMISSION
Permission to read the file's last modified time.

FILE_WRITE_LAST_MODIFIED_PERMISSION

public static final Permission FILE_WRITE_LAST_MODIFIED_PERMISSION
Permission to write the file's last modified time.

FILE_DELETE_PERMISSION

public static final Permission FILE_DELETE_PERMISSION
Permission to delete the file.

DEFAULT_PERMISSIONS

public static final PermissionSet DEFAULT_PERMISSIONS
The default permissions for a new file capability.
Constructor Detail

File

public File()
Construct an empty File capability.
Method Detail

fromBytes

protected void fromBytes(byte[] flattened,
                         CapabilityEnvelope[] sub)
                  throws java.lang.Exception
Description copied from class: Capability
Bind this capability to the given object.
Overrides:
fromBytes in class Capability
See Also:
Capability.fromBytes(byte[], CapabilityEnvelope[])

revoke

public void revoke()
Description copied from class: Capability
Revoke access to the capability.
Overrides:
revoke in class PathSpec
See Also:
Capability.revoke()

lastModified

public long lastModified(Clock clock)
Get the last modified time of the file. Since we cannot allow the actual time to leak out, a clock capability must be provided in order to form a stable base time.
Parameters:
clock - A clock from which to base the returned time value on.
Returns:
If the clock is in uptime mode, then it is the clocks base time minus the number of milliseconds since the file was last modified. Otherwise, it is the absolute time it was last modified.

length

public long length()
Returns:
The length of the file in bytes.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.FileNotFoundException,
                                          java.io.IOException
Returns:
An InputStream for reading from the file.
Throws:
java.io.FileNotFoundException - If the file no longer exists in the local file system. XXX This really shouldn't be here.
java.io.IOException - If there is a problem opening the file.

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.FileNotFoundException
Parameters:
append - True if the stream should start at the end of the file.
Returns:
An OutputStream for writing to the file.
Throws:
java.io.FileNotFoundException - If the file no longer exists in the local file system. XXX This really shouldn't be here.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.FileNotFoundException
Returns:
An OutputStream for writing to the file.
Throws:
java.io.FileNotFoundException - If the file no longer exists in the local file system. XXX This really shouldn't be here.

delete

public void delete()
Delete the file on disk.

resolveSpecifier

public edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm,
                                                                 edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
Specified by:
resolveSpecifier in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.resolveSpecifier(JSIMessage, JSIPair)

handleMessage

public void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc,
                          edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
handleMessage in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.handleMessage(JSIHandlerContext, JSIMessage)

getSuites

public void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
getSuites in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.getSuites(JSIMessage)

toString

public java.lang.String toString()
Overrides:
toString in class PathSpec
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/