1.5.1 tweaking

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_1_5_BRANCH@352698 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-06-15 03:21:07 +00:00
parent 9009364fb9
commit da6101e570
7 changed files with 111 additions and 204 deletions

View File

@ -69,7 +69,7 @@
<version major="1" <version major="1"
minor="5" minor="5"
fix ="1" fix ="1"
tag="dev"/> tag="final"/>
<package>org.apache.poi</package> <package>org.apache.poi</package>
@ -87,7 +87,7 @@
<depend project="junit"/> <depend project="junit"/>
<depend project="IzPress"/> <depend project="IzPress"/>
<!-- needed for POI --> <!-- needed for POI -->
<depend project="commons-logging"/> <!-- <depend project="commons-logging"/> -->
<!-- Project jars POI build can use --> <!-- Project jars POI build can use -->
<option project="jakarta-log4j"/> <option project="jakarta-log4j"/>

View File

@ -11,7 +11,11 @@
<person id="NKB" name="Nicola Ken Barozzi" email="barozzi@nicolaken.com"/> <person id="NKB" name="Nicola Ken Barozzi" email="barozzi@nicolaken.com"/>
<person id="POI-DEVELOPERS" name="Poi Developers" email="poi-dev@jakarta.apache.org"/> <person id="POI-DEVELOPERS" name="Poi Developers" email="poi-dev@jakarta.apache.org"/>
</devs> </devs>
<release version="1.5" date="Coming Soon"> <release version="1.5.1" date="16 June 2002">
<action dev="GJS" type="update">Removed depedency on commons logging. Now define poi.logging system property to enable logging to standard out.</action>
<action dev="GJS" type="fix">Fixed SST string handling so that spreadsheets with rich text or extended text will be read correctly.</action>
</release>
<release version="1.5" date="06 May 2002">
<action dev="NKB" type="update">New project build.</action> <action dev="NKB" type="update">New project build.</action>
<action dev="NKB" type="update">New project documentation system based on Cocoon.</action> <action dev="NKB" type="update">New project documentation system based on Cocoon.</action>
<action dev="POI-DEVELOPERS" type="update">Package rename</action> <action dev="POI-DEVELOPERS" type="update">Package rename</action>

View File

@ -397,55 +397,20 @@ export CLASSPATH=$CLASSPATH:$HSSFDIR/hssf.jar:$HSSFDIR/poi-poifs.jar:$HSSFDIR/po
<ul> <ul>
<li>Type: <li>Type:
<code>java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls</code> <code>java org.apache.poi.hssf.dev.HSSF ~/input.xls output.xls</code>
<p> <br/>
<br/>
This is the read/write/modify test. It reads in the spreadsheet, modifies a cell, and writes it back out. This is the read/write/modify test. It reads in the spreadsheet, modifies a cell, and writes it back out.
Failing this test is not necessarily a bad thing. If HSSF tries to modify a non-existant sheet then this will Failing this test is not necessarily a bad thing. If HSSF tries to modify a non-existant sheet then this will
most likely fail. No big deal. </p></li> most likely fail. No big deal. </li>
</ul> </ul>
</section> </section>
<section title="HSSF Logging facility"> <section title="HSSF Logging Facility">
<p>HSSF now has a logging facility (using
<link href="http://jakarta.apache.org/commons/logging.html">commons logging</link>)
that will record massive amounts of debugging information. Its mostly
useful to us hssf-developing geeks, but might be useful in tracking
down problems.
</p>
<p>So Why use commons logging rather than log4j? Well the following discussion from
the jakarta-general mailing list sums it up pretty well. (Thanks Morgan)
</p>
<p><em>Here's the problem, as I see it.</em>
</p>
<p><em>Suppose Commons component A decides to adopt Log4J, Commons component B
decides to adopt LogKit, and Commons component C adopts JDK1.4 logging.
They will all minimally function with the right jars in the classpath.
However you (the end-user) are left with maintaining configuration for 3
different logging APIs, which is tedious at best. When you take into
account cool features like variable log levels, Log4J appenders and the
like, you're pretty much guaranteed to swallow up useful configuration
options because sophisticated configurations are too difficult to maintain
over mutiple logging implementations.</em>
</p>
<p> <p>
<em>Contrarily, if all three Commons components use a logging facade, you can POI has a small amount of logging code embedded within it. Defining the system property
focus all your configuration efforts on one logging implementation. Sure, poi.logging will enable logging to standard out.
there is a trade-off; you don't have access to all the features, and the
interface between the facade and the implementation must be maintained. But
the benefits are not just political; they potentially make the end-users
configuration much easier.</em>
</p>
<p><em>Even if all Commons components used the same logging implementation (Log4J
for example), other projects in Jakarta-land may choose otherwise. If you
add enough Jakarta projects to your environment, you eventually end up with
the scenario described above. It's a worthwhile effort to attempt a logging
solution that plays well with the Jakarta community at large. I think in
many cases the Commons Logging component can fill that role.</em>
</p>
<p>
Refer to the commons logging package level javadoc for more information concerning how to
<link href="http://jakarta.apache.org/commons/logging/api/index.html">configure commons logging.</link>
</p> </p>
</section> </section>
<section title="HSSF Developer's tools"> <section title="HSSF Developer's Tools">
<p>HSSF has a number of tools useful for developers to debug/develop <p>HSSF has a number of tools useful for developers to debug/develop
stuff using HSSF (and more generally XLS files). We've already stuff using HSSF (and more generally XLS files). We've already

