2025-02-12 09:56:47 +00:00

109 lines
2.2 KiB
Java

package cn.montaro.aria2.bean;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
public class Task implements Serializable {
public Long completedLength;
private Integer connections;
private Long downloadSpeed;
private String gid;
private Long totalLength;
private String status;
private String dir;
private List<TaskFile> files;
static class TaskFile {
String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
public String getName() {
if (Objects.isNull(dir) || this.files.isEmpty()) {
return "";
}
String name = files.get(0).path.replace(dir + "/", "");
String substring = name.substring(0, 23);
if (name.length() > 25) {
substring = substring + "...";
}
return substring;
}
public int getProgress() {
if (Objects.isNull(completedLength)
|| completedLength == 0
|| Objects.isNull(totalLength)
|| totalLength == 0) {
return 0;
}
return (int) (completedLength * 100 / totalLength);
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getTotalLength() {
return totalLength;
}
public void setTotalLength(Long totalLength) {
this.totalLength = totalLength;
}
public String getGid() {
return gid;
}
public void setGid(String gid) {
this.gid = gid;
}
public Long getDownloadSpeed() {
return downloadSpeed;
}
public void setDownloadSpeed(Long downloadSpeed) {
this.downloadSpeed = downloadSpeed;
}
public Integer getConnections() {
return connections;
}
public void setConnections(Integer connections) {
this.connections = connections;
}
public Long getCompletedLength() {
return completedLength;
}
public void setCompletedLength(Long completedLength) {
this.completedLength = completedLength;
}
}