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 ParseraddSuffixToDuplicateColumnNames - 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
FileNotFoundExceptionpublic boolean isHandlingShortLines()
isHandlingShortLines in interface Parserpublic Parser setHandlingShortLines(boolean handleShortLines)
setHandlingShortLines in interface ParserhandleShortLines - -
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 Parserpublic Parser setIgnoreExtraColumns(boolean ignoreExtraColumns)
setIgnoreExtraColumns in interface ParserignoreExtraColumns - 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()
Parsertrue.isPreserveLeadingWhitespace in interface Parserpublic Parser setPreserveLeadingWhitespace(boolean preserveLeadingWhitespace)
Parsertrue.setPreserveLeadingWhitespace in interface ParserpreserveLeadingWhitespace - when true, the parser will preserve leading whitespace in each column when splitting a linepublic boolean isPreserveTrailingWhitespace()
Parserfalse.isPreserveTrailingWhitespace in interface Parserpublic Parser setPreserveTrailingWhitespace(boolean preserveTrailingWhitespace)
Parserfalse.setPreserveTrailingWhitespace in interface ParserpreserveTrailingWhitespace - when true, the parser will preserve trailing whitespace in each column when splitting a linepublic final DataSet parse()
Parserpublic final StreamingDataSet parseAsStream()
ParserparseAsStream in interface Parserpublic final Stream<Record> stream()
Parserprotected abstract DataSet doParse()
protected abstract void init()
protected void closeReaders()
throws IOException
IOExceptionprotected 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()
ParserisColumnNamesCaseSensitive in interface Parserpublic Parser setColumnNamesCaseSensitive(boolean columnNamesCaseSensitive)
ParsersetColumnNamesCaseSensitive in interface ParsercolumnNamesCaseSensitive - 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()
ParserisIgnoreParseWarnings in interface Parserpublic Parser setIgnoreParseWarnings(boolean ignoreParseWarnings)
setIgnoreParseWarnings in interface ParserignoreParseWarnings - when true, warnings encountered during parsing will not be
included in the DataSet errorspublic boolean isNullEmptyStrings()
isNullEmptyStrings in interface Parserpublic Parser setNullEmptyStrings(boolean nullEmptyStrings)
setNullEmptyStrings in interface ParsernullEmptyStrings - 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 Parserpublic Parser setFlagEmptyRows(boolean flagEmptyRows)
ParsersetFlagEmptyRows in interface ParserflagEmptyRows - the flagEmptyRows to setpublic boolean isStoreRawDataToDataError()
isStoreRawDataToDataError in interface Parserpublic Parser setStoreRawDataToDataError(boolean storeRawDataToDataError)
ParsersetStoreRawDataToDataError in interface ParserstoreRawDataToDataError - the storeRawDataToDataError to setpublic boolean isStoreRawDataToDataSet()
isStoreRawDataToDataSet in interface Parserpublic Parser setStoreRawDataToDataSet(boolean storeRawDataToDataSet)
ParsersetStoreRawDataToDataSet in interface ParserstoreRawDataToDataSet - the storeRawDataToDataSet to setpublic String getDataFileTable()
ParsergetDataFileTable in interface Parserpublic Parser setDataFileTable(String dataFileTable)
ParsersetDataFileTable in interface ParserdataFileTable - Name of the table name to use in place of "DATAFILE"public String getDataStructureTable()
ParsergetDataStructureTable in interface Parserpublic Parser setDataStructureTable(String dataStructureTable)
ParsersetDataStructureTable in interface ParserdataStructureTable - Name of the table name to us in placfe of "DATASTRUCTURE"Copyright © 2006–2021 Appendium - Portfolio Financing Platform. All rights reserved.