View File

@ -1,4 +1,3 @@
/* /*
* ==================================================================== * ====================================================================
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -55,12 +54,8 @@
*/ */
package org.apache.poi.util; package org.apache.poi.util;
import java.io.FileInputStream; import java.util.HashMap;
import java.io.IOException; import java.util.Map;
import java.util.*;
import org.apache.commons.logging.*;
/** /**
* Provides logging without clients having to mess with * Provides logging without clients having to mess with
@ -73,7 +68,7 @@ import org.apache.commons.logging.*;
public class POILogFactory public class POILogFactory
{ {
private static LogFactory _creator = LogFactory.getFactory(); // private static LogFactory _creator = LogFactory.getFactory();
// map of POILogger instances, with classes as keys // map of POILogger instances, with classes as keys
private static Map _loggers = new HashMap();; private static Map _loggers = new HashMap();;
@ -118,7 +113,7 @@ public class POILogFactory
} }
else else
{ {
logger = new POILogger(_creator.getInstance(cat)); logger = new POILogger( );
_loggers.put( cat, logger ); _loggers.put( cat, logger );
} }
return logger; return logger;

View File

@ -55,8 +55,6 @@
*/ */
package org.apache.poi.util; package org.apache.poi.util;
import org.apache.commons.logging.Log;
import java.util.*; import java.util.*;
/** /**
@ -72,7 +70,7 @@ import java.util.*;
public class POILogger public class POILogger
{ {
private Log log = null; // private Log log = null;
public static final int DEBUG = 1; public static final int DEBUG = 1;
public static final int INFO = 3; public static final int INFO = 3;
public static final int WARN = 5; public static final int WARN = 5;
@ -82,13 +80,10 @@ public class POILogger
/** /**
* package scope so it cannot be instantiated outside of the util * package scope so it cannot be instantiated outside of the util
* package. You need a POILogger? Go to the POILogFactory for one * package. You need a POILogger? Go to the POILogFactory for one
*
* @param log the object that does the real work of logging
*/ */
POILogger(final Log log) POILogger()
{ {
this.log = log;
} }
/** /**
@ -100,91 +95,73 @@ public class POILogger
public void log(final int level, final Object obj1) public void log(final int level, final Object obj1)
{ {
if(level==FATAL) if (check(level))
{ System.out.println( obj1 );
if(log.isFatalEnabled())
{
log.fatal(obj1);
}
}
else if(level==ERROR)
{
if(log.isErrorEnabled())
{
log.error(obj1);
}
}
else if(level==WARN)
{
if(log.isWarnEnabled())
{
log.warn(obj1);
}
}
else if(level==INFO)
{
if(log.isInfoEnabled())
{
log.info(obj1);
}
}
else if(level==DEBUG)
{
if(log.isDebugEnabled())
{
log.debug(obj1);
}
}
else
{
if(log.isTraceEnabled())
{
log.trace(obj1);
}
} }
private boolean isDebugEnabled()
{
return System.getProperty("poi.logging") != null;
}
private boolean isInfoEnabled()
{
return false;
}
private boolean isWarnEnabled()
{
return System.getProperty("poi.logging") != null;
}
private boolean isErrorEnabled()
{
return System.getProperty("poi.logging") != null;
}
private boolean isFatalEnabled()
{
return System.getProperty("poi.logging") != null;
} }
/** /**
* Check if a logger is enabled to log at the specified level * Check if a logger is enabled to log at the specified level
* *
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The logger to check.
*/ */
public boolean check(final int level)
public boolean check(final Log log, final int level)
{ {
if(level==FATAL) if(level==FATAL)
{ {
if(log.isFatalEnabled()) if(isFatalEnabled())
{ {
return true; return true;
} }
} }
else if(level==ERROR) else if(level==ERROR)
{ {
if(log.isErrorEnabled()) if(isErrorEnabled())
{ {
return true; return true;
} }
} }
else if(level==WARN) else if(level==WARN)
{ {
if(log.isWarnEnabled()) if(isWarnEnabled())
{ {
return true; return true;
} }
} }
else if(level==INFO) else if(level==INFO)
{ {
if(log.isInfoEnabled()) if(isInfoEnabled())
{ {
return true; return true;
} }
} }
else if(level==DEBUG) else if(level==DEBUG)
{ {
if(log.isDebugEnabled()) if(isDebugEnabled())
{ {
return true; return true;
} }
@ -204,7 +181,7 @@ public class POILogger
public void log(final int level, final Object obj1, final Object obj2) public void log(final int level, final Object obj1, final Object obj2)
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(32).append(obj1).append(obj2)); log(level, new StringBuffer(32).append(obj1).append(obj2));
} }
@ -222,13 +199,9 @@ public class POILogger
public void log(final int level, final Object obj1, final Object obj2, public void log(final int level, final Object obj1, final Object obj2,
final Object obj3) final Object obj3)
{ {
if (check( level))
if (check(log, level))
{ {
log(level, log(level, new StringBuffer(48).append(obj1).append(obj2 ).append(obj3));
new StringBuffer(48).append(obj1).append(obj2)
.append(obj3));
} }
} }
@ -247,7 +220,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, log(level,
new StringBuffer(64).append(obj1).append(obj2) new StringBuffer(64).append(obj1).append(obj2)
@ -271,7 +244,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, log(level,
new StringBuffer(80).append(obj1).append(obj2) new StringBuffer(80).append(obj1).append(obj2)
@ -297,7 +270,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level , log(level ,
new StringBuffer(96).append(obj1).append(obj2) new StringBuffer(96).append(obj1).append(obj2)
@ -324,7 +297,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, log(level,
new StringBuffer(112).append(obj1).append(obj2) new StringBuffer(112).append(obj1).append(obj2)
@ -353,7 +326,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, log(level,
new StringBuffer(128).append(obj1).append(obj2) new StringBuffer(128).append(obj1).append(obj2)
@ -390,7 +363,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(32).append(obj1).append(obj2), log(level, new StringBuffer(32).append(obj1).append(obj2),
exception); exception);
@ -412,7 +385,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(48).append(obj1).append(obj2) log(level, new StringBuffer(48).append(obj1).append(obj2)
.append(obj3), exception); .append(obj3), exception);
@ -436,7 +409,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(64).append(obj1).append(obj2) log(level, new StringBuffer(64).append(obj1).append(obj2)
.append(obj3).append(obj4), exception); .append(obj3).append(obj4), exception);
@ -461,7 +434,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(80).append(obj1).append(obj2) log(level, new StringBuffer(80).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5), exception); .append(obj3).append(obj4).append(obj5), exception);
@ -487,7 +460,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level , new StringBuffer(96).append(obj1) log(level , new StringBuffer(96).append(obj1)
.append(obj2).append(obj3).append(obj4).append(obj5) .append(obj2).append(obj3).append(obj4).append(obj5)
@ -516,7 +489,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(112).append(obj1).append(obj2) log(level, new StringBuffer(112).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5).append(obj6) .append(obj3).append(obj4).append(obj5).append(obj6)
@ -546,7 +519,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
log(level, new StringBuffer(128).append(obj1).append(obj2) log(level, new StringBuffer(128).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5).append(obj6) .append(obj3).append(obj4).append(obj5).append(obj6)
@ -703,7 +676,7 @@ public class POILogger
{ {
if (check(log, level)) if (check( level))
{ {
Object[] params = flattenArrays(unflatParams); Object[] params = flattenArrays(unflatParams);

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
@ -55,11 +54,9 @@
package org.apache.poi.util; package org.apache.poi.util;
import org.apache.log4j.Category; import junit.framework.TestCase;
import junit.framework.*; import java.io.IOException;
import java.io.*;
/** /**
* @author Marc Johnson (mjohnson at apache dot org) * @author Marc Johnson (mjohnson at apache dot org)

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
@ -57,9 +56,6 @@ package org.apache.poi.util;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.io.File;
import java.io.FileInputStream;
/** /**
* Tests the log class. * Tests the log class.
* *
@ -84,26 +80,11 @@ public class TestPOILogger
super( s ); super( s );
} }
/**
* Method setUp
*
*
* @exception Exception
*
*/
protected void setUp()
throws Exception
{
super.setUp();
}
/** /**
* Test different types of log output. * Test different types of log output.
* *
* @exception Exception * @exception Exception
*/ */
public void testVariousLogTypes() public void testVariousLogTypes()
throws Exception throws Exception
{ {
@ -114,18 +95,10 @@ public class TestPOILogger
POILogger log = POILogFactory.getLogger( "foo" ); POILogger log = POILogFactory.getLogger( "foo" );
log.log( POILogger.WARN, "Test = ", new Integer( 1 ) ); log.log( POILogger.WARN, "Test = ", new Integer( 1 ) );
log.logFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %", log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", "2", new Integer( 3 ) );
"2", new Integer(3)); log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", new int[]{4, 5} );
log.logFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %",
new int[]
{
4, 5
});
log.logFormatted( POILogger.ERROR, log.logFormatted( POILogger.ERROR,
"Test param 1 = %1.1, param 2 = %0.1", new double[] "Test param 1 = %1.1, param 2 = %0.1", new double[]{4, 5.23} );
{
4, 5.23
});
} }
} }