de.phleisch.app.itsucks.job.download.impl
Class UrlDownloadJob

java.lang.Object
  extended by de.phleisch.app.itsucks.job.impl.AbstractJob
      extended by de.phleisch.app.itsucks.job.download.impl.UrlDownloadJob
All Implemented Interfaces:
DownloadJob, Job, java.io.Serializable, java.lang.Cloneable

public class UrlDownloadJob
extends AbstractJob
implements DownloadJob, java.lang.Cloneable

This is the implementation of a job for downloading files. It contains a URL to the file or directory to be downloaded.

Author:
olli
See Also:
Serialized Form

Field Summary
static java.lang.String JOB_PARAMETER_SKIP_DOWNLOADED_FILE
           
static java.lang.String JOB_PROGRESS_PROPERTY
          Constant used to determine when the progress property has changed.
 
Fields inherited from class de.phleisch.app.itsucks.job.impl.AbstractJob
mContext, mJobManager
 
Fields inherited from interface de.phleisch.app.itsucks.job.Job
JOB_PRIORITY_PROPERTY, JOB_STATE_PROPERTY, MAX_PRIORITY, MIN_PRIORITY, STATE_ALREADY_PROCESSED, STATE_ASSIGNED, STATE_CLOSED, STATE_ERROR, STATE_FAILED, STATE_FINISHED, STATE_IGNORED, STATE_IN_PROGRESS, STATE_OPEN
 
Constructor Summary
UrlDownloadJob()
           
 
Method Summary
 void abort()
          Aborts the job when running.
 UrlDownloadJob clone()
           
protected  void download()
           
protected  void executeDownload()
           
 long getBytesDownloaded()
          Returns the count of bytes which are downloaded
 DataRetriever getDataRetriever()
           
 int getDepth()
          Gets the recursive depth of the job.
 int getMaxRetryCount()
          Returns the maximum count of retries when an retryable error occurs.
 Metadata getMetadata()
          Gets the metadata of the data retriever.
 long getMinTimeBetweenRetry()
          Gets the waiting time between two retries.
 Job getParent()
           
 float getProgress()
          Returns the current download progress.
 java.io.File getSavePath()
          Returns the base save path for saving downloaded files.
 java.net.URL getUrl()
          Gets the URL to be downloaded.
 boolean isSaveToDisk()
           
 void run()
          Starts the execution of the job.
 void setDataProcessorManager(DataProcessorManager pDataProcessorManager)
          Sets the data processor manager.
 void setDataRetrieverManager(DataRetrieverManager pDataRetrieverManager)
          Sets the data retriever manager.
 void setDepth(int pDepth)
          Sets the recursive depth of the job.
 void setMaxRetryCount(int pMaxRetryCount)
          Sets the maximum count of retries when an retryable error occurs.
 void setMinTimeBetweenRetry(long pMinTimeBetweenRetry)
          Sets the waiting time between two retries.
 void setParent(UrlDownloadJob pParent)
          Sets the parent of the job.
 void setSavePath(java.io.File pSavePath)
          Sets the base save path for saving downloaded files.
 void setSaveToDisk(boolean pSaveToDisk)
          Sets if this file should be saved as file.
 void setUrl(java.net.URL pUrl)
          Sets the url to be downloaded.
 java.lang.String toString()
           
 
Methods inherited from class de.phleisch.app.itsucks.job.impl.AbstractJob
addParameter, addPropertyChangeListener, firePropertyChange, getContext, getId, getJobManager, getName, getParameter, getParameterList, getPriority, getState, hashCode, isClosed, isIgnoreFilter, removePropertyChangeListener, setContext, setId, setIgnoreFilter, setJobManager, setName, setPriority, setState
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.phleisch.app.itsucks.job.Job
addParameter, addPropertyChangeListener, getContext, getId, getJobManager, getName, getParameter, getParameterList, getPriority, getState, isClosed, isIgnoreFilter, removePropertyChangeListener, setContext, setId, setIgnoreFilter, setJobManager, setName, setPriority, setState
 

Field Detail

JOB_PROGRESS_PROPERTY

public static final java.lang.String JOB_PROGRESS_PROPERTY
Constant used to determine when the progress property has changed. The old value in the PropertyChangeEvent will be the old progress and the new value will be the new progress.

