KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > workbench > tree > examples > fsmodel > SFObject


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.workbench.tree.examples.fsmodel;
16
17 import java.io.File JavaDoc;
18 import java.util.Collection JavaDoc;
19 import java.util.Date JavaDoc;
20
21 import org.apache.tapestry.contrib.tree.model.ITreeNode;
22
23 public abstract class SFObject implements IFileSystemTreeNode{
24     protected File JavaDoc m_objFile;
25     protected ITreeNode m_objParent;
26     private Date JavaDoc m_objDate;
27     protected transient AssetsHolder m_objAssetsHolder = null;
28
29     public SFObject(ITreeNode objParent, File JavaDoc objFile) {
30         m_objParent = objParent;
31         m_objFile = objFile;
32 // init();
33
}
34
35     protected void init() {
36         if(m_objFile.isFile() || m_objFile.isDirectory())
37             m_objDate = new Date JavaDoc(m_objFile.lastModified());
38     }
39
40     public String JavaDoc getName() {
41         if (m_objFile.getName().equals("")) {
42             return m_objFile.toString();
43         }
44         return m_objFile.getName();
45     }
46
47     public Date JavaDoc getDate() {
48         return m_objDate;
49     }
50
51     public Object JavaDoc getAttributes() {
52         return null;
53     }
54
55     protected File JavaDoc getFile() {
56         return m_objFile;
57     }
58
59     /**
60      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getParent()
61      */

62     public ITreeNode getParent() {
63         return m_objParent;
64     }
65
66     /**
67      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#containsChild(ITreeNode)
68      */

69     public boolean containsChild(ITreeNode node) {
70         return false;
71     }
72
73     /**
74      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getAllowsChildren()
75      */

76     public boolean getAllowsChildren() {
77         return false;
78     }
79
80     /**
81      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getChildCount()
82      */

83     public int getChildCount() {
84         return 0;
85     }
86
87     /**
88      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getChildren()
89      */

90     public Collection JavaDoc getChildren() {
91         return null;
92     }
93
94     /**
95      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#isLeaf()
96      */

97     public boolean isLeaf() {
98         return false;
99     }
100
101     /**
102      * @see java.lang.Object#equals(Object)
103      */

104     public boolean equals(Object JavaDoc arg0) {
105         if (!(arg0 instanceof SFObject)) {
106             return false;
107         }
108         SFObject objSF = (SFObject)arg0;
109         if (getFile().equals(objSF.getFile())) {
110             return true;
111         }
112         return false;
113     }
114
115     /**
116      * @see java.lang.Object#hashCode()
117      */

118     public int hashCode() {
119         return m_objFile.hashCode();
120     }
121
122     /**
123      * @see java.lang.Object#toString()
124      */

125     public String JavaDoc toString() {
126         return getName();
127     }
128
129     /**
130      * @see org.apache.tapestry.workbench.tree.examples.fsmodel.IFileSystemTreeNode#getAbsolutePath()
131      */

132     public String JavaDoc getAbsolutePath() {
133         return getFile().getAbsolutePath();
134     }
135 }
136
Popular Tags