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.io.File; 020 021import org.apache.commons.vfs2.FileName; 022import org.apache.commons.vfs2.FileObject; 023import org.apache.commons.vfs2.FileSystemException; 024import org.apache.commons.vfs2.FileSystemManager; 025import org.apache.commons.vfs2.FileSystemOptions; 026 027/** 028 * Allows VFS components to access the services they need, such as the file replicator. A VFS component is supplied with 029 * a context as part of its initialisation. 030 * 031 * @see VfsComponent#setContext 032 */ 033public interface VfsComponentContext { 034 /** 035 * Locate a file by name. See {@link FileSystemManager#resolveFile(FileObject, String)} for a description of how 036 * this works. 037 * 038 * @param baseFile The base FileObject. 039 * @param name The name of the file to locate. 040 * @param fileSystemOptions The FileSystemOptions. 041 * @return The FileObject for the located file. 042 * @throws FileSystemException if an error occurs. 043 */ 044 FileObject resolveFile(FileObject baseFile, String name, FileSystemOptions fileSystemOptions) 045 throws FileSystemException; 046 047 /** 048 * Locate a file by name. See {@link FileSystemManager#resolveFile( String)} for a description of how this works. 049 * 050 * @param name The name of the file to locate. 051 * @param fileSystemOptions The FileSystemOptions. 052 * @return The FileObject for the located file. 053 * @throws FileSystemException if an error occurs. 054 */ 055 FileObject resolveFile(String name, FileSystemOptions fileSystemOptions) throws FileSystemException; 056 057 /** 058 * Parse a URI into a FileName. 059 * 060 * @param uri The URI String. 061 * @return The FileName. 062 * @throws FileSystemException if an error occurs. 063 */ 064 FileName parseURI(String uri) throws FileSystemException; 065 066 /** 067 * Locates a file replicator for the provider to use. 068 * 069 * @return The FileReplicator. 070 * @throws FileSystemException if an error occurs. 071 */ 072 FileReplicator getReplicator() throws FileSystemException; 073 074 /** 075 * Locates a temporary file store for the provider to use. 076 * 077 * @return The TemporaryFileStore. 078 * @throws FileSystemException if an error occurs. 079 */ 080 TemporaryFileStore getTemporaryFileStore() throws FileSystemException; 081 082 /** 083 * Returns a {@link FileObject} for a local file. 084 * 085 * @param file The File to convert to a FileObject. 086 * @return the FileObject. 087 * @throws FileSystemException if an error occurs. 088 */ 089 FileObject toFileObject(File file) throws FileSystemException; 090 091 /** 092 * Returns the filesystem manager for the current context. 093 * 094 * @return the filesystem manager 095 */ 096 FileSystemManager getFileSystemManager(); 097}