Class AbstractAsciiReader

java.lang.Object
net.simplace.core.io.AbstractDataReader
net.simplace.core.io.AbstractAsciiReader
Direct Known Subclasses:
HSQLAsciiReader, MapAsciiReader

public abstract class AbstractAsciiReader extends AbstractDataReader
Base class of readers for fixed-width ASCII files: the lines between startRow and endRow (every step-th line, empty lines skipped) are passed to processLineOfFile(String, String, int). Column heads and title can be read from the lines colHeadRow and titleRow.
  • Field Details

    • iSourceFile

      protected File iSourceFile
      the ASCII file
    • iTabLen

      protected Integer iTabLen
      tab length; tabs are replaced by spaces if set
    • iSeperator

      protected String iSeperator
      column separator (not used by the fixed-width parsing)
    • iDefaultDateFormat

      protected String iDefaultDateFormat
      default date format
  • Constructor Details

    • AbstractAsciiReader

      public AbstractAsciiReader(File aSourceFile, org.jdom2.Element aConfigData, String aTabLen, String aSeperator, String aDefaultDateFormat, FWObservable aObservable)
      Parameters:
      aSourceFile - the ASCII file
      aConfigData - the configuration element with one child per column
      aTabLen - tab length as string, or null to keep tabs
      aSeperator - column separator
      aDefaultDateFormat - default date format
      aObservable - provides the parameters for the configuration values
  • Method Details

    • readData

      public void readData() throws Exception
      Reads the column definitions and then the selected lines of the file.
      Overrides:
      readData in class AbstractDataReader
      Throws:
      Exception - if the file cannot be read or a line cannot be processed
    • processLineOfFile

      protected abstract void processLineOfFile(String aOrientation, String aLine, int aRowIdx) throws Exception
      Processes one line of data.
      Parameters:
      aOrientation - vertical or horizontal (attribute orientation)
      aLine - the line (tabs replaced)
      aRowIdx - line number (1-based)
      Throws:
      Exception - if the line cannot be processed
    • getStringParameter

      protected String getStringParameter(String aKey, String aDefault)
      Parameters:
      aKey - the parameter name
      aDefault - value returned if the parameter is not set
      Returns:
      the parameter value as string, or aDefault
    • initColumnHeads

      protected void initColumnHeads() throws Exception
      Sets the names of unnamed columns from the line colHeadRow, if configured.
      Specified by:
      initColumnHeads in class AbstractDataReader
      Throws:
      Exception - if the file cannot be read
    • initTitle

      protected void initTitle() throws Exception
      Reads the title from the line titleRow, if configured.
      Specified by:
      initTitle in class AbstractDataReader
      Throws:
      Exception - if the file cannot be read
    • getTitle

      public String getTitle()
      Returns:
      the title of the data
    • setTitle

      public void setTitle(String aTitle)
      Parameters:
      aTitle - the title of the data