KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > io > swing > AbstractFileSystemView


1 /*
2  * DecoratingFileSystemView.java
3  *
4  * Created on 10. Dezember 2006, 13:51
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.io.swing;
23
24 import java.io.*;
25 import javax.swing.Icon JavaDoc;
26
27 import javax.swing.filechooser.FileSystemView JavaDoc;
28
29 /**
30  * An abstract decorator which simply delegates to another instance of
31  * {@link FileSystemView}.
32  * Subclasses should override individual methods to implement some specific
33  * behaviour.
34  * Note that this class does not override any methods in {@link Object}
35  * - this may be done in a subclass.
36  * <p>
37  * There's one exception to the delegation rule: The method
38  * {@link FileSystemView#createFileSystemRoot} has protected access and hence
39  * can't be called on a delegate.
40  * This method is left implemented by the super class instead.
41  *
42  * @author Christian Schlichtherle
43  */

44 abstract class AbstractFileSystemView extends FileSystemView {
45
46     /**
47      * The file system view to be decorated - is never <code>null</code>.
48      */

49     private FileSystemView delegate;
50     
51     /**
52      * Creates a new decorating file system view.
53      *
54      * @param delegate The file view to be decorated - may be <code>null</code>.
55      */

56     protected AbstractFileSystemView(final FileSystemView delegate) {
57         if (delegate == null)
58             throw new NullPointerException JavaDoc();
59         this.delegate = delegate;
60     }
61
62     /**
63      * Returns the file system view to be decorated
64      * - is never <code>null</code>.
65      */

66     public FileSystemView getDelegate() {
67         return delegate;
68     }
69
70     /**
71      * Sets the file system view to be decorated.
72      *
73      * @throws NullPointerException If <code>delegate</code> is <code>null</code>.
74      * @throws IllegalArgumentException If <code>delegate</code> is this
75      * instance.
76      */

77     public void setDelegate(final FileSystemView delegate) {
78         if (delegate == null)
79             throw new NullPointerException JavaDoc();
80         if (delegate == this)
81             throw new IllegalArgumentException JavaDoc();
82         this.delegate = delegate;
83     }
84
85     //
86
// Overridden methods:
87
//
88

89     public boolean isRoot(File f) {
90         return delegate.isRoot(f);
91     }
92
93     public Boolean JavaDoc isTraversable(File f) {
94         return delegate.isTraversable(f);
95     }
96
97     public String JavaDoc getSystemDisplayName(File f) {
98         return delegate.getSystemDisplayName(f);
99     }
100
101     public String JavaDoc getSystemTypeDescription(File f) {
102         return delegate.getSystemTypeDescription(f);
103     }
104
105     public Icon JavaDoc getSystemIcon(File f) {
106         return delegate.getSystemIcon(f);
107     }
108
109     public boolean isParent(File folder, File file) {
110         return delegate.isParent(folder, file);
111     }
112
113     public File getChild(File parent, String JavaDoc fileName) {
114         return delegate.getChild(parent, fileName);
115     }
116
117     public boolean isFileSystem(File f) {
118         return delegate.isFileSystem(f);
119     }
120
121     public File createNewFolder(File containingDir) throws IOException {
122         return delegate.createNewFolder(containingDir);
123     }
124
125     public boolean isHiddenFile(File f) {
126         return delegate.isHiddenFile(f);
127     }
128
129     public boolean isFileSystemRoot(File dir) {
130         return delegate.isFileSystemRoot(dir);
131     }
132
133     public boolean isDrive(File dir) {
134         return delegate.isDrive(dir);
135     }
136
137     public boolean isFloppyDrive(File dir) {
138         return delegate.isFloppyDrive(dir);
139     }
140
141     public boolean isComputerNode(File dir) {
142         return delegate.isComputerNode(dir);
143     }
144
145     public File[] getRoots() {
146         return delegate.getRoots();
147     }
148     
149     public File getHomeDirectory() {
150         return delegate.getHomeDirectory();
151     }
152
153     public File getDefaultDirectory() {
154         return delegate.getDefaultDirectory();
155     }
156     
157     public File createFileObject(File dir, String JavaDoc filename) {
158         return delegate.createFileObject(dir, filename);
159     }
160
161     public File createFileObject(String JavaDoc path) {
162         return delegate.createFileObject(path);
163     }
164
165     public File[] getFiles(File dir, boolean useFileHiding) {
166         return delegate.getFiles(dir, useFileHiding);
167     }
168
169     public File getParentDirectory(File dir) {
170         return delegate.getParentDirectory(dir);
171     }
172
173     /*protected File createFileSystemRoot(File f) {
174         return delegate.createFileSystemRoot(f);
175     }*/

176 }
177
Popular Tags