Class AbstractAsciiReader
java.lang.Object
net.simplace.core.io.AbstractDataReader
net.simplace.core.io.AbstractAsciiReader
- Direct Known Subclasses:
HSQLAsciiReader, MapAsciiReader
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Stringdefault date formatprotected Stringcolumn separator (not used by the fixed-width parsing)protected Filethe ASCII fileprotected Integertab length; tabs are replaced by spaces if setFields inherited from class AbstractDataReader
iColumnsData, iConfigData, iObservable -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAsciiReader(File aSourceFile, org.jdom2.Element aConfigData, String aTabLen, String aSeperator, String aDefaultDateFormat, FWObservable aObservable) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetStringParameter(String aKey, String aDefault) getTitle()protected voidSets the names of unnamed columns from the linecolHeadRow, if configured.protected voidReads the title from the linetitleRow, if configured.protected abstract voidprocessLineOfFile(String aOrientation, String aLine, int aRowIdx) Processes one line of data.voidreadData()Reads the column definitions and then the selected lines of the file.voidMethods inherited from class AbstractDataReader
getIntegerValue
-
Field Details
-
iSourceFile
the ASCII file -
iTabLen
tab length; tabs are replaced by spaces if set -
iSeperator
column separator (not used by the fixed-width parsing) -
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 fileaConfigData- the configuration element with one child per columnaTabLen- tab length as string, ornullto keep tabsaSeperator- column separatoraDefaultDateFormat- default date formataObservable- provides the parameters for the configuration values
-
-
Method Details
-
readData
Reads the column definitions and then the selected lines of the file.- Overrides:
readDatain classAbstractDataReader- 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-verticalorhorizontal(attributeorientation)aLine- the line (tabs replaced)aRowIdx- line number (1-based)- Throws:
Exception- if the line cannot be processed
-
getStringParameter
-
initColumnHeads
Sets the names of unnamed columns from the linecolHeadRow, if configured.- Specified by:
initColumnHeadsin classAbstractDataReader- Throws:
Exception- if the file cannot be read
-
initTitle
Reads the title from the linetitleRow, if configured.- Specified by:
initTitlein classAbstractDataReader- Throws:
Exception- if the file cannot be read
-
getTitle
- Returns:
- the title of the data
-
setTitle
- Parameters:
aTitle- the title of the data
-