org.alliance.core.comm.filetransfers
Class Download

java.lang.Object
  extended by org.alliance.core.comm.filetransfers.Download

public class Download
extends java.lang.Object

Created by IntelliJ IDEA. User: maciek Date: 2006-jan-22 Time: 22:33:24 To change this template use File | Settings | File Templates.


Nested Class Summary
static class Download.State
           
 
Constructor Summary
Download(DownloadManager parent, Hash root, BlockStorage storage, java.lang.String filename, java.util.ArrayList<java.lang.Integer> guids)
           
 
Method Summary
 void abortAndRemovePerfmanently()
           
 void addBytesComplete(int bytes)
           
 void addConnection(DownloadConnection con)
           
 void blockMaskReceived(int srcGuid, int hops, BlockMask bm)
           
 boolean checkIfDownloadIsComplete()
           
 void connectionEstablished(DownloadConnection downloadConnection)
           
 java.util.Collection<DownloadConnection> connections()
           
static Download createFrom(java.io.ObjectInputStream in, DownloadManager m)
           
 void fileDescriptorReceived(DownloadConnection source, FileDescriptor fd)
           
 java.lang.String getAuxInfoFilename()
           
 java.util.ArrayList<java.lang.Integer> getAuxInfoGuids()
           
 BandwidthAnalyzer getBandwidth()
           
 int getETAInMinutes()
           
 FileDescriptor getFd()
           
 DownloadManager getManager()
           
 int getNConnections()
           
 int getPercentComplete()
           
 Hash getRoot()
           
 long getStartedAt()
           
 Download.State getState()
           
 BlockStorage getStorage()
           
 boolean isActive()
           
 boolean isBlockComplete(int blockNumber)
           
 boolean isComplete()
           
 boolean isDownloadingFd()
           
 boolean isInvalid()
           
 void removeConnection(DownloadConnection downloadConnection)
           
 int selectBestBlockForDownload(Friend remoteFriend)
           
 void serializeTo(java.io.ObjectOutputStream out)
           
 void setFd(FileDescriptor fd)
           
 void setInvalid(boolean invalid)
           
 void signalBlockComplete(int blockNumber)
           
 void signalFriendWentOnline(Friend friend)
           
 void startDownload()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Download

public Download(DownloadManager parent,
                Hash root,
                BlockStorage storage,
                java.lang.String filename,
                java.util.ArrayList<java.lang.Integer> guids)
         throws java.io.IOException
Throws:
java.io.IOException
Method Detail

blockMaskReceived

public void blockMaskReceived(int srcGuid,
                              int hops,
                              BlockMask bm)

addConnection

public void addConnection(DownloadConnection con)

fileDescriptorReceived

public void fileDescriptorReceived(DownloadConnection source,
                                   FileDescriptor fd)
                            throws java.io.IOException
Throws:
java.io.IOException

getFd

public FileDescriptor getFd()

getRoot

public Hash getRoot()

getManager

public DownloadManager getManager()

isDownloadingFd

public boolean isDownloadingFd()

connectionEstablished

public void connectionEstablished(DownloadConnection downloadConnection)

selectBestBlockForDownload

public int selectBestBlockForDownload(Friend remoteFriend)
                               throws java.io.IOException
Throws:
java.io.IOException

getPercentComplete

public int getPercentComplete()
                       throws java.io.IOException
Throws:
java.io.IOException

getStorage

public BlockStorage getStorage()

setFd

public void setFd(FileDescriptor fd)

checkIfDownloadIsComplete

public boolean checkIfDownloadIsComplete()

isBlockComplete

public boolean isBlockComplete(int blockNumber)
                        throws java.io.IOException
Throws:
java.io.IOException

getNConnections

public int getNConnections()

removeConnection

public void removeConnection(DownloadConnection downloadConnection)
                      throws java.io.IOException
Throws:
java.io.IOException

getBandwidth

public BandwidthAnalyzer getBandwidth()

isActive

public boolean isActive()

isComplete

public boolean isComplete()

startDownload

public void startDownload()
                   throws java.io.IOException
Throws:
java.io.IOException

getState

public Download.State getState()

abortAndRemovePerfmanently

public void abortAndRemovePerfmanently()
                                throws java.io.IOException
Throws:
java.io.IOException

addBytesComplete

public void addBytesComplete(int bytes)

getETAInMinutes

public int getETAInMinutes()

getStartedAt

public long getStartedAt()

isInvalid

public boolean isInvalid()

setInvalid

public void setInvalid(boolean invalid)

signalFriendWentOnline

public void signalFriendWentOnline(Friend friend)
                            throws java.io.IOException
Throws:
java.io.IOException

signalBlockComplete

public void signalBlockComplete(int blockNumber)
                         throws java.io.IOException
Throws:
java.io.IOException

serializeTo

public void serializeTo(java.io.ObjectOutputStream out)
                 throws java.io.IOException
Throws:
java.io.IOException

createFrom

public static Download createFrom(java.io.ObjectInputStream in,
                                  DownloadManager m)
                           throws java.io.IOException
Throws:
java.io.IOException

getAuxInfoFilename

public java.lang.String getAuxInfoFilename()

getAuxInfoGuids

public java.util.ArrayList<java.lang.Integer> getAuxInfoGuids()

connections

public java.util.Collection<DownloadConnection> connections()