Class JFile

java.lang.Object
  |
  +--JFile
Direct Known Subclasses:
Directory, TextFile

public abstract class JFile
extends Object

A JFile object models a file in a hierarchical file system.

Extend this abstract class to create particular kinds of JFiles, e.g.:
Directory - a JFile that maintains a list of the files it contains.
TextFile - a JFile containing text you might want to read.

Version:
6
See Also:
Directory, TextFile

Field Summary
static String separator
          The separator used in pathnames.
 
Constructor Summary
protected JFile(String name, User creator, Directory parent)
          Construct a new JFile, set owner, parent, creation and modification dates.
 
Method Summary
 String getCreateDate()
          The date and time of the file's creation.
 String getModDate()
          The date and time of the file's last modification.
 String getName()
          The name of the file.
 User getOwner()
          The file's owner.
 Directory getParent()
          The Directory containing this file.
 String getPathName()
          The full path to this file.
abstract  int getSize()
          The size of the JFile (as defined by the child class)..
abstract  String getSuffix()
          Suffix used for printing file names (as defined by the child class).
 boolean isRoot()
          A JFile whose parent is null is defined to be the root (of a tree).
protected  void setModDate()
          Set the modification date to "now".
 void setOwner(User owner)
          Set the owner for this file.
 String toString()
          How a JFile represents itself as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

separator

public static final String separator
The separator used in pathnames.

Constructor Detail

JFile

protected JFile(String name,
                User creator,
                Directory parent)
Construct a new JFile, set owner, parent, creation and modification dates. Add this to parent (unless this is the root Directory).

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

getCreateDate

public String getCreateDate()
The date and time of the file's creation.

Returns:
the file's creation date and time.

getModDate

public String getModDate()
The date and time of the file's last modification.

Returns:
the date and time of the file's last modification.

getName

public String getName()
The name of the file.

Returns:
the file's name.

getOwner

public User getOwner()
The file's owner.

Returns:
the owner of the file.

getParent

public Directory getParent()
The Directory containing this file.

Returns:
the parent directory.

getPathName

public String getPathName()
The full path to this file.

Returns:
the path name.

getSize

public abstract int getSize()
The size of the JFile (as defined by the child class)..

Returns:
the size.

getSuffix

public abstract String getSuffix()
Suffix used for printing file names (as defined by the child class).

Returns:
the file's suffix.

isRoot

public boolean isRoot()
A JFile whose parent is null is defined to be the root (of a tree).

Returns:
true when this JFile is the root.

setModDate

protected void setModDate()
Set the modification date to "now".


setOwner

public void setOwner(User owner)
Set the owner for this file.

Parameters:
owner - the new owner.

toString

public String toString()
How a JFile represents itself as a String. That is,
    owner   size    modDate    name+suffix
 

Overrides:
toString in class Object
Returns:
the String representation.