View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.vfs2.impl;
18  
19  import java.net.URL;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import org.apache.commons.vfs2.FileContent;
24  import org.apache.commons.vfs2.FileName;
25  import org.apache.commons.vfs2.FileObject;
26  import org.apache.commons.vfs2.FileSelector;
27  import org.apache.commons.vfs2.FileSystem;
28  import org.apache.commons.vfs2.FileSystemException;
29  import org.apache.commons.vfs2.FileType;
30  import org.apache.commons.vfs2.NameScope;
31  import org.apache.commons.vfs2.operations.FileOperations;
32  
33  /**
34   * Base class to build a fileObject decoration.
35   */
36  public class DecoratedFileObject implements FileObject {
37      private final FileObject decoratedFileObject;
38  
39      public DecoratedFileObject(final FileObject decoratedFileObject) {
40          this.decoratedFileObject = decoratedFileObject;
41      }
42  
43      @Override
44      public boolean canRenameTo(final FileObject newfile) {
45          return decoratedFileObject.canRenameTo(newfile);
46      }
47  
48      @Override
49      public void close() throws FileSystemException {
50          decoratedFileObject.close();
51      }
52  
53      @Override
54      public int compareTo(final FileObject fo) {
55          return decoratedFileObject.compareTo(fo);
56      }
57  
58      @Override
59      public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException {
60          decoratedFileObject.copyFrom(srcFile, selector);
61      }
62  
63      @Override
64      public void createFile() throws FileSystemException {
65          decoratedFileObject.createFile();
66      }
67  
68      @Override
69      public void createFolder() throws FileSystemException {
70          decoratedFileObject.createFolder();
71      }
72  
73      @Override
74      public boolean delete() throws FileSystemException {
75          return decoratedFileObject.delete();
76      }
77  
78      @Override
79      public int delete(final FileSelector selector) throws FileSystemException {
80          return decoratedFileObject.delete(selector);
81      }
82  
83      @Override
84      public int deleteAll() throws FileSystemException {
85          return decoratedFileObject.deleteAll();
86      }
87  
88      @Override
89      public boolean exists() throws FileSystemException {
90          return decoratedFileObject.exists();
91      }
92  
93      @Override
94      public FileObject[] findFiles(final FileSelector selector) throws FileSystemException {
95          return decoratedFileObject.findFiles(selector);
96      }
97  
98      @Override
99      public void findFiles(final FileSelector selector, final boolean depthwise, final List<FileObject> selected)
100             throws FileSystemException {
101         decoratedFileObject.findFiles(selector, depthwise, selected);
102     }
103 
104     @Override
105     public FileObject getChild(final String name) throws FileSystemException {
106         return decoratedFileObject.getChild(name);
107     }
108 
109     @Override
110     public FileObject[] getChildren() throws FileSystemException {
111         return decoratedFileObject.getChildren();
112     }
113 
114     @Override
115     public FileContent getContent() throws FileSystemException {
116         return decoratedFileObject.getContent();
117     }
118 
119     public FileObject getDecoratedFileObject() {
120         return decoratedFileObject;
121     }
122 
123     @Override
124     public FileOperations getFileOperations() throws FileSystemException {
125         return decoratedFileObject.getFileOperations();
126     }
127 
128     @Override
129     public FileSystem getFileSystem() {
130         return decoratedFileObject.getFileSystem();
131     }
132 
133     @Override
134     public String getPublicURIString() {
135         return decoratedFileObject.getPublicURIString();
136     }
137 
138     @Override
139     public FileName getName() {
140         return decoratedFileObject.getName();
141     }
142 
143     @Override
144     public FileObject getParent() throws FileSystemException {
145         return decoratedFileObject.getParent();
146     }
147 
148     @Override
149     public FileType getType() throws FileSystemException {
150         return decoratedFileObject.getType();
151     }
152 
153     @Override
154     public URL getURL() throws FileSystemException {
155         return decoratedFileObject.getURL();
156     }
157 
158     @Override
159     public boolean isAttached() {
160         return decoratedFileObject.isAttached();
161     }
162 
163     @Override
164     public boolean isContentOpen() {
165         return decoratedFileObject.isContentOpen();
166     }
167 
168     @Override
169     public boolean isExecutable() throws FileSystemException {
170         return decoratedFileObject.isExecutable();
171     }
172 
173     @Override
174     public boolean isFile() throws FileSystemException {
175         return decoratedFileObject.isFile();
176     }
177 
178     @Override
179     public boolean isFolder() throws FileSystemException {
180         return decoratedFileObject.isFolder();
181     }
182 
183     @Override
184     public boolean isHidden() throws FileSystemException {
185         return decoratedFileObject.isHidden();
186     }
187 
188     @Override
189     public boolean isReadable() throws FileSystemException {
190         return decoratedFileObject.isReadable();
191     }
192 
193     @Override
194     public boolean isWriteable() throws FileSystemException {
195         return decoratedFileObject.isWriteable();
196     }
197 
198     @Override
199     public Iterator<FileObject> iterator() {
200         return decoratedFileObject.iterator();
201     }
202 
203     @Override
204     public void moveTo(final FileObject destFile) throws FileSystemException {
205         decoratedFileObject.moveTo(destFile);
206     }
207 
208     @Override
209     public void refresh() throws FileSystemException {
210         decoratedFileObject.refresh();
211     }
212 
213     @Override
214     public FileObject resolveFile(final String path) throws FileSystemException {
215         return decoratedFileObject.resolveFile(path);
216     }
217 
218     @Override
219     public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException {
220         return decoratedFileObject.resolveFile(name, scope);
221     }
222 
223     @Override
224     public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException {
225         return decoratedFileObject.setExecutable(executable, ownerOnly);
226     }
227 
228     @Override
229     public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
230         return decoratedFileObject.setReadable(readable, ownerOnly);
231     }
232 
233     @Override
234     public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException {
235         return decoratedFileObject.setWritable(writable, ownerOnly);
236     }
237 
238     @Override
239     public String toString() {
240         return decoratedFileObject.toString();
241     }
242 
243 }