Package uk.ac.starlink.topcat.activate

# Class Downloader<T>

java.lang.Object
uk.ac.starlink.topcat.activate.Downloader<T>

public class Downloader<T> extends 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(String dataDescription, Callable<T> supplier)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addActionListener(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(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 Details

### Downloader

public Downloader(String dataDescription, Callable<T> supplier)
Constructor.

Parameters:
  `dataDescription` - short description of downloaded data, may be used in logging messages
  `supplier` - supplier of downloaded data

## Method Details

### 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(ActionListener l)
Adds a listener that will be notified when the data has become available.

Parameters:
  `l` - listener

### removeActionListener

public void removeActionListener(ActionListener l)
Removes a listener previously added.

Parameters:
  `l` - listener