001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.impl; 018 019import java.net.URL; 020import java.util.Iterator; 021import java.util.List; 022 023import org.apache.commons.vfs2.FileContent; 024import org.apache.commons.vfs2.FileName; 025import org.apache.commons.vfs2.FileObject; 026import org.apache.commons.vfs2.FileSelector; 027import org.apache.commons.vfs2.FileSystem; 028import org.apache.commons.vfs2.FileSystemException; 029import org.apache.commons.vfs2.FileType; 030import org.apache.commons.vfs2.NameScope; 031import org.apache.commons.vfs2.operations.FileOperations; 032 033/** 034 * Base class to build a FileObject decoration. 035 */ 036public class DecoratedFileObject implements FileObject { 037 038 private final FileObject fileObject; 039 040 /** 041 * Constructs a new instance to decorate the given FileObject. 042 * 043 * @param fileObject the FileObject to decorate. 044 */ 045 public DecoratedFileObject(final FileObject fileObject) { 046 this.fileObject = fileObject; 047 } 048 049 @Override 050 public boolean canRenameTo(final FileObject newfile) { 051 return fileObject.canRenameTo(newfile); 052 } 053 054 @Override 055 public void close() throws FileSystemException { 056 fileObject.close(); 057 } 058 059 @Override 060 public int compareTo(final FileObject fo) { 061 return fileObject.compareTo(fo); 062 } 063 064 @Override 065 public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { 066 fileObject.copyFrom(srcFile, selector); 067 } 068 069 @Override 070 public void createFile() throws FileSystemException { 071 fileObject.createFile(); 072 } 073 074 @Override 075 public void createFolder() throws FileSystemException { 076 fileObject.createFolder(); 077 } 078 079 @Override 080 public boolean delete() throws FileSystemException { 081 return fileObject.delete(); 082 } 083 084 @Override 085 public int delete(final FileSelector selector) throws FileSystemException { 086 return fileObject.delete(selector); 087 } 088 089 @Override 090 public int deleteAll() throws FileSystemException { 091 return fileObject.deleteAll(); 092 } 093 094 @Override 095 public boolean exists() throws FileSystemException { 096 return fileObject.exists(); 097 } 098 099 @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}