Class Downloader<T>


  • public class Downloader<T>
    extends java.lang.Object
    Manages download of data that may be required in multiple places.
    Since:
    24 Oct 2019
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      Downloader​(java.lang.String dataDescription, java.util.concurrent.Callable<T> supplier)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addActionListener​(java.awt.event.ActionListener l)
      Adds a listener that will be notified when the data has become available.
      T getData()
      Immediately returns the downloaded data, or null if it has not been downloaded, or if a download has failed.
      void removeActionListener​(java.awt.event.ActionListener l)
      Removes a listener previously added.
      void start()
      Ensures that this downloader has started to downloading the data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Downloader

        public Downloader​(java.lang.String dataDescription,
                          java.util.concurrent.Callable<T> supplier)
        Constructor.
        Parameters:
        dataDescription - short description of downloaded data, may be used in logging messages
        supplier - supplier of downloaded data
    • Method Detail

      • start

        public void start()
        Ensures that this downloader has started to downloading the data. If it has already started (and possibly finished), this has no effect.
      • getData

        public T getData()
        Immediately returns the downloaded data, or null if it has not been downloaded, or if a download has failed.
        Returns:
        downloaded result, or null
      • addActionListener

        public void addActionListener​(java.awt.event.ActionListener l)
        Adds a listener that will be notified when the data has become available.
        Parameters:
        l - listener
      • removeActionListener

        public void removeActionListener​(java.awt.event.ActionListener l)
        Removes a listener previously added.
        Parameters:
        l - listener