Class DataImport<T>

java.lang.Object
PamView.importData.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

public abstract class DataImport<T> extends Object
This class is used to define what data to import and how to import it. It is used in conjunction with ImportDataSystem to create a generic system to load any type of data into a data block.

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 were T is the type of data we're trying to save. So for example if you are loading in NMEA data then you would use create loadDataIntermediate(String filePath) which imports the file (filepath) and converts into an ArrayList of strings io.e ArrayList such that T=String;

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 Details

    • DataImport

      public DataImport()
  • Method Details

    • loadDataIntermediate

      public abstract ArrayList<T> loadDataIntermediate(String filePath)
      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

      public abstract boolean isDataFormatOK(T dataLine)
      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

      public abstract PamDataUnit createDataUnit(T dataLine)
      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

      public abstract PamDataBlock getDataBlock()
      Get the data block to to save data to.
      Returns:
    • getExtensionsStrings

      public abstract String[] getExtensionsStrings()
      Return the file extensions that can be loaded.
      Returns:
      an array of file extensions that can be loaded.
    • getDataUnitName

      public String getDataUnitName()
      The name of the data unit to appear on the dialog boxes.
      Returns:
      name of the data unit to be imported.