Class DataImport<T>
- Type Parameters:
T
- - the data type loaded from a file. This could be a String, ArrayList, ArrayListinvalid input: '<'ArrayList > etc.
- Direct Known Subclasses:
HydrophoneImport
,QuickAnnotationImport
,StreamerImport
,TideManager
First getExtensionsStrings() defines which file types can be selected for import.
Before loading in any data we need to perform pre-checks with the function performPreChecks(). This function is called before the load thread is called. Often this will remain blank but say you needed extra user imput then this function could be used to create another dialog box before the data is loaded.
To create a new importer first we need to load a file into memory using the
loadDataIntermediate(String filePath) function. This will create an
ArrayList
Once the data has been loaded into memory it must be converted into a data
unit and saved to a data block. The function createDataUnit(T dataLine)
converts data into a PamDatUnit. This function would for example, convert an
NMEA strings into a GPSDataUnit. The function isDataFormatOK() needs to be
used to check that each T is in the correct format.
- Author:
- Jamie Macaulay
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract PamDataUnit
createDataUnit
(T dataLine) Create a data unit from the data loaded from the imported file.abstract PamDataBlock
Get the data block to to save data to.The name of the data unit to appear on the dialog boxes.abstract String[]
Return the file extensions that can be loaded.abstract boolean
isDataFormatOK
(T dataLine) Check that a row of imported data is in the correct format.loadDataIntermediate
(String filePath) Loads the file into memory - each element of the output array list is then processed.boolean
Use this function to perform any pre checks on data/ bring up extra dialog boxes before loading data.
-
Constructor Details
-
DataImport
public DataImport()
-
-
Method Details
-
loadDataIntermediate
Loads the file into memory - each element of the output array list is then processed.- Parameters:
filePath
- - the filepath.- Returns:
- a list of imported objects.
-
isDataFormatOK
Check that a row of imported data is in the correct format.- Parameters:
dataLine
- -a row of data loaded from file- Returns:
- true if the format is OK.
-
performPreChecks
public boolean performPreChecks()Use this function to perform any pre checks on data/ bring up extra dialog boxes before loading data.- Returns:
- true iof pre checks are OK.
-
createDataUnit
Create a data unit from the data loaded from the imported file.- Parameters:
dataLine
- -a row of data loaded from file- Returns:
- a data unit to be saved to the datablock.
-
getDataBlock
Get the data block to to save data to.- Returns:
-
getExtensionsStrings
Return the file extensions that can be loaded.- Returns:
- an array of file extensions that can be loaded.
-
getDataUnitName
The name of the data unit to appear on the dialog boxes.- Returns:
- name of the data unit to be imported.
-