/** * Set the state based on the states of all file downloads. Assumes all file * downloads are done. * <p> * A single failed sub-transfer makes the entire transfer failed. If there * are no failed sub-transfers, a single canceled sub-transfer makes the * entire transfer canceled. Otherwise, we consider ourselves Completed. */ public void collateFinalState() { boolean seenCanceled = false; for ( T download : subTransfers ) { if ( download.getState() == TransferState.Failed ) { setState(TransferState.Failed); return; } else if ( download.getState() == TransferState.Canceled ) { seenCanceled = true; } } if ( seenCanceled ) setState(TransferState.Canceled); else setState(TransferState.Completed); }
public static void showTransferProgress(Transfer xfer) { // print the transfer's human-readable description System.out.println(xfer.getDescription()); // print an empty progress bar... printProgressBar(0.0); // update the progress bar while the xfer is ongoing. do { try { Thread.sleep(100); } catch (InterruptedException e) { return; } // Note: so_far and total aren't used, they're just for // documentation purposes. TransferProgress progress = xfer.getProgress(); long so_far = progress.getBytesTransferred(); long total = progress.getTotalBytesToTransfer(); double pct = progress.getPercentTransferred(); eraseProgressBar(); printProgressBar(pct); } while (xfer.isDone() == false); // print the final state of the transfer. TransferState xfer_state = xfer.getState(); System.out.println(": " + xfer_state); }
/** * Set the state based on the states of all file downloads. Assumes all file * downloads are done. * <p> * A single failed sub-transfer makes the entire transfer failed. If there * are no failed sub-transfers, a single canceled sub-transfer makes the * entire transfer canceled. Otherwise, we consider ourselves Completed. */ public void collateFinalState() { boolean seenCanceled = false; for ( T download : subTransfers ) { if ( download.getState() == TransferState.Failed ) { setState(TransferState.Failed); return; } else if ( download.getState() == TransferState.Canceled ) { seenCanceled = true; } } if ( seenCanceled ) setState(TransferState.Canceled); else setState(TransferState.Completed); }
return transfer.getState() == Transfer.TransferState.Completed;
TransferState transferState = transfer.getState(); if (transferState == TransferState.Failed)
TransferState transferState = transfer.getState(); if (transferState == TransferState.Failed)