Class ZipFileObject
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractFileObject<ZipFileSystem>
-
- org.apache.commons.vfs2.provider.zip.ZipFileObject
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Comparable<FileObject>,java.lang.Iterable<FileObject>,FileObject
- Direct Known Subclasses:
JarFileObject
public class ZipFileObject extends AbstractFileObject<ZipFileSystem>
A file in a ZIP file system.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.zip.ZipEntryentryThe ZipEntry.
-
Constructor Summary
Constructors Modifier Constructor Description protectedZipFileObject(AbstractFileName name, java.util.zip.ZipEntry entry, ZipFileSystem fs, boolean zipExists)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachChild(FileName childName)Attaches a child.protected voiddoAttach()Attaches this file object to its file resource.protected voiddoDetach()Detaches this file object from its file resource.protected longdoGetContentSize()Returns the size of the file content (in bytes).protected java.io.InputStreamdoGetInputStream()Creates an input stream to read the file content from.protected longdoGetLastModifiedTime()Returns the last modified time of this file.protected FileTypedoGetType()Returns the file's type.protected java.lang.String[]doListChildren()Lists the children of the file.booleanisWriteable()Determines if this file can be written to.protected voidsetZipEntry(java.util.zip.ZipEntry entry)Sets the details for this file object.-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObject
canRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doCreateFileContent, doCreateFolder, doDelete, doGetAttributes, doGetCertificates, doGetOutputStream, doGetRandomAccessContent, doIsExecutable, doIsHidden, doIsReadable, doIsSameFile, doIsWriteable, doListChildrenResolved, doRemoveAttribute, doRename, doSetAttribute, doSetExecutable, doSetLastModifiedTime, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toString
-
-
-
-
Field Detail
-
entry
protected java.util.zip.ZipEntry entry
The ZipEntry.
-
-
Constructor Detail
-
ZipFileObject
protected ZipFileObject(AbstractFileName name, java.util.zip.ZipEntry entry, ZipFileSystem fs, boolean zipExists) throws FileSystemException
- Throws:
FileSystemException
-
-
Method Detail
-
setZipEntry
protected void setZipEntry(java.util.zip.ZipEntry entry)
Sets the details for this file object.- Parameters:
entry- ZIP information related to this file.
-
attachChild
public void attachChild(FileName childName)
Attaches a child.TODO: Shouldn't this method have package-only visibility? Cannot change this without breaking binary compatibility.
- Parameters:
childName- The name of the child.
-
isWriteable
public boolean isWriteable() throws FileSystemException
Determines if this file can be written to.- Specified by:
isWriteablein interfaceFileObject- Overrides:
isWriteablein classAbstractFileObject<ZipFileSystem>- Returns:
trueif this file is writable,falseif not.- Throws:
FileSystemException- if an error occurs.
-
doGetType
protected FileType doGetType()
Returns the file's type.- Specified by:
doGetTypein classAbstractFileObject<ZipFileSystem>- Returns:
- the type of the file.
-
doListChildren
protected java.lang.String[] doListChildren()
Lists the children of the file.- Specified by:
doListChildrenin classAbstractFileObject<ZipFileSystem>- Returns:
- a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
-
doGetContentSize
protected long doGetContentSize()
Returns the size of the file content (in bytes). Is only called ifdoGetType()returnsFileType.FILE.- Specified by:
doGetContentSizein classAbstractFileObject<ZipFileSystem>- Returns:
- The size of the file in bytes.
-
doGetLastModifiedTime
protected long doGetLastModifiedTime() throws java.lang.Exception
Returns the last modified time of this file.- Overrides:
doGetLastModifiedTimein classAbstractFileObject<ZipFileSystem>- Returns:
- The last modification time.
- Throws:
java.lang.Exception- if an error occurs.
-
doGetInputStream
protected java.io.InputStream doGetInputStream() throws java.lang.Exception
Creates an input stream to read the file content from. Is only called ifdoGetType()returnsFileType.FILE. The input stream returned by this method is guaranteed to be closed before this method is called again.- Specified by:
doGetInputStreamin classAbstractFileObject<ZipFileSystem>- Returns:
- An InputStream to read the file content.
- Throws:
java.lang.Exception- if an error occurs.
-
doAttach
protected void doAttach() throws java.lang.Exception
Description copied from class:AbstractFileObjectAttaches this file object to its file resource.This method is called before any of the doBlah() or onBlah() methods. Sub-classes can use this method to perform lazy initialisation.
This implementation does nothing.
- Overrides:
doAttachin classAbstractFileObject<ZipFileSystem>- Throws:
java.lang.Exception- if an error occurs.
-
doDetach
protected void doDetach() throws java.lang.Exception
Description copied from class:AbstractFileObjectDetaches this file object from its file resource.Called when this file is closed. Note that the file object may be reused later, so should be able to be reattached.
This implementation does nothing.
- Overrides:
doDetachin classAbstractFileObject<ZipFileSystem>- Throws:
java.lang.Exception- if an error occurs.
-
-