]> source.dussan.org Git - poi.git/commitdiff
Bug 52628 - Replace System.err info messages with a POILogger
authorYegor Kozlov <yegor@apache.org>
Fri, 16 Nov 2012 12:21:49 +0000 (12:21 +0000)
committerYegor Kozlov <yegor@apache.org>
Fri, 16 Nov 2012 12:21:49 +0000 (12:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1410318 13f79535-47bb-0310-9956-ffa450edef68

30 files changed:
src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/POIDocument.java
src/java/org/apache/poi/hpsf/HPSFRuntimeException.java
src/java/org/apache/poi/hpsf/VariantSupport.java
src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
src/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java
src/java/org/apache/poi/hssf/record/FeatRecord.java
src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
src/java/org/apache/poi/hssf/record/SSTDeserializer.java
src/java/org/apache/poi/hssf/record/common/UnicodeString.java
src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java
src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
src/java/org/apache/poi/ss/util/DateFormatConverter.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java
src/scratchpad/src/org/apache/poi/hdgf/streams/ChunkStream.java
src/scratchpad/src/org/apache/poi/hmef/attribute/MAPIDateAttribute.java
src/scratchpad/src/org/apache/poi/hmef/attribute/MAPIStringAttribute.java
src/scratchpad/src/org/apache/poi/hmef/attribute/TNEFDateAttribute.java
src/scratchpad/src/org/apache/poi/hmef/attribute/TNEFStringAttribute.java
src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/Record.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/MessageSubmissionChunk.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java
src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java

index 1e13ea8060d060c6707eeae37ef2be15a067ed1f..f4ae431eee7fe3ad4026d5953c7ac726aefc56e4 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="fix">52628 - Replace System.err info messages with a POILogger</action>
           <action dev="poi-developers" type="fix">54137 - improved performance of DataFormatter with Fractions</action>
           <action dev="poi-developers" type="fix">54099 - Ensure that CTHMerge and CTTcBorders go to poi-ooxml-schemas jar</action>
           <action dev="poi-developers" type="fix">54111 - Fixed extracting text from table cells in HSLF</action>
index 169e9241bcf2703bbc3f108444ee66b6dc53ad8b..8f177fec947ae2e5621628f584b08b017adde2ba 100644 (file)
@@ -221,7 +221,7 @@ public abstract class POIDocument {
 
                        logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
                } catch(org.apache.poi.hpsf.WritingNotSupportedException wnse) {
-                       System.err.println("Couldn't write property set with name " + name + " as not supported by HPSF yet");
+                       logger.log( POILogger.ERROR, "Couldn't write property set with name " + name + " as not supported by HPSF yet");
                }
        }
        
index 79825ebf824d2af5d9fbc2ed5d7d44e8cb14be3e..203498f13ca69ec3577186bececd9ba82187010d 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hpsf;
 
-import java.io.PrintStream;
-import java.io.PrintWriter;
 
 /**
  * <p>This exception is the superclass of all other unchecked
@@ -30,8 +28,8 @@ import java.io.PrintWriter;
  */
 public class HPSFRuntimeException extends RuntimeException
 {
-
-    /** <p>The underlying reason for this exception - may be
+       private static final long serialVersionUID = -7804271670232727159L;
+       /** <p>The underlying reason for this exception - may be
      * <code>null</code>.</p> */
     private Throwable reason;
 
@@ -105,44 +103,44 @@ public class HPSFRuntimeException extends RuntimeException
 
 
 
-    /**
-     * @see Throwable#printStackTrace()
-     */
-    public void printStackTrace()
-    {
-        printStackTrace(System.err);
-    }
-
-
-
-    /**
-     * @see Throwable#printStackTrace(java.io.PrintStream)
-     */
-    public void printStackTrace(final PrintStream p)
-    {
-        final Throwable reason = getReason();
-        super.printStackTrace(p);
-        if (reason != null)
-        {
-            p.println("Caused by:");
-            reason.printStackTrace(p);
-        }
-    }
-
-
-
-    /**
-     * @see Throwable#printStackTrace(java.io.PrintWriter)
-     */
-    public void printStackTrace(final PrintWriter p)
-    {
-        final Throwable reason = getReason();
-        super.printStackTrace(p);
-        if (reason != null)
-        {
-            p.println("Caused by:");
-            reason.printStackTrace(p);
-        }
-    }
+//    /**
+//     * @see Throwable#printStackTrace()
+//     */
+//    public void printStackTrace()
+//    {
+//        printStackTrace(System.err);
+//    }
+
+
+
+//    /**
+//     * @see Throwable#printStackTrace(java.io.PrintStream)
+//     */
+//    public void printStackTrace(final PrintStream p)
+//    {
+//        final Throwable reason = getReason();
+//        super.printStackTrace(p);
+//        if (reason != null)
+//        {
+//            p.println("Caused by:");
+//            reason.printStackTrace(p);
+//        }
+//    }
+
+
+
+//    /**
+//     * @see Throwable#printStackTrace(java.io.PrintWriter)
+//     */
+//    public void printStackTrace(final PrintWriter p)
+//    {
+//        final Throwable reason = getReason();
+//        super.printStackTrace(p);
+//        if (reason != null)
+//        {
+//            p.println("Caused by:");
+//            reason.printStackTrace(p);
+//        }
+//    }
 
 }
