View Javadoc
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.io.File;
20  
21  import org.apache.commons.vfs2.FileName;
22  import org.apache.commons.vfs2.FileObject;
23  import org.apache.commons.vfs2.FileSystemException;
24  import org.apache.commons.vfs2.FileSystemManager;
25  import org.apache.commons.vfs2.FileSystemOptions;
26  
27  /**
28   * Allows VFS components to access the services they need, such as the file replicator. A VFS component is supplied with
29   * a context as part of its initialization.
30   *
31   * @see VfsComponent#setContext
32   */
33  public interface VfsComponentContext {
34  
35      /**
36       * Resolves a file by name. See {@link FileSystemManager#resolveFile(FileObject, String)} for a description of how
37       * this works.
38       *
39       * @param baseFile The base FileObject.
40       * @param name The name of the file to locate.
41       * @param fileSystemOptions The FileSystemOptions.
42       * @return The FileObject for the located file.
43       * @throws FileSystemException if an error occurs.
44       */
45      FileObject../../../org/apache/commons/vfs2/FileObject.html#FileObject">FileObject resolveFile(FileObject baseFile, String name, FileSystemOptions fileSystemOptions)
46              throws FileSystemException;
47  
48      /**
49       * Resolves a file by name. See {@link FileSystemManager#resolveFile( String)} for a description of how this works.
50       *
51       * @param name The name of the file to locate.
52       * @param fileSystemOptions The FileSystemOptions.
53       * @return The FileObject for the located file.
54       * @throws FileSystemException if an error occurs.
55       */
56      FileObject resolveFile(String name, FileSystemOptions fileSystemOptions) throws FileSystemException;
57  
58      /**
59       * Parses a URI into a FileName.
60       *
61       * @param uri The URI String.
62       * @return The FileName.
63       * @throws FileSystemException if an error occurs.
64       */
65      FileName parseURI(String uri) throws FileSystemException;
66  
67      /**
68       * Gets a file replicator for the provider to use.
69       *
70       * @return The FileReplicator.
71       * @throws FileSystemException if an error occurs.
72       */
73      FileReplicator getReplicator() throws FileSystemException;
74  
75      /**
76       * Gets a temporary file store for the provider to use.
77       *
78       * @return The TemporaryFileStore.
79       * @throws FileSystemException if an error occurs.
80       */
81      TemporaryFileStore getTemporaryFileStore() throws FileSystemException;
82  
83      /**
84       * Returns a {@link FileObject} for a local file.
85       *
86       * @param file The File to convert to a FileObject.
87       * @return the FileObject.
88       * @throws FileSystemException if an error occurs.
89       */
90      FileObject toFileObject(File file) throws FileSystemException;
91  
92      /**
93       * Gets the file system manager for the current context.
94       *
95       * @return the file system manager
96       */
97      FileSystemManager getFileSystemManager();
98  }