org.eclipse.ecf.filetransfer

## Interface IFileTransfer

All Superinterfaces:
  org.eclipse.core.runtime.IAdaptable, IIdentifiable

All Known Subinterfaces:
  IIncomingFileTransfer, IOutgoingFileTransfer

All Known Implementing Classes:
  AbstractOutgoingFileTransfer, AbstractRetrieveFileTransfer, AbstractUrlConnectionOutgoingFileTransfer, HttpClientRetrieveFileTransfer, HttpClientRetrieveFileTransfer, LocalFileOutgoingFileTransfer, UrlConnectionRetrieveFileTransfer

    public interface IFileTransfer
    extends org.eclipse.core.runtime.IAdaptable, IIdentifiable

File transfer super interface. This interface provides the abstract file transfer semantics for both `IOutgoingFileTransfer` and `IIncomingFileTransfer` transfer sub interfaces.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `cancel()` Cancel this file transfer.
`Exception` `getException()` Get any exception associated with this file transfer.
`long` `getFileLength()` Return resulting file length (in bytes) for this file transfer instance.
`double` `getPercentComplete()` Get the percent complete for this file transfer.
`boolean` `isDone()` Return true if this file transfer is done, false if not yet completed.

### Methods inherited from interface org.eclipse.core.runtime.IAdaptable

`getAdapter`

### Methods inherited from interface org.eclipse.ecf.core.identity.IIdentifiable

`getID`

### Method Detail

#### cancel

    void cancel()

Cancel this file transfer. If file transfer has already been completed, then this method has no effect. If the file transfer has not been completed then calling this method will result in an `IFileTransferEvent` being delivered to the `IFileTransferListener` indicating that transfer is done (`isDone()` returns true), and some exception will be made available

#### getPercentComplete

    double getPercentComplete()

Get the percent complete for this file transfer. The returned value will be either -1.0, meaning that the underlying provider does not support reporting percent complete for this file transfer, or a value between 0 and 1 reflecting the percent complete for this file transfer. If 0.0 no data has been sent, if 1.0, the file transfer is 100 percent complete. The value returned from this method should not be used to determine whether the transfer has completed, as it may not show completion in the event of an transfer failure. Note that the `isDone()` method should be consulted to determine if the file transfer has completed (with or without error).

Returns:
  double percent complete. Returns -1.0 if the underlying provider does not support reporting percentage complete, or between 0 and 1 to indicate actual percent complete for this file transfer

#### getException

    Exception getException()

Get any exception associated with this file transfer. The value returned from this method is valid only if `isDone()` method returns true. If the file transfer completed successfully, `isDone()` will return true, and this method will return null. If the file transfer completed unsuccessfully (some exception occurred), then `isDone()` will return true, and this method will return a non-null Exception instance that occurred.

If the the file transfer was canceled by the user, then the exception returned will be an instance of `UserCancelledException`.

Returns:
  Exception associated with this file transfer. `null` if transfer completed successfully, non-null if transfer completed with some exception. Only valid after `isDone()` returns true.

#### isDone

    boolean isDone()

Return true if this file transfer is done, false if not yet completed. The file transfer can be completed successfully, or an exception can occur and the file transfer will have failed. In either case of successful or unsuccessful transfer, this method will return true when the file transfer is complete. To determine whether the transfer completed successfully, it is necessary to also consult the `getException()` method.

Returns:
  boolean true if file transfer is done, false if file transfer is still in progress.

#### getFileLength

    long getFileLength()

Return resulting file length (in bytes) for this file transfer instance. If the length is not known, -1 will be returned. Note that if a `IFileRangeSpecification` is provided that the returned file length is the expected file length of just the range retrieved (and not the entire file).

Returns:
  long file length
Since:
  2.0