edu.virginia.cs.mng.hypercast.demo
Class FileSystemModel2.FileNode

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.demo.FileSystemModel2.FileNode

class FileSystemModel2.FileNode
extends java.lang.Object

A FileNode is a derivative of the File class - though we delegate to the File object rather than subclassing it. It is used to maintain a cache of a directory's children and therefore avoid repeated access to the underlying file system during rendering.


Field Summary
protected  java.lang.String canonicalPath
          Path of the receiver.
protected  FileSystemModel2.FileNode[] children
          Children of the receiver.
protected  java.io.File file
          java.io.File the receiver represents.
protected  boolean isLink
          True if the canonicalPath of this instance does not start with the canonical path of the parent.
protected  java.util.Date lastModified
          Date last modified.
private  FileSystemModel2.FileNode parent
          Parent FileNode of the receiver.
protected  long totalSize
          Size of the receiver and all its children.
protected  boolean totalSizeValid
          Valid if the totalSize has finished being calced.
 
Constructor Summary
protected FileSystemModel2.FileNode(java.io.File file)
           
protected FileSystemModel2.FileNode(FileSystemModel2.FileNode parent, java.io.File file)
           
 
Method Summary
protected  void alterTotalSize(long sizeDelta)
           
protected  void childTotalSizeChanged(FileSystemModel2.FileNode child)
          Invoked when a childs total size has changed.
protected  FileSystemModel2.FileNode[] createChildren(MergeSort sorter)
          Loads the children of of the receiver.
protected  void forceTotalSizeValid()
          Marks the receivers total size as valid, but does not invoke node changed, nor message the parent.
 java.lang.String getCanonicalPath()
          Returns the canonical path for the receiver.
protected  FileSystemModel2.FileNode[] getChildren()
          Loads the children, caching the results in the children instance variable.
 java.io.File getFile()
          Returns the java.io.File the receiver represents.
 FileSystemModel2.FileNode getParent()
          Returns the parent of the receiver.
 FileSystemModel2.FileNode[] getPath()
          Gets the path from the root to the receiver.
protected  FileSystemModel2.FileNode[] getPathToRoot(FileSystemModel2.FileNode aNode, int depth)
           
 boolean isLeaf()
          Returns true if the receiver represents a leaf, that is it is isn't a directory.
 boolean isLink()
          Returns true if the receiver's path does not begin with the parent's canonical path.
 boolean isTotalSizeValid()
          Returns true if the total size is valid.
 java.util.Date lastModified()
          Returns the date the receiver was last modified.
protected  void loadChildren(MergeSort sorter)
          Recursively loads all the children of the receiver.
protected  boolean loadedChildren()
          Returns true if the children have been loaded.
protected  void nodeChanged()
          Can be invoked when a node has changed, will create the appropriate event.
protected  void resetLastModified()
          Clears the date.
protected  void resetSize()
          Sets the size of the receiver to be 0.
protected  void setChildren(FileSystemModel2.FileNode[] newChildren, boolean generateEvent)
          Sets the children of the receiver, updates the total size, and if generateEvent is true a tree structure changed event is created.
protected  void setTotalSizeValid(boolean newValue)
          This should only be invoked on the event dispatching thread.
 java.lang.String toString()
          Returns the the string to be used to display this leaf in the JTree.
 long totalSize()
          Returns size of the receiver and all its children.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

file

protected java.io.File file
java.io.File the receiver represents.

parent

private FileSystemModel2.FileNode parent
Parent FileNode of the receiver.

children

protected FileSystemModel2.FileNode[] children
Children of the receiver.

totalSize

protected long totalSize
Size of the receiver and all its children.

totalSizeValid

protected boolean totalSizeValid
Valid if the totalSize has finished being calced.

canonicalPath

protected java.lang.String canonicalPath
Path of the receiver.

isLink

protected boolean isLink
True if the canonicalPath of this instance does not start with the canonical path of the parent.

lastModified

protected java.util.Date lastModified
Date last modified.
Constructor Detail

FileSystemModel2.FileNode

protected FileSystemModel2.FileNode(java.io.File file)

FileSystemModel2.FileNode

protected FileSystemModel2.FileNode(FileSystemModel2.FileNode parent,
                                    java.io.File file)
Method Detail

lastModified

public java.util.Date lastModified()
Returns the date the receiver was last modified.

toString

public java.lang.String toString()
Returns the the string to be used to display this leaf in the JTree.
Overrides:
toString in class java.lang.Object

getFile

public java.io.File getFile()
Returns the java.io.File the receiver represents.

totalSize

public long totalSize()
Returns size of the receiver and all its children.

getParent

public FileSystemModel2.FileNode getParent()
Returns the parent of the receiver.

isLeaf

public boolean isLeaf()
Returns true if the receiver represents a leaf, that is it is isn't a directory.

isTotalSizeValid

public boolean isTotalSizeValid()
Returns true if the total size is valid.

resetLastModified

protected void resetLastModified()
Clears the date.

resetSize

protected void resetSize()
Sets the size of the receiver to be 0.

getChildren

protected FileSystemModel2.FileNode[] getChildren()
Loads the children, caching the results in the children instance variable.

loadChildren

protected void loadChildren(MergeSort sorter)
Recursively loads all the children of the receiver.

createChildren

protected FileSystemModel2.FileNode[] createChildren(MergeSort sorter)
Loads the children of of the receiver.

loadedChildren

protected boolean loadedChildren()
Returns true if the children have been loaded.

getPath

public FileSystemModel2.FileNode[] getPath()
Gets the path from the root to the receiver.

getCanonicalPath

public java.lang.String getCanonicalPath()
Returns the canonical path for the receiver.

isLink

public boolean isLink()
Returns true if the receiver's path does not begin with the parent's canonical path.

getPathToRoot

protected FileSystemModel2.FileNode[] getPathToRoot(FileSystemModel2.FileNode aNode,
                                                    int depth)

setChildren

protected void setChildren(FileSystemModel2.FileNode[] newChildren,
                           boolean generateEvent)
Sets the children of the receiver, updates the total size, and if generateEvent is true a tree structure changed event is created.

alterTotalSize

protected void alterTotalSize(long sizeDelta)

setTotalSizeValid

protected void setTotalSizeValid(boolean newValue)
This should only be invoked on the event dispatching thread.

forceTotalSizeValid

protected void forceTotalSizeValid()
Marks the receivers total size as valid, but does not invoke node changed, nor message the parent.

childTotalSizeChanged

protected void childTotalSizeChanged(FileSystemModel2.FileNode child)
Invoked when a childs total size has changed.

nodeChanged

protected void nodeChanged()
Can be invoked when a node has changed, will create the appropriate event.