org.openstreetmap.fma.jtiledownloader
Class TileListDownloader

java.lang.Object
  extended by org.openstreetmap.fma.jtiledownloader.TileListDownloader

public class TileListDownloader
extends java.lang.Object


Nested Class Summary
 class TileListDownloader.TileListDownloaderThread
           
 
Field Summary
private  java.lang.String _downloadPath
           
private  int _errorCount
           
private  java.util.LinkedList<TileDownloadError> _errorTileList
           
private  TileDownloaderListener _listener
           
private  int _numberOfTilesToDownload
           
private  TileProviderIf _tileProvider
           
private  java.util.LinkedList<Tile> _tilesToDownload
           
private  int _updatedTilesCount
           
private  java.util.ArrayList<TileListDownloader.TileListDownloaderThread> downloaderThreads
           
private static java.util.logging.Logger log
           
private static int MAX_RETRIES
           
private  boolean paused
           
 
Constructor Summary
TileListDownloader(java.lang.String downloadPath, TileList tilesToDownload, TileProviderIf tileProvider)
           
 
Method Summary
 void abort()
           
private  void addedTileDownloadError(TileDownloadResult result, Tile tileToDownload)
           
private  TileDownloadResult doDownload(Tile tileToDownload)
           
private  TileDownloadResult doSingleDownload(java.lang.String fileName, java.net.URL url)
           
private  void fireDownloadCompleteEvent()
           
private  void fireDownloadedTileEvent(java.lang.String fileName, boolean updatedTile)
           
private  void fireDownloadPausedEvent()
           
private  void fireDownloadStoppedEvent()
           
private  void fireErrorOccuredEvent(Tile tile)
           
private  void fireWaitHttp500ErrorToResume(java.lang.String message)
           
private  void fireWaitResume(java.lang.String message)
           
 java.lang.String getDownloadPath()
          Getter for downloadPath
private  Tile getTilesToDownload()
          Get tile to download
private  void increaseUpdatedCount()
           
private  boolean isLastThread()
           
 void pause()
           
private  void requeueTile(Tile tile)
           
private  int runningThreads()
           
 void setDownloadPath(java.lang.String downloadPath)
          Setter for downloadPath
 void setListener(TileDownloaderListener listener)
           
 void setTilesToDownload(java.util.ArrayList<Tile> tilesToDownload)
          Setter for tilesToDownload
 void start()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

_tilesToDownload

private java.util.LinkedList<Tile> _tilesToDownload

_downloadPath

private java.lang.String _downloadPath

_tileProvider

private TileProviderIf _tileProvider

downloaderThreads

private java.util.ArrayList<TileListDownloader.TileListDownloaderThread> downloaderThreads

_listener

private TileDownloaderListener _listener

paused

private boolean paused

_numberOfTilesToDownload

private int _numberOfTilesToDownload

_errorCount

private int _errorCount

_updatedTilesCount

private int _updatedTilesCount

_errorTileList

private java.util.LinkedList<TileDownloadError> _errorTileList

MAX_RETRIES

private static final int MAX_RETRIES
See Also:
Constant Field Values
Constructor Detail

TileListDownloader

public TileListDownloader(java.lang.String downloadPath,
                          TileList tilesToDownload,
                          TileProviderIf tileProvider)
Parameters:
downloadPath -
tilesToDownload -
tileProvider -
Method Detail

start

public void start()

abort

public void abort()

pause

public void pause()

increaseUpdatedCount

private void increaseUpdatedCount()

addedTileDownloadError

private void addedTileDownloadError(TileDownloadResult result,
                                    Tile tileToDownload)

doDownload

private TileDownloadResult doDownload(Tile tileToDownload)

doSingleDownload

private TileDownloadResult doSingleDownload(java.lang.String fileName,
                                            java.net.URL url)
Parameters:
fileName -
url -
Returns:
TileDownloadResult

setListener

public void setListener(TileDownloaderListener listener)

fireDownloadedTileEvent

private void fireDownloadedTileEvent(java.lang.String fileName,
                                     boolean updatedTile)
Parameters:
fileName -
updatedTile -

fireErrorOccuredEvent

private void fireErrorOccuredEvent(Tile tile)
Parameters:
tile -

fireDownloadStoppedEvent

private void fireDownloadStoppedEvent()

fireDownloadPausedEvent

private void fireDownloadPausedEvent()

fireDownloadCompleteEvent

private void fireDownloadCompleteEvent()

runningThreads

private int runningThreads()

isLastThread

private boolean isLastThread()
Returns:
is the current thread is the last thread

fireWaitResume

private void fireWaitResume(java.lang.String message)

fireWaitHttp500ErrorToResume

private void fireWaitHttp500ErrorToResume(java.lang.String message)

setDownloadPath

public void setDownloadPath(java.lang.String downloadPath)
Setter for downloadPath

Parameters:
downloadPath - the downloadPath to set

getDownloadPath

public java.lang.String getDownloadPath()
Getter for downloadPath

Returns:
the downloadPath

setTilesToDownload

public void setTilesToDownload(java.util.ArrayList<Tile> tilesToDownload)
Setter for tilesToDownload

Parameters:
tilesToDownload - the tilesToDownload to set

getTilesToDownload

private Tile getTilesToDownload()
Get tile to download

Returns:
a tile

requeueTile

private void requeueTile(Tile tile)