de.phleisch.app.itsucks.io.impl
Class FileResumeRetriever

java.lang.Object
  extended by de.phleisch.app.itsucks.io.impl.FileResumeRetriever
All Implemented Interfaces:
DataRetriever

public class FileResumeRetriever
extends java.lang.Object
implements DataRetriever

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. So it can send the complete data through the processing chain without receiving it completly from the data retriever.

Author:
olli

Field Summary
protected  DataProcessorChain mDataProcessorChain
           
 
Fields inherited from interface de.phleisch.app.itsucks.io.DataRetriever
NOTIFICATION_PROGRESS, RESULT_RETRIEVAL_ABORTED, RESULT_RETRIEVAL_FAILED, RESULT_RETRIEVAL_FAILED_BUT_RETRYABLE, RESULT_RETRIEVAL_NOT_STARTED_YET, RESULT_RETRIEVAL_OK
 
Constructor Summary
FileResumeRetriever(DataRetriever pDataRetriever, java.io.File pFile)
           
 
Method Summary
 void abort()
          Aborts the current retrieving.
 void addObserver(java.util.Observer pO)
          Adds an observer to the retriever, usable to retrieve progress change events.
 void connect()
          Advise the Retriever to connect to the data source.
 void deleteObserver(java.util.Observer pO)
          Deletes an registered observer.
 void disconnect()
          Disconnect from the data source.
 long getBytesRetrieved()
          Returns the count of bytes read from the data source.
 long getBytesSkipped()
          Returns the skipped bytes.
 Context getContext()
          Gets the context from this data retriever.
 DataConsumer getDataConsumer()
           
 DataProcessorChain getDataProcessorChain()
           
 Metadata getMetadata()
          Returns the metadata of the data source connection.
 float getProgress()
          Returns the progress in processing the data in percent.
 int getResultCode()
          Returns the internal state and result code.
 java.net.URL getUrl()
          Returns the URL which is retrieved.
 boolean isDataAvailable()
          Returns true if the data source contains any data to be read.
 void retrieve()
          Retrieves all available data and send it through the processor chain.
 void setBytesToSkip(long pBytesToSkip)
          Skip the given bytes (seek) when reading the data source.
 void setContext(Context pContext)
          Sets the context for this data retriever.
 void setDataConsumer(DataConsumer pDataConsumer)
           
 void setDataProcessorChain(DataProcessorChain pDataProcessorChain)
           
 void setUrl(java.net.URL pUrl)
          Sets the URL to be retrieved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDataProcessorChain

protected DataProcessorChain mDataProcessorChain
Constructor Detail

FileResumeRetriever

public FileResumeRetriever(DataRetriever pDataRetriever,
                           java.io.File pFile)
Method Detail

abort

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

Specified by:
abort in interface DataRetriever

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
Throws:
java.io.IOException

retrieve

public void retrieve()
              throws java.io.IOException
Description copied from interface: DataRetriever
Retrieves all available data and send it through the processor chain.

Specified by:
retrieve in interface DataRetriever
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
Throws:
java.io.IOException

getBytesRetrieved

public long getBytesRetrieved()
Description copied from interface: DataRetriever
Returns the count of bytes read from the data source.

Specified by:
getBytesRetrieved in interface DataRetriever
Returns:

getMetadata

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

Specified by:
getMetadata in interface DataRetriever
Returns:

getProgress

public float getProgress()
Description copied from interface: DataRetriever
Returns the progress in processing the data in percent.

Specified by:
getProgress in interface DataRetriever
Returns:

setUrl

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

Specified by:
setUrl in interface DataRetriever

getUrl

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

Specified by:
getUrl in interface DataRetriever
Returns:

isDataAvailable

public boolean isDataAvailable()
                        throws java.io.IOException
Description copied from interface: DataRetriever
Returns true if the data source contains any data to be read.

Specified by:
isDataAvailable in interface DataRetriever
Returns:
Throws:
java.io.IOException

getDataConsumer

public DataConsumer getDataConsumer()
Specified by:
getDataConsumer in interface DataRetriever

setDataConsumer

public void setDataConsumer(DataConsumer pDataConsumer)
Specified by:
setDataConsumer in interface DataRetriever

addObserver

public void addObserver(java.util.Observer pO)
Description copied from interface: DataRetriever
Adds an observer to the retriever, usable to retrieve progress change events. NOTIFICATION_PROGRESS will be sent when the progress is updated.

Specified by:
addObserver in interface DataRetriever

deleteObserver

public void deleteObserver(java.util.Observer pO)
Description copied from interface: DataRetriever
Deletes an registered observer.

Specified by:
deleteObserver in interface DataRetriever

setBytesToSkip

public void setBytesToSkip(long pBytesToSkip)
Description copied from interface: DataRetriever
Skip the given bytes (seek) when reading the data source.

Specified by:
setBytesToSkip in interface DataRetriever

getBytesSkipped

public long getBytesSkipped()
Description copied from interface: DataRetriever
Returns the skipped bytes.

Specified by:
getBytesSkipped in interface DataRetriever
Returns:

getResultCode

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

Specified by:
getResultCode in interface DataRetriever
Returns:

getContext

public Context getContext()
Description copied from interface: DataRetriever
Gets the context from this data retriever.

Specified by:
getContext in interface DataRetriever
Returns:

setContext

public void setContext(Context pContext)
Description copied from interface: DataRetriever
Sets the context for this data retriever.

Specified by:
setContext in interface DataRetriever

getDataProcessorChain

public DataProcessorChain getDataProcessorChain()

setDataProcessorChain

public void setDataProcessorChain(DataProcessorChain pDataProcessorChain)


Copyright © 2008. All Rights Reserved.