Class Directory

java.lang.Object
  extended byJFile
      extended byDirectory
All Implemented Interfaces:
Serializable

public class Directory
extends JFile

Directory of JFiles. A Directory is a JFile that maintains a table of the JFiles it contains.

Version:
10
See Also:
Serialized Form

Field Summary
 
Fields inherited from class JFile
separator
 
Constructor Summary
Directory(String name, User creator, Directory parent)
          Construct a Directory.
 
Method Summary
 void addJFile(String name, JFile afile)
          Add a JFile to this Directory.
 String[] getFileNames()
          Get the contents of this Directory as an array of the file names, each of which is a String.
 int getSize()
          The size of a Directory is the number of JFiles it contains.
 String getSuffix()
          Suffix used for printing Directory names; we define it as the (system dependent) name separator used in path names.
 void removeJFile(String filename)
          Remove a JFile in this Directory, by name .
 JFile retrieveJFile(String filename)
          Get a JFile in this Directory, by name .
 
Methods inherited from class JFile
getCreateDate, getModDate, getName, getOwner, getParent, getPathName, isRoot, setModDate, setOwner, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Directory

public Directory(String name,
                 User creator,
                 Directory parent)
Construct a Directory.

Parameters:
name - the name for this Directory (in its parent Directory)
creator - the owner of this new Directory.
parent - the Directory in which this Directory lives.
Method Detail

addJFile

public void addJFile(String name,
                     JFile afile)
Add a JFile to this Directory. Overwrite if a JFile of that name already exists.

Parameters:
name - the name under which this JFile is added.
afile - the JFile to add.

getFileNames

public String[] getFileNames()
Get the contents of this Directory as an array of the file names, each of which is a String.

Returns:
the array of names.

getSize

public int getSize()
The size of a Directory is the number of JFiles it contains.

Specified by:
getSize in class JFile
Returns:
the Directory's size.

getSuffix

public String getSuffix()
Suffix used for printing Directory names; we define it as the (system dependent) name separator used in path names.

Specified by:
getSuffix in class JFile
Returns:
the suffix for Directory names.

removeJFile

public void removeJFile(String filename)
Remove a JFile in this Directory, by name .

Parameters:
filename - the name of the JFile to remove

retrieveJFile

public JFile retrieveJFile(String filename)
Get a JFile in this Directory, by name .

Parameters:
filename - the name of the JFile to find.
Returns:
the JFile found.