1 /*
   2  * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.nio.file.spi.FileSystemProvider;
  25 import java.nio.file.*;
  26 import java.nio.file.attribute.*;
  27 import java.nio.channels.SeekableByteChannel;
  28 import java.net.URI;
  29 import java.util.*;
  30 import java.io.IOException;
  31 
  32 public class TestProvider extends FileSystemProvider {
  33 
  34     private final FileSystem theFileSystem;
  35 
  36     public TestProvider(FileSystemProvider defaultProvider) {
  37         theFileSystem = new TestFileSystem(this);
  38     }
  39 
  40     @Override
  41     public String getScheme() {
  42         return "file";
  43     }
  44 
  45     @Override
  46     public FileSystem newFileSystem(URI uri, Map<String,?> env) {
  47         throw new RuntimeException("not implemented");
  48     }
  49 
  50     @Override
  51     public FileSystem getFileSystem(URI uri) {
  52         return theFileSystem;
  53     }
  54 
  55     @Override
  56     public Path getPath(URI uri) {
  57         throw new RuntimeException("not implemented");
  58     }
  59     
  60     @Override
  61     public void setAttribute(Path file, String attribute, Object value,
  62                              LinkOption... options)
  63         throws IOException
  64     {
  65         throw new RuntimeException("not implemented");
  66     }
  67 
  68     @Override
  69     public Map<String,Object> readAttributes(Path file, String attributes,
  70                                              LinkOption... options)
  71         throws IOException
  72     {
  73         throw new RuntimeException("not implemented");
  74     }
  75 
  76     @Override
  77     public <A extends BasicFileAttributes> A readAttributes(Path file,
  78                                                             Class<A> type,
  79                                                             LinkOption... options)
  80         throws IOException
  81     {
  82         throw new RuntimeException("not implemented");
  83     }
  84 
  85     @Override
  86     public <V extends FileAttributeView> V getFileAttributeView(Path file,
  87                                                                 Class<V> type,
  88                                                                 LinkOption... options)
  89     {
  90         throw new RuntimeException("not implemented");
  91     }
  92 
  93 
  94     @Override
  95     public void delete(Path file) throws IOException {
  96         throw new RuntimeException("not implemented");
  97     }
  98 
  99     @Override
 100     public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
 101         throws IOException
 102     {
 103         throw new RuntimeException("not implemented");
 104     }
 105 
 106     @Override
 107     public void createLink(Path link, Path existing) throws IOException {
 108         throw new RuntimeException("not implemented");
 109     }
 110 
 111     @Override
 112     public Path readSymbolicLink(Path link) throws IOException {
 113         throw new RuntimeException("not implemented");
 114     }
 115 
 116 
 117     @Override
 118     public void copy(Path source, Path target, CopyOption... options)
 119         throws IOException
 120     {
 121         throw new RuntimeException("not implemented");
 122     }
 123 
 124     @Override
 125     public void move(Path source, Path target, CopyOption... options)
 126         throws IOException
 127     {
 128         throw new RuntimeException("not implemented");
 129     }
 130 
 131     @Override
 132     public DirectoryStream<Path> newDirectoryStream(Path dir,
 133                                                     DirectoryStream.Filter<? super Path> filter)
 134         throws IOException
 135     {
 136         throw new RuntimeException("not implemented");
 137     }
 138 
 139     @Override
 140     public void createDirectory(Path dir, FileAttribute<?>... attrs)
 141         throws IOException
 142     {
 143         throw new RuntimeException("not implemented");
 144     }
 145 
 146     @Override
 147     public SeekableByteChannel newByteChannel(Path file,
 148                                               Set<? extends OpenOption> options,
 149                                               FileAttribute<?>... attrs)
 150         throws IOException
 151     {
 152         throw new RuntimeException("not implemented");
 153     }
 154 
 155 
 156     @Override
 157     public boolean isHidden(Path file) throws IOException {
 158         throw new RuntimeException("not implemented");
 159     }
 160 
 161     @Override
 162     public FileStore getFileStore(Path file) throws IOException {
 163         throw new RuntimeException("not implemented");
 164     }
 165 
 166     @Override
 167     public boolean isSameFile(Path file, Path other) throws IOException {
 168         throw new RuntimeException("not implemented");
 169     }
 170 
 171     @Override
 172     public void checkAccess(Path file, AccessMode... modes)
 173         throws IOException
 174     {
 175         throw new RuntimeException("not implemented");
 176     }    
 177 
 178     static class TestFileSystem extends FileSystem {
 179         private final TestProvider provider;
 180 
 181         TestFileSystem(TestProvider provider) {
 182             this.provider = provider;
 183         }
 184 
 185         @Override
 186         public FileSystemProvider provider() {
 187             return provider;
 188         }
 189 
 190         @Override
 191         public void close() throws IOException {
 192             throw new RuntimeException("not implemented");
 193         }
 194 
 195         @Override
 196         public boolean isOpen() {
 197             throw new RuntimeException("not implemented");
 198         }
 199 
 200         @Override
 201         public boolean isReadOnly() {
 202             throw new RuntimeException("not implemented");
 203         }
 204 
 205         @Override
 206         public String getSeparator() {
 207             throw new RuntimeException("not implemented");
 208         }
 209 
 210         @Override
 211         public Iterable<Path> getRootDirectories() {
 212             throw new RuntimeException("not implemented");
 213         }
 214 
 215         @Override
 216         public Iterable<FileStore> getFileStores() {
 217             throw new RuntimeException("not implemented");
 218         }
 219 
 220         @Override
 221         public Set<String> supportedFileAttributeViews() {
 222             throw new RuntimeException("not implemented");
 223         }
 224 
 225         @Override
 226         public Path getPath(String first, String... more) {
 227             throw new RuntimeException("not implemented");
 228         }
 229 
 230         @Override
 231         public PathMatcher getPathMatcher(String syntaxAndPattern) {
 232             throw new RuntimeException("not implemented");
 233         }
 234 
 235         @Override
 236         public UserPrincipalLookupService getUserPrincipalLookupService() {
 237             throw new RuntimeException("not implemented");
 238         }
 239 
 240         @Override
 241         public WatchService newWatchService() throws IOException {
 242             throw new RuntimeException("not implemented");
 243         }
 244     }
 245 }