Interface DownloadTask
-
- All Known Implementing Classes:
AbstractChangesetDownloadTask
,AbstractDownloadTask
,ChangesetContentDownloadTask
,ChangesetHeaderDownloadTask
,ChangesetQueryTask
,DownloadGeoJsonTask
,DownloadGpsTask
,DownloadNotesTask
,DownloadNotesUrlBoundsTask
,DownloadNotesUrlIdTask
,DownloadOsmChangeTask
,DownloadOsmIdTask
,DownloadOsmInViewAction.DownloadOsmInViewTask
,DownloadOsmTask
,DownloadOsmUrlTask
,DownloadSessionTask
public interface DownloadTask
Interface defining a general download task used to download geographic data (OSM data, GPX tracks, etc.) for a given URL or geographic area.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.String
acceptsDocumentationSummary()
Returns a short HTML documentation string, describing acceptable URLs.boolean
acceptsUrl(java.lang.String url, boolean isRemotecontrol)
Returns true if the task is able to open the given URL, false otherwise.void
cancel()
Cancels the asynchronous download task.java.util.concurrent.Future<?>
download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box.java.lang.String
getConfirmationMessage(java.net.URL url)
Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.default java.util.List<java.lang.String>
getErrorMessages()
Replies the error messages of the task.java.util.List<java.lang.Object>
getErrorObjects()
Replies the error objects of the task.java.lang.String[]
getPatterns()
Returns regular expressions that match the URLsjava.lang.String
getTitle()
Returns human-readable description of the taskjava.util.concurrent.Future<?>
loadUrl(DownloadParams settings, java.lang.String url, ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding URL.void
setZoomAfterDownload(boolean zoomAfterDownload)
Sets whether the map view will zoom to download area after download
-
-
-
Method Detail
-
download
java.util.concurrent.Future<?> download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box.Set
progressMonitor
to null, if the task should create, open, and close a progress monitor. Set progressMonitor toNullProgressMonitor.INSTANCE
if progress information is to be discarded.You can wait for the asynchronous download task to finish by synchronizing on the returned
Future
, but make sure not to freeze up JOSM. Example:Future<?> future = task.download(...); // DON'T run this on the Swing EDT or JOSM will freeze future.get(); // waits for the dowload task to complete
The following example uses a pattern which is better suited if a task is launched from the Swing EDT:final Future<?> future = task.download(...); Runnable runAfterTask = new Runnable() { public void run() { // this is not strictly necessary because of the type of executor service // Main.worker is initialized with, but it doesn't harm either // future.get(); // wait for the download task to complete doSomethingAfterTheTaskCompleted(); } } MainApplication.worker.submit(runAfterTask);
- Parameters:
settings
- download settingsdownloadArea
- the area to downloadprogressMonitor
- the progressMonitor- Returns:
- the future representing the asynchronous task
- Since:
- 13927
-
loadUrl
java.util.concurrent.Future<?> loadUrl(DownloadParams settings, java.lang.String url, ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding URL.Set progressMonitor to null, if the task should create, open, and close a progress monitor. Set progressMonitor to
NullProgressMonitor.INSTANCE
if progress information is to be discarded.- Parameters:
settings
- download settingsurl
- the url to download fromprogressMonitor
- the progressMonitor- Returns:
- the future representing the asynchronous task
- Since:
- 13927
- See Also:
download(DownloadParams, Bounds, ProgressMonitor)
-
acceptsUrl
boolean acceptsUrl(java.lang.String url, boolean isRemotecontrol)
Returns true if the task is able to open the given URL, false otherwise.- Parameters:
url
- the url to download fromisRemotecontrol
- True if download request comes from remotecontrol.- Returns:
- True if the task is able to open the given URL, false otherwise. Return false, if the request comes from remotecontrol, but the task is not safe for remotecontrol. A task is not safe for remotecontrol if it is possible to prepare a file for download which does something unintended, e.g. gain access to the local file system.
-
acceptsDocumentationSummary
default java.lang.String acceptsDocumentationSummary()
Returns a short HTML documentation string, describing acceptable URLs.- Returns:
- The HTML documentation
- Since:
- 6031
-
getTitle
java.lang.String getTitle()
Returns human-readable description of the task- Returns:
- The task description
- Since:
- 6031
-
getPatterns
java.lang.String[] getPatterns()
Returns regular expressions that match the URLs- Returns:
- The array of accepted URL patterns
- Since:
- 6031
-
getErrorObjects
java.util.List<java.lang.Object> getErrorObjects()
Replies the error objects of the task. Empty list, if no error messages are available.Error objects are either
String
s with error messages orException
s.- Returns:
- the list of error objects
-
getErrorMessages
default java.util.List<java.lang.String> getErrorMessages()
Replies the error messages of the task. Empty list, if no error messages are available.- Returns:
- the list of error messages
- Since:
- 17330
-
cancel
void cancel()
Cancels the asynchronous download task.
-
getConfirmationMessage
java.lang.String getConfirmationMessage(java.net.URL url)
Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.- Parameters:
url
- The URL to be confirmed- Returns:
- The HTML-formatted confirmation message to be shown to user
- Since:
- 5691
-
setZoomAfterDownload
void setZoomAfterDownload(boolean zoomAfterDownload)
Sets whether the map view will zoom to download area after download- Parameters:
zoomAfterDownload
- if true, the map view will zoom to download area after download- Since:
- 13261
-
-