com.mucommander.desktop
Class AbstractTrash

java.lang.Object
  extended by com.mucommander.desktop.AbstractTrash
Direct Known Subclasses:
QueuedTrash

public abstract class AbstractTrash
extends java.lang.Object

AbstractTrash is an abstract representation of a file trash, i.e. a temporary place where deleted files are stored before the trash is emptied. A trash implementation provides methods to access basic trash operations: move files to the trash, empty the trash, ...

Since AbstractTrash implementations are system-dependent, they should not be instanciated directly. Use DesktopManager.getTrash() to retrieve an instance of a trash implementation that can be used on the current platform.
Also, some AbstractTrash subclasses may not be able to provide working implementations for all trash operations; probe methods are provided to find out if a particular operation is available.

Author:
Maxence Bernard
See Also:
TrashProvider, DesktopManager.getTrash()

Constructor Summary
AbstractTrash()
           
 
Method Summary
abstract  boolean canEmpty()
          Returns true if this trash can be emptied.
abstract  boolean canMoveToTrash(AbstractFile file)
          Returns true if the specified file is eligible for being moved to the trash.
abstract  boolean canOpen()
          Returns true if this trash can be opened in the default file manager of the current OS/Desktop manager by calling open().
abstract  boolean empty()
          Attempts to empty this trash and returns true if it was successfully emptied.
abstract  int getItemCount()
          Returns the number of items that currently are in this trash, -1 if this information is not available.
abstract  boolean isTrashFile(AbstractFile file)
          Returns true if the given file is a trash folder, or one of its children.
abstract  boolean moveToTrash(AbstractFile file)
          Attempts to move the given file to the trash and returns true if the file could be moved successfully.
abstract  void open()
          Opens the trash in the default file manager of the current OS/Desktop manager.
abstract  void waitForPendingOperations()
          Waits (locks the caller thread) until all pending trash operations are completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTrash

public AbstractTrash()
Method Detail

canMoveToTrash

public abstract boolean canMoveToTrash(AbstractFile file)
Returns true if the specified file is eligible for being moved to the trash. This doesn't mean that a call to moveToTrash(com.mucommander.file.AbstractFile) will necessarily succeed, but it should at least ensure that basic prerequisites are met.

Parameters:
file - the file to test
Returns:
true if the given file can be moved to the trash

moveToTrash

public abstract boolean moveToTrash(AbstractFile file)
Attempts to move the given file to the trash and returns true if the file could be moved successfully.

Parameters:
file - the file to move to the trash
Returns:
true if the file could successfully be moved to the trash

canEmpty

public abstract boolean canEmpty()
Returns true if this trash can be emptied.

Returns:
true if the trash can be emptied.

empty

public abstract boolean empty()
Attempts to empty this trash and returns true if it was successfully emptied.

Returns:
true if the trash was successfully emptied

isTrashFile

public abstract boolean isTrashFile(AbstractFile file)
Returns true if the given file is a trash folder, or one of its children. For example, if /home/someuser/.Trash is a trash folder, calling this method with:

Note that this method does not check the existence of the given file, the test is solely based on the file's path.

Parameters:
file - the file to test
Returns:
true if the given file is a trash folder, or one of its children.

getItemCount

public abstract int getItemCount()
Returns the number of items that currently are in this trash, -1 if this information is not available.

Returns:
the number of items that currently are in this trash, -1 if this information is not available

open

public abstract void open()
Opens the trash in the default file manager of the current OS/Desktop manager.


canOpen

public abstract boolean canOpen()
Returns true if this trash can be opened in the default file manager of the current OS/Desktop manager by calling open().

Returns:
true if this trash can be opened in the default file manager of the current OS/Desktop manager.

waitForPendingOperations

public abstract void waitForPendingOperations()
Waits (locks the caller thread) until all pending trash operations are completed. This method can be useful since some AbstractTrash implementations are asynchroneous, i.e. perform operations in separate threads.



This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard