From: <be...@us...> - 2006-10-27 14:06:44
|
Revision: 142 http://svn.sourceforge.net/pzfilereader/?rev=142&view=rev Author: benoitx Date: 2006-10-27 07:06:22 -0700 (Fri, 27 Oct 2006) Log Message: ----------- First cut at re-org to use Factory mechanisms. Converted 2 unit tests and they seem happy... Still using IDataSet for the interface. LargeSet not covered at this stage. Modified Paths: -------------- trunk/PZFileReader/.classpath trunk/PZFileReader/src/main/java/net/sf/pzfilereader/IDataSet.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/PZParserFactory.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/columninfile/DelimitedColumnNamesInFile.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/columninfile/DelimitedColumnNamesInFileTest.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/delim/tab/TabDelimited.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/delim/tab/TabDelimitedTest.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsLTrimTest.java trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java Added Paths: ----------- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBDelimiterPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBFixedLengthPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultDataSet.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultPZParserFactory.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DelimiterPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/FixedLengthPZParser.java trunk/PZFileReader/src/main/java/net/sf/pzfilereader/InitialisationException.java Modified: trunk/PZFileReader/.classpath =================================================================== --- trunk/PZFileReader/.classpath 2006-10-27 11:55:43 UTC (rev 141) +++ trunk/PZFileReader/.classpath 2006-10-27 14:06:22 UTC (rev 142) @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> - <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"></classpathentry> - <classpathentry excluding="" kind="src" path="src/main/java"></classpathentry> - <classpathentry output="target/test-classes" kind="src" path="src/test/java"></classpathentry> - <classpathentry path="MAVEN_REPO/junit/jars/junit-3.8.2.jar" kind="var"></classpathentry> - <classpathentry path="MAVEN_REPO/jdom/jars/jdom-1.0.jar" kind="var"></classpathentry> - <classpathentry path="MAVEN_REPO/jexcelapi/jars/jxl-2.4.2.jar" kind="var"></classpathentry> - <classpathentry kind="output" path="target/classes"></classpathentry> -</classpath> \ No newline at end of file + <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/> + <classpathentry path="src/main/java" kind="src"/> + <classpathentry path="src/test/java" output="target/test-classes" kind="src"/> + <classpathentry path="MAVEN_REPO/junit/jars/junit-3.8.2.jar" kind="var"/> + <classpathentry path="ECLIPSE_HOME/plugins/org.eclipse.hyades.test.tools.core_4.2.1.v200607310100/common.runner.jar" kind="var"/> + <classpathentry path="ECLIPSE_HOME/plugins/org.eclipse.hyades.test.tools.core_4.2.1.v200607310100/java.runner.jar" kind="var"/> + <classpathentry path="MAVEN_REPO/jdom/jars/jdom-1.0.jar" kind="var"/> + <classpathentry path="MAVEN_REPO/jexcelapi/jars/jxl-2.4.2.jar" kind="var"/> + <classpathentry path="target/classes" kind="output"/> +</classpath> Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,285 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; + +import net.sf.pzfilereader.structure.Row; +import net.sf.pzfilereader.util.PZConstants; +import net.sf.pzfilereader.util.ParserUtils; + +/** + * @author xhensevb + * + */ +public abstract class AbstractDelimiterPZParser extends AbstractPZParser { + private char delimiter = 0; + + private char qualifier = 0; + + private boolean ignoreFirstRecord = false; + + public AbstractDelimiterPZParser(InputStream dataSourceStream, String dataDefinition, char delimiter, char qualifier, + boolean ignoreFirstRecord) { + super(dataSourceStream, dataDefinition); + this.delimiter = delimiter; + this.qualifier = qualifier; + this.ignoreFirstRecord = ignoreFirstRecord; + } + + public AbstractDelimiterPZParser(File dataSource, char delimiter, char qualifier, boolean ignoreFirstRecord) { + super(dataSource); + this.delimiter = delimiter; + this.qualifier = qualifier; + this.ignoreFirstRecord = ignoreFirstRecord; + } + + public AbstractDelimiterPZParser(InputStream dataSourceStream, char delimiter, char qualifier, boolean ignoreFirstRecord) { + super(dataSourceStream); + this.delimiter = delimiter; + this.qualifier = qualifier; + this.ignoreFirstRecord = ignoreFirstRecord; + } + + public IDataSet doParse() { + try { + if (getDataSourceStream() != null) { + return doDelimitedFile(getDataSourceStream(), getDelimiter(), getQualifier(), isIgnoreFirstRecord(), shouldCreateMDFromFile()); + } else { + InputStream stream = null; + try { + stream = ParserUtils.createInputStream(getDataSource()); + return doDelimitedFile(stream, getDelimiter(), getQualifier(), isIgnoreFirstRecord(), shouldCreateMDFromFile()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (stream != null) { + stream.close(); + } + } + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + protected abstract boolean shouldCreateMDFromFile(); + + protected char getDelimiter() { + return delimiter; + } + + protected void setDelimiter(char delimiter) { + this.delimiter = delimiter; + } + + protected boolean isIgnoreFirstRecord() { + return ignoreFirstRecord; + } + + protected void setIgnoreFirstRecord(boolean ignoreFirstRecord) { + this.ignoreFirstRecord = ignoreFirstRecord; + } + + protected char getQualifier() { + return qualifier; + } + + protected void setQualifier(char qualifier) { + this.qualifier = qualifier; + } + + /* + * This is the new version of doDelimitedFile using InputStrem instead of + * File. This is more flexible especially it is working with WebStart. + * + * puts together the dataset for a DELIMITED file. This is used for PZ XML + * mappings, and SQL table mappings + */ + private IDataSet doDelimitedFile(final InputStream dataSource, final char delimiter, final char qualifier, + final boolean ignoreFirstRecord, final boolean createMDFromFile) throws IOException, Exception { + if (dataSource == null) { + throw new NullPointerException("dataSource is null"); + } + + InputStreamReader isr = null; + BufferedReader br = null; + DefaultDataSet ds = new DefaultDataSet(getColumnMD()); + try { + // get the total column count + // columnCount = columnMD.size(); + + /** Read in the flat file */ + // fr = new FileReader(dataSource.getAbsolutePath()); + isr = new InputStreamReader(dataSource); + br = new BufferedReader(isr); + + boolean processedFirst = false; + boolean processingMultiLine = false; + int lineCount = 0; + String lineData = ""; + /** loop through each line in the file */ + String line = null; + while ((line = br.readLine()) != null) { + lineCount++; + /** empty line skip past it */ + String trimmed = line.trim(); + if (!processingMultiLine && trimmed.length() == 0) { + continue; + } + + // check to see if the user has elected to skip the first record + if (!processedFirst && ignoreFirstRecord) { + processedFirst = true; + continue; + } else if (!processedFirst && createMDFromFile) { + processedFirst = true; + setColumnMD(ParserUtils.getColumnMDFromFile(line, delimiter, qualifier)); + ds.setColumnMD(getColumnMD()); + continue; + } + + // ******************************************************** + // new functionality as of 2.1.0 check to see if we have + // any line breaks in the middle of the record, this will only + // be checked if we have specified a delimiter + // ******************************************************** + final char[] chrArry = trimmed.toCharArray(); + if (!processingMultiLine && delimiter > 0) { + processingMultiLine = ParserUtils.isMultiLine(chrArry, delimiter, qualifier); + } + + // check to see if we have reached the end of the linebreak in + // the record + + final String trimmedLineData = lineData.trim(); + if (processingMultiLine && trimmedLineData.length() > 0) { + // need to do one last check here. it is possible that the " + // could be part of the data + // excel will escape these with another quote; here is some + // data "" This would indicate + // there is more to the multiline + if (trimmed.charAt(trimmed.length() - 1) == qualifier && !trimmed.endsWith("" + qualifier + qualifier)) { + // it is safe to assume we have reached the end of the + // line break + processingMultiLine = false; + if (trimmedLineData.length() > 0) { // + would always be + // true surely.... + lineData += "\r\n"; + } + lineData += line; + } else { + // check to see if this is the last line of the record + // looking for a qualifier followed by a delimiter + if (trimmedLineData.length() > 0) { // + here again, + // this should + // always be true... + lineData += "\r\n"; + } + lineData += line; + boolean qualiFound = false; + for (int i = 0; i < chrArry.length; i++) { + if (qualiFound) { + if (chrArry[i] == ' ') { + continue; + } else { + // not a space, if this char is the + // delimiter, then we have reached the end + // of + // the record + if (chrArry[i] == delimiter) { + // processingMultiLine = false; + // fix put in, setting to false caused + // bug when processing multiple + // multi-line + // columns on the same record + processingMultiLine = ParserUtils.isMultiLine(chrArry, delimiter, qualifier); + break; + } + qualiFound = false; + continue; + } + } else if (chrArry[i] == qualifier) { + qualiFound = true; + } + } + // check to see if we are still in multi line mode, if + // so grab the next line + if (processingMultiLine) { + continue; + } + } + } else { + // throw the line into lineData var. + lineData += line; + if (processingMultiLine) { + continue; // if we are working on a multiline rec, get + // the data on the next line + } + } + // ******************************************************************** + // end record line break logic + // ******************************************************************** + + // column values + final List columns = ParserUtils.splitLine(lineData, delimiter, qualifier); + lineData = ""; + final String mdkey = ParserUtils.getCMDKeyForDelimitedFile(getColumnMD(), columns); + final List cmds = ParserUtils.getColumnMetaData(mdkey, getColumnMD()); + final int columnCount = cmds.size(); + // DEBUG + + // Incorrect record length on line log the error. Line + // will not be included in the dataset + if (columns.size() > columnCount) { + // log the error + addError(ds, "TOO MANY COLUMNS WANTED: " + columnCount + " GOT: " + columns.size(), lineCount, 2); + continue; + } else if (columns.size() < columnCount) { + if (isHandlingShortLines()) { + // We can pad this line out + while (columns.size() < columnCount) { + columns.add(""); + } + + // log a warning + addError(ds, "PADDED LINE TO CORRECT NUMBER OF COLUMNS", lineCount, 1); + + } else { + addError(ds, "TOO FEW COLUMNS WANTED: " + columnCount + " GOT: " + columns.size(), lineCount, 2); + continue; + } + } + + final Row row = new Row(); + row.setMdkey(mdkey.equals(PZConstants.DETAIL_ID) ? null : mdkey); // try + // to limit the memory use + row.setCols(columns); + row.setRowNumber(lineCount); + /** add the row to the array */ + ds.addRow(row); + } + } finally { + if (isr != null) { + isr.close(); + } + if (br != null) { + br.close(); + } + } + return ds; + } +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,154 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; +import java.util.Map; + +import net.sf.pzfilereader.structure.Row; +import net.sf.pzfilereader.util.FixedWidthParserUtils; +import net.sf.pzfilereader.util.PZConstants; +import net.sf.pzfilereader.util.ParserUtils; + +/** + * @author xhensevb + * + */ +public abstract class AbstractFixedLengthPZParser extends AbstractPZParser { + + protected AbstractFixedLengthPZParser(File dataSource, String dataDefinition) { + super(dataSource, dataDefinition); + } + + protected AbstractFixedLengthPZParser(File dataSource) { + super(dataSource); + } + + protected AbstractFixedLengthPZParser(InputStream dataSourceStream, String dataDefinition) { + super(dataSourceStream, dataDefinition); + } + + protected AbstractFixedLengthPZParser(InputStream dataSourceStream) { + super(dataSourceStream); + } + + public IDataSet doParse() { + try { + if (getDataSourceStream() != null) { + return doFixedLengthFile(getDataSourceStream()); + } else { + InputStream stream; + stream = ParserUtils.createInputStream(getDataSource()); + try { + return doFixedLengthFile(stream); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (stream != null) { + stream.close(); + } + } + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /* + * This is the new version of doDelimitedFile using InputStrem instead of + * File. This is more flexible especially it is working with WebStart. + * + * puts together the dataset for fixed length file. This is used for PZ XML + * mappings, and SQL table mappings + */ + private IDataSet doFixedLengthFile(final InputStream dataSource) throws IOException { + InputStreamReader isr = null; + BufferedReader br = null; + + DefaultDataSet ds = new DefaultDataSet(getColumnMD()); + + try { + final Map recordLengths = ParserUtils.calculateRecordLengths(getColumnMD()); + + // Read in the flat file + isr = new InputStreamReader(dataSource); + br = new BufferedReader(isr); + String line = null; + int lineCount = 0; + // map of record lengths corrisponding to the ID's in the columnMD + // array + // loop through each line in the file + while ((line = br.readLine()) != null) { + lineCount++; + // empty line skip past it + if (line.trim().length() == 0) { + continue; + } + + final String mdkey = FixedWidthParserUtils.getCMDKey(getColumnMD(), line); + final int recordLength = ((Integer) recordLengths.get(mdkey)).intValue(); + + // Incorrect record length on line log the error. Line will not + // be included in the + // dataset + if (line.length() > recordLength) { + addError(ds, "LINE TOO LONG. LINE IS " + line.length() + " LONG. SHOULD BE " + recordLength, lineCount, 2); + continue; + } else if (line.length() < recordLength) { + if (isHandlingShortLines()) { + // We can pad this line out + line += ParserUtils.padding(recordLength - line.length(), ' '); + + // log a warning + addError(ds, "PADDED LINE TO CORRECT RECORD LENGTH", lineCount, 1); + + } else { + addError(ds, "LINE TOO SHORT. LINE IS " + line.length() + " LONG. SHOULD BE " + recordLength, lineCount, + 2); + continue; + } + } + + // int recPosition = 1; + final Row row = new Row(); + row.setMdkey(mdkey.equals(PZConstants.DETAIL_ID) ? null : mdkey); // try + + final List cmds = ParserUtils.getColumnMetaData(mdkey, getColumnMD()); + row.addColumn(FixedWidthParserUtils.splitFixedText(cmds, line)); + // to limit the memory use + // Build the columns for the row + // for (int i = 0; i < cmds.size(); i++) { + // final String tempValue = line.substring(recPosition - 1, + // recPosition + // + (((ColumnMetaData) cmds.get(i)).getColLength() - 1)); + // recPosition += ((ColumnMetaData) cmds.get(i)).getColLength(); + // row.addColumn(tempValue.trim()); + // } + row.setRowNumber(lineCount); + // add the row to the array + ds.addRow(row); + } + } finally { + if (isr != null) { + isr.close(); + } + if (br != null) { + br.close(); + } + } + return ds; + } +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,140 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.File; +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author xhensevb + * + */ +public abstract class AbstractPZParser implements PZParser { + + private boolean handlingShortLines = false; + + private boolean initialised = false; + + /** Map of column metadata's */ + private Map columnMD = null; + + private String dataDefinition = null; + + private InputStream dataSourceStream = null; + + private File dataSource = null; + + protected AbstractPZParser(File dataSource) { + this.dataSource = dataSource; + } + + protected AbstractPZParser(InputStream dataSourceStream) { + this.dataSourceStream = dataSourceStream; + } + + protected AbstractPZParser(File dataSource, String dataDefinition) { + this.dataSource = dataSource; + this.dataDefinition = dataDefinition; + } + + protected AbstractPZParser(InputStream dataSourceStream, String dataDefinition) { + this.dataSourceStream = dataSourceStream; + this.dataDefinition = dataDefinition; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParser#isHandlingShortLines() + */ + public boolean isHandlingShortLines() { + return handlingShortLines; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParser#setHandlingShortLines(boolean) + */ + public void setHandlingShortLines(boolean handleShortLines) { + this.handlingShortLines = handleShortLines; + } + + public final IDataSet parse() { + if (!initialised) { + init(); + } + return doParse(); + } + + protected abstract IDataSet doParse(); + + protected abstract void init(); + + protected void setColumnMD(final Map map) { + columnMD = map; + } + + protected void addToColumnMD(final Object key, final Object value) { + if (columnMD == null) { + columnMD = new LinkedHashMap(); + } + columnMD.put(key, value); + } + + protected boolean isInitialised() { + return initialised; + } + + protected void setInitialised(boolean initialised) { + this.initialised = initialised; + } + + protected String getDataDefinition() { + return dataDefinition; + } + + protected void setDataDefinition(String dataDefinition) { + this.dataDefinition = dataDefinition; + } + + protected File getDataSource() { + return dataSource; + } + + protected void setDataSource(File dataSource) { + this.dataSource = dataSource; + } + + protected InputStream getDataSourceStream() { + return dataSourceStream; + } + + protected void setDataSourceStream(InputStream dataSourceStream) { + this.dataSourceStream = dataSourceStream; + } + + protected Map getColumnMD() { + return columnMD; + } + + /** + * Adds a new error to this DataSet. These can be collected, and retreived + * after processing + * + * @param errorDesc - + * String description of error + * @param lineNo - + * int line number error occured on + * @param errorLevel - + * int errorLevel 1,2,3 1=warning 2=error 3= severe error + */ + protected void addError(final DefaultDataSet ds, final String errorDesc, final int lineNo, final int errorLevel) { + final DataError de = new DataError(errorDesc,lineNo,errorLevel); + ds.addError(de); + } + +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBDelimiterPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBDelimiterPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBDelimiterPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,100 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import net.sf.pzfilereader.structure.ColumnMetaData; +import net.sf.pzfilereader.util.PZConstants; +import net.sf.pzfilereader.util.ParserUtils; + +/** + * @author xhensevb + * + */ +public class DBDelimiterPZParser extends AbstractDelimiterPZParser { + + private Connection con; + + public DBDelimiterPZParser(Connection con, InputStream dataSourceStream, String dataDefinition, char delimiter, + char qualifier, boolean ignoreFirstRecord) { + super(dataSourceStream, dataDefinition, delimiter, qualifier, ignoreFirstRecord); + this.con = con; + } + + protected void init() { + ResultSet rs = null; + PreparedStatement stmt = null; + + try { + final String sql = "SELECT * FROM DATAFILE INNER JOIN DATASTRUCTURE ON " + + "DATAFILE.DATAFILE_NO = DATASTRUCTURE.DATAFILE_NO " + "WHERE DATAFILE.DATAFILE_DESC = '" + + getDataDefinition() + "' " + "ORDER BY DATASTRUCTURE_COL_ORDER"; + + stmt = con.prepareStatement(sql); // always use PreparedStatement + // as the DB can do clever things. + rs = stmt.executeQuery(); + + int recPosition = 1; + final List cmds = new ArrayList(); + // put array of columns together. These will be used to put together + // the dataset when reading in the file + while (rs.next()) { + + final ColumnMetaData column = new ColumnMetaData(); + column.setColName(rs.getString("DATASTRUCTURE_COLUMN")); + column.setColLength(rs.getInt("DATASTRUCTURE_LENGTH")); + column.setStartPosition(recPosition); + column.setEndPosition(recPosition + (rs.getInt("DATASTRUCTURE_LENGTH") - 1)); + recPosition += rs.getInt("DATASTRUCTURE_LENGTH"); + + cmds.add(column); + } + + addToColumnMD(PZConstants.DETAIL_ID, cmds); + addToColumnMD(PZConstants.COL_IDX, ParserUtils.buidColumnIndexMap(cmds)); + + if (cmds.isEmpty()) { + throw new FileNotFoundException("DATA DEFINITION CAN NOT BE FOUND IN THE DATABASE " + getDataDefinition()); + } + + // read in the fixed length file and construct the DataSet object + // doFixedLengthFile(dataSourceStream); + setInitialised(true); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public IDataSet doParse() { + return null; + } + + protected boolean shouldCreateMDFromFile() { + return true; + } +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBFixedLengthPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBFixedLengthPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DBFixedLengthPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,101 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import net.sf.pzfilereader.structure.ColumnMetaData; +import net.sf.pzfilereader.util.PZConstants; +import net.sf.pzfilereader.util.ParserUtils; + +/** + * @author xhensevb + * + */ +public class DBFixedLengthPZParser extends AbstractFixedLengthPZParser { + + private Connection con; + + public DBFixedLengthPZParser(final Connection con, final InputStream dataSourceStream, final String dataDefinition) { + super(dataSourceStream, dataDefinition); + this.con = con; + } + + public DBFixedLengthPZParser(Connection con, File dataSource, String dataDefinition) { + super(dataSource, dataDefinition); + this.con = con; + } + + protected void init() { + ResultSet rs = null; + PreparedStatement stmt = null; + + try { + final String sql = "SELECT * FROM DATAFILE INNER JOIN DATASTRUCTURE ON " + + "DATAFILE.DATAFILE_NO = DATASTRUCTURE.DATAFILE_NO " + "WHERE DATAFILE.DATAFILE_DESC = '" + + getDataDefinition() + "' " + "ORDER BY DATASTRUCTURE_COL_ORDER"; + + stmt = con.prepareStatement(sql); // always use PreparedStatement + // as the DB can do clever things. + rs = stmt.executeQuery(); + + int recPosition = 1; + final List cmds = new ArrayList(); + // put array of columns together. These will be used to put together + // the dataset when reading in the file + while (rs.next()) { + + final ColumnMetaData column = new ColumnMetaData(); + column.setColName(rs.getString("DATASTRUCTURE_COLUMN")); + column.setColLength(rs.getInt("DATASTRUCTURE_LENGTH")); + column.setStartPosition(recPosition); + column.setEndPosition(recPosition + (rs.getInt("DATASTRUCTURE_LENGTH") - 1)); + recPosition += rs.getInt("DATASTRUCTURE_LENGTH"); + + cmds.add(column); + } + + addToColumnMD(PZConstants.DETAIL_ID, cmds); + addToColumnMD(PZConstants.COL_IDX, ParserUtils.buidColumnIndexMap(cmds)); + + if (cmds.isEmpty()) { + throw new FileNotFoundException("DATA DEFINITION CAN NOT BE FOUND IN THE DATABASE " + getDataDefinition()); + } + + // read in the fixed length file and construct the DataSet object + // doFixedLengthFile(dataSourceStream); + setInitialised(true); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (stmt != null) { + stmt.close(); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public IDataSet doParse() { + return null; + } +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultDataSet.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultDataSet.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultDataSet.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,426 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import net.sf.pzfilereader.ordering.OrderBy; +import net.sf.pzfilereader.structure.ColumnMetaData; +import net.sf.pzfilereader.structure.Row; +import net.sf.pzfilereader.util.PZConstants; +import net.sf.pzfilereader.util.ParserUtils; + +/** + * @author xhensevb + * + */ +public class DefaultDataSet implements IDataSet { + private List rows = new ArrayList(); + + private List errors = new ArrayList(); + + /** Pointer for the current row in the array we are on */ + private int pointer = -1; + + /** flag to indicate if data should be pulled as lower case */ + private boolean lowerCase = false; + + /** flag to inidicate if data should be pulled as upper case */ + private boolean upperCase = false; + + /** + * flag to indicate if a strict parse should be used when getting doubles + * and ints + */ + private boolean strictNumericParse = false; + + private Map columnMD; + + public DefaultDataSet(Map columnMD2) { + this.columnMD = columnMD2; + } + + public void addRow(Row row) { + rows.add(row); + } + + public void addError(DataError dataError) { + errors.add(dataError); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getColumns() + */ + public String[] getColumns() { + ColumnMetaData column = null; + String[] array = null; + + if (columnMD != null) { + final List cmds = ParserUtils.getColumnMetaData(PZConstants.DETAIL_ID, columnMD); + + array = new String[cmds.size()]; + for (int i = 0; i < cmds.size(); i++) { + column = (ColumnMetaData) cmds.get(i); + array[i] = column.getColName(); + } + } + + return array; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getColumns(java.lang.String) + */ + public String[] getColumns(String recordID) { + String[] array = null; + + if (columnMD != null) { + final List cmds = ParserUtils.getColumnMetaData(recordID, columnMD); + array = new String[cmds.size()]; + for (int i = 0; i < cmds.size(); i++) { + final ColumnMetaData column = (ColumnMetaData) cmds.get(i); + array[i] = column.getColName(); + } + } + + return array; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getDate(java.lang.String) + */ + public Date getDate(String column) throws ParseException { + final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + final Row row = (Row) rows.get(pointer); + final String s = row.getValue(ParserUtils.getColumnIndex(row.getMdkey(), columnMD, column)); + return sdf.parse(s); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getDate(java.lang.String, + * java.text.SimpleDateFormat) + */ + public Date getDate(String column, SimpleDateFormat sdf) throws ParseException { + final Row row = (Row) rows.get(pointer); + final String s = row.getValue(ParserUtils.getColumnIndex(row.getMdkey(), columnMD, column)); + return sdf.parse(s); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getDouble(java.lang.String) + */ + public double getDouble(String column) { + final StringBuffer newString = new StringBuffer(); + final Row row = (Row) rows.get(pointer); + + final String s = row.getValue(ParserUtils.getColumnIndex(row.getMdkey(), columnMD, column)); + + if (!strictNumericParse) { + if (s.trim().length() == 0) { + return 0; + } + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (c >= '0' && c <= '9' || c == '.' || c == '-') { + newString.append(c); + } + } + if (newString.length() == 0 || (newString.length() == 1 && newString.toString().equals(".")) + || (newString.length() == 1 && newString.toString().equals("-"))) { + newString.append("0"); + } + } else { + newString.append(s); + } + + return Double.parseDouble(newString.toString()); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getErrorCount() + */ + public int getErrorCount() { + if (getErrors() != null) { + return getErrors().size(); + } + + return 0; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getErrors() + */ + public List getErrors() { + return errors; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getIndex() + */ + public int getIndex() { + return pointer; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getInt(java.lang.String) + */ + public int getInt(String column) { + final StringBuffer newString = new StringBuffer(); + final Row row = (Row) rows.get(pointer); + final String s = row.getValue(ParserUtils.getColumnIndex(row.getMdkey(), columnMD, column)); + + if (!strictNumericParse) { + if (s.trim().length() == 0) { + return 0; + } + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (c >= '0' && c <= '9' || c == '-') { + newString.append(c); + } + } + // check to make sure we do not have a single length string with + // just a minus sign + if (newString.length() == 0 || (newString.length() == 1 && newString.toString().equals("-"))) { + newString.append("0"); + } + } else { + newString.append(s); + } + + return Integer.parseInt(newString.toString()); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getRowCount() + */ + public int getRowCount() { + return rows.size(); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getRowNo() + */ + public int getRowNo() { + return ((Row) rows.get(pointer)).getRowNumber(); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getRows() + */ + public List getRows() { + return rows; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#getString(java.lang.String) + */ + public String getString(String column) { + final Row row = (Row) rows.get(pointer); + final String s = row.getValue(ParserUtils.getColumnIndex(row.getMdkey(), columnMD, column)); + + if (upperCase) { + // convert data to uppercase before returning + // return row.getValue(ParserUtils.findColumn(column, + // cmds)).toUpperCase(Locale.getDefault()); + return s.toUpperCase(Locale.getDefault()); + } + + if (lowerCase) { + // convert data to lowercase before returning + // return row.getValue(ParserUtils.findColumn(column, + // cmds)).toLowerCase(Locale.getDefault()); + return s.toLowerCase(Locale.getDefault()); + } + + // return value as how it is in the file + return s; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#goBottom() + */ + public void goBottom() { + pointer = rows.size() - 1; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#goTop() + */ + public void goTop() { + pointer = -1; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#isAnError(int) + */ + public boolean isAnError(int lineNo) { + for (int i = 0; i < errors.size(); i++) { + if (((DataError) errors.get(i)).getLineNo() == lineNo && ((DataError) errors.get(i)).getErrorLevel() > 1) { + return true; + } + } + return false; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#next() + */ + public boolean next() { + if (pointer < rows.size() && pointer + 1 != rows.size()) { + pointer++; + return true; + } + return false; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#orderRows(net.sf.pzfilereader.ordering.OrderBy) + */ + public void orderRows(OrderBy ob) throws Exception { + // PZ try to handle other <records> by sending them to + // the bottom of the sort + // if (columnMD.size() > 1) { + // throw new Exception("orderRows does not currently support ordering + // with <RECORD> mappings"); + // } + if (ob != null && rows != null) { + final List cmds = ParserUtils.getColumnMetaData(PZConstants.DETAIL_ID, columnMD); + ob.setColumnMD(cmds); + Collections.sort(rows, ob); + goTop(); + } + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#previous() + */ + public boolean previous() { + if (pointer <= 0) { + return false; + } + pointer--; + return true; + } + + /** + * Sets data in the DataSet to lowercase + */ + public void setLowerCase() { + upperCase = false; + lowerCase = true; + } + + /** + * Sets data in the DataSet to uppercase + */ + public void setUpperCase() { + upperCase = true; + lowerCase = false; + } + + /** + * Checks to see if the row has the given <RECORD> id + * + * @param recordID + * @return boolean + */ + public boolean isRecordID(final String recordID) { + String rowID = ((Row) rows.get(pointer)).getMdkey(); + if (rowID == null) { + rowID = PZConstants.DETAIL_ID; + } + + return rowID.equals(recordID); + } + + /** + * Sets the absolute position of the record pointer + * + * @param localPointer - + * int + * @exception IndexOutOfBoundsException + */ + public void absolute(final int localPointer) { + if (localPointer < 0 || localPointer > rows.size() - 1) { + throw new IndexOutOfBoundsException("INVALID POINTER LOCATION: " + localPointer); + } + + pointer = localPointer; + } + + /** + * Setting this to True will parse text as is and throw a + * NumberFormatException. Setting to false, which is the default, will + * remove any non numeric charcter from the field. The remaining numeric + * chars's will be returned. If it is an empty string,or there are no + * numeric chars, 0 will be returned for getInt() and getDouble() + * + * @param strictNumericParse + * The strictNumericParse to set. + */ + public void setStrictNumericParse(final boolean strictNumericParse) { + this.strictNumericParse = strictNumericParse; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.IDataSet#remove() + */ + public void remove() { + rows.remove(pointer); + pointer--; + } + + void setColumnMD(Map columnMD) { + this.columnMD = columnMD; + } + +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultPZParserFactory.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultPZParserFactory.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DefaultPZParserFactory.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,142 @@ +/* + * ObjectLab, http://www.objectlab.co.uk/open is supporting PZFileReader. + * + * Based in London, we are world leaders in the design and development + * of bespoke applications for the securities financing markets. + * + * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a> + * ___ _ _ _ _ _ + * / _ \| |__ (_) ___ ___| |_| | __ _| |__ + * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ + * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | + * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ + * |__/ + * + * www.ObjectLab.co.uk + * + * $Id: ColorProvider.java 74 2006-10-24 22:19:05Z benoitx $ + * + * Copyright 2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.pzfilereader; + +import java.io.File; +import java.io.InputStream; +import java.sql.Connection; + +/** + * @author xhensevb + * + */ +public class DefaultPZParserFactory implements PZParserFactory { + private static final DefaultPZParserFactory INSTANCE = new DefaultPZParserFactory(); + + public static PZParserFactory getInstance() { + return INSTANCE; + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newFixedWidthParser(java.sql.Connection, + * java.io.File, java.lang.String) + */ + public PZParser newFixedLengthParser(Connection con, File dataSource, String dataDefinition) { + return new DBFixedLengthPZParser(con, dataSource, dataDefinition); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newFixedWidthParser(java.sql.Connection, + * java.io.InputStream, java.lang.String) + */ + public PZParser newFixedLengthParser(Connection con, InputStream dataSourceStream, String dataDefinition) { + return new DBFixedLengthPZParser(con, dataSourceStream, dataDefinition); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.File, + * java.io.File) + */ + public PZParser newFixedLengthParser(File pzmapXML, File dataSource) { + return new FixedLengthPZParser(pzmapXML, dataSource); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.InputStream, + * java.io.InputStream) + */ + public PZParser newFixedLengthParser(InputStream pzmapXMLStream, InputStream dataSourceStream) { + return new FixedLengthPZParser(pzmapXMLStream, dataSourceStream); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.sql.Connection, + * java.io.InputStream, java.lang.String, char, char, boolean) + */ + public PZParser newDelimitedParser(Connection con, InputStream dataSourceStream, String dataDefinition, char delimiter, + char qualifier, boolean ignoreFirstRecord) { + return new DBDelimiterPZParser(con, dataSourceStream, dataDefinition, delimiter, qualifier, ignoreFirstRecord); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.File, + * java.io.File, char, char, boolean) + */ + public PZParser newDelimitedParser(File pzmapXML, File dataSource, char delimiter, char qualifier, boolean ignoreFirstRecord) { + return new DelimiterPZParser(pzmapXML, dataSource, delimiter, qualifier, ignoreFirstRecord); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.InputStream, + * java.io.InputStream, char, char, boolean) + */ + public PZParser newDelimitedParser(InputStream pzmapXMLStream, InputStream dataSourceStream, char delimiter, char qualifier, + boolean ignoreFirstRecord) { + return new DelimiterPZParser(pzmapXMLStream, dataSourceStream, delimiter, qualifier, ignoreFirstRecord); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.File, char, + * char) + */ + public PZParser newDelimitedParser(File dataSource, char delimiter, char qualifier) { + return new DelimiterPZParser(dataSource, delimiter, qualifier, false); + } + + /* + * (non-Javadoc) + * + * @see net.sf.pzfilereader.PZParserFactory#newParser(java.io.InputStream, + * char, char) + */ + public PZParser newDelimitedParser(InputStream dataSourceStream, char delimiter, char qualifier) { + return new DelimiterPZParser(dataSourceStream, delimiter, qualifier, false); + } + +} Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DelimiterPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DelimiterPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/DelimiterPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,68 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import net.sf.pzfilereader.util.ParserUtils; +import net.sf.pzfilereader.xml.PZMapParser; + +import org.jdom.JDOMException; + +/** + * @author xhensevb + * + */ +public class DelimiterPZParser extends AbstractDelimiterPZParser { + private InputStream pzmapXMLStream = null; + + private File pzmapXML = null; + + public DelimiterPZParser(File pzmapXML, File dataSource, char delimiter, char qualifier, boolean ignoreFirstRecord) { + super(dataSource, delimiter, qualifier, ignoreFirstRecord); + this.pzmapXML = pzmapXML; + } + + public DelimiterPZParser(InputStream pzmapXMLStream, InputStream dataSourceStream, char delimiter, char qualifier, + boolean ignoreFirstRecord) { + super(dataSourceStream, delimiter, qualifier, ignoreFirstRecord); + this.pzmapXMLStream = pzmapXMLStream; + } + + public DelimiterPZParser(File dataSource, char delimiter, char qualifier, boolean ignoreFirstRecord) { + super(dataSource, delimiter, qualifier, ignoreFirstRecord); + } + + public DelimiterPZParser(InputStream dataSourceStream, char delimiter, char qualifier, boolean ignoreFirstRecord) { + super(dataSourceStream, delimiter, qualifier, ignoreFirstRecord); + } + + protected void init() throws InitialisationException { + try { + if (pzmapXMLStream != null) { + setColumnMD(PZMapParser.parse(pzmapXMLStream)); + } else if (pzmapXML != null) { + InputStream stream = ParserUtils.createInputStream(pzmapXML); + try { + setColumnMD(PZMapParser.parse(stream)); + } finally { + if (stream != null) { + stream.close(); + } + } + } + setInitialised(true); + } catch (JDOMException e) { + throw new InitialisationException(e); + } catch (IOException e) { + throw new InitialisationException(e); + } + } + + protected boolean shouldCreateMDFromFile() { + return pzmapXML == null && pzmapXMLStream == null; + } +} \ No newline at end of file Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/FixedLengthPZParser.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/FixedLengthPZParser.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/FixedLengthPZParser.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,54 @@ +/** + * + */ +package net.sf.pzfilereader; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import net.sf.pzfilereader.util.ParserUtils; +import net.sf.pzfilereader.xml.PZMapParser; + +import org.jdom.JDOMException; + +/** + * @author xhensevb + * + */ +public class FixedLengthPZParser extends AbstractFixedLengthPZParser { + private InputStream pzmapXMLStream; + + private File pzmapXML; + + public FixedLengthPZParser(final InputStream pzmapXMLStream, final InputStream dataSourceStream) { + super(dataSourceStream); + this.pzmapXMLStream = pzmapXMLStream; + } + + public FixedLengthPZParser(File pzmapXML, File dataSource) { + super(dataSource); + this.pzmapXML = pzmapXML; + } + + protected void init() throws InitialisationException { + try { + if (pzmapXMLStream != null) { + setColumnMD(PZMapParser.parse(pzmapXMLStream)); + } else { + InputStream stream = ParserUtils.createInputStream(pzmapXML); + try { + setColumnMD(PZMapParser.parse(stream)); + } finally { + if (stream != null) { + stream.close(); + } + } + } + } catch (JDOMException e) { + throw new InitialisationException(e); + } catch (IOException e) { + throw new InitialisationException(e); + } + } +} Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/IDataSet.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/IDataSet.java 2006-10-27 11:55:43 UTC (rev 141) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/IDataSet.java 2006-10-27 14:06:22 UTC (rev 142) @@ -219,4 +219,42 @@ List getRows(); + /** + * Sets data in the DataSet to lowercase + */ + void setLowerCase(); + + /** + * Sets data in the DataSet to uppercase + */ + void setUpperCase(); + + /** + * Checks to see if the row has the given <RECORD> id + * + * @param recordID + * @return boolean + */ + boolean isRecordID(final String recordID); + + /** + * Sets the absolute position of the record pointer + * + * @param localPointer - + * int + * @exception IndexOutOfBoundsException + */ + void absolute(final int localPointer); + + /** + * Setting this to True will parse text as is and throw a + * NumberFormatException. Setting to false, which is the default, will + * remove any non numeric charcter from the field. The remaining numeric + * chars's will be returned. If it is an empty string,or there are no + * numeric chars, 0 will be returned for getInt() and getDouble() + * + * @param strictNumericParse + * The strictNumericParse to set. + */ + void setStrictNumericParse(final boolean strictNumericParse); } \ No newline at end of file Added: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/InitialisationException.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/InitialisationException.java (rev 0) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/InitialisationException.java 2006-10-27 14:06:22 UTC (rev 142) @@ -0,0 +1,40 @@ +/** + * + */ +package net.sf.pzfilereader; + +/** + * @author xhensevb + * + */ +public class InitialisationException extends RuntimeException { + private static final long serialVersionUID = -4181701730609348676L; + + /** + * + */ + public InitialisationException() { + } + + /** + * @param message + */ + public InitialisationException(String message) { + super(message); + } + + /** + * @param cause + */ + public InitialisationException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public InitialisationException(String message, Throwable cause) { + super(message, cause); + } +} Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/PZParserFactory.java =================================================================== --- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/PZParserFactory.java 2006-10-27 11:55:43 UTC (rev 141) +++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/PZParserFactory.java 2006-10-27 14:06:22 UTC (rev 142) @@ -137,7 +137,7 @@ * @param ignoreFirstRecord - * skips the first line that contains data in the file */ - PZParser newParser(final Connection con, final InputStream dataSourceStream, final String dataDefinition, + PZParser newDelimitedParser(final Connection con, final InputStream dataSourceStream, final String dataDefinition, final char delimiter, final char qualifier, final boolean ignoreFirstRecord); /** @@ -160,7 +160,7 @@ * @param ignoreFirstRecord - * skips the first line that contains data in the file */ - PZParser newParser(final File pzmapXML, final File dataSource, final char delimiter, final char qualifier, + PZParser newDelimitedParser(final File pzmapXML, final File dataSource, final char delimiter, final char qualifier, ... [truncated message content] |