<version major="1"
minor="5"
fix ="1"
- tag="dev"/>
+ tag="final"/>
<package>org.apache.poi</package>
<depend project="junit"/>
<depend project="IzPress"/>
<!-- needed for POI -->
- <depend project="commons-logging"/>
+ <!-- <depend project="commons-logging"/> -->
<!-- Project jars POI build can use -->
<option project="jakarta-log4j"/>
<person id="NKB" name="Nicola Ken Barozzi" email="barozzi@nicolaken.com"/>
<person id="POI-DEVELOPERS" name="Poi Developers" email="poi-dev@jakarta.apache.org"/>
</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 documentation system based on Cocoon.</action>
<action dev="POI-DEVELOPERS" type="update">Package rename</action>
<ul>
<li>Type:
<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.
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>
</section>
- <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>
-<em>Contrarily, if all three Commons components use a logging facade, you can
-focus all your configuration efforts on one logging implementation. Sure,
-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>
+ <section title="HSSF Logging Facility">
<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>
+ POI has a small amount of logging code embedded within it. Defining the system property
+ poi.logging will enable logging to standard out.
</p>
</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
stuff using HSSF (and more generally XLS files). We've already
-
/*
* ====================================================================
* The Apache Software License, Version 1.1
*/
package org.apache.poi.util;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import java.util.*;
-
-import org.apache.commons.logging.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* Provides logging without clients having to mess with
public class POILogFactory
{
- private static LogFactory _creator = LogFactory.getFactory();
+// private static LogFactory _creator = LogFactory.getFactory();
// map of POILogger instances, with classes as keys
- private static Map _loggers = new HashMap();;
+ private static Map _loggers = new HashMap();;
/**
* @return a POILogger for the specified class
*/
- public static POILogger getLogger(final Class theclass)
+ public static POILogger getLogger( final Class theclass )
{
- return getLogger(theclass.getName());
+ return getLogger( theclass.getName() );
}
-
+
/**
* Get a logger, based on a String
*
* @return a POILogger for the specified class
*/
- public static POILogger getLogger(final String cat)
+ public static POILogger getLogger( final String cat )
{
POILogger logger = null;
- if (_loggers.containsKey(cat))
+ if ( _loggers.containsKey( cat ) )
{
- logger = ( POILogger ) _loggers.get(cat);
+ logger = (POILogger) _loggers.get( cat );
}
else
{
- logger = new POILogger(_creator.getInstance(cat));
- _loggers.put(cat, logger);
+ logger = new POILogger( );
+ _loggers.put( cat, logger );
}
return logger;
}
-
+
} // end public class POILogFactory
*/
package org.apache.poi.util;
-import org.apache.commons.logging.Log;
-
import java.util.*;
/**
public class POILogger
{
- private Log log = null;
+// private Log log = null;
public static final int DEBUG = 1;
public static final int INFO = 3;
public static final int WARN = 5;
/**
* package scope so it cannot be instantiated outside of the util
* 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;
}
/**
public void log(final int level, final Object obj1)
{
- if(level==FATAL)
- {
- 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);
- }
- }
+ if (check(level))
+ System.out.println( 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
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 The logger to check.
*/
-
- public boolean check(final Log log, final int level)
+ public boolean check(final int level)
{
if(level==FATAL)
{
- if(log.isFatalEnabled())
+ if(isFatalEnabled())
{
return true;
}
}
else if(level==ERROR)
{
- if(log.isErrorEnabled())
+ if(isErrorEnabled())
{
return true;
}
}
else if(level==WARN)
{
- if(log.isWarnEnabled())
+ if(isWarnEnabled())
{
return true;
}
}
else if(level==INFO)
{
- if(log.isInfoEnabled())
+ if(isInfoEnabled())
{
return true;
}
}
else if(level==DEBUG)
{
- if(log.isDebugEnabled())
+ if(isDebugEnabled())
{
return true;
}
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));
}
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3)
{
-
-
- if (check(log, level))
+ if (check( level))
{
- log(level,
- new StringBuffer(48).append(obj1).append(obj2)
- .append(obj3));
+ log(level, new StringBuffer(48).append(obj1).append(obj2 ).append(obj3));
}
}
{
- if (check(log, level))
+ if (check( level))
{
log(level,
new StringBuffer(64).append(obj1).append(obj2)
{
- if (check(log, level))
+ if (check( level))
{
log(level,
new StringBuffer(80).append(obj1).append(obj2)
{
- if (check(log, level))
+ if (check( level))
{
log(level ,
new StringBuffer(96).append(obj1).append(obj2)
{
- if (check(log, level))
+ if (check( level))
{
log(level,
new StringBuffer(112).append(obj1).append(obj2)
{
- if (check(log, level))
+ if (check( level))
{
log(level,
new StringBuffer(128).append(obj1).append(obj2)
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(32).append(obj1).append(obj2),
exception);
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(48).append(obj1).append(obj2)
.append(obj3), exception);
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(64).append(obj1).append(obj2)
.append(obj3).append(obj4), exception);
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(80).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5), exception);
{
- if (check(log, level))
+ if (check( level))
{
log(level , new StringBuffer(96).append(obj1)
.append(obj2).append(obj3).append(obj4).append(obj5)
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(112).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5).append(obj6)
{
- if (check(log, level))
+ if (check( level))
{
log(level, new StringBuffer(128).append(obj1).append(obj2)
.append(obj3).append(obj4).append(obj5).append(obj6)
{
- if (check(log, level))
+ if (check( level))
{
Object[] params = flattenArrays(unflatParams);
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
package org.apache.poi.util;
-import org.apache.log4j.Category;
-
-import junit.framework.*;
+import junit.framework.TestCase;
-import java.io.*;
+import java.io.IOException;
/**
* @author Marc Johnson (mjohnson at apache dot org)
*/
public class TestPOILogFactory
- extends TestCase
+ extends TestCase
{
/**
* Creates new TestPOILogFactory
* @param name
*/
- public TestPOILogFactory(String name)
+ public TestPOILogFactory( String name )
{
- super(name);
+ super( name );
}
/**
*/
public void testLog()
- throws IOException
+ throws IOException
{
//NKB Testing only that logging classes use gives no exception
// Since logging can be disabled, no checking of logging
// output is done.
-
- POILogger l1 = POILogFactory.getLogger("org.apache.poi.hssf.test");
- POILogger l2 = POILogFactory.getLogger("org.apache.poi.hdf.test");
- l1.log(POILogger.FATAL, "testing cat org.apache.poi.hssf.*:FATAL");
- l1.log(POILogger.ERROR, "testing cat org.apache.poi.hssf.*:ERROR");
- l1.log(POILogger.WARN, "testing cat org.apache.poi.hssf.*:WARN");
- l1.log(POILogger.INFO, "testing cat org.apache.poi.hssf.*:INFO");
- l1.log(POILogger.DEBUG, "testing cat org.apache.poi.hssf.*:DEBUG");
+ POILogger l1 = POILogFactory.getLogger( "org.apache.poi.hssf.test" );
+ POILogger l2 = POILogFactory.getLogger( "org.apache.poi.hdf.test" );
+
+ l1.log( POILogger.FATAL, "testing cat org.apache.poi.hssf.*:FATAL" );
+ l1.log( POILogger.ERROR, "testing cat org.apache.poi.hssf.*:ERROR" );
+ l1.log( POILogger.WARN, "testing cat org.apache.poi.hssf.*:WARN" );
+ l1.log( POILogger.INFO, "testing cat org.apache.poi.hssf.*:INFO" );
+ l1.log( POILogger.DEBUG, "testing cat org.apache.poi.hssf.*:DEBUG" );
- l2.log(POILogger.FATAL, "testing cat org.apache.poi.hdf.*:FATAL");
- l2.log(POILogger.ERROR, "testing cat org.apache.poi.hdf.*:ERROR");
- l2.log(POILogger.WARN, "testing cat org.apache.poi.hdf.*:WARN");
- l2.log(POILogger.INFO, "testing cat org.apache.poi.hdf.*:INFO");
- l2.log(POILogger.DEBUG, "testing cat org.apache.poi.hdf.*:DEBUG");
+ l2.log( POILogger.FATAL, "testing cat org.apache.poi.hdf.*:FATAL" );
+ l2.log( POILogger.ERROR, "testing cat org.apache.poi.hdf.*:ERROR" );
+ l2.log( POILogger.WARN, "testing cat org.apache.poi.hdf.*:WARN" );
+ l2.log( POILogger.INFO, "testing cat org.apache.poi.hdf.*:INFO" );
+ l2.log( POILogger.DEBUG, "testing cat org.apache.poi.hdf.*:DEBUG" );
}
* @param ignored_args
*/
- public static void main(String [] ignored_args)
+ public static void main( String[] ignored_args )
{
- System.out.println("Testing basic util.POILogFactory functionality");
- junit.textui.TestRunner.run(TestPOILogFactory.class);
+ System.out.println( "Testing basic util.POILogFactory functionality" );
+ junit.textui.TestRunner.run( TestPOILogFactory.class );
}
}
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
import junit.framework.TestCase;
-import java.io.File;
-import java.io.FileInputStream;
-
/**
* Tests the log class.
*
* @author Glen Stampoultzis (glens at apache.org)
* @author Marc Johnson (mjohnson at apache dot org)
- * @author Nicola Ken Barozzi (nicolaken at apache.org)
+ * @author Nicola Ken Barozzi (nicolaken at apache.org)
*/
public class TestPOILogger
- extends TestCase
+ extends TestCase
{
/**
* Constructor TestPOILogger
*
*/
- public TestPOILogger(String s)
- {
- super(s);
- }
-
- /**
- * Method setUp
- *
- *
- * @exception Exception
- *
- */
-
- protected void setUp()
- throws Exception
+ public TestPOILogger( String s )
{
- super.setUp();
+ super( s );
}
/**
*
* @exception Exception
*/
-
public void testVariousLogTypes()
- throws Exception
+ throws Exception
{
//NKB Testing only that logging classes use gives no exception
// Since logging can be disabled, no checking of logging
// output is done.
-
- POILogger log = POILogFactory.getLogger("foo");
- log.log(POILogger.WARN, "Test = ", new Integer(1));
- log.logFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %",
- "2", new Integer(3));
- log.logFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %",
- new int[]
- {
- 4, 5
- });
- log.logFormatted(POILogger.ERROR,
- "Test param 1 = %1.1, param 2 = %0.1", new double[]
- {
- 4, 5.23
- });
+ POILogger log = POILogFactory.getLogger( "foo" );
+
+ log.log( POILogger.WARN, "Test = ", new Integer( 1 ) );
+ log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", "2", new Integer( 3 ) );
+ log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", new int[]{4, 5} );
+ log.logFormatted( POILogger.ERROR,
+ "Test param 1 = %1.1, param 2 = %0.1", new double[]{4, 5.23} );
}
}