|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.file.AbstractFile
com.mucommander.file.impl.ProxyFile
com.mucommander.file.AbstractArchiveFile
public abstract class AbstractArchiveFile
AbstractArchiveFile is the superclass of all archive files. It allows archive file to be browsed as if
they were regular directories, independently of the underlying protocol used to access the actual file.
AbstractArchiveFile extends ProxyFile to delegate the AbstractFile
implementation to the actual archive file and overrides some methods to provide the added functionality.
There are two kinds of AbstractArchiveFile, both of which extend this class:
AbstractROArchiveFile: read-only archives, these are only able to perform read operations such as
listing the archive's contents or retrieving a particular entry's contents.
AbstractRWArchiveFile: read-write archives, these are also able to modify the archive by adding or
deleting an entry from the archive. These operations usually require random access to the underlying file,
so write operations may not be available on all underlying file types. The isWritableArchive() method allows
to determine whether the archive file is able to carry out write operations or not.
AbstractROArchiveFile or AbstractRWArchiveFile
should be subclassed, but not this class.
The first time one of the ls() methods is called to list the archive's contents, the
getEntries() method is called to retrieve a list of *all* the entries contained by the archive, not only the
ones at the top level but also the ones nested one of several levels below. Using this list of entries, it creates
a tree to map the structure of the archive and list the content of any particular directory within the archive.
This tree is recreated (getEntries() is called again) only if the archive file has changed, i.e. its
date has changed since the tree was created.
Files returned by the ls() are ArchiveEntryFile instances which use an ArchiveEntry
object to retrieve the entry's attributes. In turn, these ArchiveEntryFile instances query the
associated AbstractArchiveFile to list their content.
From an implementation perspective, one only needs to deal with ArchiveEntry instances, all the nuts
and bolts are taken care of by this class.
FileFactory,
ArchiveFormatProvider,
ArchiveEntry,
ArchiveEntryFile,
Archiver| Field Summary | |
|---|---|
protected long |
entryTreeDate
Date this file had when the entries tree was created. |
protected ArchiveEntryTree |
entryTreeRoot
Archive entries tree |
| Fields inherited from class com.mucommander.file.impl.ProxyFile |
|---|
file |
| Fields inherited from class com.mucommander.file.AbstractFile |
|---|
DEFAULT_SEPARATOR, fileURL, IO_BUFFER_SIZE, MUST_HINT, MUST_NOT_HINT, SHOULD_HINT, SHOULD_NOT_HINT, windowsDriveRootPattern |
| Fields inherited from interface com.mucommander.file.PermissionTypes |
|---|
EXECUTE_PERMISSION, READ_PERMISSION, WRITE_PERMISSION |
| Fields inherited from interface com.mucommander.file.PermissionAccesses |
|---|
GROUP_ACCESS, OTHER_ACCESS, USER_ACCESS |
| Constructor Summary | |
|---|---|
protected |
AbstractArchiveFile(AbstractFile file)
Creates an AbstractArchiveFile on top of the given file. |
| Method Summary | |
|---|---|
protected void |
addToEntriesTree(ArchiveEntry entry)
Adds the given ArchiveEntry to the entries tree. |
boolean |
canRunProcess()
Always returns false. |
protected void |
checkEntriesTree()
Checks if the entries tree exists and if this file hasn't been modified since the tree was last created. |
protected void |
createEntriesTree()
Creates the entries tree, used by ls(ArchiveEntryFile, com.mucommander.file.filter.FilenameFilter, com.mucommander.file.filter.FileFilter)
to quickly list the contents of an archive's subfolder. |
protected void |
declareEntriesTreeUpToDate()
Declares the entries tree up-to-date by setting the current tree date to the archive file's. |
protected AbstractFile |
getArchiveEntryFile(ArchiveEntry entry,
AbstractFile parentFile,
boolean exists)
Creates and returns an AbstractFile using the provided entry and parent file. |
AbstractFile |
getArchiveEntryFile(java.lang.String entryPath)
Creates and returns an AbstractFile that corresponds to the given entry path within the archive. |
abstract java.util.Vector |
getEntries()
Returns a Vector of ArchiveEntry, representing all the entries this archive file contains. |
abstract java.io.InputStream |
getEntryInputStream(ArchiveEntry entry)
Returns an InputStream to read from the given archive entry. |
long |
getFreeSpace()
Returns the proxied file's free space if this archive is writable (as reported by isWritableArchive(),
else returns 0. |
boolean |
isBrowsable()
Always returns true, archive files can be browsed even though they are not directories. |
boolean |
isDirectory()
Always returns false, archive files can be browsed but they are not directiories. |
abstract boolean |
isWritableArchive()
Returns true if this archive file is writable, i.e. |
AbstractFile[] |
ls()
This method is overridden to list and return the topmost entries contained by this archive. |
protected AbstractFile[] |
ls(ArchiveEntryFile entryFile,
FilenameFilter filenameFilter,
FileFilter fileFilter)
Returns the contents of the specified folder entry. |
protected AbstractFile[] |
ls(javax.swing.tree.DefaultMutableTreeNode treeNode,
AbstractFile parentFile,
FilenameFilter filenameFilter,
FileFilter fileFilter)
Returns the contents (direct children) of the specified tree node. |
AbstractFile[] |
ls(FileFilter filter)
This method is overridden to list and return the topmost entries contained by this archive, filtering out the ones that do not match the specified FileFilter. |
AbstractFile[] |
ls(FilenameFilter filter)
This method is overridden to list and return the topmost entries contained by this archive, filtering out the ones that do not match the specified FilenameFilter. |
protected void |
removeFromEntriesTree(ArchiveEntry entry)
Removes the given ArchiveEntry from the entries tree. |
AbstractProcess |
runProcess(java.lang.String[] tokens)
Always throws an IOException. |
| Methods inherited from class com.mucommander.file.AbstractFile |
|---|
addTrailingSeparator, calculateChecksum, calculateChecksum, calculateChecksum, changePermissions, checkCopyPrerequisites, copyRecursively, deleteRecursively, getAbsolutePath, getAncestor, getAncestor, getCanonicalPath, getChild, getDirectChild, getExtension, getIcon, getIcon, getNameWithoutExtension, getParentArchive, getParentSilently, getTopAncestor, hasAncestor, hasAncestor, isParentOf, mkdir, mkdirs, mkfile, removeTrailingSeparator |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ArchiveEntryTree entryTreeRoot
protected long entryTreeDate
| Constructor Detail |
|---|
protected AbstractArchiveFile(AbstractFile file)
file - the file on top of which to create the archive| Method Detail |
|---|
protected void createEntriesTree()
throws java.io.IOException
ls(ArchiveEntryFile, com.mucommander.file.filter.FilenameFilter, com.mucommander.file.filter.FileFilter)
to quickly list the contents of an archive's subfolder.
java.io.IOException - if an error occured while retrieving this archive's entries
protected void checkEntriesTree()
throws java.io.IOException
java.io.IOException - if an error occurred while creating the treeprotected void declareEntriesTreeUpToDate()
AbstractRWArchiveFile implementations when the archive file has been
modified and the entries propagated in the tree, to avoid the tree from being automatically re-created when
checkEntriesTree() is called.
protected void addToEntriesTree(ArchiveEntry entry)
throws java.io.IOException
ArchiveEntry to the entries tree. This method will create the tree if it doesn't already
exist, or re-create it if the archive file has changed since it was last created.
entry - the ArchiveEntry to add to the tree
java.io.IOException - if an error occurred while creating the entries tree
protected void removeFromEntriesTree(ArchiveEntry entry)
throws java.io.IOException
ArchiveEntry from the entries tree. This method will create the tree if it doesn't
already exist, or re-create it if the archive file has changed since it was last created.
entry - the ArchiveEntry to remove from the tree
java.io.IOException - if an error occurred while creating the entries tree
protected AbstractFile[] ls(ArchiveEntryFile entryFile,
FilenameFilter filenameFilter,
FileFilter fileFilter)
throws java.io.IOException
java.io.IOException
protected AbstractFile[] ls(javax.swing.tree.DefaultMutableTreeNode treeNode,
AbstractFile parentFile,
FilenameFilter filenameFilter,
FileFilter fileFilter)
throws java.io.IOException
java.io.IOException
protected AbstractFile getArchiveEntryFile(ArchiveEntry entry,
AbstractFile parentFile,
boolean exists)
throws java.io.IOException
ProxyFile.getSeparator().
That means entries paths of archives located on Windows local filesystems will use '\' as a separator, and
'/' for Unix local archives.
java.io.IOException
public AbstractFile getArchiveEntryFile(java.lang.String entryPath)
throws java.io.IOException
ProxyFile.exists() method of the returned entry file
can be used used to get this information. However, if the requested entry does not exist in the archive and is
not located at the top level (i.e. is located in a subfolder), its parent folder must exist in the archive or
else an IOException will be thrown.
Important note: the given path's separator character must be '/' and the path must be relative to the archive's root, i.e. not start with a leading '/', otherwise the entry will not be found.
entryPath - path to an entry within this archive
java.io.IOException - if neither the entry nor its parent exist within the archive
public abstract java.util.Vector getEntries()
throws java.io.IOException
ArchiveEntry, representing all the entries this archive file contains.
This method will be called the first time one of the ls() is called. If will not be further called,
unless the file's date has changed since the last time one of the ls() methods was called.
java.io.IOException
public abstract java.io.InputStream getEntryInputStream(ArchiveEntry entry)
throws java.io.IOException
ArchiveEntry instance is
necessarily one of the entries that were returned by getEntries().
java.io.IOExceptionpublic abstract boolean isWritableArchive()
true if this archive file is writable, i.e. is capable of adding and deleting entries to
the underlying archive file.
This method is implemented by AbstractROArchiveFile and
AbstractRWArchiveFile to respectively return false and
true. This method may be overridden by AbstractRWArchiveFile implementations if write
access is only available under certain conditions, for example if it requires random write access to the
proxied archive file (which may not always be available).
Therefore, this method should be used to test if an AbstractArchiveFile is writable, rather than
testing if it is an instance of AbstractRWArchiveFile.
public AbstractFile[] ls()
throws java.io.IOException
ArchiveEntryFile instances.
ls in class ProxyFilejava.io.IOException - if the archive entries could not be listed
public AbstractFile[] ls(FilenameFilter filter)
throws java.io.IOException
FilenameFilter. The returned files are ArchiveEntryFile
instances.
ls in class ProxyFilefilter - the FilenameFilter to be used to filter files out from the list, may be null
java.io.IOException - if the archive entries could not be listed
public AbstractFile[] ls(FileFilter filter)
throws java.io.IOException
FileFilter. The returned files are ArchiveEntryFile instances.
ls in class ProxyFilefilter - the FilenameFilter to be used to filter files out from the list, may be null
java.io.IOException - if the archive entries could not be listedpublic boolean isBrowsable()
true, archive files can be browsed even though they are not directories.
isBrowsable in class ProxyFilepublic boolean isDirectory()
false, archive files can be browsed but they are not directiories.
isDirectory in class ProxyFiletrue if this file is a directory, false in any of the cases listed abovepublic long getFreeSpace()
isWritableArchive(),
else returns 0.
getFreeSpace in class ProxyFilepublic boolean canRunProcess()
false.
canRunProcess in class ProxyFiletrue if it's possible to run processes on the underlying file system, false otherwise.
public AbstractProcess runProcess(java.lang.String[] tokens)
throws java.io.IOException
IOException.
runProcess in class ProxyFiletokens - command and its arguments for the process to create.
java.io.IOException - thrown if an error occured while creating the process, if the current file is not a directory or if the operation is not supported.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard