Class ZipFileSystem
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.provider.AbstractFileSystem
-
- org.apache.commons.vfs2.provider.zip.ZipFileSystem
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,FileSystem
,VfsComponent
- Direct Known Subclasses:
JarFileSystem
public class ZipFileSystem extends AbstractFileSystem
A read-only file system for ZIP and JAR files.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<FileName,FileObject>
cache
Cache doesn't need to be synchronized since it is read-only.private java.nio.charset.Charset
charset
private char[]
ENC
private java.io.File
file
private static org.apache.commons.logging.Log
LOG
private java.util.zip.ZipFile
zipFile
-
Constructor Summary
Constructors Constructor Description ZipFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCapabilities(java.util.Collection<Capability> caps)
Returns the capabilities of this file system.protected FileObject
createFile(AbstractFileName name)
Creates a file object.protected java.util.zip.ZipFile
createZipFile(java.io.File file)
protected ZipFileObject
createZipFileObject(AbstractFileName name, java.util.zip.ZipEntry entry)
protected void
doCloseCommunicationLink()
Closes the underlying link used to access the files.protected java.nio.charset.Charset
getCharset()
protected FileObject
getFileFromCache(FileName name)
Returns a cached file.protected java.util.zip.ZipFile
getZipFile()
void
init()
Initializes this component.protected void
putFileToCache(FileObject file)
Adds a file object to the cache.protected void
removeFileFromCache(FileName name)
remove a cached file.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileSystem
addJunction, addListener, close, closeCommunicationLink, decorateFileObject, doReplicateFile, fireFileChanged, fireFileCreated, fireFileDeleted, getAttribute, getFileSystemManager, getFileSystemOptions, getLastModTimeAccuracy, getParentLayer, getRoot, getRootName, getRootURI, hasCapability, isOpen, isReleaseable, notifyAllStreamsClosed, removeJunction, removeListener, replicateFile, resolveFile, resolveFile, setAttribute
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
-
-
-
Field Detail
-
ENC
private final char[] ENC
-
LOG
private static final org.apache.commons.logging.Log LOG
-
file
private final java.io.File file
-
charset
private final java.nio.charset.Charset charset
-
zipFile
private java.util.zip.ZipFile zipFile
-
cache
private final java.util.Map<FileName,FileObject> cache
Cache doesn't need to be synchronized since it is read-only.
-
-
Constructor Detail
-
ZipFileSystem
public ZipFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) throws FileSystemException
- Throws:
FileSystemException
-
-
Method Detail
-
init
public void init() throws FileSystemException
Description copied from class:AbstractFileSystem
Initializes this component.- Specified by:
init
in interfaceVfsComponent
- Overrides:
init
in classAbstractFileSystem
- Throws:
FileSystemException
- if an error occurs.
-
getZipFile
protected java.util.zip.ZipFile getZipFile() throws FileSystemException
- Throws:
FileSystemException
-
createZipFileObject
protected ZipFileObject createZipFileObject(AbstractFileName name, java.util.zip.ZipEntry entry) throws FileSystemException
- Throws:
FileSystemException
-
createZipFile
protected java.util.zip.ZipFile createZipFile(java.io.File file) throws FileSystemException
- Throws:
FileSystemException
-
doCloseCommunicationLink
protected void doCloseCommunicationLink()
Description copied from class:AbstractFileSystem
Closes the underlying link used to access the files.- Overrides:
doCloseCommunicationLink
in classAbstractFileSystem
-
addCapabilities
protected void addCapabilities(java.util.Collection<Capability> caps)
Returns the capabilities of this file system.- Specified by:
addCapabilities
in classAbstractFileSystem
- Parameters:
caps
- collections of Capabilities, can be immutable.
-
createFile
protected FileObject createFile(AbstractFileName name) throws FileSystemException
Creates a file object.- Specified by:
createFile
in classAbstractFileSystem
- Parameters:
name
- name referencing the new file.- Returns:
- new created FileObject.
- Throws:
FileSystemException
-
putFileToCache
protected void putFileToCache(FileObject file)
Adds a file object to the cache.- Overrides:
putFileToCache
in classAbstractFileSystem
- Parameters:
file
- the file to add.
-
getCharset
protected java.nio.charset.Charset getCharset()
-
getFileFromCache
protected FileObject getFileFromCache(FileName name)
Returns a cached file.- Overrides:
getFileFromCache
in classAbstractFileSystem
- Parameters:
name
- name to search for.- Returns:
- file object or null if not found.
-
removeFileFromCache
protected void removeFileFromCache(FileName name)
remove a cached file.- Overrides:
removeFileFromCache
in classAbstractFileSystem
- Parameters:
name
- The file name to remove.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-