private void download() throws IOException, Exception{
switch(this.task){
case Task.NewDownload:{
ConnectionItem nextConnection=new ConnectionItem(filename,
startByte,endByte);
ApplicationProtocol appProto=null;
switch(downloadManager.protocol){
case Protocol.HTTP:{
appProto=new HTTPHandler();
break;
}
}
nextConnection.setConnectionStatus(DownloadStatus.Downloading);
//nextConnection.connectionThread=this;
downloadManager.connectionList.add(nextConnection);
storeObject();
appProto.connect(downloadManager.host);
appProto.get(downloadManager.url, filename,startByte,endByte);
nextConnection.setConnectionStatus(DownloadStatus.Downloaded);
break;
}
case Task.Resume:{
ApplicationProtocol appProto=null;
switch(downloadManager.protocol){
case Protocol.HTTP:{
appProto=new HTTPHandler();
break;
}
}
if(connectionItem.getConnectionStatus()==DownloadStatus.Downloading){
//downloadManager.connectionList.add(connectionItem);
appProto.connect(downloadManager.host);
appProto.get(downloadManager.url, filename,startByte,endByte);
connectionItem.setConnectionStatus(DownloadStatus.Downloaded);
}
break;
}
}