au.com.prunge.jgenfile
Interface Operation

All Known Subinterfaces:
BatchOperation, CanCopyItemOperation, CanCopyItemToDestinationOperation, CanCreateFileOperation, CanCreateLinkOperation, CanCreateSubdirectoryOperation, CanDeleteItemOperation, CanGetAbsolutePathOperation, CanGetChildOperation, CanGetChildrenOperation, CanGetFileAccessorOperation, CanGetFileSizeOperation, CanGetFileSystemMetadataOperation, CanGetItemFromAbsoluteReferenceOperation, CanGetItemFromRelativeReferenceOperation, CanGetLinkTargetOperation, CanGetMetadataOperation, CanGetParentOperation, CanGetRelativePathOperation, CanGetRootsOperation, CanSetFileSystemMetadataOperation, CanSetLinkTargetOperation, CanSetMetadataOperation, CanSetNameOperation, CanSetParentOperation, CloseFileAccessorOperation, CloseFileSystemOperation, ConstantOperation, CopyItemOperation, CreateFileOperation, CreateLinkOperation, CreateSubdirectoryOperation, DeleteItemOperation, DirectoryOperation, FileAccessorOperation, FileOperation, FileSystemOperation, GetAbsolutePathOperation, GetAllMetadataKeysOperation, GetChildOperation, GetChildrenOperation, GetFileAccessorOperation, GetFileSizeOperation, GetFileSystemMetadataOperation, GetItemFromAbsoluteReferenceOperation, GetItemFromRelativeReferenceOperation, GetLinkTargetOperation, GetMetadataOperation, GetParentOperation, GetRelativePathOperation, GetRootOperation, GetRootsOperation, ItemOperation, LinkOperation, SetFileSystemMetadataOperation, SetLinkTargetOperation, SetMetadataOperation, SetNameOperation, SetParentOperation
All Known Implementing Classes:
AbstractDirectoryOperation, AbstractFileAccessorOperation, AbstractFileOperation, AbstractFileSystemOperation, AbstractItemOperation, AbstractOperation, ConstantCanCreateFileOperation, ConstantCanCreateLinkOperation, ConstantCanCreateSubdirectoryOperation, ConstantCanDeleteItemOperation, ConstantCanGetAbsolutePathOperation, ConstantCanGetChildrenOperation, ConstantCanGetFileSizeOperation, ConstantCanGetFileSystemMetadataOperation, ConstantCanGetParentOperation, ConstantCanGetRootsOperation, ConstantCanSetFileSystemMetadataOperation, ConstantCanSetMetadataOperation, ConstantCanSetNameOperation, ConstantCanSetParentOperation, ConstantGetAllMetadataKeysOperation, DefaultBatchOperation, DefaultCopyItemOperation, LocalCanCopyItemOperation, LocalCanCopyItemToDestinationOperation, LocalCanGetChildOperation, LocalCanGetFileAccessorOperation, LocalCanGetItemFromAbsoluteReferenceOperation, LocalCanGetItemFromRelativeReferenceOperation, LocalCanGetMetadataOperation, LocalCanGetRelativePathOperation, LocalCanGetRootsOperation, LocalCloseFileAccessorOperation, LocalCreateFileOperation, LocalCreateSubdirectoryOperation, LocalDeleteItemOperation, LocalFastCopyItemOperation, LocalGetAbsolutePathOperation, LocalGetChildOperation, LocalGetChildrenOperation, LocalGetFileAccessorOperation, LocalGetFileSizeOperation, LocalGetItemFromAbsoluteReferenceOperation, LocalGetItemFromRelativeReferenceOperation, LocalGetMetadataOperation, LocalGetParentOperation, LocalGetRelativePathOperation, LocalGetRootOperation, LocalGetRootsOperation, LocalSetMetadataOperation, LocalSetNameOperation, LocalSetParentOperation, NullCloseFileSystemOperation, NullCreateLinkOperation, NullGetFileSystemMetadataOperation, NullSetFileSystemMetadataOperation

public interface Operation

An operation does something with a filesystem, for instance it might query the size of a file or rename a file.

When finished with any operation, it should be closed using the close() method.

Version:
1.1
Author:
Peter Runge

Method Summary
 void abort()
          Aborts the operation if it is currently running.
 void addOperationHints(au.com.prunge.jgenfile.OperationHints hints)
          Adds operation hints to this operation.
 au.com.prunge.jgenfile.JGenFileException getLastRunException()
          Returns the exception that occurred on the last run of this operation.
 OperationHints.Value getOperationHint(OperationHints.Key key)
          Returns the value of a single hint.
 au.com.prunge.jgenfile.OperationHints getOperationHints()
          Returns the operation hints used for this operation.
 boolean hasRun()
           
 void run()
          Begins execution of this operation.
 void setOperationHint(OperationHints.Key key, OperationHints.Value value)
          Sets the value of a single hint for this operation.
 void setOperationHints(au.com.prunge.jgenfile.OperationHints hints)
          Sets the hints for this operation.
 

Method Detail

run

public void run()
         throws JGenFileException,
                OperationNotSupportedException,
                OperationAbortedException
Begins execution of this operation. This method blocks until the operation has completed running or the operation has been aborted.

Throws:
JGenFileException - if an error occurs executing the operation.
OperationNotSupportedException - if this operation is not supported by the file system.
OperationAbortedException - if the operation was aborted before it completed running.
See Also:
abort()

hasRun

public boolean hasRun()
Returns:
true if the operation has finished running and no exception occurred.

getLastRunException

public au.com.prunge.jgenfile.JGenFileException getLastRunException()
Returns the exception that occurred on the last run of this operation. Returns null if no exceptions were encountered on the last run.

Returns:
the last run exception, or null if no exception occurred.

addOperationHints

public void addOperationHints(au.com.prunge.jgenfile.OperationHints hints)
                       throws NullPointerException
Adds operation hints to this operation. The specified hints are combined with the hints already in this operation.

Parameters:
hints - the hints to add.
Throws:
NullPointerException - if hints is null.

setOperationHints

public void setOperationHints(au.com.prunge.jgenfile.OperationHints hints)
                       throws NullPointerException
Sets the hints for this operation. Any hints that are already added to this operation will be lost.

Parameters:
hints - the hints to set.
Throws:
NullPointerException - if hints is null.

getOperationHints

public au.com.prunge.jgenfile.OperationHints getOperationHints()
Returns the operation hints used for this operation.

Returns:
the operation hints used for this operation.

getOperationHint

public OperationHints.Value getOperationHint(OperationHints.Key key)
                                      throws NullPointerException
Returns the value of a single hint. Returns null if the specified hint has not been set for this operation.

Parameters:
key - the operation hints key to get the value of.
Returns:
the value of a single hint, or null.
Throws:
NullPointerException - if key is null.

setOperationHint

public void setOperationHint(OperationHints.Key key,
                             OperationHints.Value value)
                      throws NullPointerException
Sets the value of a single hint for this operation.

Parameters:
key - the key for the operation hint.
value - the value to give the operation hint.
Throws:
NullPointerException - if key or value is null.

abort

public void abort()
Aborts the operation if it is currently running. Has no effect if the operation has not yet started or has finished.

This method should be executed in different thread than the one executing the run method. Operations do not have to immediately abort, but rather should make a best effort to end any long-running operations. When an operation finally does abort, the run method will return, perhaps not comleting all its required work. If this happens, an OperationAbortedException should be thrown.

An aborted operation should not leave the file system in an unstable state. All operations should tie up any loose ends before aborting.

This method could be called in response to a cancel button being pressed.

See Also:
run()