KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > provider > tar > TarFileProvider


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.provider.tar;
17
18 import org.apache.commons.vfs.Capability;
19 import org.apache.commons.vfs.FileName;
20 import org.apache.commons.vfs.FileObject;
21 import org.apache.commons.vfs.FileSystem;
22 import org.apache.commons.vfs.FileSystemException;
23 import org.apache.commons.vfs.FileSystemOptions;
24 import org.apache.commons.vfs.FileType;
25 import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
26 import org.apache.commons.vfs.provider.FileProvider;
27 import org.apache.commons.vfs.provider.LayeredFileName;
28
29 import java.util.Arrays JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.Collections JavaDoc;
32
33 /**
34  * A file system provider for Tar files. Provides read-only file systems.
35  */

36 public class TarFileProvider
37     extends AbstractLayeredFileProvider
38     implements FileProvider
39 {
40     protected final static Collection JavaDoc capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
41         {
42             Capability.GET_LAST_MODIFIED,
43             Capability.GET_TYPE,
44             Capability.LIST_CHILDREN,
45             Capability.READ_CONTENT,
46             Capability.URI,
47             Capability.VIRTUAL
48         }));
49
50     public TarFileProvider()
51     {
52         super();
53     }
54
55     /**
56      * Creates a layered file system. This method is called if the file system
57      * is not cached.
58      *
59      * @param scheme The URI scheme.
60      * @param file The file to create the file system on top of.
61      * @return The file system.
62      */

63     protected FileSystem doCreateFileSystem(final String JavaDoc scheme,
64                                             final FileObject file,
65                                             final FileSystemOptions fileSystemOptions)
66         throws FileSystemException
67     {
68         final FileName rootName =
69             new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
70         return new TarFileSystem(rootName, file, fileSystemOptions);
71     }
72
73     public Collection JavaDoc getCapabilities()
74     {
75         return capabilities;
76     }
77 }
78
Popular Tags