Whitespace, javadocs and @Overrides for the Logger classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1755192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2016-08-04 14:23:54 +00:00
parent a1f6d9c832
commit f8bc502028
5 changed files with 21 additions and 24 deletions

View File

@ -27,19 +27,13 @@ import org.apache.commons.logging.LogFactory;
* developers to write log calls, while simultaneously making those * developers to write log calls, while simultaneously making those
* calls as cheap as possible by performing lazy evaluation of the log * calls as cheap as possible by performing lazy evaluation of the log
* message.<p> * message.<p>
*
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/ */
public class CommonsLogger extends POILogger public class CommonsLogger extends POILogger
{ {
private static LogFactory _creator = LogFactory.getFactory(); private static LogFactory _creator = LogFactory.getFactory();
private Log log = null; private Log log = null;
@Override
public void initialize(final String cat) public void initialize(final String cat)
{ {
this.log = _creator.getInstance(cat); this.log = _creator.getInstance(cat);
@ -51,6 +45,7 @@ public class CommonsLogger extends POILogger
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log. * @param obj1 The object to log.
*/ */
@Override
public void log(final int level, final Object obj1) public void log(final int level, final Object obj1)
{ {
if(level==FATAL) if(level==FATAL)
@ -104,6 +99,7 @@ public class CommonsLogger extends POILogger
* @param obj1 The object to log. This is converted to a string. * @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged * @param exception An exception to be logged
*/ */
@Override
public void log(final int level, final Object obj1, public void log(final int level, final Object obj1,
final Throwable exception) final Throwable exception)
{ {
@ -175,7 +171,7 @@ public class CommonsLogger extends POILogger
* *
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
*/ */
@Override
public boolean check(final int level) public boolean check(final int level)
{ {
if(level==FATAL) if(level==FATAL)

View File

@ -22,14 +22,10 @@ package org.apache.poi.util;
* developers to write log calls, while simultaneously making those * developers to write log calls, while simultaneously making those
* calls as cheap as possible by performing lazy evaluation of the log * calls as cheap as possible by performing lazy evaluation of the log
* message.<p> * message.<p>
*
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/ */
public class NullLogger extends POILogger { public class NullLogger extends POILogger {
@Override @Override
public void initialize(final String cat){ public void initialize(final String cat) {
// do nothing // do nothing
} }
@ -41,8 +37,7 @@ public class NullLogger extends POILogger {
*/ */
@Override @Override
public void log(final int level, final Object obj1) public void log(final int level, final Object obj1) {
{
// do nothing // do nothing
} }
@ -53,6 +48,7 @@ public class NullLogger extends POILogger {
* @param obj1 The object to log. This is converted to a string. * @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged * @param exception An exception to be logged
*/ */
@Override
public void log(int level, Object obj1, final Throwable exception) { public void log(int level, Object obj1, final Throwable exception) {
// do nothing // do nothing
} }

View File

@ -24,15 +24,12 @@ package org.apache.poi.util;
* developers to write log calls, while simultaneously making those * developers to write log calls, while simultaneously making those
* calls as cheap as possible by performing lazy evaluation of the log * calls as cheap as possible by performing lazy evaluation of the log
* message. * message.
*
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/ */
public class SystemOutLogger extends POILogger public class SystemOutLogger extends POILogger
{ {
private String _cat; private String _cat;
@Override
public void initialize(final String cat) public void initialize(final String cat)
{ {
this._cat=cat; this._cat=cat;
@ -44,7 +41,7 @@ public class SystemOutLogger extends POILogger
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log. * @param obj1 The object to log.
*/ */
@Override
public void log(final int level, final Object obj1) public void log(final int level, final Object obj1)
{ {
log(level, obj1, null); log(level, obj1, null);
@ -57,6 +54,7 @@ public class SystemOutLogger extends POILogger
* @param obj1 The object to log. This is converted to a string. * @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged * @param exception An exception to be logged
*/ */
@Override
@SuppressForbidden("uses printStackTrace") @SuppressForbidden("uses printStackTrace")
public void log(final int level, final Object obj1, public void log(final int level, final Object obj1,
final Throwable exception) { final Throwable exception) {
@ -78,6 +76,7 @@ public class SystemOutLogger extends POILogger
* @see #ERROR * @see #ERROR
* @see #FATAL * @see #FATAL
*/ */
@Override
public boolean check(final int level) public boolean check(final int level)
{ {
int currentLevel; int currentLevel;

View File

@ -30,16 +30,20 @@ public class DummyPOILogger extends POILogger {
logged = new ArrayList<String>(); logged = new ArrayList<String>();
} }
@Override
public boolean check(int level) { public boolean check(int level) {
return true; return true;
} }
@Override
public void initialize(String cat) {} public void initialize(String cat) {}
@Override
public void log(int level, Object obj1) { public void log(int level, Object obj1) {
logged.add(level + " - " + obj1); logged.add(level + " - " + obj1);
} }
@Override
public void log(int level, Object obj1, Throwable exception) { public void log(int level, Object obj1, Throwable exception) {
logged.add(level + " - " + obj1 + " - " + exception); logged.add(level + " - " + obj1 + " - " + exception);
} }

View File

@ -26,10 +26,6 @@ import org.junit.Test;
/** /**
* Tests the log class. * 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)
*/ */
public final class TestPOILogger extends POILogger { public final class TestPOILogger extends POILogger {
private String lastLog = ""; private String lastLog = "";
@ -61,20 +57,26 @@ public final class TestPOILogger extends POILogger {
POILogFactory._loggerClassName = oldLCN; POILogFactory._loggerClassName = oldLCN;
} }
} }
// ---------- POI Logger methods implemented for testing ----------
@Override
public void initialize(String cat) { public void initialize(String cat) {
} }
@Override
public void log(int level, Object obj1) { public void log(int level, Object obj1) {
lastLog = (obj1 == null) ? "" : obj1.toString(); lastLog = (obj1 == null) ? "" : obj1.toString();
lastEx = null; lastEx = null;
} }
@Override
public void log(int level, Object obj1, Throwable exception) { public void log(int level, Object obj1, Throwable exception) {
lastLog = (obj1 == null) ? "" : obj1.toString(); lastLog = (obj1 == null) ? "" : obj1.toString();
lastEx = exception; lastEx = exception;
} }
@Override
public boolean check(int level) { public boolean check(int level) {
return true; return true;
} }