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 * Gets the file system manager for the current context.
37 *
38 * @return the file system manager
39 */
40 FileSystemManager getFileSystemManager();
41
42 /**
43 * Gets a file replicator for the provider to use.
44 *
45 * @return The FileReplicator.
46 * @throws FileSystemException if an error occurs.
47 */
48 FileReplicator getReplicator() throws FileSystemException;
49
50 /**
51 * Gets a temporary file store for the provider to use.
52 *
53 * @return The TemporaryFileStore.
54 * @throws FileSystemException if an error occurs.
55 */
56 TemporaryFileStore getTemporaryFileStore() 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 * Resolves a file by name. See {@link FileSystemManager#resolveFile(FileObject, String)} for a description of how
69 * this works.
70 *
71 * @param baseFile The base FileObject.
72 * @param name The name of the file to locate.
73 * @param fileSystemOptions The FileSystemOptions.
74 * @return The FileObject for the located file.
75 * @throws FileSystemException if an error occurs.
76 */
77 FileObject resolveFile(FileObject baseFile, String name, FileSystemOptions fileSystemOptions)
78 throws FileSystemException;
79
80 /**
81 * Resolves a file by name. See {@link FileSystemManager#resolveFile( String)} for a description of how this works.
82 *
83 * @param name The name of the file to locate.
84 * @param fileSystemOptions The FileSystemOptions.
85 * @return The FileObject for the located file.
86 * @throws FileSystemException if an error occurs.
87 */
88 FileObject resolveFile(String name, FileSystemOptions fileSystemOptions) throws FileSystemException;
89
90 /**
91 * Returns a {@link FileObject} for a local file.
92 *
93 * @param file The File to convert to a FileObject.
94 * @return the FileObject.
95 * @throws FileSystemException if an error occurs.
96 */
97 FileObject toFileObject(File file) throws FileSystemException;
98 }