FileDocCategorySizeDatePackage
StoreTreeNode.javaAPI DocGlassfish v2 API4080Mon Oct 17 14:54:18 BST 2005None

StoreTreeNode

public class StoreTreeNode extends DefaultMutableTreeNode
Node which represents a Store in the javax.mail apis.
version
1.9, 01/05/23
author
Christopher Cotton

Fields Summary
protected Store
store
protected Folder
folder
protected String
display
Constructors Summary
public StoreTreeNode(Store what)
creates a tree node that points to the particular Store.

param
what the store for this node


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

	if (folder == null) {
	    loadChildren();
	}
	return super.getChildCount();
    
public booleanisLeaf()
a Store is never a leaf node. It can always contain stuff

	return false;
    
protected voidloadChildren()

	try {
	    // connect to the Store if we need to
	    if (!store.isConnected()) {
		store.connect();
	    }

	    // get the default folder, and list the
	    // subscribed folders on it
	    folder = store.getDefaultFolder();
	    // 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()
We override toString() so we can display the store URLName without the password.

	if (display == null) {
	    URLName url = store.getURLName();
	    if (url == null) {
		display = store.toString();
	    } else {
		// don't show the password
		URLName too = new URLName( url.getProtocol(), url.getHost(), url.getPort(),
					   url.getFile(), url.getUsername(), null);
		display = too.toString();
	    }
	}
	
	return display;