|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.file.AbstractFile
com.mucommander.bookmark.file.BookmarkFile
public class BookmarkFile
Represents a file in the bookmark:// file system.
| Field Summary |
|---|
| 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 | |
|---|---|
BookmarkFile(Bookmark bookmark)
Creates a new bookmark file wrapping the specified bookmark. |
|
| Method Summary | |
|---|---|
boolean |
canChangeDate()
Returns true if this file's date can be changed using AbstractFile.changeDate(long). |
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()
Returns true if the wrapped file knows how to create processes. |
boolean |
changeDate(long lastModified)
Changes last modified date and returns true if date was changed successfully, false
if the operation could not be completed, either because this method is not implemented for this file type, or
because of insufficient permissions or a low-level I/O error. |
boolean |
changePermission(int access,
int permission,
boolean enabled)
Returns false. |
boolean |
copyTo(AbstractFile destination)
Tries to copy the bookmark to the specified destination. |
void |
delete()
Deletes the bookmark. |
boolean |
equals(java.lang.Object o)
Tests a file for equality: returns true if the given file has the same canonical path,
as returned by AbstractFile.getCanonicalPath(). |
boolean |
exists()
Returns true if the specified bookmark exists. |
Bookmark |
getBookmark()
Returns the underlying bookmark. |
java.lang.String |
getCanonicalPath()
Returns the canonical path to this file, resolving any symbolic links or '..' and '.' occurrences. |
PermissionBits |
getChangeablePermissions()
Returns a bit mask describing the permission bits that can be changed on this file when calling AbstractFile.changePermission(int, int, boolean) and AbstractFile.changePermissions(int). |
int |
getCopyToHint(AbstractFile destination)
Returns a hint that indicates whether the AbstractFile.copyTo(AbstractFile) method should be used to
copy this file to the specified destination file, rather than copying the file 'manually', using
AbstractFile.copyStream(InputStream, boolean), or AbstractFile.getInputStream() and AbstractFile.getOutputStream(boolean). |
long |
getDate()
Returns this file's last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970). |
long |
getFreeSpace()
Returns the result of the wrapped file's getFreeSpace() methods. |
java.lang.String |
getGroup()
Returns information about the group this file belongs to. |
java.io.InputStream |
getInputStream()
Returns an InputStream to read the contents of this file. |
int |
getMoveToHint(AbstractFile destination)
Returns AbstractFile.MUST_HINT. |
java.lang.String |
getName()
Returns the underlying bookmark's name. |
java.io.OutputStream |
getOutputStream(boolean append)
Returns an OuputStream to write the contents of this file, appending or overwriting the existing
contents. |
java.lang.String |
getOwner()
Returns information about the owner of this file. |
AbstractFile |
getParent()
Returns the wrapped file's parent. |
FilePermissions |
getPermissions()
Returns the same permissions for all boookmark files: rw- (600 octal). |
RandomAccessInputStream |
getRandomAccessInputStream()
Returns a RandomAccessInputStream to read the contents of this file with random access. |
RandomAccessOutputStream |
getRandomAccessOutputStream()
Returns a RandomAccessOutputStream to write the contents of this file with random access. |
long |
getSize()
Returns this file's size in bytes, 0 if this file doesn't exist, -1 if the size is
undetermined. |
long |
getTotalSpace()
Returns the result of the wrapped file's getTotalSpace() methods. |
java.lang.Object |
getUnderlyingFileObject()
Returns the file Object of the underlying API providing access to the filesystem. |
boolean |
hasRandomAccessInputStream()
Returns true if the underlying filesystem has support for random access input streams. |
boolean |
hasRandomAccessOutputStream()
Returns true if the underlying filesystem has support for random access output streams. |
boolean |
isBrowsable()
Returns true. |
boolean |
isDirectory()
Returns false. |
boolean |
isSymlink()
Returns true if this file is a symbolic link. |
AbstractFile[] |
ls()
Returns the wrapped file's descendants. |
void |
mkdir()
Creates this file as a directory. |
void |
mkfile()
Creates this file as an empty, non-directory file. |
boolean |
moveTo(AbstractFile destination)
Tries to move the bookmark to the specified destination. |
AbstractProcess |
runProcess(java.lang.String[] tokens)
Runs the specified command on the wrapped file. |
void |
setParent(AbstractFile parent)
Sets the wrapped file's parent. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BookmarkFile(Bookmark bookmark)
throws java.io.IOException
bookmark - bookmark to wrap.
java.io.IOException - if the specified bookmark's URL cannot be resolved.| Method Detail |
|---|
public Bookmark getBookmark()
public java.lang.String getName()
getName in class AbstractFile
public AbstractFile[] ls()
throws java.io.IOException
ls in class AbstractFilejava.io.IOException - if an I/O error occurs.
public AbstractFile getParent()
throws java.io.IOException
getParent in class AbstractFilejava.io.IOException - if an IO error occurs.setParent(AbstractFile)public boolean canRunProcess()
true if the wrapped file knows how to create processes.
canRunProcess in class AbstractFiletrue if the wrapped file knows how to create processes.
public AbstractProcess runProcess(java.lang.String[] tokens)
throws java.io.IOException
runProcess in class AbstractFiletokens - command to run.
java.io.IOException - if an IO error occurs.public long getFreeSpace()
getFreeSpace() methods.
getFreeSpace in class AbstractFilegetFreeSpace() methods.public long getTotalSpace()
getTotalSpace() methods.
getTotalSpace in class AbstractFilegetTotalSpace() methods.public boolean isDirectory()
false.
isDirectory in class AbstractFilefalse.public boolean isBrowsable()
true.
isBrowsable in class AbstractFiletrue.public void setParent(AbstractFile parent)
setParent in class AbstractFileparent - object to use as the wrapped file's parent.getParent()public boolean exists()
true if the specified bookmark exists.
A bookmark is said to exist if and only if it is known to the BookmarkManager.
exists in class AbstractFiletrue if the specified bookmark exists, false otherwise.public void mkfile()
AbstractFileIOException)
if this file already exists. Note that this method may not always yield a zero-byte file (see below).
This generic implementation simply creates a zero-byte file. AbstractRWArchiveFile implementations
may want to override this method so that it creates a valid archive with no entry. To illustrate, an empty Zip
file with proper headers is 22-byte long.
mkfile in class AbstractFilepublic boolean equals(java.lang.Object o)
AbstractFiletrue if the given file has the same canonical path,
as returned by AbstractFile.getCanonicalPath().
It is noteworthy that this method uses java.lang.String#equals(Object) to compare paths, which
in some rare cases may return false for non-ascii/Unicode paths that have the same written
representation but are not equal according to java.lang.String#equals(Object). Handling such cases
would require a locale-aware String comparison which is not an option here.
This method should be overriden for network-based filesystems for which a host can have multiple path representations (hostname and IP address).
equals in class AbstractFilepublic java.lang.String getCanonicalPath()
AbstractFileThis implementation simply returns the value of AbstractFile.getAbsolutePath(), and thus should be overridden
if canonical path resolution is available.
getCanonicalPath in class AbstractFilepublic int getMoveToHint(AbstractFile destination)
AbstractFile.MUST_HINT.
If the specified file is a BookmarkFile, then we must use the custom
moveTo method. Otherwise, the point is moot as any
other move operation will fail.
getMoveToHint in class AbstractFiledestination - where the file will be moved to.
AbstractFile.MUST_HINT.
public boolean moveTo(AbstractFile destination)
throws FileTransferException
If the specified destination is an instance of BookmarkFile,
this will rename the bookmark. Otherwise, this method will fail.
moveTo in class AbstractFiledestination - where to move the bookmark to.
true.
FileTransferException - if the specified destination is not an instance of BookmarkFile.public void delete()
Deleting a bookmark means unregistering it from the BookmarkManager.
delete in class AbstractFilepublic int getCopyToHint(AbstractFile destination)
AbstractFileAbstractFile.copyTo(AbstractFile) method should be used to
copy this file to the specified destination file, rather than copying the file 'manually', 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_NOT_HINT as some granularity is lost when using
copyTo() making it impossible to monitor progress when copying a file.
This method should be overridden when copyTo() should be favored over copyStream().
getCopyToHint in class AbstractFiledestination - the destination file that is considered being copied
AbstractFile.copyTo(AbstractFile) method should be used
public boolean copyTo(AbstractFile destination)
throws FileTransferException
If the specified destination is an instance of BookmarkFile,
this will duplicate the bookmark. Otherwise, this method will fail.
copyTo in class AbstractFiledestination - where to copy the bookmark to.
true.
FileTransferException - if the specified destination is not an instance of BookmarkFile.public FilePermissions getPermissions()
getPermissions in class AbstractFilechangePermission(int,int,boolean)
public boolean changePermission(int access,
int permission,
boolean enabled)
false.
Bookmarks always have all permissions, this is not changeable. Calls to this method will always be ignored.
changePermission in class AbstractFileaccess - ignored.permission - ignored.enabled - ignored.
false.getPermissions()
public java.io.InputStream getInputStream()
throws java.io.IOException
AbstractFileInputStream to read the contents of this file.
Throws an IOException in any of the following cases:
RandomAccessInputStream cannot be provided because the underlying file protocol doesn't have
random access support (see AbstractFile.hasRandomAccessInputStream()null.
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
AbstractFileOuputStream to write the contents of this file, appending or overwriting the existing
contents. This file will be created as a zero-byte file if it does not yet exist.
Throws an IOException in any of the following cases:
append is specified but not supportednull.
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 - in any of the cases listed above
public void mkdir()
throws java.io.IOException
AbstractFileIOException) if this file
already exists.
mkdir in class AbstractFilejava.io.IOException - if the directory could not be created, either because this file already exists or for any
other reason.public long getDate()
AbstractFile
getDate in class AbstractFilepublic boolean canChangeDate()
AbstractFiletrue if this file's date can be changed using AbstractFile.changeDate(long). It's important
to note that a true return value doesn't mean that a call to AbstractFile.changeDate(long) will
necessarily succeed ; it could fail because of unsufficient permissions or simply because of a low-level I/O ;
but it should at least ensure that AbstractFile.changeDate(long) is implemented and has a chance of succeeding.
canChangeDate in class AbstractFiletrue if this file's date can be changed using AbstractFile.changeDate(long)public PermissionBits getChangeablePermissions()
AbstractFileAbstractFile.changePermission(int, int, boolean) and AbstractFile.changePermissions(int).
getChangeablePermissions in class AbstractFilepublic boolean changeDate(long lastModified)
AbstractFiletrue if date was changed successfully, false
if the operation could not be completed, either because this method is not implemented for this file type, or
because of insufficient permissions or a low-level I/O error.
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 hasRandomAccessInputStream()
AbstractFiletrue if the underlying filesystem has support for random access input streams.
Note that of true is returned, this doesn't necessarily mean that
AbstractFile.getRandomAccessInputStream() will return a RandomAccessInputStream, it might still throw
an IOException if random access to the file cannot be provided.
hasRandomAccessInputStream in class AbstractFiletrue if the underlying filesystem has support for random access input streams
public RandomAccessInputStream getRandomAccessInputStream()
throws java.io.IOException
AbstractFileRandomAccessInputStream to read the contents of this file with random access.
Throws an IOException in any of the following cases:
RandomAccessInputStream cannot be provided because the underlying file protocol doesn't have
random access support (see AbstractFile.hasRandomAccessInputStream()null.
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()
AbstractFiletrue if the underlying filesystem has support for random access output streams.
Note that of true is returned, this doesn't necessarily mean that
AbstractFile.getRandomAccessOutputStream() will return a RandomAccessOutputStream, it might still throw
an IOException if random access to the file cannot be provided.
hasRandomAccessOutputStream in class AbstractFiletrue if the underlying filesystem has support for random access output streams
public RandomAccessOutputStream getRandomAccessOutputStream()
throws java.io.IOException
AbstractFileRandomAccessOutputStream to write the contents of this file with random access.
This file will be created as a zero-byte file if it does not yet exist.
Throws an IOException in any of the following cases:
RandomAccessOutputStream cannot be provided because the underlying file protocol doesn't have
random access support (see AbstractFile.hasRandomAccessOutputStream()null.
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()
AbstractFileAbstractFile. Note however that the
returned Object type may change over time, if the underlying API used to provide access to the filesystem
changes, so this method should be used only as a last resort.
If the implemented filesystem has no such Object, null is returned.
getUnderlyingFileObject in class AbstractFilenull if there
is nonepublic boolean isSymlink()
AbstractFiletrue if this file is a symbolic link. Symbolic links need to be handled with special care,
especially when manipulating files recursively.
isSymlink in class AbstractFiletrue if this file is a symbolic linkpublic 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 AbstractFile
|
|||||||||
| 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