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

public abstract class AbstractDownloadTask<T> extends Object implements DownloadTask
Common abstract implementation of other download tasks.
Since:
2322
  • Field Details

  • Constructor Details

  • Method Details

    • isCanceled

      public boolean isCanceled()
      Determines if the download task has been canceled.
      Returns:
      true if the download task has been canceled
    • setCanceled

      public void setCanceled(boolean canceled)
      Marks this download task as canceled.
      Parameters:
      canceled - true to mark this download task as canceled
    • isFailed

      public boolean isFailed()
      Determines if the download task has failed.
      Returns:
      true if the download task has failed
    • setFailed

      public void setFailed(boolean failed)
      Marks this download task as failed.
      Parameters:
      failed - true to mark this download task as failed
    • patterns

      protected static <T extends Enum<T> & UrlPattern> String[] patterns(Class<T> urlPatternEnum)
    • rememberErrorMessage

      protected final void rememberErrorMessage(String message)
    • rememberException

      protected final void rememberException(Exception exception)
    • rememberDownloadedData

      protected final void rememberDownloadedData(T data)
    • getDownloadedData

      public final T getDownloadedData()
      Replies the downloaded data.
      Returns:
      The downloaded data.
    • setZoomAfterDownload

      public final void setZoomAfterDownload(boolean zoomAfterDownload)
      Description copied from interface: DownloadTask
      Sets whether the map view will zoom to download area after download
      Specified by:
      setZoomAfterDownload in interface DownloadTask
      Parameters:
      zoomAfterDownload - if true, the map view will zoom to download area after download
    • getErrorObjects

      Description copied from interface: DownloadTask
      Replies the error objects of the task. Empty list, if no error messages are available.

      Error objects are either Strings with error messages or Exceptions.

      Specified by:
      getErrorObjects in interface DownloadTask
      Returns:
      the list of error objects
    • acceptsUrl

      public boolean acceptsUrl(String url)
      Determines if the given URL is accepted by getPatterns(). Can be overridden for more complex checking logic.
      Parameters:
      url - URL to download
      Returns:
      true if 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

      public boolean acceptsUrl(String url, boolean isRemotecontrol)
      Description copied from interface: DownloadTask
      Returns true if the task is able to open the given URL, false otherwise.
      Specified by:
      acceptsUrl in interface DownloadTask
      Parameters:
      url - the url to download from
      isRemotecontrol - 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

      public String getTitle()
      Description copied from interface: DownloadTask
      Returns human-readable description of the task
      Specified by:
      getTitle in interface DownloadTask
      Returns:
      The task description
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPatterns

      public String[] getPatterns()
      Description copied from interface: DownloadTask
      Returns regular expressions that match the URLs
      Specified by:
      getPatterns in interface DownloadTask
      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