TMFileNode

Kind of class:public class
Package:treemap.demo
Inherits from:none
Implements:
Version:2.5
Author:Christophe Bouthier [bouthier@loria.fr]
Package classpath:treemap.demo.TMFileNode
File last modified:Friday, 28 December 2001, 20:58:42
The TMFileNode implements an example of TMNode encapsulating a File.

Summary


Constructors
Instance methods
  • buildTree
    • Builds the tree hierarchie of a TMFileNode.
  • addChild
    • Add child to the node.
  • removeChild
    • Removes a child from the node.
  • getFullName
    • Returns the full name of the file.
  • getName
    • Returns the name of the file.
  • getSize
    • Returns the size of the node.
  • getDate
    • Returns the last modification date.
  • toString
    • Returns the node in a String form : return the name.
  • children
    • Returns the children of this node in an Enumeration.
  • isLeaf
    • Returns true if this node is not a directory.
  • setUpdater
    • Sets the updater for this node.
  • hasChanged
    • Checks if something has changed.

Inner classes

CheckingThread

 (package private) (inner) class
The inner class CheackingThread implements
a Thread that checks if files have changed.

ProgressStatus

 (package private) (inner) class
The inner class ProgressStatus implements
a simple way to update a JLabel to reflect
the progress of an activity.

Constructors

TMFileNode

public TMFileNode(
File file)

Constructor.
Parameters:
file:
the File encapsulated in this node

TMFileNode

protected TMFileNode(
File file, TMFileNode parent, ProgressStatus status)

Constructor.
Parameters:
file :
the File encapsulated in this node
parent:
the parent of this node
status:
the progress status to update

Instance fields

children

protected Hashtable children = null

date

protected long date = -1L

delay

protected final int delay = 1000

file

protected File file = null

name

protected String name = null

parent

protected TMFileNode parent = null

size

protected long size = -1L

updater

protected TMUpdater updater = null

Instance methods

addChild

protected void addChild(
TMFileNode child)

Add child to the node.
Parameters:
child:
the TMFileNode to add as a child

buildTree

protected void buildTree(

Builds the tree hierarchie of a TMFileNode.
A status view shows the progression of the activity.
Parameters:
node :
the TMFileNode root of the tree
status:
the progress status to update

children

public Enumeration children(
)

Returns the children of this node in an Enumeration.
If this node is a file, return a empty Enumeration.
Else, return an Enumeration full with TMFileNode.
Returns:
  • an Enumeration containing childs of this node
Specified by:

getDate

public long getDate(
)

Returns the last modification date.
Returns:
  • the last modification date

getFullName

public String getFullName(
)

Returns the full name of the file.
Returns:
  • the full name of the file

getName

public String getName(
)

Returns the name of the file.
Returns:
  • the name of the file

getSize

public long getSize(
)

Returns the size of the node.
If the node is a file, returns the size of the file.
If the node is a folder, returns 0.
Returns:
  • the size of the node

hasChanged

protected boolean hasChanged(
)

Checks if something has changed.
Returns:
  • true if something has changed;
    false otherwise

isLeaf

public boolean isLeaf(
)

Returns true if this node is not a directory.
Returns:
  • false if this node is a directory;
    true otherwise
Specified by:

removeChild

protected void removeChild(
TMFileNode child)

Removes a child from the node.
Parameters:
child:
the TMFileChild to remove.

setUpdater

public void setUpdater(
TMUpdater updater)

Sets the updater for this node.
Parameters:
updater:
the updater for this node
Specified by:

toString

public String toString(
)

Returns the node in a String form : return the name.
Returns:
  • the name of the file