*/
private MutableTreeNode getNode(final POIFSDocumentPath path,
final String fsName,
final MutableTreeNode root)
{
MutableTreeNode n = (MutableTreeNode) pathToNode.get(path);
if (n != null)
/* Node found in map, just return it. */
return n;
if (path.length() == 0)
{
/* This is the root path of the POI filesystem. Its tree
* node is resp. must be located below the tree node of
* the POI filesystem itself. This is a tree node with the
* POI filesystem's name (this the operating system file's
* name) as its key it the path-to-node map. */
n = (MutableTreeNode) pathToNode.get(fsName);
if (n == null)
{
/* A tree node for the POI filesystem does not yet
* exist. */
n = new DefaultMutableTreeNode(fsName);
pathToNode.put(fsName, n);
root.insert(n, 0);
}
return n;
}
/* else - The path is somewhere down in the POI filesystem's
* hierarchy. We need the tree node of this path's parent
* and attach our new node to it. */
final String name = path.getComponent(path.length() - 1);
final POIFSDocumentPath parentPath = path.getParent();
final MutableTreeNode parentNode =
getNode(parentPath, fsName, root);
n = new DefaultMutableTreeNode(name);
pathToNode.put(path, n);
parentNode.insert(n, 0);
return n;
}