2025-02-17 09:58:41 +00:00

117 lines
2.4 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 following;
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 + "/", "");
if (name.length() <= 20) {
return String.format("%-20s", name);
}
return name.substring(0, 17) + "...";
}
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;
}
public String getFollowing() {
return following;
}
public void setFollowing(String following) {
this.following = following;
}
}