|
|||||||||
| 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.ArchiveEntryFile
public class ArchiveEntryFile
ArchiveEntryFile represents a file entry inside an archive. An ArchiveEntryFile is always associated with an
ArchiveEntry object which contains information about the entry (name, size, date, ...) and with an
AbstractArchiveFile which acts as an entry repository and provides operations such as listing a directory
entry's files, adding or removing entries (if the archive is writable), etc...
ArchiveEntryFile implements AbstractFile by delegating methods to the
ArchiveEntry and AbstractArchiveFile instances.
ArchiveEntryFile is agnostic to the actual archive format. In other words, there is no need to extend
this class for a particular archive format, ArchiveEntry and AbstractArchiveFile provide a
general framework that isolates from the archive format's specifics.
| Field Summary | |
|---|---|
protected AbstractArchiveFile |
archiveFile
The archive file that contains this entry |
protected ArchiveEntry |
entry
The ArchiveEntry object that contains information about this entry |
protected boolean |
exists
True if this entry exists in the archive |
protected AbstractFile |
parent
This entry file's parent, can be the archive file itself if this entry is located at the top level |
| 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 |
ArchiveEntryFile(FileURL url,
AbstractArchiveFile archiveFile,
ArchiveEntry entry,
boolean exists)
Creates a new ArchiveEntryFile. |
| Method Summary | |
|---|---|
boolean |
canChangeDate()
Returns true only if the archive file that contains this entry is writable. |
boolean |
canGetGroup()
Returns true if this file implementation is able to return some information about file groups, not
necessarily for all files or this file in particular but at least for some of them. |
boolean |
canGetOwner()
Returns true if this file implementation is able to return some information about file owners, not
necessarily for all files or this file in particular but at least for some of them. |
boolean |
canRunProcess()
Always returns false: archive entries cannot run processes. |
boolean |
changeDate(long lastModified)
Always returns false only if the archive file that contains this entry is not writable. |
boolean |
changePermission(int access,
int permission,
boolean enabled)
Always returns false only if the archive file that contains this entry is not writable. |
boolean |
changePermissions(int permissions)
Always returns false only if the archive file that contains this entry is not writable. |
void |
delete()
Deletes this entry from the associated AbstractArchiveFile if it is writable (as reported by
AbstractArchiveFile.isWritableArchive()). |
boolean |
exists()
Returns true if this entry exists within the archive file. |
AbstractArchiveFile |
getArchiveFile()
Returns the AbstractArchiveFile that contains the entry represented by this file. |
java.lang.String |
getCanonicalPath()
This method is overridden to use the archive file's canonical path as the base path of this entry file. |
PermissionBits |
getChangeablePermissions()
Returns PermissionBits.FULL_PERMISSION_BITS or PermissionBits.EMPTY_PERMISSION_BITS, depending
on whether the archive that contains this entry is writable or not. |
long |
getDate()
Returns this file's last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970). |
ArchiveEntry |
getEntry()
Returns the ArchiveEntry instance that contains information about the archive entry (path, size, date, ...). |
long |
getFreeSpace()
Delegates to the archive file's AbstractArchiveFile.getFreeSpace() method. |
java.lang.String |
getGroup()
Returns information about the group this file belongs to. |
java.io.InputStream |
getInputStream()
Delegates to the archive file's AbstractArchiveFile.getEntryInputStream(ArchiveEntry)} method. |
int |
getMoveToHint(AbstractFile destFile)
Returns a hint that indicates whether the AbstractFile.moveTo(AbstractFile) method should be used to
move this file to the specified destination file, rather than moving the file using
AbstractFile.copyStream(InputStream, boolean) or AbstractFile.getInputStream() and AbstractFile.getOutputStream(boolean). |
java.io.OutputStream |
getOutputStream(boolean append)
Returns an OutputStream that allows to write this entry's contents if the archive is
writable (as reported by AbstractArchiveFile.isWritableArchive()). |
java.lang.String |
getOwner()
Returns information about the owner of this file. |
AbstractFile |
getParent()
Returns this file's parent, null if it doesn't have one. |
FilePermissions |
getPermissions()
Returns this file's permissions, as a FilePermissions object. |
RandomAccessInputStream |
getRandomAccessInputStream()
Always throws an IOException: random read access is not available for archive entries. |
RandomAccessOutputStream |
getRandomAccessOutputStream()
Always throws an IOException: random write access is not available for archive entries. |
java.lang.String |
getRelativeEntryPath()
Returns the relative path of this entry, with respect to the archive file. |
java.lang.String |
getSeparator()
This method is overridden to return the separator of the archive file that contains
this entry. |
long |
getSize()
Returns this file's size in bytes, 0 if this file doesn't exist, -1 if the size is
undetermined. |
long |
getTotalSpace()
Delegates to the archive file's ProxyFile.getTotalSpace() method. |
java.lang.Object |
getUnderlyingFileObject()
Returns the same ArchiveEntry instance as getEntry(). |
boolean |
hasRandomAccessInputStream()
Always returns false: random read access is not available for archive entries. |
boolean |
hasRandomAccessOutputStream()
Always returns false: random write access is not available for archive entries. |
boolean |
isDirectory()
Returns true if this file is a directory, false in any of the following cases:
this file does not exist
this file is a regular file
this file is browsable (as reported by AbstractFile.isBrowsable() but not a directory
|
boolean |
isSymlink()
Always returns false. |
AbstractFile[] |
ls()
Returns the children files that this file contains. |
AbstractFile[] |
ls(FileFilter filter)
Returns the children files that this file contains, filtering out files that do not match the specified FileFilter. |
AbstractFile[] |
ls(FilenameFilter filter)
Returns the children files that this file contains, filtering out files that do not match the specified FilenameFilter. |
void |
mkdir()
Creates this entry as a directory in the associated AbstractArchiveFile if the archive is
writable (as reported by AbstractArchiveFile.isWritableArchive()). |
AbstractProcess |
runProcess(java.lang.String[] tokens)
Always throws an IOException: archive entries cannot run processes. |
void |
setParent(AbstractFile parent)
Sets this file's parent. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected AbstractArchiveFile archiveFile
protected AbstractFile parent
protected ArchiveEntry entry
protected boolean exists
| Constructor Detail |
|---|
protected ArchiveEntryFile(FileURL url,
AbstractArchiveFile archiveFile,
ArchiveEntry entry,
boolean exists)
url - the FileURL instance that represents this file's locationarchiveFile - the AbstractArchiveFile instance that contains this entryentry - the ArchiveEntry object that contains information about this entryexists - true if this entry exists in the archive| Method Detail |
|---|
public ArchiveEntry getEntry()
public AbstractArchiveFile getArchiveFile()
AbstractArchiveFile that contains the entry represented by this file.
public java.lang.String getRelativeEntryPath()
getSeparator(). As a relative path, the returned path does not start
with a separator character.
public long getDate()
AbstractFile
getDate in class AbstractFilepublic boolean canChangeDate()
true only if the archive file that contains this entry is writable.
canChangeDate in class AbstractFiletrue if this file's date can be changed using AbstractFile.changeDate(long)public boolean changeDate(long lastModified)
false only if the archive file that contains this entry is not writable.
changeDate in class AbstractFilelastModified - last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
true if date was changed successfully.public long getSize()
AbstractFile0 if this file doesn't exist, -1 if the size is
undetermined.
getSize in class AbstractFilepublic boolean isDirectory()
AbstractFiletrue if this file is a directory, false in any of the following cases:
AbstractFile.isBrowsable() but not a directory
isDirectory in class AbstractFiletrue if this file is a directory, false in any of the cases listed above
public AbstractFile[] ls()
throws java.io.IOException
AbstractFileAbstractFile.isBrowsable() must return true.
This method may return a zero-length array if it has no children but may never return null.
ls in class AbstractFilejava.io.IOException - if this operation is not possible (file is not browsable) or if an error occurred.
public AbstractFile[] ls(FilenameFilter filter)
throws java.io.IOException
AbstractFileAbstractFile.isBrowsable() must return
true.
This default implementation filters out files *after* they have been created. This method should be overridden if a more efficient implementation can be provided by subclasses.
ls in class AbstractFilefilter - the FilenameFilter to be used to filter out files from the list, may be null
java.io.IOException - if this operation is not possible (file is not browsable) or if an error occurred.
public AbstractFile[] ls(FileFilter filter)
throws java.io.IOException
AbstractFileAbstractFile.isBrowsable() must return
true.
ls in class AbstractFilefilter - the FileFilter to be used to filter files out from the list, may be null
java.io.IOException - if this operation is not possible (file is not browsable) or if an error occurred.public AbstractFile getParent()
AbstractFilenull if it doesn't have one.
getParent in class AbstractFilenull if it doesn't have onepublic void setParent(AbstractFile parent)
AbstractFilenull can be specified if this file doesn't have a parent.
setParent in class AbstractFileparent - the new parent of this filepublic boolean exists()
true if this entry exists within the archive file.
exists in class AbstractFilepublic FilePermissions getPermissions()
AbstractFileFilePermissions object. Note that this file may only support
certain permission bits, use the permission mask to find
out which bits are supported.
This method may return permissions for which none of the bits are supported, but may never return
null.
getPermissions in class AbstractFilepublic PermissionBits getChangeablePermissions()
PermissionBits.FULL_PERMISSION_BITS or PermissionBits.EMPTY_PERMISSION_BITS, depending
on whether the archive that contains this entry is writable or not.
getChangeablePermissions in class AbstractFile
public boolean changePermission(int access,
int permission,
boolean enabled)
false only if the archive file that contains this entry is not writable.
changePermission in class AbstractFileaccess - see PermissionTypes for allowed valuespermission - see PermissionAccesses for allowed valuesenabled - true to enable the flag, false to disable it
AbstractFile.getChangeablePermissions()public java.lang.String getOwner()
AbstractFileAbstractFile implementation (cannot be retrieved or
the filesystem doesn't have any notion of owner) or not available for this particular file, null
will be returned.
getOwner in class AbstractFilepublic boolean canGetOwner()
AbstractFiletrue if this file implementation is able to return some information about file owners, not
necessarily for all files or this file in particular but at least for some of them. In other words, a
true return value doesn't mean that AbstractFile.getOwner() will necessarily return a non-null value,
but rather that there is a chance that it does.
canGetOwner in class AbstractFilepublic java.lang.String getGroup()
AbstractFileAbstractFile implementation (cannot be retrieved or
the filesystem doesn't have any notion of owner) or not available for this particular file, null
will be returned.
getGroup in class AbstractFilepublic boolean canGetGroup()
AbstractFiletrue if this file implementation is able to return some information about file groups, not
necessarily for all files or this file in particular but at least for some of them. In other words, a
true return value doesn't mean that AbstractFile.getGroup() will necessarily return a non-null value,
but rather that there is a chance that it does.
canGetGroup in class AbstractFilepublic boolean isSymlink()
false.
isSymlink in class AbstractFiletrue if this file is a symbolic link
public void delete()
throws java.io.IOException
AbstractArchiveFile if it is writable (as reported by
AbstractArchiveFile.isWritableArchive()).
Throws an IOException in any of the following cases:
AbstractArchiveFile is not writable
delete in class AbstractFilejava.io.IOException - in any of the cases listed above.
public void mkdir()
throws java.io.IOException
AbstractArchiveFile if the archive is
writable (as reported by AbstractArchiveFile.isWritableArchive()).
Throws an IOException if it isn't, if this entry already exists in the archive or if an I/O error
occurred.
mkdir in class AbstractFilejava.io.IOException - if the associated archive file is not writable, if this entry already exists in the archive,
or if an I/O error occurredpublic long getFreeSpace()
AbstractArchiveFile.getFreeSpace() method.
getFreeSpace in class AbstractFile-1 if this information is
not available.public long getTotalSpace()
ProxyFile.getTotalSpace() method.
getTotalSpace in class AbstractFile
public java.io.InputStream getInputStream()
throws java.io.IOException
AbstractArchiveFile.getEntryInputStream(ArchiveEntry)} method.
getInputStream in class AbstractFileInputStream to read the contents of this file
java.io.IOException - in any of the cases listed above
public java.io.OutputStream getOutputStream(boolean append)
throws java.io.IOException
OutputStream that allows to write this entry's contents if the archive is
writable (as reported by AbstractArchiveFile.isWritableArchive()).
Throws an IOException if it isn't or if an I/O error occurred.
This method will create this entry as a regular file in the archive if it doesn't already exist, or replace it if it already does.
getOutputStream in class AbstractFileappend - if true, data written to the OutputStream will be appended to the end of this file. If false,
any existing data this file contains will be discarded and overwritten.
OuputStream to write the contents of this file
java.io.IOException - if the associated archive file is not writable, if this entry already exists in the archive,
or if an I/O error occurredpublic boolean hasRandomAccessInputStream()
false: random read access is not available for archive entries.
hasRandomAccessInputStream in class AbstractFiletrue if the underlying filesystem has support for random access input streams
public RandomAccessInputStream getRandomAccessInputStream()
throws java.io.IOException
IOException: random read access is not available for archive entries.
getRandomAccessInputStream in class AbstractFileRandomAccessInputStream to read the contents of this file with random access
java.io.IOException - in any of the cases listed abovepublic boolean hasRandomAccessOutputStream()
false: random write access is not available for archive entries.
hasRandomAccessOutputStream in class AbstractFiletrue if the underlying filesystem has support for random access output streams
public RandomAccessOutputStream getRandomAccessOutputStream()
throws java.io.IOException
IOException: random write access is not available for archive entries.
getRandomAccessOutputStream in class AbstractFileRandomAccessOutputStream to write the contents of this file with random access
java.io.IOException - in any of the cases listed abovepublic java.lang.Object getUnderlyingFileObject()
getEntry().
getUnderlyingFileObject in class AbstractFilenull if there
is nonepublic boolean canRunProcess()
false: archive entries cannot run processes.
canRunProcess in class AbstractFiletrue 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: archive entries cannot run processes.
runProcess in class AbstractFiletokens - 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.public java.lang.String getSeparator()
archive file that contains
this entry.
getSeparator in class AbstractFilepublic java.lang.String getCanonicalPath()
getCanonicalPath in class AbstractFilepublic boolean changePermissions(int permissions)
false only if the archive file that contains this entry is not writable.
changePermissions in class AbstractFilepermissions - new permissions for this file
public int getMoveToHint(AbstractFile destFile)
AbstractFileAbstractFile.moveTo(AbstractFile) method should be used to
move this file to the specified destination file, rather than moving the file using
AbstractFile.copyStream(InputStream, boolean) or AbstractFile.getInputStream() and AbstractFile.getOutputStream(boolean).
Potential returned values are:
AbstractFile.SHOULD_HINT if copyTo() should be preferred (more efficient)
AbstractFile.SHOULD_NOT_HINT if the file should rather be copied using copyStream()
AbstractFile.MUST_HINT if the file can only be copied using copyTo(), that's the case when getOutputStream() or copyStream() is not implemented
AbstractFile.MUST_NOT_HINT if the file can only be copied using copyStream()
This default implementation returns AbstractFile.SHOULD_HINT if both this file and the specified destination file
use the same protocol and are located on the same host, AbstractFile.SHOULD_NOT_HINT otherwise.
This method should be overridden to return AbstractFile.SHOULD_NOT_HINT if the underlying file protocol doesn't not
allow direct move/renaming without copying the contents of the source (this) file.
getMoveToHint in class AbstractFiledestFile - the destination file that is considered being copied
AbstractFile.moveTo(AbstractFile) method should be used
|
|||||||||
| 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