KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > provider > zip > ZipFileProvider


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.zip;
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 Zip files. Provides read-only file systems.
35  *
36  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
37  */

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

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