org.lastbamboo.common.download
Class DummySha1Downloader<DsT extends DownloaderState>

java.lang.Object
  extended by org.lastbamboo.common.download.AbstractDownloader<Sha1DState<DsT>>
      extended by org.lastbamboo.common.download.DummySha1Downloader<DsT>
Type Parameters:
DsT - The state type of the delegate downloader.
All Implemented Interfaces:
Downloader<Sha1DState<DsT>>

public final class DummySha1Downloader<DsT extends DownloaderState>
extends AbstractDownloader<Sha1DState<DsT>>
implements Downloader<Sha1DState<DsT>>

A downloader that checks the SHA-1 of a resource downloaded by a delegate downloader.


Constructor Summary
DummySha1Downloader(Downloader<DsT> delegate, long expectedSize)
          Constructs a new downloader.
 
Method Summary
 File getCompleteFile()
          Returns the final path for the file.
 String getFinalName()
          The final name for the file.
 File getIncompleteFile()
          Returns the file to which this downloader downloads the resource.
 long getSize()
          Returns the size of the resource that is downloaded by this downloader.
 Sha1DState<DsT> getState()
          Returns the current state of this downloader.
 boolean isStarted()
          Returns whether or not this downloader has already started.
 void pause()
          Pauses the download.
 void resume()
          Resumes the download.
 void start()
          Starts downloading the resource.
 void stop(boolean removeFiles)
          Stops the download.
 void write(OutputStream os, boolean cancelOnStreamClose)
          Writes the resource that this downloader downloads to a given stream.
 
Methods inherited from class org.lastbamboo.common.download.AbstractDownloader
addListener, fireStateChanged, getStartTime, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.lastbamboo.common.download.Downloader
addListener, getStartTime, removeListener
 

Constructor Detail

DummySha1Downloader

public DummySha1Downloader(Downloader<DsT> delegate,
                           long expectedSize)
Constructs a new downloader.

Parameters:
delegate - The delegate downloader.
expectedSize - The expected size of the file.
Method Detail

getIncompleteFile

public File getIncompleteFile()
Description copied from interface: Downloader
Returns the file to which this downloader downloads the resource.

Specified by:
getIncompleteFile in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
The file to which this downloader downloads the resource.

getSize

public long getSize()
Description copied from interface: Downloader
Returns the size of the resource that is downloaded by this downloader.

Specified by:
getSize in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
The size of the resource that is downloaded by this downloader.

getState

public Sha1DState<DsT> getState()
Description copied from interface: Downloader
Returns the current state of this downloader.

Specified by:
getState in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
The current state of this downloader.

start

public void start()
Description copied from interface: Downloader
Starts downloading the resource.

Specified by:
start in interface Downloader<Sha1DState<DsT extends DownloaderState>>

stop

public void stop(boolean removeFiles)
Description copied from interface: Downloader
Stops the download.

Specified by:
stop in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Parameters:
removeFiles - Whether or not to also remove all downloaded files.

pause

public void pause()
Description copied from interface: Downloader
Pauses the download.

Specified by:
pause in interface Downloader<Sha1DState<DsT extends DownloaderState>>

resume

public void resume()
Description copied from interface: Downloader
Resumes the download.

Specified by:
resume in interface Downloader<Sha1DState<DsT extends DownloaderState>>

isStarted

public boolean isStarted()
Description copied from interface: Downloader
Returns whether or not this downloader has already started.

Specified by:
isStarted in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
true if this downloader has already started, otherwise false.

write

public void write(OutputStream os,
                  boolean cancelOnStreamClose)
Description copied from interface: Downloader
Writes the resource that this downloader downloads to a given stream. The download does not have to be complete for writing to occur. This can be used to stream the content of this downloader while it is still downloading.

Specified by:
write in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Parameters:
os - The output stream to which to write the resource.
cancelOnStreamClose - Whether or not the cancel the download when the stream closes.

getFinalName

public String getFinalName()
Description copied from interface: Downloader
The final name for the file.

Specified by:
getFinalName in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
The final name for the file.

getCompleteFile

public File getCompleteFile()
Description copied from interface: Downloader
Returns the final path for the file.

Specified by:
getCompleteFile in interface Downloader<Sha1DState<DsT extends DownloaderState>>
Returns:
The final path for the file.


Copyright © 2013 LittleShoot. All Rights Reserved.