Class AbstractDownloadTask<T>
java.lang.Object
org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask<T>
- Type Parameters:
T- The downloaded data type
- All Implemented Interfaces:
DownloadTask
- Direct Known Subclasses:
AbstractChangesetDownloadTask,DownloadGpsTask,DownloadNotesTask,DownloadOsmTask,DownloadSessionTask
Common abstract implementation of other download tasks.
- Since:
- 2322
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a newAbstractDownloadTask. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsUrl(String url) Determines if the given URL is accepted bygetPatterns().booleanacceptsUrl(String url, boolean isRemotecontrol) Returns true if the task is able to open the given URL, false otherwise.final TReplies the downloaded data.Returns the projection bounds of downloaded data.Replies the error objects of the task.String[]Returns regular expressions that match the URLsgetTitle()Returns human-readable description of the taskbooleanDetermines if the download task has been canceled.booleanisFailed()Determines if the download task has failed.booleanCheck / decide if the task is safe for remotecontrol.protected static <T extends Enum<T> & UrlPattern>
String[]protected final voidrememberDownloadedData(T data) protected final voidrememberErrorMessage(String message) protected final voidrememberException(Exception exception) voidsetCanceled(boolean canceled) Marks this download task as canceled.voidsetFailed(boolean failed) Marks this download task as failed.final voidsetZoomAfterDownload(boolean zoomAfterDownload) Sets whether the map view will zoom to download area after downloadtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.actions.downloadtasks.DownloadTask
acceptsDocumentationSummary, cancel, download, getConfirmationMessage, getErrorMessages, loadUrl, providesOldData
-
Field Details
-
errorMessages
-
canceled
-
failed
-
downloadedData
-
zoomAfterDownload
-
-
Constructor Details
-
AbstractDownloadTask
protected AbstractDownloadTask()Constructs a newAbstractDownloadTask.
-
-
Method Details
-
isCanceled
Determines if the download task has been canceled.- Returns:
trueif the download task has been canceled
-
setCanceled
Marks this download task as canceled.- Parameters:
canceled-trueto mark this download task as canceled
-
isFailed
Determines if the download task has failed.- Returns:
trueif the download task has failed
-
setFailed
Marks this download task as failed.- Parameters:
failed-trueto mark this download task as failed
-
patterns
-
rememberErrorMessage
-
rememberException
-
rememberDownloadedData
-
getDownloadedData
Replies the downloaded data.- Returns:
- The downloaded data.
-
setZoomAfterDownload
Description copied from interface:DownloadTaskSets whether the map view will zoom to download area after download- Specified by:
setZoomAfterDownloadin interfaceDownloadTask- Parameters:
zoomAfterDownload- if true, the map view will zoom to download area after download
-
getErrorObjects
Description copied from interface:DownloadTaskReplies the error objects of the task. Empty list, if no error messages are available.Error objects are either
Strings with error messages orExceptions.- Specified by:
getErrorObjectsin interfaceDownloadTask- Returns:
- the list of error objects
-
acceptsUrl
Determines if the given URL is accepted bygetPatterns(). Can be overridden for more complex checking logic.- Parameters:
url- URL to download- Returns:
trueif this URL is accepted
-
isSafeForRemotecontrolRequests
Check / decide if the task is safe for remotecontrol.Keep in mind that a potential attacker has full control over the content of the file that will be downloaded. If it is possible to run arbitrary code or write to the local file system, then the task is (obviously) not save for remote execution.
The default value is false = unsafe. Override in a subclass to allow running the task via remotecontol.
- Returns:
- true if it is safe to download and open any file of the corresponding format, false otherwise
-
acceptsUrl
Description copied from interface:DownloadTaskReturns true if the task is able to open the given URL, false otherwise.- Specified by:
acceptsUrlin interfaceDownloadTask- 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.
-
getTitle
Description copied from interface:DownloadTaskReturns human-readable description of the task- Specified by:
getTitlein interfaceDownloadTask- Returns:
- The task description
-
toString
-
getPatterns
Description copied from interface:DownloadTaskReturns regular expressions that match the URLs- Specified by:
getPatternsin interfaceDownloadTask- Returns:
- The array of accepted URL patterns
-
getDownloadProjectionBounds
Returns the projection bounds of downloaded data.- Returns:
- the projection bounds of downloaded data or
null - Since:
- 11774
-