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.provider;
018
019import java.util.Collection;
020
021import org.apache.commons.vfs2.Capability;
022import org.apache.commons.vfs2.FileName;
023import org.apache.commons.vfs2.FileObject;
024import org.apache.commons.vfs2.FileSystemConfigBuilder;
025import org.apache.commons.vfs2.FileSystemException;
026import org.apache.commons.vfs2.FileSystemOptions;
027
028/**
029 * A file provider. Each file provider is responsible for handling files for a particular URI scheme.
030 * <p>
031 * A file provider may also implement {@link VfsComponent}.
032 */
033public interface FileProvider {
034    /**
035     * Locates a file object, by absolute URI.
036     *
037     * @param baseFile The base file to use for resolving the individual parts of a compound URI.
038     * @param uri The absolute URI of the file to find.
039     * @param fileSystemOptions The FileSystemOptions
040     * @return The FileObject.
041     * @throws FileSystemException if an error occurs locating the file.
042     */
043    FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
044            throws FileSystemException;
045
046    /**
047     * Creates a layered file system.
048     *
049     * @param scheme The URI scheme for the layered file system.
050     * @param file The file to build the file system on.
051     * @param fileSystemOptions The FileSystemOptions.
052     * @return A FileObject in the file system.
053     * @throws FileSystemException if an error occurs.
054     */
055    FileObject createFileSystem(String scheme, FileObject file, FileSystemOptions fileSystemOptions)
056            throws FileSystemException;
057
058    /**
059     * Gets the configbuilder useable to collect the needed fileSystemOptions.
060     *
061     * @return a FileSystemConfigBuilder for the particular file system.
062     */
063    FileSystemConfigBuilder getConfigBuilder();
064
065    /**
066     * Get the filesystem capabilities.<br>
067     * These are the same as on the filesystem, but available before the first filesystem was instanciated.
068     *
069     * @return a Collection of the file systems Capabilities.
070     */
071    Collection<Capability> getCapabilities();
072
073    /**
074     * Parse the URI into a FileName.
075     *
076     * @param root The base FileName.
077     * @param uri The file to be accessed.
078     * @return A FileName representing the target file.
079     * @throws FileSystemException if an error occurs.
080     */
081    FileName parseUri(FileName root, String uri) throws FileSystemException;
082}