de.phleisch.app.itsucks.io.http.impl
Class HttpFileResumeUrlRetriever

java.lang.Object
  extended by de.phleisch.app.itsucks.io.impl.FilterDataRetriever
      extended by de.phleisch.app.itsucks.io.http.impl.HttpFileResumeUrlRetriever
All Implemented Interfaces:
DataRetriever, ResumeUrlDataRetriever, UrlDataRetriever

public class HttpFileResumeUrlRetriever
extends FilterDataRetriever
implements ResumeUrlDataRetriever

This retriever is used to resume partial downloaded files. It creates an additional retriever, the file retriever, and combine it with the original data retriever. It can send the complete data through the processing chain without receiving it completly from the data retriever.

Author:
olli

Nested Class Summary
protected static class HttpFileResumeUrlRetriever.OperatingState
           
 
Field Summary
protected  java.io.File mLocalFile
           
protected  HttpFileResumeUrlRetriever.OperatingState mOperatingState
           
protected  long mResumeOffset
           
protected  UrlDataRetriever mWrappedUrlDataRetriever
           
 
Fields inherited from class de.phleisch.app.itsucks.io.impl.FilterDataRetriever
mDataRetriever
 
Fields inherited from interface de.phleisch.app.itsucks.io.UrlDataRetriever
RESULT_RETRIEVAL_ABORTED, RESULT_RETRIEVAL_FAILED, RESULT_RETRIEVAL_FAILED_BUT_RETRYABLE, RESULT_RETRIEVAL_NOT_STARTED_YET, RESULT_RETRIEVAL_OK, RESULT_RETRIEVAL_UNKNOWN
 
Fields inherited from interface de.phleisch.app.itsucks.io.DataRetriever
NOTIFICATION_PROGRESS
 
Constructor Summary
HttpFileResumeUrlRetriever(UrlDataRetriever pDataRetriever, java.io.File pFile)
           
 
Method Summary
 void abort()
          Aborts the current retrieving.
 void connect()
          Advise the Retriever to connect to the data source.
 void disconnect()
          Disconnect from the data source.
protected  void doDelgateDownload()
           
protected  void doReadOnlyFile(long bytesOnDisk)
           
protected  void doResumeDownload(long bytesOnDisk)
           
 HttpMetadata getMetadata()
          Returns the metadata of the data source connection.
 int getResultCode()
          Returns the internal state and result code after connecting.
 long getResumeOffset()
           
 long getSuggestedTimeToWaitForRetry()
          Returns the suggested time to wait befory retry the retrieval in ms.
 java.net.URL getUrl()
          Returns the URL which is retrieved.
 boolean isConnected()
          Returns true if the retriever is connected.
 void setUrl(java.net.URL pUrl)
          Sets the URL to be retrieved.
 
Methods inherited from class de.phleisch.app.itsucks.io.impl.FilterDataRetriever
getBytesSkipped, getContentLenght, getDataAsInputStream, isDataAvailable, setBytesToSkip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.phleisch.app.itsucks.io.DataRetriever
getBytesSkipped, getContentLenght, getDataAsInputStream, isDataAvailable, setBytesToSkip
 

Field Detail

mWrappedUrlDataRetriever

protected UrlDataRetriever mWrappedUrlDataRetriever

mLocalFile

protected java.io.File mLocalFile

mOperatingState

protected HttpFileResumeUrlRetriever.OperatingState mOperatingState

mResumeOffset

protected long mResumeOffset
Constructor Detail

HttpFileResumeUrlRetriever

public HttpFileResumeUrlRetriever(UrlDataRetriever pDataRetriever,
                                  java.io.File pFile)
Method Detail

connect

public void connect()
             throws java.io.IOException
Description copied from interface: DataRetriever
Advise the Retriever to connect to the data source.

Specified by:
connect in interface DataRetriever
Overrides:
connect in class FilterDataRetriever
Throws:
java.io.IOException

doResumeDownload

protected void doResumeDownload(long bytesOnDisk)
                         throws java.io.IOException
Throws:
java.io.IOException

doReadOnlyFile

protected void doReadOnlyFile(long bytesOnDisk)
                       throws java.io.IOException
Throws:
java.io.IOException

doDelgateDownload

protected void doDelgateDownload()
                          throws java.io.IOException
Throws:
java.io.IOException

disconnect

public void disconnect()
                throws java.io.IOException
Description copied from interface: DataRetriever
Disconnect from the data source.

Specified by:
disconnect in interface DataRetriever
Overrides:
disconnect in class FilterDataRetriever
Throws:
java.io.IOException

abort

public void abort()
Description copied from interface: DataRetriever
Aborts the current retrieving.

Specified by:
abort in interface DataRetriever
Overrides:
abort in class FilterDataRetriever

getResumeOffset

public long getResumeOffset()
Specified by:
getResumeOffset in interface ResumeUrlDataRetriever

getResultCode

public int getResultCode()
Description copied from interface: UrlDataRetriever
Returns the internal state and result code after connecting. Check RESULT_RETRIEVAL_* constants for possible values.

Specified by:
getResultCode in interface UrlDataRetriever
Returns:

getSuggestedTimeToWaitForRetry

public long getSuggestedTimeToWaitForRetry()
Description copied from interface: UrlDataRetriever
Returns the suggested time to wait befory retry the retrieval in ms.

Specified by:
getSuggestedTimeToWaitForRetry in interface UrlDataRetriever
Returns:

getUrl

public java.net.URL getUrl()
Description copied from interface: UrlDataRetriever
Returns the URL which is retrieved.

Specified by:
getUrl in interface UrlDataRetriever
Returns:

setUrl

public void setUrl(java.net.URL pUrl)
Description copied from interface: UrlDataRetriever
Sets the URL to be retrieved.

Specified by:
setUrl in interface UrlDataRetriever

getMetadata

public HttpMetadata getMetadata()
Description copied from interface: DataRetriever
Returns the metadata of the data source connection.

Specified by:
getMetadata in interface DataRetriever
Overrides:
getMetadata in class FilterDataRetriever
Returns:

isConnected

public boolean isConnected()
                    throws java.io.IOException
Description copied from interface: DataRetriever
Returns true if the retriever is connected.

Specified by:
isConnected in interface DataRetriever
Throws:
java.io.IOException


Copyright © 2010. All Rights Reserved.