org.eclipse.emf.emfstore.internal.client.model.filetransfer
Class FileDownloadStatus

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.filetransfer.FileDownloadStatus

public final class FileDownloadStatus
extends Object

An object of this class is returned from any workspace method that starts a file transfer. It provides information about this file transfer and allows to add Progressmonitors and Observers

Author:
jfinis

Nested Class Summary
static class FileDownloadStatus.Status
          Return value of the getStatus method.
 
Field Summary
static int NOT_AVAILABLE
          Constant signaling "not available".
 
Method Summary
 void addDefaultFailObserver()
          Adds a default observer that is notified when the transfer fails.
 void addTransferFailedObserver(Observer o)
          Adds an observer which is notified if the transfer fails due to an exception.
 void addTransferFinishedObserver(Observer o)
          Adds an observer that is notified once the transfer is finished.
 Exception getException()
          Returns the exception that caused the download to fail, if the status == FAILED.
 FileIdentifier getFileIdentifier()
          Returns the identifier of the file to be downloaded.
 FileTransferStatistics getStatistics()
          Gets the statistics object for this file transfer, which provides useful information, especially while the transfer is active.
 FileDownloadStatus.Status getStatus()
          This is the ultimate method for checking in which "stage" a file transfer currently is.
 File getTransferredFile()
          Returns the transferred file.
 File getTransferredFile(boolean block)
          Similar to getTransferredFile(), but this method blocks the client thread.
 ProjectSpace getTransferringProjectSpace()
          Returns the project space which started this file transfer.
 boolean isNotOnServer()
          Whether the file to be downloaded is on server.
 boolean isTransferFinished()
          Returns true if the transfer is finished.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_AVAILABLE

public static final int NOT_AVAILABLE
Constant signaling "not available".

See Also:
Constant Field Values
Method Detail

getFileIdentifier

public FileIdentifier getFileIdentifier()
Returns the identifier of the file to be downloaded.

Returns:
the identifier

getStatus

public FileDownloadStatus.Status getStatus()
This is the ultimate method for checking in which "stage" a file transfer currently is. i.e. if it is still waiting, transferring or finished. See the enum Status for possible values.

Returns:
the stage in which the file transfer currently is

addTransferFinishedObserver

public void addTransferFinishedObserver(Observer o)
Adds an observer that is notified once the transfer is finished. If the transfer is already finished at the moment when this method is called, then the observer is instantly notified. The object that is passed to the observer's update message is this instance of FileTransferStatus

Parameters:
o - an observer to be notified when the transfer is finished

addTransferFailedObserver

public void addTransferFailedObserver(Observer o)
Adds an observer which is notified if the transfer fails due to an exception. The getException method can then be used to retrieve the thrown exception.

Parameters:
o - an observer that is notified if the transfer fails

addDefaultFailObserver

public void addDefaultFailObserver()
Adds a default observer that is notified when the transfer fails. This observer logs the failure.


isTransferFinished

public boolean isTransferFinished()
Returns true if the transfer is finished.

Returns:
Whether the transfer is finished

isNotOnServer

public boolean isNotOnServer()
Whether the file to be downloaded is on server.

Returns:
true if the file is not on the server, false otherwise

getStatistics

public FileTransferStatistics getStatistics()
Gets the statistics object for this file transfer, which provides useful information, especially while the transfer is active. It provides information like the file size, the amount of already transfered bytes the estimated remaining time and more.

Returns:
the statistics for this transfer

getTransferredFile

public File getTransferredFile()
                        throws FileTransferException
Returns the transferred file. If this is a download, then the file is only available, if the download is finished. If it is not finished yet, an file transfer exception is thrown.

Returns:
the transferred file or a FileTransferException exception if the file is not yet transferred.
Throws:
FileTransferException - if the file is not yet fully transferred

getTransferredFile

public File getTransferredFile(boolean block)
                        throws FileTransferException
Similar to getTransferredFile(), but this method blocks the client thread.

Parameters:
block - whether to block or not
Returns:
the transferred file
Throws:
FileTransferException - in case of an error during transfer

getTransferringProjectSpace

public ProjectSpace getTransferringProjectSpace()
Returns the project space which started this file transfer.

Returns:
the project space owning this file transfer

getException

public Exception getException()
Returns the exception that caused the download to fail, if the status == FAILED. Otherwise, returns null

Returns:
the exception that caused the failure or null if not failed


Copyright © 2015. All Rights Reserved.