Class Directory

java.lang.Object
  extended byDirectory

public class Directory
extends Object

Directory of TextFiles.

Version:
4

Constructor Summary
Directory()
          Construct a Directory.
 
Method Summary
 void addTextFile(String name, TextFile afile)
          Add a TextFile 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 TextFiles it contains.
static void main(String[] args)
          main, for unit testing.
 TextFile retrieveTextFile(String filename)
          Get a TextFile in this Directory, by name .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Directory

public Directory()
Construct a Directory.

Method Detail

addTextFile

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

Parameters:
name - the name under which this TextFile is added.
afile - the TextFile 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 TextFiles it contains.

Returns:
the number of TextFiles.

main

public static void main(String[] args)
main, for unit testing. The command
   java Directory
 
should produce output
 bill     17      Sun Jan 06 19:40:13 EST 2003    diary
 eb       12      Sun Jan 06 19:40:13 EST 2003    greeting
 
(with current dates, of course).


retrieveTextFile

public TextFile retrieveTextFile(String filename)
Get a TextFile in this Directory, by name .

Parameters:
filename - the name of the TextFile to find.
Returns:
the TextFile found, null if none.