KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > impl > DefaultVfsComponentContext


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs.impl;
17
18 import org.apache.commons.vfs.FileName;
19 import org.apache.commons.vfs.FileObject;
20 import org.apache.commons.vfs.FileSystemException;
21 import org.apache.commons.vfs.FileSystemManager;
22 import org.apache.commons.vfs.FileSystemOptions;
23 import org.apache.commons.vfs.provider.FileReplicator;
24 import org.apache.commons.vfs.provider.TemporaryFileStore;
25 import org.apache.commons.vfs.provider.VfsComponentContext;
26
27 import java.io.File JavaDoc;
28
29
30 /**
31  * The default context implementation.
32  *
33  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
34  */

35 final class DefaultVfsComponentContext
36     implements VfsComponentContext
37 {
38     private final DefaultFileSystemManager manager;
39
40     public DefaultVfsComponentContext(final DefaultFileSystemManager manager)
41     {
42         this.manager = manager;
43     }
44
45     /**
46      * Locate a file by name.
47      */

48     public FileObject resolveFile(final FileObject baseFile, final String JavaDoc name, final FileSystemOptions fileSystemOptions)
49         throws FileSystemException
50     {
51         return manager.resolveFile(baseFile, name, fileSystemOptions);
52     }
53
54     /**
55      * Locate a file by name.
56      */

57     public FileObject resolveFile(final String JavaDoc name, final FileSystemOptions fileSystemOptions)
58         throws FileSystemException
59     {
60         return manager.resolveFile(name, fileSystemOptions);
61     }
62
63     public FileName parseURI(String JavaDoc uri) throws FileSystemException
64     {
65         return manager.resolveURI(uri);
66     }
67
68     /**
69      * Returns a {@link FileObject} for a local file.
70      */

71     public FileObject toFileObject(File JavaDoc file)
72         throws FileSystemException
73     {
74         return manager.toFileObject(file);
75     }
76
77     /**
78      * Locates a file replicator for the provider to use.
79      */

80     public FileReplicator getReplicator() throws FileSystemException
81     {
82         return manager.getReplicator();
83     }
84
85     /**
86      * Locates a temporary file store for the provider to use.
87      */

88     public TemporaryFileStore getTemporaryFileStore() throws FileSystemException
89     {
90         return manager.getTemporaryFileStore();
91     }
92
93     /**
94      * Returns the filesystem manager for the current context
95      *
96      * @return the filesystem manager
97      */

98     public FileSystemManager getFileSystemManager()
99     {
100         return manager;
101     }
102 }
103
Popular Tags