net.sf.flatpack
Class AbstractParser

java.lang.Object
  extended by net.sf.flatpack.AbstractParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
AbstractDelimiterParser, AbstractFixedLengthParser

public abstract class AbstractParser
extends java.lang.Object
implements Parser

Author:
xhensevb, zepernick

Constructor Summary
protected AbstractParser(java.io.Reader dataSourceReader)
           
protected AbstractParser(java.io.Reader dataSourceReader, java.lang.String dataDefinition)
           
 
Method Summary
protected  void addError(DefaultDataSet ds, java.lang.String errorDesc, int lineNo, int errorLevel)
          Adds a new error to this DataSet.
protected  void addToCloseReaderList(java.io.Reader r)
           
protected  void addToMetaData(java.util.List columns)
           
protected  void closeReaders()
          Deprecated.  
protected abstract  DataSet doParse()
           
protected  java.lang.String getDataDefinition()
           
protected  java.io.Reader getDataSourceReader()
           
 MetaData getPzMetaData()
           
protected abstract  void init()
           
 boolean isColumnNamesCaseSensitive()
          Default is false
 boolean isHandlingShortLines()
           
 boolean isIgnoreExtraColumns()
           
 boolean isIgnoreParseWarnings()
          Default is false
protected  boolean isInitialised()
           
 boolean isNullEmptyStrings()
           
 DataSet parse()
          Start the parsing.
 void setColumnNamesCaseSensitive(boolean columnNamesCaseSensitive)
          Default is false
protected  void setDataDefinition(java.lang.String dataDefinition)
           
protected  void setDataSourceReader(java.io.Reader dataSourceReader)
           
 void setHandlingShortLines(boolean handleShortLines)
           
 void setIgnoreExtraColumns(boolean ignoreExtraColumns)
           
 void setIgnoreParseWarnings(boolean ignoreParseWarnings)
           
protected  void setInitialised(boolean initialised)
           
 void setNullEmptyStrings(boolean nullEmptyStrings)
           
 void setPzMetaData(MetaData pzMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParser

protected AbstractParser(java.io.Reader dataSourceReader)

AbstractParser

protected AbstractParser(java.io.Reader dataSourceReader,
                         java.lang.String dataDefinition)
Method Detail

isHandlingShortLines

public boolean isHandlingShortLines()
Specified by:
isHandlingShortLines in interface Parser
Returns:
true, lines with less columns then the amount of column headers will be added as empty's instead of producing an error

setHandlingShortLines

public void setHandlingShortLines(boolean handleShortLines)
Specified by:
setHandlingShortLines in interface Parser
Parameters:
handleShortLines - - when flaged as true, lines with less columns then the amount of column headers will be added as empty's instead of producing an error

isIgnoreExtraColumns

public boolean isIgnoreExtraColumns()
Specified by:
isIgnoreExtraColumns in interface Parser
Returns:
true, detail lines with a length or column count > the mapping definition will be truncated and the reader will NOT register these lines as erros in the DataError collection.

setIgnoreExtraColumns

public void setIgnoreExtraColumns(boolean ignoreExtraColumns)
Specified by:
setIgnoreExtraColumns in interface Parser
Parameters:
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 erros in the DataError collection.

parse

public final DataSet parse()
Description copied from interface: Parser
Start the parsing. Will return "null" if the parse fails and the DataSet cannot be created

Specified by:
parse in interface Parser
Returns:
the data set resulting from parsing

doParse

protected abstract DataSet doParse()

init

protected abstract void init()

closeReaders

protected void closeReaders()
                     throws java.io.IOException
Deprecated. 

Throws:
java.io.IOException

addToCloseReaderList

protected void addToCloseReaderList(java.io.Reader r)

addToMetaData

protected void addToMetaData(java.util.List columns)

isInitialised

protected boolean isInitialised()

setInitialised

protected void setInitialised(boolean initialised)

getDataDefinition

protected java.lang.String getDataDefinition()

setDataDefinition

protected void setDataDefinition(java.lang.String dataDefinition)

addError

protected void addError(DefaultDataSet ds,
                        java.lang.String errorDesc,
                        int lineNo,
                        int errorLevel)
Adds a new error to this DataSet. These can be collected, and retreived after processing

Parameters:
errorDesc - - String description of error
lineNo - - int line number error occured on
errorLevel - - int errorLevel 1,2,3 1=warning 2=error 3= severe error

getDataSourceReader

protected java.io.Reader getDataSourceReader()
Returns:
the dataSourceReader

setDataSourceReader

protected void setDataSourceReader(java.io.Reader dataSourceReader)
Parameters:
dataSourceReader - the dataSourceReader to set

isColumnNamesCaseSensitive

public boolean isColumnNamesCaseSensitive()
Description copied from interface: Parser
Default is false

Specified by:
isColumnNamesCaseSensitive in interface Parser
Returns:
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 pass

setColumnNamesCaseSensitive

public void setColumnNamesCaseSensitive(boolean columnNamesCaseSensitive)
Description copied from interface: Parser
Default is false

Specified by:
setColumnNamesCaseSensitive in interface Parser
Parameters:
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 pass

isIgnoreParseWarnings

public boolean isIgnoreParseWarnings()
Description copied from interface: Parser
Default is false

Specified by:
isIgnoreParseWarnings in interface Parser
Returns:
true, warnings encountered durring parsing will not be included in the DataSet errors

setIgnoreParseWarnings

public void setIgnoreParseWarnings(boolean ignoreParseWarnings)
Specified by:
setIgnoreParseWarnings in interface Parser
Parameters:
ignoreParseWarnings - when true, warnings encountered durring parsing will not be included in the DataSet errors

isNullEmptyStrings

public boolean isNullEmptyStrings()
Specified by:
isNullEmptyStrings in interface Parser
Returns:
true, empty Strings will get returned as NULL when calling DataSet.getString()

setNullEmptyStrings

public void setNullEmptyStrings(boolean nullEmptyStrings)
Specified by:
setNullEmptyStrings in interface Parser
Parameters:
nullEmptyStrings - when true, empty Strings will get returned as NULL when calling DataSet.getString()

getPzMetaData

public MetaData getPzMetaData()

setPzMetaData

public void setPzMetaData(MetaData pzMap)