01: package com.sun.portal.netfile.applet.java2.model;
02:
03: import java.util.HashMap;
04: import java.util.Set;
05: import java.util.Iterator;
06: import java.util.Hashtable;
07:
08: // this is the base class for ShareNode and FolderNode classes.
09:
10: public abstract class ShareFolderNode extends NetFileNode {
11:
12: public ShareFolderNode(String name, String iconName,
13: String openIconName) {
14: super (name, iconName, openIconName);
15: fileRows = new HashMap();
16: loaded = false;
17: }
18:
19: public abstract void addFolderNode(FolderNode folderNode);
20:
21: public FolderNode getFolderNode(String folderName) {
22: return (FolderNode) getChildNode(folderName);
23: }
24:
25: public FolderNode removeFolderNode(String folderName) {
26: return (FolderNode) removeChildNode(folderName);
27:
28: }
29:
30: public void addFileRow(FileRow fileInfo) {
31: fileRows.put(fileInfo.getFileName(), fileInfo);
32: fileInfo.setParent(this );
33: }
34:
35: public FileRow getFileRow(String fileName) {
36: return (FileRow) fileRows.get(fileName);
37: }
38:
39: public FileRow removeFileRow(String fileName) {
40: FileRow fileRow = getFileRow(fileName);
41: if (null == fileRow) {
42: return null;
43: }
44: fileRow.delinkFromParent();
45: fileRows.remove(fileName);
46: return fileRow;
47: }
48:
49: public FolderNode[] getAllFolderNodes() {
50: return (FolderNode[]) getAllChildren(new FolderNode[0]);
51: }
52:
53: public FileRow[] getAllFileRows() {
54: return (FileRow[]) fileRows.values().toArray(new FileRow[0]);
55: }
56:
57: public void removeAllFileRows() {
58: Set nodes = fileRows.keySet();
59: for (Iterator it = nodes.iterator(); it.hasNext();) {
60: String fileName = (String) it.next();
61: FileRow fileRow = getFileRow(fileName);
62: fileRow.delinkFromParent();
63: }
64: fileRows.clear();
65:
66: }
67:
68: public boolean isLoaded() {
69: return loaded;
70: }
71:
72: public void setLoaded(boolean loaded) {
73: this .loaded = loaded;
74: }
75:
76: public abstract ShareNode getShareNode();
77:
78: public abstract SystemNode getSystemNode();
79:
80: public abstract String getFQDirectoryName();
81:
82: private HashMap fileRows;
83:
84: private boolean loaded;
85:
86: public Hashtable toHashtable() {
87: SystemNode systemNode = getSystemNode();
88: Hashtable ret = systemNode.toHashtable();
89: ShareNode shareNode = getShareNode();
90: ret.put("ShareName", shareNode.getName());
91: ret.put("SharePwd", shareNode.getPassword());
92: ret.put("Dir", getFQDirectoryName());
93: return ret;
94: }
95:
96: }
|