KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
19 import java.util.Collection JavaDoc;
20
21 import org.apache.tapestry.contrib.tree.model.ITreeNode;
22
23 public class FileObject extends SFObject {
24     private long m_lSize;
25
26     public FileObject(ITreeNode objParent, File JavaDoc objFile) {
27         super(objParent, objFile);
28         init();
29     }
30
31     protected void init() {
32         super.init();
33         m_lSize = m_objFile.length();
34     }
35
36     public long getSize() {
37         return m_lSize;
38     }
39
40     /**
41      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#containsChild(ITreeNode)
42      */

43     public boolean containsChild(ITreeNode node) {
44         return false;
45     }
46
47     /**
48      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getAllowsChildren()
49      */

50     public boolean getAllowsChildren() {
51         return false;
52     }
53
54     /**
55      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getChildCount()
56      */

57     public int getChildCount() {
58         return 0;
59     }
60
61     /**
62      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#getChildren()
63      */

64     public Collection JavaDoc getChildren() {
65         return new ArrayList JavaDoc();
66     }
67
68     /**
69      * @see org.apache.tapestry.contrib.tree.model.ITreeNode#isLeaf()
70      */

71     public boolean isLeaf() {
72         return true;
73     }
74
75     /**
76      * @see org.apache.tapestry.workbench.tree.examples.fsmodel.IFileSystemTreeNode#getAssets()
77      */

78     public AssetsHolder getAssets() {
79         if (m_objAssetsHolder == null) {
80             final String JavaDoc a = "/org/apache/tapestry/workbench/tree/examples/fsmodel/file.gif";
81             m_objAssetsHolder = new AssetsHolder(a, a);
82         }
83         return m_objAssetsHolder;
84     }
85 }
86
Popular Tags