Package yearreview.app.data.sources
Class DataSource
java.lang.Object
java.lang.Thread
yearreview.app.data.sources.DataSource
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
AudioDataSource
,FitnessDataSource
A Datasource loads data from paths specified in the configuration.
Each Datasource runs on a separate Thread to speed up loading.
- Author:
- ColdStone37
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataSource
getDataSource
(XmlNode config) Gets a DataSource by the name stored inside the configuration and initializes it with that configuration.abstract void
Loads the data of the DataSource inside the given time interval.abstract void
Parses the configuration of the DataSource.void
run()
Function that loads the data on a separate Thread.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
tag
Tag of the source. Might be used to specify dependencies. -
logger
-
-
Constructor Details
-
DataSource
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 onThread.start()
. -
parseConfig
Parses the configuration of the DataSource.- Parameters:
c
- configuration
-
loadData
Loads the data of the DataSource inside the given time interval.- Parameters:
start
- start time of data to loadend
- end time of data to load- Throws:
IOException
- if some files cannot be accessed or parsed
-
getDataSource
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
-