See Also:
getProgress(), AbstractJob.addPropertyChangeListener(java.beans.PropertyChangeListener), Constant Field Values

JOB_PARAMETER_SKIP_DOWNLOADED_FILE

public static final java.lang.String JOB_PARAMETER_SKIP_DOWNLOADED_FILE
See Also:
Constant Field Values
Constructor Detail

UrlDownloadJob

public UrlDownloadJob()
Method Detail

run

public void run()
         throws java.lang.Exception
Description copied from interface: Job
Starts the execution of the job. It returns when the job is finished.

Specified by:
run in interface Job
Specified by:
run in class AbstractJob
Throws:
java.lang.Exception

download

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

executeDownload

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

abort

public void abort()
Description copied from interface: Job
Aborts the job when running.

Specified by:
abort in interface Job
Specified by:
abort in class AbstractJob

getUrl

public java.net.URL getUrl()
Gets the URL to be downloaded.

Returns:

setUrl

public void setUrl(java.net.URL pUrl)
Sets the url to be downloaded.

Parameters:
pUrl -

setDataRetrieverManager

public void setDataRetrieverManager(DataRetrieverManager pDataRetrieverManager)
Sets the data retriever manager.

Parameters:
pDataRetrieverManager -

setDataProcessorManager

public void setDataProcessorManager(DataProcessorManager pDataProcessorManager)
Sets the data processor manager.

Parameters:
pDataProcessorManager -

getDepth

public int getDepth()
Description copied from interface: DownloadJob
Gets the recursive depth of the job.

Specified by:
getDepth in interface DownloadJob
Returns:

setDepth

public void setDepth(int pDepth)
Sets the recursive depth of the job.

Parameters:
pDepth -

getParent

public Job getParent()
Returns:
the parent of the job, null if none.

setParent

public void setParent(UrlDownloadJob pParent)
Sets the parent of the job. This method also copies the configuration from the parent to this instance.

Parameters:
pParent -

isSaveToDisk

public boolean isSaveToDisk()
Specified by:
isSaveToDisk in interface DownloadJob
Returns:
true if this file should be saved as file.

setSaveToDisk

public void setSaveToDisk(boolean pSaveToDisk)
Sets if this file should be saved as file.

Parameters:
pSaveToFile -

getSavePath

public java.io.File getSavePath()
Description copied from interface: DownloadJob
Returns the base save path for saving downloaded files.

Specified by:
getSavePath in interface DownloadJob
Returns:

setSavePath

public void setSavePath(java.io.File pSavePath)
Sets the base save path for saving downloaded files.

Parameters:
pSavePath -

getDataRetriever

public DataRetriever getDataRetriever()
Specified by:
getDataRetriever in interface DownloadJob
Returns:
the data retriever used to download from the url.

getProgress

public float getProgress()
Description copied from interface: DownloadJob
Returns the current download progress.

Specified by:
getProgress in interface DownloadJob
Returns:

getMaxRetryCount

public int getMaxRetryCount()
Description copied from interface: DownloadJob
Returns the maximum count of retries when an retryable error occurs.

Specified by:
getMaxRetryCount in interface DownloadJob
Returns:

setMaxRetryCount

public void setMaxRetryCount(int pMaxRetryCount)
Sets the maximum count of retries when an retryable error occurs.

Parameters:
pMaxRetryCount -

getMinTimeBetweenRetry

public long getMinTimeBetweenRetry()
Description copied from interface: DownloadJob
Gets the waiting time between two retries.

Specified by:
getMinTimeBetweenRetry in interface DownloadJob
Returns:

setMinTimeBetweenRetry

public void setMinTimeBetweenRetry(long pMinTimeBetweenRetry)
Sets the waiting time between two retries.

Parameters:
pMinTimeBetweenRetry -

getBytesDownloaded

public long getBytesDownloaded()
Description copied from interface: DownloadJob
Returns the count of bytes which are downloaded

Specified by:
getBytesDownloaded in interface DownloadJob
Returns:

getMetadata

public Metadata getMetadata()
Description copied from interface: DownloadJob
Gets the metadata of the data retriever.

Specified by:
getMetadata in interface DownloadJob
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public UrlDownloadJob clone()
Overrides:
clone in class java.lang.Object


Copyright © 2008. All Rights Reserved.