public abstract class AbstractParser extends Object implements Parser
Modifier | Constructor and Description |
---|---|
protected |
AbstractParser(Reader dataSourceReader) |
protected |
AbstractParser(Reader dataSourceReader,
String dataDefinition) |
Modifier and Type | Method and Description |
---|---|
protected void |
addError(DefaultDataSet ds,
String errorDesc,
int lineNo,
int errorLevel,
String lineData)
Adds a new error to this DataSet.
|
protected void |
addError(DefaultDataSet ds,
String errorDesc,
int lineNo,
int errorLevel,
String lineData,
String lastColName,
String lastColValue)
Adds a new error to this DataSet.
|
protected void |
addToCloseReaderList(Reader r) |
protected void |
addToMetaData(List<ColumnMetaData> columns) |
protected void |
closeReaders() |
protected abstract DataSet |
doParse() |
protected String |
getDataDefinition() |
String |
getDataFileTable()
Returns the table name that will be used to read the MetaData from the db.
|
protected Reader |
getDataSourceReader() |
String |
getDataStructureTable()
Returns the table name that will be used to read the MetaData from the db.
|
MetaData |
getPzMetaData() |
protected abstract void |
init() |
protected void |
initStreamOrSource(InputStream dataSourceStream,
File dataSource) |
boolean |
isAddSuffixToDuplicateColumnNames() |
boolean |
isColumnNamesCaseSensitive()
Default is false
|
boolean |
isFlagEmptyRows() |
boolean |
isHandlingShortLines() |
boolean |
isIgnoreExtraColumns() |
boolean |
isIgnoreParseWarnings()
Default is false
|
protected boolean |
isInitialised() |
boolean |
isNullEmptyStrings() |
boolean |
isPreserveLeadingWhitespace()
Defaults to
true . |
boolean |
isPreserveTrailingWhitespace()
Defaults to
false . |
boolean |
isStoreRawDataToDataError() |
boolean |
isStoreRawDataToDataSet() |
DataSet |
parse()
Start the parsing.
|
StreamingDataSet |
parseAsStream()
Parse the data and return an interface where one can extract one record at a time, until
next returns false;
|
Parser |
setAddSuffixToDuplicateColumnNames(boolean addSuffixToDuplicateColumnNames) |
Parser |
setColumnNamesCaseSensitive(boolean columnNamesCaseSensitive)
Default is false
|
protected void |
setDataDefinition(String dataDefinition) |
Parser |
setDataFileTable(String dataFileTable)
Sets the table name that will be used to read the MetaData from the db.
|
protected void |
setDataSourceReader(Reader dataSourceReader) |
Parser |
setDataStructureTable(String dataStructureTable)
Sets the table name that will be used to read the MetaData from the db.
|
Parser |
setFlagEmptyRows(boolean flagEmptyRows)
when true, will analyze the row to see if all elements are empty and
place a flag on the DataSet indicating if the row is empty.
|
Parser |
setHandlingShortLines(boolean handleShortLines) |
Parser |
setIgnoreExtraColumns(boolean ignoreExtraColumns) |
Parser |
setIgnoreParseWarnings(boolean ignoreParseWarnings) |
protected void |
setInitialised(boolean initialised) |
Parser |
setNullEmptyStrings(boolean nullEmptyStrings) |
Parser |
setPreserveLeadingWhitespace(boolean preserveLeadingWhitespace)
Defaults to
true . |
Parser |
setPreserveTrailingWhitespace(boolean preserveTrailingWhitespace)
Defaults to
false . |
void |
setPzMetaData(MetaData pzMap) |
Parser |
setStoreRawDataToDataError(boolean storeRawDataToDataError)
when true, the parser will place the data of the line which failed the parse and
place it into the DataError object.
|
Parser |
setStoreRawDataToDataSet(boolean storeRawDataToDataSet)
WARNING!! Setting this option has potential to cause high memory usage.
|
Stream<Record> |
stream()
Parse the data and return a stream or records;
|
protected AbstractParser(Reader dataSourceReader)
public boolean isAddSuffixToDuplicateColumnNames()
public Parser setAddSuffixToDuplicateColumnNames(boolean addSuffixToDuplicateColumnNames)
setAddSuffixToDuplicateColumnNames
in interface Parser
addSuffixToDuplicateColumnNames
- when true, add a count to duplicate colum names. eg the second column called "Asset" will become "Asset2".protected void initStreamOrSource(InputStream dataSourceStream, File dataSource) throws FileNotFoundException
FileNotFoundException
public boolean isHandlingShortLines()
isHandlingShortLines
in interface Parser
public Parser setHandlingShortLines(boolean handleShortLines)
setHandlingShortLines
in interface Parser
handleShortLines
- -
when flagged as true, lines with less columns then the amount
of column headers will be added as empty's instead of
producing an errorpublic boolean isIgnoreExtraColumns()
isIgnoreExtraColumns
in interface Parser
public Parser setIgnoreExtraColumns(boolean ignoreExtraColumns)
setIgnoreExtraColumns
in interface Parser
ignoreExtraColumns
- when true, detail lines with a length or column count > the
mapping definition will be truncated and the reader will NOT
register these lines as errors in the DataError collection.public boolean isPreserveLeadingWhitespace()
Parser
true
.isPreserveLeadingWhitespace
in interface Parser
public Parser setPreserveLeadingWhitespace(boolean preserveLeadingWhitespace)
Parser
true
.setPreserveLeadingWhitespace
in interface Parser
preserveLeadingWhitespace
- when true, the parser will preserve leading whitespace in each column when splitting a linepublic boolean isPreserveTrailingWhitespace()
Parser
false
.isPreserveTrailingWhitespace
in interface Parser
public Parser setPreserveTrailingWhitespace(boolean preserveTrailingWhitespace)
Parser
false
.setPreserveTrailingWhitespace
in interface Parser
preserveTrailingWhitespace
- when true, the parser will preserve trailing whitespace in each column when splitting a linepublic final DataSet parse()
Parser
public final StreamingDataSet parseAsStream()
Parser
parseAsStream
in interface Parser
public final Stream<Record> stream()
Parser
protected abstract DataSet doParse()
protected abstract void init()
protected void closeReaders() throws IOException
IOException
protected void addToCloseReaderList(Reader r)
protected void addToMetaData(List<ColumnMetaData> columns)
protected boolean isInitialised()
protected void setInitialised(boolean initialised)
protected String getDataDefinition()
protected void setDataDefinition(String dataDefinition)
protected void addError(DefaultDataSet ds, String errorDesc, int lineNo, int errorLevel, String lineData)
ds
- the data set from the parsererrorDesc
- String description of errorlineNo
- line number error occurred onerrorLevel
- errorLevel 1,2,3 1=warning 2=error 3= severe error'lineData
- Data of the line which failed the parseprotected void addError(DefaultDataSet ds, String errorDesc, int lineNo, int errorLevel, String lineData, String lastColName, String lastColValue)
ds
- the data set from the parsererrorDesc
- String description of errorlineNo
- line number error occurred onerrorLevel
- errorLevel 1,2,3 1=warning 2=error 3= severe error'lineData
- Data of the line which failed the parselastColName
- Column name which was the last one parsed successfully (in case of too few col)lastColValue
- value of the last Columnprotected Reader getDataSourceReader()
protected void setDataSourceReader(Reader dataSourceReader)
dataSourceReader
- the dataSourceReader to setpublic boolean isColumnNamesCaseSensitive()
Parser
isColumnNamesCaseSensitive
in interface Parser
public Parser setColumnNamesCaseSensitive(boolean columnNamesCaseSensitive)
Parser
setColumnNamesCaseSensitive
in interface Parser
columnNamesCaseSensitive
- when true, column names will have to be an exact match when
retrieving the value of a column. Example when true: Column
name = AColumnName ; getString("acolumnname") would fail
Example when false: Column name = AColumnName ;
getString("acolumnname") would passpublic boolean isIgnoreParseWarnings()
Parser
isIgnoreParseWarnings
in interface Parser
public Parser setIgnoreParseWarnings(boolean ignoreParseWarnings)
setIgnoreParseWarnings
in interface Parser
ignoreParseWarnings
- when true, warnings encountered during parsing will not be
included in the DataSet errorspublic boolean isNullEmptyStrings()
isNullEmptyStrings
in interface Parser
public Parser setNullEmptyStrings(boolean nullEmptyStrings)
setNullEmptyStrings
in interface Parser
nullEmptyStrings
- when true, empty Strings will get returned as NULL when
calling DataSet.getString()public MetaData getPzMetaData()
public void setPzMetaData(MetaData pzMap)
public boolean isFlagEmptyRows()
isFlagEmptyRows
in interface Parser
public Parser setFlagEmptyRows(boolean flagEmptyRows)
Parser
setFlagEmptyRows
in interface Parser
flagEmptyRows
- the flagEmptyRows to setpublic boolean isStoreRawDataToDataError()
isStoreRawDataToDataError
in interface Parser
public Parser setStoreRawDataToDataError(boolean storeRawDataToDataError)
Parser
setStoreRawDataToDataError
in interface Parser
storeRawDataToDataError
- the storeRawDataToDataError to setpublic boolean isStoreRawDataToDataSet()
isStoreRawDataToDataSet
in interface Parser
public Parser setStoreRawDataToDataSet(boolean storeRawDataToDataSet)
Parser
setStoreRawDataToDataSet
in interface Parser
storeRawDataToDataSet
- the storeRawDataToDataSet to setpublic String getDataFileTable()
Parser
getDataFileTable
in interface Parser
public Parser setDataFileTable(String dataFileTable)
Parser
setDataFileTable
in interface Parser
dataFileTable
- Name of the table name to use in place of "DATAFILE"public String getDataStructureTable()
Parser
getDataStructureTable
in interface Parser
public Parser setDataStructureTable(String dataStructureTable)
Parser
setDataStructureTable
in interface Parser
dataStructureTable
- Name of the table name to us in placfe of "DATASTRUCTURE"Copyright © 2006–2021 Appendium - Portfolio Financing Platform. All rights reserved.