summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferEvent.java
blob: af63b0c6ec4fec6933d6102b2fc6d56012748d50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.openslx.dozmod.filetransfer;

import org.openslx.bwlp.thrift.iface.TransferState;
import org.openslx.dozmod.util.FormatHelper;

public class TransferEvent {

	/**
	 * Block-based progress of transfer
	 */
	public final byte[] progress;
	/**
	 * Speed of transfer, human readable
	 */
	public final String speed;
	/**
	 * Estimated remaining time, human readable. <code>null</code> == not
	 * updated
	 */
	public final String remaining;
	/**
	 * Speed of transfer, in bytes per second
	 */
	public final long speedRaw;
	/**
	 * Estimated remaining time, in milliseconds. 0 == not updated
	 */
	public final long remainingRaw;
	/**
	 * State of the transfer
	 */
	public final TransferState state;
	/**
	 * An optional error message
	 */
	public final String errorMessage;

	public TransferEvent(TransferState state, byte[] progress, long speedRaw, long remainingRaw,
			String errorMessage) {
		this.state = state;
		this.progress = progress;
		this.speedRaw = speedRaw;
		this.speed = FormatHelper.bytes(speedRaw, false) + "/s";
		this.remainingRaw = remainingRaw;
		if (remainingRaw == 0) {
			this.remaining = null;
		} else {
			this.remaining = FormatHelper.formatMilliseconds(remainingRaw + 30000, false);
		}
		this.errorMessage = errorMessage;
	}

}