Class BaseFileSystem

java.lang.Object
  extended byBaseFileSystem

public class BaseFileSystem
extends java.lang.Object

A BaseFileSystem represents a low-level file system in which files are referenced by file number. This is intended as a general low-level file system interface that could be implemented for many different file system structures. In UNIX, inode numbers play the role of file numbers.


Field Summary
private  java.util.BitSet allBits
          allBits is a bit set of all valid file numbers.
private  int capacity
          capacity is the number of files in this base file system.
private  java.util.List files
          files is the list of file accessors for this base file system.
private  java.util.BitSet freeBits
          freeBits is a bit set of the file numbers that are not in use.
private  java.lang.String name
          name is the name of this base file system.
static int NO_FILE
          BaseFileSystem.NO_FILE is the file number for nonexistent files.
 
Constructor Summary
private BaseFileSystem()
          This constructor is disabled.
  BaseFileSystem(java.lang.String nm, int cap)
          new BaseFileSystem(nm, cap) returns a new base file system with a capacity of cap files.
 
Method Summary
 int create(File f)
          fs.create(f) returns the file number assigned to a new file f.
 int delete(int fn)
          fs.delete(fn) removes the file with file number fn from fs and returns fn.
 java.util.Iterator files()
          fs.files() returns an iterator for the files in fs.
 java.lang.String fileSet()
          fs.fileSet() returns a string describing the set of files in fs.
 int getCapacity()
          fs.getCapacity() returns the maximum number of files for fs.
 java.lang.String getName()
          fs.getName() returns the file system name of fs as a string.
static void main(java.lang.String[] args)
          main(args) is a test program for the BaseFileSystem class.
 File open(int fn)
          fs.open(fn) returns an accessor for the file with file number fn, or null if there is no such file.
 java.lang.String toString()
          fs.toString() returns the class name and file system name of fs as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_FILE

public static final int NO_FILE
BaseFileSystem.NO_FILE is the file number for nonexistent files.

See Also:
Constant Field Values

name

private java.lang.String name
name is the name of this base file system.


capacity

private int capacity
capacity is the number of files in this base file system.


files

private java.util.List files
files is the list of file accessors for this base file system. Here, the simulation departs from reality. In a real file system, file accessors are constructed as needed.


allBits

private java.util.BitSet allBits
allBits is a bit set of all valid file numbers.


freeBits

private java.util.BitSet freeBits
freeBits is a bit set of the file numbers that are not in use.

Constructor Detail

BaseFileSystem

private BaseFileSystem()
This constructor is disabled.


BaseFileSystem

public BaseFileSystem(java.lang.String nm,
                      int cap)
new BaseFileSystem(nm, cap) returns a new base file system with a capacity of cap files.

Method Detail

create

public int create(File f)
fs.create(f) returns the file number assigned to a new file f. If there is no space in fs for a new file then the return value is File.NULL;


delete

public int delete(int fn)
fs.delete(fn) removes the file with file number fn from fs and returns fn. If there is no such file then no action is taken and File.NULL is returned.


open

public File open(int fn)
fs.open(fn) returns an accessor for the file with file number fn, or null if there is no such file.


getCapacity

public int getCapacity()
fs.getCapacity() returns the maximum number of files for fs.


files

public java.util.Iterator files()
fs.files() returns an iterator for the files in fs.


fileSet

public java.lang.String fileSet()
fs.fileSet() returns a string describing the set of files in fs.


getName

public java.lang.String getName()
fs.getName() returns the file system name of fs as a string.


toString

public java.lang.String toString()
fs.toString() returns the class name and file system name of fs as a string.


main

public static void main(java.lang.String[] args)
main(args) is a test program for the BaseFileSystem class.