index 8b13fc0e3ce952de8be0ed4f81b17af49cd86536..f24c2a91879683cbe526022c2c572467ebf509de 100644 (file)
@@ -24,6 +24,9 @@ import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
 /**
  * <p>Supports reading and writing of variant data.</p>
  *
@@ -45,7 +48,7 @@ import java.util.List;
  */
 public class VariantSupport extends Variant
 {
-
+       private static POILogger logger = POILogFactory.getLogger(VariantSupport.class);
     private static boolean logUnsupportedTypes = false;
 
     /**
@@ -78,7 +81,7 @@ public class VariantSupport extends Variant
      * <p>Keeps a list of the variant types an "unsupported" message has already
      * been issued for.</p>
      */
-    protected static List unsupportedMessage;
+    protected static List<Long> unsupportedMessage;
 
     /**
      * <p>Writes a warning to <code>System.err</code> that a variant type is
@@ -93,11 +96,11 @@ public class VariantSupport extends Variant
         if (isLogUnsupportedTypes())
         {
             if (unsupportedMessage == null)
-                unsupportedMessage = new LinkedList();
+                unsupportedMessage = new LinkedList<Long>();
             Long vt = Long.valueOf(ex.getVariantType());
             if (!unsupportedMessage.contains(vt))
             {
-                System.err.println(ex.getMessage());
+               logger.log( POILogger.ERROR, ex.getMessage());
                 unsupportedMessage.add(vt);
             }
         }
index 60c11d35210a1566721c22c4a4e185e2bd35e69f..1ca3db366fec61567433a9191ef6adfd03e262d2 100644 (file)
@@ -31,6 +31,8 @@ import org.apache.poi.hssf.record.NumberRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.usermodel.HSSFDataFormat;
 import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * A proxy HSSFListener that keeps track of the document formatting records, and
@@ -38,6 +40,7 @@ import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
  * ids.
  */
 public class FormatTrackingHSSFListener implements HSSFListener {
+       private static POILogger logger = POILogFactory.getLogger(FormatTrackingHSSFListener.class);
        private final HSSFListener _childListener;
        private final HSSFDataFormatter _formatter;
        private final NumberFormat _defaultFormat;
@@ -137,7 +140,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
                if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
                        FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex));
                        if (tfr == null) {
-                               System.err.println("Requested format at index " + formatIndex
+                               logger.log( POILogger.ERROR, "Requested format at index " + formatIndex
                                                + ", but it wasn't found");
                        } else {
                                format = tfr.getFormatString();
@@ -167,7 +170,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
        public int getFormatIndex(CellValueRecordInterface cell) {
                ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
                if (xfr == null) {
-                       System.err.println("Cell " + cell.getRow() + "," + cell.getColumn()
+                       logger.log( POILogger.ERROR, "Cell " + cell.getRow() + "," + cell.getColumn()
                                        + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
                        return -1;
                }
index 6e74173d4c88b092dbec8c2ed1c842a48bee3952..77e9fd86d61899bde062b75a628ea89153466328 100644 (file)
@@ -29,6 +29,8 @@ import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianInput;
 import org.apache.poi.util.LittleEndianInputStream;
 import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
 
 /**
@@ -39,6 +41,7 @@ import org.apache.poi.util.StringUtil;
  * @author Daniel Noll
  */
 public final class EmbeddedObjectRefSubRecord extends SubRecord {
+       private static POILogger logger = POILogFactory.getLogger(EmbeddedObjectRefSubRecord.class);
        public static final short sid = 0x0009;
 
        private static final byte[] EMPTY_BYTE_ARRAY = { };
@@ -137,7 +140,7 @@ public final class EmbeddedObjectRefSubRecord extends SubRecord {
                int nUnexpectedPadding = remaining - dataLenAfterFormula;
 
                if (nUnexpectedPadding > 0) {
-                       System.err.println("Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
+                       logger.log( POILogger.ERROR, "Discarding " + nUnexpectedPadding + " unexpected padding bytes ");
                        readRawData(in, nUnexpectedPadding);
                        remaining-=nUnexpectedPadding;
                }
index 267eced88e848cdc5c4845c08d83551f92340952..572d6959d9582e2cb89f88ebfc0781a3b4c03989 100644 (file)
@@ -24,6 +24,8 @@ import org.apache.poi.hssf.record.common.FtrHeader;
 import org.apache.poi.hssf.record.common.SharedFeature;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Title: Feat (Feature) Record
@@ -32,6 +34,7 @@ import org.apache.poi.util.LittleEndianOutput;
  *  up with a {@link FeatHdrRecord}.
  */
 public final class FeatRecord extends StandardRecord  {
+       private static POILogger logger = POILogFactory.getLogger(FeatRecord.class);
        public final static short sid = 0x0868;
        
        private FtrHeader futureHeader;
@@ -90,7 +93,7 @@ public final class FeatRecord extends StandardRecord  {
                        sharedFeature = new FeatSmartTag(in);
                        break;
                default:
-                       System.err.println("Unknown Shared Feature " + isf_sharedFeatureType + " found!");
+                       logger.log( POILogger.ERROR, "Unknown Shared Feature " + isf_sharedFeatureType + " found!");
                }
        }
 
index 3d6b237cf8a57620a01cda54ad9d5de8e96ca62b..f13d7f0eb434a4ec71b0ef51aa8717793b9da202 100644 (file)
@@ -41,7 +41,7 @@ import org.apache.poi.util.StringUtil;
  */
 public final class HyperlinkRecord extends StandardRecord {
     public final static short sid = 0x01B8;
-    private POILogger logger = POILogFactory.getLogger(getClass());
+    private static POILogger logger = POILogFactory.getLogger(HyperlinkRecord.class);
 
     static final class GUID {
                /*
@@ -641,7 +641,7 @@ public final class HyperlinkRecord extends StandardRecord {
        if (false) { // Quite a few examples in the unit tests which don't have the exact expected tail
             for (int i = 0; i < expectedTail.length; i++) {
                 if (expectedTail[i] != result[i]) {
-                    System.err.println("Mismatch in tail byte [" + i + "]"
+                       logger.log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]"
                                + "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF));
                 }
             }
index 280bc26c9fc7ebdd599ff75edefc74b1196c6079..181616185f5d9176a2f20af262dada0f457aef2e 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.poi.hssf.record;
 
 import org.apache.poi.hssf.record.common.UnicodeString;
 import org.apache.poi.util.IntMapper;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Handles the task of deserializing a SST string.  The two main entry points are
@@ -30,7 +32,7 @@ import org.apache.poi.util.IntMapper;
  */
 class SSTDeserializer
 {
-
+       private static POILogger logger = POILogFactory.getLogger(SSTDeserializer.class);
     private IntMapper<UnicodeString> strings;
 
     public SSTDeserializer( IntMapper<UnicodeString> strings )
@@ -49,7 +51,7 @@ class SSTDeserializer
          // Extract exactly the count of strings from the SST record.
          UnicodeString str;
          if(in.available() == 0 && ! in.hasNextRecord()) {
-            System.err.println("Ran out of data before creating all the strings! String at index " + i + "");
+                logger.log( POILogger.ERROR, "Ran out of data before creating all the strings! String at index " + i + "");
             str = new UnicodeString("");
          } else {
             str = new UnicodeString(in);
index 3ee5e4e66cf4ad211ee0ad94026c1c3b71832ec3..9e9ca039251027ff5ecb419bd4a053cab9f274c0 100644 (file)
@@ -179,7 +179,7 @@ public class UnicodeString implements Comparable<UnicodeString> { // TODO - make
 
           int extraDataLength = runData - (numRuns*6);
           if(extraDataLength < 0) {
-             System.err.println("Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
+                _logger.log( POILogger.WARN, "Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
              extraDataLength = 0;
           }
           extraData = new byte[extraDataLength];
index 0d130452ba3179bf097652dfe660b763673279a4..7e350e88f52cacb19b54d2576d1e023738a94729 100644 (file)
@@ -34,6 +34,8 @@ import org.apache.poi.ss.formula.FormulaParsingWorkbook;
 import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.udf.UDFFinder;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Internal POI use only
@@ -41,7 +43,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
  * @author Josh Micich
  */
 public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook {
-
+       private static POILogger logger = POILogFactory.getLogger(HSSFEvaluationWorkbook.class);
        private final HSSFWorkbook _uBook;
        private final InternalWorkbook _iBook;
 
@@ -139,7 +141,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
                                // Note - as of Bugzilla 48036 (svn r828244, r828247) POI is capable of evaluating
                                // IntesectionPtg.  However it is still not capable of parsing it.
                                // So FormulaEvalTestData.xls now contains a few formulas that produce errors here.
-                               System.err.println(e.getMessage());
+                               logger.log( POILogger.ERROR, e.getMessage());
                        }
                }
                FormulaRecordAggregate fra = (FormulaRecordAggregate) cell.getCellValueRecord();
index 1f20d9f0faab8bc8977744d6b2f3a65cbe9abda7..56b2f699e1d4c74deb601a02dd96e29ebce6ec7b 100644 (file)
@@ -27,6 +27,8 @@ import org.apache.poi.hssf.record.EscherAggregate;
 import org.apache.poi.hssf.record.ObjRecord;
 import org.apache.poi.ss.usermodel.Picture;
 import org.apache.poi.ss.util.ImageUtils;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.hssf.model.InternalWorkbook;
 
 /**
@@ -36,6 +38,8 @@ import org.apache.poi.hssf.model.InternalWorkbook;
  * @author Yegor Kozlov (yegor at apache.org)
  */
 public class HSSFPicture extends HSSFSimpleShape implements Picture {
+       private static POILogger logger = POILogFactory.getLogger(HSSFPicture.class);
+       
     public static final int PICTURE_TYPE_EMF = HSSFWorkbook.PICTURE_TYPE_EMF;                // Windows Enhanced Metafile
     public static final int PICTURE_TYPE_WMF = HSSFWorkbook.PICTURE_TYPE_WMF;                // Windows Metafile
     public static final int PICTURE_TYPE_PICT = HSSFWorkbook.PICTURE_TYPE_PICT;              // Macintosh PICT
@@ -283,7 +287,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
             EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, data.getBytes("UTF-16LE"));
             setPropertyValue(prop);
         } catch (UnsupportedEncodingException e) {
-            System.out.println("Unsupported encoding: UTF-16LE");
+               logger.log( POILogger.ERROR, "Unsupported encoding: UTF-16LE");
         }
     }
 
index 98936f90cb4331e385aa8fc0b7406426c3a683c8..07209ae3e7770bb6ce2d2866033c8ac72240a156 100644 (file)
@@ -20,12 +20,14 @@ package org.apache.poi.hssf.usermodel;
 import org.apache.poi.ddf.*;
 import org.apache.poi.hssf.record.*;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * @author Glen Stampoultzis  (glens at superlinksoftware.com)
  */
 public class HSSFPolygon  extends HSSFSimpleShape {
-
+       private static POILogger logger = POILogFactory.getLogger(HSSFPolygon.class);
     public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 0x1E;
 
     public HSSFPolygon(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord _textObjectRecord) {
@@ -157,11 +159,11 @@ public class HSSFPolygon  extends HSSFSimpleShape {
      */
     public void setPoints(int[] xPoints, int[] yPoints) {
         if (xPoints.length != yPoints.length){
-            System.out.println("xPoint.length must be equal to yPoints.length");
+               logger.log( POILogger.ERROR, "xPoint.length must be equal to yPoints.length");
             return;
         }
         if (xPoints.length == 0){
-            System.out.println("HSSFPolygon must have at least one point");
+               logger.log( POILogger.ERROR, "HSSFPolygon must have at least one point");
         }
         EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
         verticesProp.setNumberOfElementsInArray(xPoints.length+1);
index 3233dfa260974e45e92633b4179987145dd6ce5c..60f2b8d38cba63719fd4446371025f9f9a790b6e 100644 (file)
@@ -36,7 +36,7 @@ public class EntryUtils
     public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
             throws IOException
     {
-        // System.err.println("copyNodeRecursively called with "+entry.getName()+
+        // logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+
         // ","+target.getName());
         DirectoryEntry newTarget = null;
         if ( entry.isDirectoryEntry() )
index 5a58db92786740cd52b8574e18e166f321c4da30..b3c7ee72079039564a94b07e898fe32272ba4b75 100644 (file)
@@ -18,6 +18,8 @@
 package org.apache.poi.ss.formula.constant;
 
 import org.apache.poi.ss.usermodel.ErrorConstants;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 /**
  * Represents a constant error code value as encoded in a constant values array. <p/>
  * 
@@ -27,6 +29,7 @@ import org.apache.poi.ss.usermodel.ErrorConstants;
  * @author Josh Micich
  */
 public class ErrorConstant {
+       private static POILogger logger = POILogFactory.getLogger(ErrorConstant.class);
        // convenient access to name space
        private static final ErrorConstants EC = null;
 
@@ -64,7 +67,7 @@ public class ErrorConstant {
                        case ErrorConstants.ERROR_NUM:   return NUM;
                        case ErrorConstants.ERROR_NA:   return NA;
                }
-               System.err.println("Warning - unexpected error code (" + errorCode + ")");
+               logger.log( POILogger.WARN, "Warning - unexpected error code (" + errorCode + ")");
                return new ErrorConstant(errorCode);
        }
        public String toString() {
index b11f7a58d5ac5d45d69b21efa5c63b6c3e24cbb9..316d1ed7b64fd2e41b1832cfb8348f75cf2879a8 100644 (file)
@@ -24,6 +24,9 @@ import java.util.List;
 import java.util.Locale;\r
 import java.util.Map;\r
 \r
+import org.apache.poi.util.POILogFactory;\r
+import org.apache.poi.util.POILogger;\r
+\r
 /**\r
  *  Convert java DateFormat patterns into Excel custom number formats.\r
  *  For example, to format a date in excel using the "dd MMMM, yyyy" pattern and Japanese\r
@@ -45,6 +48,7 @@ import java.util.Map;
  *\r
  */\r
 public class DateFormatConverter  {\r
+       private static POILogger logger = POILogFactory.getLogger(DateFormatConverter.class);\r
        \r
        public static class DateFormatTokenizer {\r
                String format;\r
@@ -329,7 +333,7 @@ public class DateFormatConverter  {
                        result = localePrefixes.get( localeString.substring( 0, 2 ) );\r
                        if( result ==  null ) {\r
                                Locale parentLocale = new Locale(localeString.substring( 0, 2 ));\r
-                               System.out.println( "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " \r
+                               logger.log( POILogger.ERROR, "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " \r
                                                + localeString.substring( 0, 2 ) + "(" + parentLocale.getDisplayName() + ")" );\r
                                return "";\r
                        }\r
index 55cb5a7f18eed8d8996924376cba338ab8ea74ce..1a7c3c6da47d7b973301fc6594abe7dce412083a 100644 (file)
@@ -51,7 +51,7 @@ public final class ChunkFactory {
                "/org/apache/poi/hdgf/chunks_parse_cmds.tbl";
 
        /** For logging problems we spot with the file */
-       private POILogger logger = POILogFactory.getLogger(ChunkFactory.class);
+       private static POILogger logger = POILogFactory.getLogger(ChunkFactory.class);
 
        public ChunkFactory(int version) throws IOException {
                this.version = version;
@@ -153,7 +153,7 @@ public final class ChunkFactory {
                                        data, endOfDataPos);
                                endOfDataPos += 8;
                        } else {
-                               System.err.println("Header claims a length to " + endOfDataPos + " there's then no space for the trailer in the data (" + data.length + ")");
+                               logger.log(POILogger.ERROR, "Header claims a length to " + endOfDataPos + " there's then no space for the trailer in the data (" + data.length + ")");
                        }
                }
                if(header.hasSeparator()) {
@@ -161,7 +161,7 @@ public final class ChunkFactory {
                                separator = new ChunkSeparator(
                                                data, endOfDataPos);
                        } else {
-                               System.err.println("Header claims a length to " + endOfDataPos + " there's then no space for the separator in the data (" + data.length + ")");
+                               logger.log(POILogger.ERROR, "Header claims a length to " + endOfDataPos + " there's then no space for the separator in the data (" + data.length + ")");
                        }
                }
 
index 5956334800a38e4f9db5ecf1781c3b76a1f1766d..9f15e40b9fa14c6af49e7bbfde5acf9ebe8d867e 100644 (file)
@@ -23,8 +23,12 @@ import org.apache.poi.hdgf.chunks.Chunk;
 import org.apache.poi.hdgf.chunks.ChunkFactory;
 import org.apache.poi.hdgf.chunks.ChunkHeader;
 import org.apache.poi.hdgf.pointers.Pointer;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 public final class ChunkStream extends Stream {
+       private static POILogger logger = POILogFactory.getLogger(ChunkStream.class);
+       
        private ChunkFactory chunkFactory;
        /** All the Chunks we contain */
        private Chunk[] chunks;
@@ -62,14 +66,14 @@ public final class ChunkStream extends Stream {
 
                                        pos += chunk.getOnDiskSize();
                                } else {
-                                       System.err.println("Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
+                                       logger.log(POILogger.WARN, "Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
                                        pos = contents.length;
                                }
                        }
                }
                catch (Exception e)
                {
-                       System.err.println("Failed to create chunk at " + pos + ", ignoring rest of data." + e);
+                       logger.log(POILogger.ERROR, "Failed to create chunk at " + pos + ", ignoring rest of data." + e);
                }
 
                chunks = chunksA.toArray(new Chunk[chunksA.size()]);
index bf786366d1e3452c28197c291bd1cfa2ff7498bc..243359639e7a3d464ac6000dba0b0d6216227c4b 100644 (file)
@@ -24,12 +24,15 @@ import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hpsf.Util;
 import org.apache.poi.hsmf.datatypes.MAPIProperty;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * A pure-MAPI attribute holding a Date, which applies 
  *  to a {@link HMEFMessage} or one of its {@link Attachment}s.
  */
 public final class MAPIDateAttribute extends MAPIAttribute {
+   private static POILogger logger = POILogFactory.getLogger(MAPIDateAttribute.class);
    private Date data;
    
    /**
@@ -64,7 +67,7 @@ public final class MAPIDateAttribute extends MAPIAttribute {
          return ((MAPIDateAttribute)attr).getDate();
       }
       
-      System.err.println("Warning, non date property found: " + attr.toString());
+      logger.log(POILogger.WARN, "Warning, non date property found: " + attr.toString());
       return null;
   }
 }
index b48651c0943c17935632ad7c1cbc227532d04b86..72992086ba164371d4771f7fdcf15c375ff015e2 100644 (file)
@@ -23,6 +23,8 @@ import org.apache.poi.hmef.Attachment;
 import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hsmf.datatypes.MAPIProperty;
 import org.apache.poi.hsmf.datatypes.Types;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
 
 /**
@@ -30,6 +32,7 @@ import org.apache.poi.util.StringUtil;
  *  to a {@link HMEFMessage} or one of its {@link Attachment}s.
  */
 public final class MAPIStringAttribute extends MAPIAttribute {
+   private static POILogger logger = POILogFactory.getLogger(MAPIStringAttribute.class);
    private static final String CODEPAGE = "CP1252";
    private final String data;
    
@@ -78,7 +81,7 @@ public final class MAPIStringAttribute extends MAPIAttribute {
          return ((MAPIRtfAttribute)attr).getDataString();
       }
       
-      System.err.println("Warning, non string property found: " + attr.toString());
+      logger.log(POILogger.WARN, "Warning, non string property found: " + attr.toString());
       return null;
   }
 }
index 70793899f4e12fde007ec3c29bc9f310fd6c68cb..890845229c59d996e80886333018e1795faccde3 100644 (file)
@@ -27,12 +27,15 @@ import org.apache.poi.hmef.Attachment;
 import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hpsf.Util;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * A Date attribute which applies to a {@link HMEFMessage}
  *  or one of its {@link Attachment}s.
  */
 public final class TNEFDateAttribute extends TNEFAttribute {
+   private static POILogger logger = POILogFactory.getLogger(TNEFDateAttribute.class);
    private Date data;
    
    /**
@@ -85,7 +88,7 @@ public final class TNEFDateAttribute extends TNEFAttribute {
          return ((TNEFDateAttribute)attr).getDate();
       }
       
-      System.err.println("Warning, non date property found: " + attr.toString());
+      logger.log(POILogger.WARN, "Warning, non date property found: " + attr.toString());
       return null;
   }
 }
index 983d3f9a23c45058cd7efe24fc1e601601ffee88..34e1ef36916fdd4f546cf54ecc62d08c57960bee 100644 (file)
@@ -22,6 +22,8 @@ import java.io.InputStream;
 
 import org.apache.poi.hmef.Attachment;
 import org.apache.poi.hmef.HMEFMessage;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
 
 /**
@@ -29,6 +31,7 @@ import org.apache.poi.util.StringUtil;
  *  or one of its {@link Attachment}s.
  */
 public final class TNEFStringAttribute extends TNEFAttribute {
+   private static POILogger logger = POILogFactory.getLogger(TNEFStringAttribute.class);
    private String data;
    
    /**
@@ -75,7 +78,7 @@ public final class TNEFStringAttribute extends TNEFAttribute {
          return ((TNEFStringAttribute)attr).getString();
       }
       
-      System.err.println("Warning, non string property found: " + attr.toString());
+      logger.log(POILogger.WARN, "Warning, non string property found: " + attr.toString());
       return null;
   }
 }
index 217a60f850b446959f63afeab76122021fd3b8b5..6fef2cc8e835c97a926b08a990f8a633b2f4558c 100644 (file)
@@ -20,6 +20,8 @@ package org.apache.poi.hslf.model;
 import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -35,6 +37,8 @@ import java.awt.*;
  */
 
 public abstract class Sheet {
+       private static POILogger logger = POILogFactory.getLogger(Sheet.class);
+
     /**
      * The <code>SlideShow</code> we belong to
      */
@@ -194,7 +198,7 @@ public abstract class Sheet {
                 } else if (records[i + 1].getRecordType() == 4010l) {
                     // TextSpecInfoAtom - Safe to ignore
                 } else {
-                    System.err.println("Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + records[i + 1].getRecordType());
+                       logger.log(POILogger.ERROR, "Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + records[i + 1].getRecordType());
                 }
 
                 if (trun != null) {
index 1c7ad9f7ff28f1ceea92ae8edf004588b711f0cf..0335cece396427f55b365c78f9a2bae3f8234ee2 100644 (file)
@@ -23,6 +23,8 @@ package org.apache.poi.hslf.record;
 import java.io.*;
 import org.apache.poi.poifs.filesystem.*;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
@@ -39,6 +41,8 @@ import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
 
 public class CurrentUserAtom
 {
+       private static POILogger logger = POILogFactory.getLogger(CurrentUserAtom.class);
+
        /** Standard Atom header */
        public static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
        /** The PowerPoint magic number for a non-encrypted file */
@@ -128,7 +132,7 @@ public class CurrentUserAtom
                        if(_contents.length >= 4) {
                                // PPT95 has 4 byte size, then data
                                int size = LittleEndian.getInt(_contents);
-                               System.err.println(size);
+                               //System.err.println(size);
                                if(size + 4 == _contents.length) {
                                        throw new OldPowerPointFormatException("Based on the Current User stream, you seem to have supplied a PowerPoint95 file, which isn't supported");
                                }
@@ -173,7 +177,7 @@ public class CurrentUserAtom
                long usernameLen = LittleEndian.getUShort(_contents,20);
                if(usernameLen > 512) {
                        // Handle the case of it being garbage
-                       System.err.println("Warning - invalid username length " + usernameLen + " found, treating as if there was no username set");
+                       logger.log(POILogger.WARN, "Warning - invalid username length " + usernameLen + " found, treating as if there was no username set");
                        usernameLen = 0;
                }
 
index 09126999e546475619cb67b0f5b84d415381b8f0..5530e2454d3f879ff84996acde798e87504b8958 100644 (file)
@@ -38,7 +38,7 @@ import org.apache.poi.util.POILogger;
 public abstract class Record
 {
     // For logging
-    protected POILogger logger = POILogFactory.getLogger(this.getClass());
+       protected static POILogger logger = POILogFactory.getLogger(Record.class);
 
        /**
         * Is this record type an Atom record (only has data),
@@ -155,7 +155,7 @@ public abstract class Record
                // Handle case of a corrupt last record, whose claimed length
                //  would take us passed the end of the file
                if(start + len > b.length) {
-                       System.err.println("Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
+                       logger.log(POILogger.WARN, "Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
                        return null;
                }
 
index 55f8a5f254776bc7d505b762a4eba3550b1ea157..aa17b7f7bb88e2dc14127e6350e4037c3536edc4 100644 (file)
@@ -37,11 +37,14 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.apache.poi.hsmf.MAPIMessage;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Collection of convenence chunks for standard parts of the MSG file attachment.
  */
 public class AttachmentChunks implements ChunkGroup {
+   private static POILogger logger = POILogFactory.getLogger(AttachmentChunks.class);
    public static final String PREFIX = "__attach_version1.0_#";
    
    public ByteChunk attachData;
@@ -131,7 +134,7 @@ public class AttachmentChunks implements ChunkGroup {
          } else if(chunk instanceof DirectoryChunk) {
              attachmentDirectory = (DirectoryChunk)chunk;
          } else {
-             System.err.println("Unexpected data chunk of type " + chunk);
+                logger.log(POILogger.ERROR, "Unexpected data chunk of type " + chunk);
          }
       }
       else if(chunk.getChunkId() == ATTACH_DISPOSITION.id) {
index 397717c7fabb195999aa1483326a8728e6d41b70..0c59b02eb5ed7c96fff52d510420ef2f9da1a395 100644 (file)
@@ -26,6 +26,8 @@ import java.util.regex.Pattern;
 
 import org.apache.poi.hsmf.datatypes.Types.MAPIType;
 import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * A Chunk that holds the details given back by the
@@ -36,6 +38,7 @@ import org.apache.poi.util.IOUtils;
  */
 
 public class MessageSubmissionChunk extends Chunk {
+       private static POILogger logger = POILogFactory.getLogger(MessageSubmissionChunk.class);
        private String rawId;
        private Calendar date;
        
@@ -87,7 +90,7 @@ public class MessageSubmissionChunk extends Chunk {
                   date.set(Calendar.SECOND,      Integer.parseInt(m.group(6)));
                   date.set(Calendar.MILLISECOND, 0);
                } else {
-                  System.err.println("Warning - unable to make sense of date " + dateS);
+                  logger.log(POILogger.WARN, "Warning - unable to make sense of date " + dateS);
                }
             }
          }
index dd3c47057c0ccdfc987f32061fd43cfb1cc289df..a3f57248ac5e294d39ea2a109e0d7fbdd2913c13 100644 (file)
@@ -21,6 +21,9 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
 
 /**
  * Collection of convenience chunks for the
@@ -30,6 +33,8 @@ import java.util.List;
  *  several of these.
  */
 public final class RecipientChunks implements ChunkGroup {
+   private static POILogger logger = POILogFactory.getLogger(RecipientChunks.class);
+
    public static final String PREFIX = "__recip_version1.0_#";
    
    public static final MAPIProperty RECIPIENT_NAME   = MAPIProperty.DISPLAY_NAME;
@@ -82,7 +87,7 @@ public final class RecipientChunks implements ChunkGroup {
          try {
             recipientNumber = Integer.parseInt(number, 16);
          } catch(NumberFormatException e) {
-            System.err.println("Invalid recipient number in name " + name);
+                logger.log(POILogger.ERROR, "Invalid recipient number in name " + name);
          }
       }
    }
index 6800b0ac77d74d8dee5346bca0194ede49219daa..434d0cbd6b34e8fa981ed6aed2d097e9eb56d05f 100644 (file)
@@ -41,6 +41,8 @@ import org.apache.poi.poifs.filesystem.DocumentInputStream;
 import org.apache.poi.poifs.filesystem.DocumentNode;
 import org.apache.poi.poifs.filesystem.Entry;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Processes a POIFS of a .msg file into groups of Chunks, such as
@@ -48,6 +50,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  * data and so on.
  */
 public final class POIFSChunkParser {
+   private static POILogger logger = POILogFactory.getLogger(POIFSChunkParser.class);
+
    public static ChunkGroup[] parse(POIFSFileSystem fs) throws IOException {
       return parse(fs.getRoot());
    }
@@ -200,7 +204,7 @@ public final class POIFSChunkParser {
                 chunk.readValue(inp);
                 grouping.record(chunk);
              } catch(IOException e) {
-                System.err.println("Error reading from part " + entry.getName() + " - " + e.toString());
+                logger.log(POILogger.ERROR, "Error reading from part " + entry.getName() + " - " + e.toString());
              }
           } else {
              grouping.record(chunk);
index 89ac7e5634d42b1580a9257bf8a1d8676ec15868..6efb6ad22813772507b4d4eb2d53d240552509a2 100644 (file)
@@ -453,7 +453,7 @@ public class AbstractWordUtils
     {
 
         if ( format != 0 )
-            System.err.println( "NYI: toListItemNumberLabel(): " + format );
+               logger.log( POILogger.INFO, "NYI: toListItemNumberLabel(): " + format );
 
         return String.valueOf( number );
     }