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.provider;
18
19 import java.util.Collection;
20
21 import org.apache.commons.vfs2.Capability;
22 import org.apache.commons.vfs2.FileName;
23 import org.apache.commons.vfs2.FileObject;
24 import org.apache.commons.vfs2.FileSystemConfigBuilder;
25 import org.apache.commons.vfs2.FileSystemException;
26 import org.apache.commons.vfs2.FileSystemOptions;
27
28 /**
29 * A file provider. Each file provider is responsible for handling files for a particular URI scheme.
30 * <p>
31 * A file provider may also implement {@link VfsComponent}.
32 * </p>
33 */
34 public interface FileProvider {
35
36 /**
37 * Creates a layered file system.
38 *
39 * @param scheme The URI scheme for the layered file system.
40 * @param file The file to build the file system on.
41 * @param fileSystemOptions The FileSystemOptions.
42 * @return A FileObject in the file system.
43 * @throws FileSystemException if an error occurs.
44 */
45 FileObject createFileSystem(String scheme, FileObject file, FileSystemOptions fileSystemOptions) throws FileSystemException;
46
47 /**
48 * Locates a file object, by absolute URI.
49 *
50 * @param baseFile The base file to use for resolving the individual parts of a compound URI.
51 * @param uri The absolute URI of the file to find.
52 * @param fileSystemOptions The FileSystemOptions
53 * @return The FileObject.
54 * @throws FileSystemException if an error occurs locating the file.
55 */
56 FileObject findFile(FileObject baseFile, String uri, FileSystemOptions fileSystemOptions) throws FileSystemException;
57
58 /**
59 * Gets the file system capabilities.
60 * <p>
61 * These are the same as on the file system, but available before the first file system was instantiated.
62 * </p>
63 *
64 * @return a Collection of the file systems Capabilities.
65 */
66 Collection<Capability> getCapabilities();
67
68 /**
69 * Gets the configbuilder usable to collect the needed fileSystemOptions.
70 *
71 * @return a FileSystemConfigBuilder for the particular file system.
72 */
73 FileSystemConfigBuilder getConfigBuilder();
74
75 /**
76 * Parses the URI into a FileName.
77 *
78 * @param root The base FileName.
79 * @param uri The file to be accessed.
80 * @return A FileName representing the target file.
81 * @throws FileSystemException if an error occurs.
82 */
83 FileName parseUri(FileName root, String uri) throws FileSystemException;
84 }