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  
38      private final FileObject fileObject;
39  
40      /**
41       * Constructs a new instance to decorate the given FileObject.
42       *
43       * @param fileObject the FileObject to decorate.
44       */
45      public DecoratedFileObject(final FileObject fileObject) {
46          this.fileObject = fileObject;
47      }
48  
49      @Override
50      public boolean canRenameTo(final FileObject newfile) {
51          return fileObject.canRenameTo(newfile);
52      }
53  
54      @Override
55      public void close() throws FileSystemException {
56          fileObject.close();
57      }
58  
59      @Override
60      public int compareTo(final FileObject fo) {
61          return fileObject.compareTo(fo);
62      }
63  
64      @Override
65      public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException {
66          fileObject.copyFrom(srcFile, selector);
67      }
68  
69      @Override
70      public void createFile() throws FileSystemException {
71          fileObject.createFile();
72      }
73  
74      @Override
75      public void createFolder() throws FileSystemException {
76          fileObject.createFolder();
77      }
78  
79      @Override
80      public boolean delete() throws FileSystemException {
81          return fileObject.delete();
82      }
83  
84      @Override
85      public int delete(final FileSelector selector) throws FileSystemException {
86          return fileObject.delete(selector);
87      }
88  
89      @Override
90      public int deleteAll() throws FileSystemException {
91          return fileObject.deleteAll();
92      }
93  
94      @Override
95      public boolean exists() throws FileSystemException {
96          return fileObject.exists();
97      }
98  
99      @Override
100     public FileObject[] findFiles(final FileSelector selector) throws FileSystemException {
101         return fileObject.findFiles(selector);
102     }
103 
104     @Override
105     public void findFiles(final FileSelector selector, final boolean depthwise, final List<FileObject> selected)
106             throws FileSystemException {
107         fileObject.findFiles(selector, depthwise, selected);
108     }
109 
110     @Override
111     public FileObject getChild(final String name) throws FileSystemException {
112         return fileObject.getChild(name);
113     }
114 
115     @Override
116     public FileObject[] getChildren() throws FileSystemException {
117         return fileObject.getChildren();
118     }
119 
120     @Override
121     public FileContent getContent() throws FileSystemException {
122         return fileObject.getContent();
123     }
124 
125     /**
126      * Gets the decorated fileObject.
127      *
128      * @return the decorated fileObject.
129      */
130     public FileObject getDecoratedFileObject() {
131         return fileObject;
132     }
133 
134     @Override
135     public FileOperations getFileOperations() throws FileSystemException {
136         return fileObject.getFileOperations();
137     }
138 
139     @Override
140     public FileSystem getFileSystem() {
141         return fileObject.getFileSystem();
142     }
143 
144     @Override
145     public FileName getName() {
146         return fileObject.getName();
147     }
148 
149     @Override
150     public FileObject getParent() throws FileSystemException {
151         return fileObject.getParent();
152     }
153 
154     @Override
155     public String getPublicURIString() {
156         return fileObject.getPublicURIString();
157     }
158 
159     @Override
160     public FileType getType() throws FileSystemException {
161         return fileObject.getType();
162     }
163 
164     @Override
165     public URL getURL() throws FileSystemException {
166         return fileObject.getURL();
167     }
168 
169     @Override
170     public boolean isAttached() {
171         return fileObject.isAttached();
172     }
173 
174     @Override
175     public boolean isContentOpen() {
176         return fileObject.isContentOpen();
177     }
178 
179     @Override
180     public boolean isExecutable() throws FileSystemException {
181         return fileObject.isExecutable();
182     }
183 
184     @Override
185     public boolean isFile() throws FileSystemException {
186         return fileObject.isFile();
187     }
188 
189     @Override
190     public boolean isFolder() throws FileSystemException {
191         return fileObject.isFolder();
192     }
193 
194     @Override
195     public boolean isHidden() throws FileSystemException {
196         return fileObject.isHidden();
197     }
198 
199     @Override
200     public boolean isReadable() throws FileSystemException {
201         return fileObject.isReadable();
202     }
203 
204     @Override
205     public boolean isWriteable() throws FileSystemException {
206         return fileObject.isWriteable();
207     }
208 
209     @Override
210     public Iterator<FileObject> iterator() {
211         return fileObject.iterator();
212     }
213 
214     @Override
215     public void moveTo(final FileObject destFile) throws FileSystemException {
216         fileObject.moveTo(destFile);
217     }
218 
219     @Override
220     public void refresh() throws FileSystemException {
221         fileObject.refresh();
222     }
223 
224     @Override
225     public FileObject resolveFile(final String path) throws FileSystemException {
226         return fileObject.resolveFile(path);
227     }
228 
229     @Override
230     public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException {
231         return fileObject.resolveFile(name, scope);
232     }
233 
234     @Override
235     public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException {
236         return fileObject.setExecutable(executable, ownerOnly);
237     }
238 
239     @Override
240     public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
241         return fileObject.setReadable(readable, ownerOnly);
242     }
243 
244     @Override
245     public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException {
246         return fileObject.setWritable(writable, ownerOnly);
247     }
248 
249     @Override
250     public String toString() {
251         return fileObject.toString();
252     }
253 
254 }