public class DataReader extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
private Project.Data |
data |
private DatabaseImpl |
dbImpl |
private String |
dbName |
private Lookup |
lookup |
Constructor and Description |
---|
DataReader(Project.Data data)
Create the object that will read the data element of the configuration file.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
private void |
logDbStatistics()
Save a message giving the numbers of elements in the database.
|
private int |
readAllBatchedMovementSections(List<DataFiles.BatchMovementFile> batchMovementFiles,
String addingFileMsg)
Read the batched movements sections of the configuration file.
|
private int |
readAllDirectedMovementSections(List<DataFiles.DirectedMovementFile> directedMovementFiles,
String addingFileMsg)
Read the directed movements sections of the configuration file.
|
private int |
readAllFullMovementSections(List<DataFiles.FullMovementFile> fullMovementFiles,
String addingFileMsg)
Read the full movements sections of the configuration file.
|
private int |
readAllLocationSections(List<DataFiles.LocationsFile> locationsFile,
String addingFileMsg)
Read the location sections of the configuration file.
|
private int |
readAllPopulationSections(List<DataFiles.PopulationFile> populationsFiles,
String addingFileMsg)
Read the populations sections of the configuration file.
|
private int |
readAllTestSections(List<DataFiles.TestsFile> testsFile,
String addingFileMsg)
Read the test sections of the configuration file.
|
private void |
readDataFiles(DataFiles files)
Read the datafiles, each section type of the
|
void |
readDataSection()
Read the data section from the configuration file.
|
protected void |
updateSectionDefiniton(String elementName,
int indexInDataFile,
Map<String,Integer> keyValueMapping,
StringBuilder errors,
boolean recordErrors,
String sectionName)
Add a description of a configuration file section to an internal key value pair so that the correct column of a
data file can be read.
|
private Lookup lookup
private Project.Data data
private DatabaseImpl dbImpl
private String dbName
public DataReader(Project.Data data)
data
- the element of the configuration file.public final void readDataSection()
public final void close()
close
in interface AutoCloseable
private void logDbStatistics()
private void readDataFiles(DataFiles files)
files
- the Datafiles object from the configuration file.protected final void updateSectionDefiniton(String elementName, int indexInDataFile, Map<String,Integer> keyValueMapping, StringBuilder errors, boolean recordErrors, String sectionName)
elementName
- the name of the element in the configuration file.indexInDataFile
- the location of the element in each row of the data file.keyValueMapping
- a table of the keyValueMapping name index and type.errors
- a description of any parsing errors found.recordErrors
- flag to control whether or not error are recorded in the errors parameter.sectionName
- the name of the section from which the element being added to the table has been read.private int readAllDirectedMovementSections(List<DataFiles.DirectedMovementFile> directedMovementFiles, String addingFileMsg)
directedMovementFiles
- a collection of directedMovement sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.private int readAllFullMovementSections(List<DataFiles.FullMovementFile> fullMovementFiles, String addingFileMsg)
fullMovementFiles
- a collection of fullMovement sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.private int readAllBatchedMovementSections(List<DataFiles.BatchMovementFile> batchMovementFiles, String addingFileMsg)
batchMovementFiles
- a collection of batchMovement sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.private int readAllLocationSections(List<DataFiles.LocationsFile> locationsFile, String addingFileMsg)
locationsFile
- a collection of locations sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.private int readAllTestSections(List<DataFiles.TestsFile> testsFile, String addingFileMsg)
testsFile
- a collection of locations sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.private int readAllPopulationSections(List<DataFiles.PopulationFile> populationsFiles, String addingFileMsg)
populationsFiles
- a collection of populations sections.addingFileMsg
- formatted string (in the form "Adding %s to reading list") to be added to log files.Copyright © 2015 University of Glasgow. All rights reserved.