summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferEvent.java
blob: bc75cad8d30934c1fcb4d5d42796e069c818650c (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
54
55
56
57
58
59
60
61
62
63
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;
	/**
	 * Speed of transfer, human readable, including server side copying
	 */
	public final String virtualSpeed;
	/**
	 * Speed of transfer, in bytes per second, including server side copying
	 */
	public final long virtualSpeedRaw;
	/**
	 * 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 virtualSpeedRaw, long remainingRaw,
			String errorMessage) {
		this.state = state;
		this.progress = progress;
		this.speedRaw = speedRaw;
		this.speed = FormatHelper.bytes(speedRaw, false) + "/s";
		this.virtualSpeedRaw = virtualSpeedRaw;
		this.virtualSpeed = FormatHelper.bytes(virtualSpeedRaw, false) + "/s";
		this.remainingRaw = remainingRaw;
		if (remainingRaw == 0) {
			this.remaining = null;
		} else {
			this.remaining = FormatHelper.formatMilliseconds(remainingRaw + 30000, false);
		}
		this.errorMessage = errorMessage;
	}

}