Method from net.bonzoun.cocodonkey.DownloadItem Detail: |
public String chunks() {
return chunks;
}
|
public float chunksFoundPercent() {
return chunksPercentOf('V') + chunksPercentOf('p') + chunksPercentOf('!') + chunksPercentOf('?');
}
|
public float chunksNotFoundPercent() {
return chunksPercentOf('_') + chunksPercentOf('.');
}
|
public void completeData(String name,
int total,
String hash,
int downloaded) {
if (completion!=1) {
this.name=name;
this.hash=hash;
completion = 2;
}
}
|
public int downloaded() {
if (isFinished())
return size();
else
return downloaded;
}
|
public boolean isFinished() {
return completion==1;
}
|
public int nbConn() {
return nbConn;
}
|
public float percent() {
return percent;
}
|
public String prettyDownloaded() {
return displaySize(downloaded());
}
|
public float rate() {
return rate;
}
|
public void setChunks(String chunks) {
this.chunks = chunks;
}
|
public void setNbConn(int n) {
nbConn = n;
}
|
public int timeLeft() {
rateCalculator.addRate(rate());
float meanRate = rateCalculator.meanRate();
if (meanRate > 0) {
int remaining = size() - downloaded();
return (int) (Math.round((float) remaining / (1024 * meanRate) ));
} else {
return -1;
}
}
|
public boolean updateWith(DownloadItem item) {
boolean modified = false;
if (completion!=1 && item.completion!=1) {
/*if (id!=item.id) {
modified = true;
id=item.id;
}
if (name!=item.name) {
modified = true;
name=item.name;
}*/
if (percent!=item.percent) {
modified = true;
percent=item.percent;
}
if (downloaded!=item.downloaded) {
modified = true;
downloaded=item.downloaded;
}
/*if (size!=item.size) {
modified = true;
size=item.size;
}*/
if (rate!=item.rate) {
modified = true;
rate=item.rate;
}
}
else if (completion!=1 && item.completion==1) {
// We have got a finished item
modified = true;
if (completion==0) {
name=item.name;
hash=item.hash;
}
completion = 1;
}
return modified;
}
|