Class HSQLAsciiReader
java.lang.Object
net.simplace.core.io.AbstractDataReader
net.simplace.core.io.AbstractAsciiReader
net.simplace.core.database.HSQLAsciiReader
Reads a fixed-width or separated ASCII file (see
AbstractAsciiReader) into a database table; the table is
created from the column definitions if it does not exist.-
Field Summary
Fields inherited from class AbstractAsciiReader
iDefaultDateFormat, iSeperator, iSourceFile, iTabLenFields inherited from class AbstractDataReader
iColumnsData, iConfigData, iObservable -
Constructor Summary
ConstructorsConstructorDescriptionHSQLAsciiReader(File aSourceFile, org.jdom2.Element aConfigData, String aTabLen, String aSeperator, String aDefaultDateFormat, Connection aConnection, String aTableName, FWObservable aObservable) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateTable(Connection aConnection, String aTableName, Vector<ColumnData> aColumnDatas, boolean aDropBeforeDelete) Creates new table in the database with one column per column definition (sorted by column index; dots in names become__, array types becomeVARCHAR(10000), DOUBLE becomesDOUBLE PRECISION).static StringgetCanonicalForm(String aText) booleanChecks if the table exists (by selecting from it).protected voidprocessLineOfFile(String aOrientation, String aLine, int aRowIdx) Inserts one line of the file as row (creating the table first if necessary).Methods inherited from class AbstractAsciiReader
getStringParameter, getTitle, initColumnHeads, initTitle, readData, setTitleMethods inherited from class AbstractDataReader
getIntegerValue
-
Constructor Details
-
HSQLAsciiReader
public HSQLAsciiReader(File aSourceFile, org.jdom2.Element aConfigData, String aTabLen, String aSeperator, String aDefaultDateFormat, Connection aConnection, String aTableName, FWObservable aObservable) - Parameters:
aSourceFile- the ASCII fileaConfigData- the column definitionsaTabLen- tab length (for fixed-width files)aSeperator- column separatoraDefaultDateFormat- default date formataConnection- the database connectionaTableName- name of the target tableaObservable- provides the parameters
-
-
Method Details
-
isTableCreated
public boolean isTableCreated()Checks if the table exists (by selecting from it).- Returns:
trueif the table exists
-
createTable
public static void createTable(Connection aConnection, String aTableName, Vector<ColumnData> aColumnDatas, boolean aDropBeforeDelete) Creates new table in the database with one column per column definition (sorted by column index; dots in names become__, array types becomeVARCHAR(10000), DOUBLE becomesDOUBLE PRECISION). Errors are logged.- Parameters:
aConnection- the database connectionaTableName- name of the tableaColumnDatas- the column definitions (sorted in place)aDropBeforeDelete-trueto drop an existing table first
-
getCanonicalForm
-
processLineOfFile
Inserts one line of the file as row (creating the table first if necessary). Values that cannot be parsed are logged and inserted asNULL; errors inserting the row are logged.- Specified by:
processLineOfFilein classAbstractAsciiReader- Parameters:
aOrientation- orientation of the data (not used)aLine- the lineaRowIdx- index of the line- Throws:
Exception- if the insert statement cannot be prepared
-