Class DataSource

java.lang.Object
java.lang.Thread
yearreview.app.data.sources.DataSource
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AudioDataSource, FitnessDataSource

public abstract class DataSource extends Thread
A Datasource loads data from paths specified in the configuration. Each Datasource runs on a separate Thread to speed up loading.
Author:
ColdStone37
  • Field Details

    • tag

      public final String tag
      Tag of the source. Might be used to specify dependencies.
    • logger

      protected static final Logger logger
  • Constructor Details

    • DataSource

      public DataSource(XmlNode c)
      Constructs a DataSource from a configuration.
      Parameters:
      c - configuration of the DataSource
  • Method Details

    • run

      public void run()
      Function that loads the data on a separate Thread. Gets called on Thread.start().
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • parseConfig

      public abstract void parseConfig(XmlNode c)
      Parses the configuration of the DataSource.
      Parameters:
      c - configuration
    • loadData

      public abstract void loadData(Instant start, Instant end) throws IOException
      Loads the data of the DataSource inside the given time interval.
      Parameters:
      start - start time of data to load
      end - end time of data to load
      Throws:
      IOException - if some files cannot be accessed or parsed
    • getDataSource

      public static DataSource getDataSource(XmlNode config)
      Gets a DataSource by the name stored inside the configuration and initializes it with that configuration.
      Parameters:
      config - configuration
      Returns:
      the DataSource or null if a DataSource with the given name does not exist