StoreTreeNodepublic class StoreTreeNode extends DefaultMutableTreeNode Node which represents a Store in the javax.mail apis. |
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.
super(what);
store = what;
|
Methods Summary |
---|
public int | getChildCount()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 boolean | isLeaf()a Store is never a leaf node. It can always contain stuff
return false;
| protected void | loadChildren()
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.String | toString()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;
|
|