Save This Page
Home » poi-src-3.1-FINAL-20080629 » org.apache.poi.contrib » poibrowser » [javadoc | source]
org.apache.poi.contrib.poibrowser
public class: TreeReaderListener [javadoc | source]
java.lang.Object
   org.apache.poi.contrib.poibrowser.TreeReaderListener

All Implemented Interfaces:
    POIFSReaderListener

Organizes document information in a tree model in order to be e.g. displayed in a Swing javax.swing.JTree . An instance of this class is created with a root tree node (MutableTreeNode ) and registered as a POIFSReaderListener with a org.apache.poi.poifs.eventfilesystem.POIFSReader . While the latter processes a POI filesystem it calls this class' #processPOIFSReaderEvent for each document it has been registered for. This method appends the document it processes at the appropriate position into the tree rooted at the above mentioned root tree node.

The root tree node should be the root tree node of a javax.swing.tree.TreeModel .

A top-level element in the tree model, i.e. an immediate child node of the root node, describes a POI filesystem as such. It is suggested to use the file's name (as seen by the operating system) but it could be any other string.

The value of a tree node is a DocumentDescriptor . Unlike a org.apache.poi.poifs.filesystem.POIFSDocument which may be as heavy as many megabytes, an instance of DocumentDescriptor is a light-weight object and contains only some meta-information about a document.

Field Summary
protected  MutableTreeNode rootNode   

The tree's root node. POI filesystems get attached to this node as children.

 
protected  Map pathToNode   

Maps filenames and POI document paths to their associated tree nodes.

 
protected  String filename   

The name of the file this TreeReaderListener processes. It is used to identify a top-level element in the tree. Alternatively any other string can be used. It is just a label which should identify a POI filesystem.

 
Constructor:
 public TreeReaderListener(String filename,
    MutableTreeNode rootNode) 
    Parameters:
    filename - The name of the POI filesystem, i.e. the name of the file the POI filesystem resides in. Alternatively any other string can be used.
    rootNode - All document information will be attached as descendands to this tree node.
Method from org.apache.poi.contrib.poibrowser.TreeReaderListener Summary:
getNrOfBytes,   processPOIFSReaderEvent,   setNrOfBytes
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.contrib.poibrowser.TreeReaderListener Detail:
 public int getNrOfBytes() 
 public  void processPOIFSReaderEvent(POIFSReaderEvent event) 

    A document in the POI filesystem has been opened for reading. This method retrieves properties of the document and adds them to a tree model.

 public  void setNrOfBytes(int nrOfBytes)