FileDocCategorySizeDatePackage
FolderTreeNode.javaAPI DocGlassfish v2 API4002Mon Oct 17 14:54:16 BST 2005None

FolderTreeNode

public class FolderTreeNode extends DefaultMutableTreeNode
Node which represents a Folder in the javax.mail apis.
version
1.8, 01/05/23
author
Christopher Cotton

Fields Summary
protected Folder
folder
protected boolean
hasLoaded
Constructors Summary
public FolderTreeNode(Folder what)
creates a tree node that points to the particular Store.

param
what the store for this node


                	         
       
	super(what);
	folder = what;
    
Methods Summary
public intgetChildCount()
return the number of children for this folder node. The first time this method is called we load up all of the folders under the store's defaultFolder

	if (!hasLoaded) {
	    loadChildren();
	}
	return super.getChildCount();
    
public javax.mail.FoldergetFolder()
returns the folder for this node

	return folder;
    
public booleanisLeaf()
a Folder is a leaf if it cannot contain sub folders

	try {
	    if ((folder.getType() & Folder.HOLDS_FOLDERS) == 0)
	    	return true;
	} catch (MessagingException me) { }
	
	// otherwise it does hold folders, and therefore not
	// a leaf
	return false;
    
protected voidloadChildren()

	// if it is a leaf, just say we have loaded them
	if (isLeaf()) {
	    hasLoaded = true;
	    return;
	}

	try {
	    // Folder[] sub = folder.listSubscribed();
	    Folder[] sub = folder.list();

	    // add a FolderTreeNode for each Folder
	    int num = sub.length;
	    for(int i = 0; i < num; i++) {
		FolderTreeNode node = new FolderTreeNode(sub[i]);
		// we used insert here, since add() would make
		// another recursive call to getChildCount();
		insert(node, i);
	    }
	    
	} catch (MessagingException me) {
	    me.printStackTrace();
	}
    
public java.lang.StringtoString()
override toString() since we only want to display a folder's name, and not the full path of the folder

	return folder.getName();