TreeMap Java Library

treemap.demo
Class TMFileNode

java.lang.Object
  extended by treemap.demo.TMFileNode
All Implemented Interfaces:
TMNode

public class TMFileNode
extends java.lang.Object
implements TMNode

The TMFileNode implements an example of TMNode encapsulating a File.

Version:
2.5
Author:
Christophe Bouthier [bouthier@loria.fr]

Field Summary
protected  java.util.Hashtable children
           
protected  long date
           
protected  int delay
           
protected  java.io.File file
           
protected  java.lang.String name
           
protected  TMFileNode parent
           
protected  long size
           
protected  TMUpdater updater
           
 
Constructor Summary
  TMFileNode(java.io.File file)
          Constructor.
protected TMFileNode(java.io.File file, TMFileNode parent, treemap.demo.TMFileNode.ProgressStatus status)
          Constructor.
 
Method Summary
protected  void addChild(TMFileNode child)
          Add child to the node.
protected  void buildTree(treemap.demo.TMFileNode.ProgressStatus status)
          Builds the tree hierarchie of a TMFileNode.
 java.util.Enumeration children()
          Returns the children of this node in an Enumeration.
 long getDate()
          Returns the last modification date.
 java.lang.String getFullName()
          Returns the full name of the file.
 java.lang.String getName()
          Returns the name of the file.
 long getSize()
          Returns the size of the node.
protected  boolean hasChanged()
          Checks if something has changed.
 boolean isLeaf()
          Returns true if this node is not a directory.
protected  void removeChild(TMFileNode child)
          Removes a child from the node.
 void setUpdater(TMUpdater updater)
          Sets the updater for this node.
 java.lang.String toString()
          Returns the node in a String form : return the name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

delay

protected final int delay
See Also:
Constant Field Values

file

protected java.io.File file

parent

protected TMFileNode parent

children

protected java.util.Hashtable children

updater

protected TMUpdater updater

size

protected long size

date

protected long date

name

protected java.lang.String name
Constructor Detail

TMFileNode

public TMFileNode(java.io.File file)
Constructor.

Parameters:
file - the File encapsulated in this node

TMFileNode

protected TMFileNode(java.io.File file,
                     TMFileNode parent,
                     treemap.demo.TMFileNode.ProgressStatus status)
Constructor.

Parameters:
file - the File encapsulated in this node
parent - the parent of this node
status - the progress status to update
Method Detail

buildTree

protected void buildTree(treemap.demo.TMFileNode.ProgressStatus status)
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

addChild

protected void addChild(TMFileNode child)
Add child to the node.

Parameters:
child - the TMFileNode to add as a child

removeChild

protected void removeChild(TMFileNode child)
Removes a child from the node.

Parameters:
child - the TMFileChild to remove.

getFullName

public java.lang.String getFullName()
Returns the full name of the file.

Returns:
the full name of the file

getName

public java.lang.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

getDate

public long getDate()
Returns the last modification date.

Returns:
the last modification date

toString

public java.lang.String toString()
Returns the node in a String form : return the name.

Overrides:
toString in class java.lang.Object
Returns:
the name of the file

children

public java.util.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.

Specified by:
children in interface TMNode
Returns:
an Enumeration containing childs of this node

isLeaf

public boolean isLeaf()
Returns true if this node is not a directory.

Specified by:
isLeaf in interface TMNode
Returns:
false if this node is a directory; true otherwise

setUpdater

public void setUpdater(TMUpdater updater)
Sets the updater for this node.

Specified by:
setUpdater in interface TMNode
Parameters:
updater - the updater for this node

hasChanged

protected boolean hasChanged()
Checks if something has changed.

Returns:
true if something has changed; false otherwise

TreeMap Java Library

TreeMap Java Library - www.bouthier.net - treemap.sf.net - 2001