|
From: <zep...@us...> - 2006-12-24 17:53:36
|
Revision: 254
http://svn.sourceforge.net/pzfilereader/?rev=254&view=rev
Author: zepernick
Date: 2006-12-24 09:53:35 -0800 (Sun, 24 Dec 2006)
Log Message:
-----------
added SLF4J logging...
Benoit,
I will follow up with an email with some of the details of the logger.
It is pretty simplistic.
Paul
Modified 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/brparse/BuffReaderDelimPZParser.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderFixedPZParser.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderPZDataSet.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/ResolveLocalDTD.java
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractDelimiterPZParser.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -39,6 +39,9 @@
import java.io.InputStreamReader;
import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.pzfilereader.structure.Row;
import net.sf.pzfilereader.util.PZConstants;
import net.sf.pzfilereader.util.ParserUtils;
@@ -55,7 +58,9 @@
private boolean ignoreFirstRecord = false;
private int lineCount = 0;
-
+
+ private final Logger logger = LoggerFactory.getLogger(AbstractDelimiterPZParser.class);
+
public AbstractDelimiterPZParser(final InputStream dataSourceStream, final String dataDefinition, final char delimiter,
final char qualifier, final boolean ignoreFirstRecord) {
super(dataSourceStream, dataDefinition);
@@ -97,8 +102,7 @@
}
}
} catch (final IOException e) {
- // TODO add logger
- e.printStackTrace();
+ logger.error("error accessing/creating inputstream", e);
}
return null;
}
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/AbstractFixedLengthPZParser.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -34,13 +34,15 @@
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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.pzfilereader.structure.Row;
import net.sf.pzfilereader.util.FixedWidthParserUtils;
import net.sf.pzfilereader.util.PZConstants;
@@ -51,7 +53,8 @@
*
*/
public abstract class AbstractFixedLengthPZParser extends AbstractPZParser {
-
+ private final Logger logger = LoggerFactory.getLogger(AbstractFixedLengthPZParser.class);
+
protected AbstractFixedLengthPZParser(final File dataSource, final String dataDefinition) {
super(dataSource, dataDefinition);
}
@@ -77,21 +80,14 @@
stream = ParserUtils.createInputStream(getDataSource());
try {
return doFixedLengthFile(stream);
- } catch (final Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
} finally {
if (stream != null) {
stream.close();
}
}
}
- } catch (final FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (final Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (final IOException e) {
+ logger.error("error accessing/creating inputstream", e);
}
return null;
}
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderDelimPZParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderDelimPZParser.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderDelimPZParser.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -40,6 +40,9 @@
import java.util.List;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.pzfilereader.DataSet;
import net.sf.pzfilereader.DefaultDataSet;
import net.sf.pzfilereader.DelimiterPZParser;
@@ -49,8 +52,12 @@
public class BuffReaderDelimPZParser extends DelimiterPZParser {
private BufferedReader br;
+
private InputStreamReader isr;
+
private boolean processedFirst = false;
+
+ private final Logger logger = LoggerFactory.getLogger(BuffReaderDelimPZParser.class);
public BuffReaderDelimPZParser(final File pzmapXML, final File dataSource, final char delimiter, final char qualifier,
final boolean ignoreFirstRecord) {
@@ -88,7 +95,7 @@
return ds;
} catch(IOException ex) {
- ex.printStackTrace();
+ logger.error("error accessing/creating inputstream", ex);
}
return null;
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderFixedPZParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderFixedPZParser.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderFixedPZParser.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -40,6 +40,9 @@
import java.util.List;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.pzfilereader.DataSet;
import net.sf.pzfilereader.DefaultDataSet;
import net.sf.pzfilereader.FixedLengthPZParser;
@@ -57,6 +60,8 @@
private Map recordLengths = null;
+ private final Logger logger = LoggerFactory.getLogger(BuffReaderFixedPZParser.class);
+
public BuffReaderFixedPZParser(final InputStream pzmapXMLStream, final InputStream dataSourceStream) {
super(pzmapXMLStream, dataSourceStream);
}
@@ -84,7 +89,7 @@
return ds;
} catch(IOException ex) {
- ex.printStackTrace();
+ logger.error("error accessing/creating inputstream", ex);
}
return null;
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderPZDataSet.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderPZDataSet.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/brparse/BuffReaderPZDataSet.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -36,6 +36,9 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.sf.pzfilereader.DefaultDataSet;
import net.sf.pzfilereader.ordering.OrderBy;
import net.sf.pzfilereader.structure.Row;
@@ -45,6 +48,8 @@
private final BuffReaderFixedPZParser brFixedPzParser;
+ private final Logger logger = LoggerFactory.getLogger(BuffReaderPZDataSet.class);
+
public BuffReaderPZDataSet(final Map columnMD2, final BuffReaderDelimPZParser brDelimPzParser) {
super(columnMD2);
//register the parser with the dataset so we can fetch rows from
@@ -95,8 +100,7 @@
return true;
} catch(final IOException ex) {
- //TODO real logging here
- ex.printStackTrace();
+ logger.error("error building Row on next()", ex);
}
return false;
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -51,6 +51,8 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author zepernick
@@ -59,7 +61,8 @@
*/
public final class PZMapParser {
private static boolean showDebug = false;
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PZMapParser.class);
/**
* Constructor
*
@@ -223,15 +226,15 @@
columns = xmlrecEle.getColumns().iterator();
}
- System.out.println(">>>>Column MD Id: " + recordID);
+ LOGGER.debug(">>>>Column MD Id: " + recordID);
if (xmlrecEle != null) {
- System.out.println("Start Position: " + xmlrecEle.getStartPosition() + " " + "End Position: "
+ LOGGER.debug("Start Position: " + xmlrecEle.getStartPosition() + " " + "End Position: "
+ xmlrecEle.getEndPositition() + " " + "Element Number: " + xmlrecEle.getElementNumber() + " "
+ "Indicator: " + xmlrecEle.getIndicator());
}
while (columns.hasNext()) {
final ColumnMetaData cmd = (ColumnMetaData) columns.next();
- System.out.println(" Column Name: " + cmd.getColName() + " LENGTH: " + cmd.getColLength());
+ LOGGER.debug("Column Name: " + cmd.getColName() + " LENGTH: " + cmd.getColLength());
}
}
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/ResolveLocalDTD.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/ResolveLocalDTD.java 2006-12-21 20:58:52 UTC (rev 253)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/ResolveLocalDTD.java 2006-12-24 17:53:35 UTC (rev 254)
@@ -61,7 +61,9 @@
if (resource != null) {
return new InputSource(resource.openStream());
} else {
- throw new RuntimeException("could not load dtd resource from jar!!");
+ //should probably not happen, this may indicate that the dtd has been
+ //removed from the jar for some reason
+ throw new IOException("could not load dtd resource from jar!!");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|