KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > provider > jar > JarFileProvider


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.jar;
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.LayeredFileName;
26 import org.apache.commons.vfs.provider.zip.ZipFileProvider;
27
28 import java.util.ArrayList JavaDoc;
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 Jar files. Provides read-only file
35  * systems. This provides access to Jar specific features like Signing and
36  * Manifest Attributes.
37  *
38  * @author <a HREF="mailto:brian@mmmanager.org">Brian Olsen</a>
39  */

40 public class JarFileProvider
41     extends ZipFileProvider
42 {
43     final static Collection JavaDoc capabilities;
44
45     static
46     {
47         Collection JavaDoc combined = new ArrayList JavaDoc();
48         combined.addAll(ZipFileProvider.capabilities);
49         combined.addAll(Arrays.asList(new Capability[]
50             {
51                 Capability.ATTRIBUTES,
52                 Capability.FS_ATTRIBUTES,
53                 Capability.SIGNING,
54                 Capability.MANIFEST_ATTRIBUTES,
55                 Capability.VIRTUAL
56             }));
57         capabilities = Collections.unmodifiableCollection(combined);
58     }
59
60     public JarFileProvider()
61     {
62         super();
63     }
64
65     /**
66      * Creates a layered file system. This method is called if the file system
67      * is not cached.
68      *
69      * @param scheme The URI scheme.
70      * @param file The file to create the file system on top of.
71      * @return The file system.
72      */

73     protected FileSystem doCreateFileSystem(final String JavaDoc scheme,
74                                             final FileObject file,
75                                             final FileSystemOptions fileSystemOptions)
76         throws FileSystemException
77     {
78         final FileName name =
79             new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
80         return new JarFileSystem(name, file, fileSystemOptions);
81     }
82
83     public Collection JavaDoc getCapabilities()
84     {
85         return capabilities;
86     }
87 }
88
Popular Tags