From 5b4f46e180e99d1e570451b8da59d8614f127aa3 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 4 Aug 2016 14:23:54 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/util/CommonsLogger.java | 12 ++++-------- src/java/org/apache/poi/util/NullLogger.java | 10 +++------- src/java/org/apache/poi/util/SystemOutLogger.java | 9 ++++----- .../org/apache/poi/util/DummyPOILogger.java | 4 ++++ src/testcases/org/apache/poi/util/TestPOILogger.java | 10 ++++++---- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/java/org/apache/poi/util/CommonsLogger.java b/src/java/org/apache/poi/util/CommonsLogger.java index 16a48f28f6..1cbb9628ca 100644 --- a/src/java/org/apache/poi/util/CommonsLogger.java +++ b/src/java/org/apache/poi/util/CommonsLogger.java @@ -27,19 +27,13 @@ import org.apache.commons.logging.LogFactory; * developers to write log calls, while simultaneously making those * calls as cheap as possible by performing lazy evaluation of the log * 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 CommonsLogger extends POILogger { - private static LogFactory _creator = LogFactory.getFactory(); private Log log = null; - + @Override public void initialize(final String 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 obj1 The object to log. */ + @Override public void log(final int level, final Object obj1) { 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 exception An exception to be logged */ + @Override public void log(final int level, final Object obj1, final Throwable exception) { @@ -175,7 +171,7 @@ public class CommonsLogger extends POILogger * * @param level One of DEBUG, INFO, WARN, ERROR, FATAL */ - + @Override public boolean check(final int level) { if(level==FATAL) diff --git a/src/java/org/apache/poi/util/NullLogger.java b/src/java/org/apache/poi/util/NullLogger.java index 24643c8fde..fe0979cfef 100644 --- a/src/java/org/apache/poi/util/NullLogger.java +++ b/src/java/org/apache/poi/util/NullLogger.java @@ -22,14 +22,10 @@ package org.apache.poi.util; * developers to write log calls, while simultaneously making those * calls as cheap as possible by performing lazy evaluation of the log * 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 NullLogger extends POILogger { @Override - public void initialize(final String cat){ + public void initialize(final String cat) { // do nothing } @@ -41,8 +37,7 @@ public class NullLogger extends POILogger { */ @Override - public void log(final int level, final Object obj1) - { + public void log(final int level, final Object obj1) { // do nothing } @@ -53,6 +48,7 @@ public class NullLogger extends POILogger { * @param obj1 The object to log. This is converted to a string. * @param exception An exception to be logged */ + @Override public void log(int level, Object obj1, final Throwable exception) { // do nothing } diff --git a/src/java/org/apache/poi/util/SystemOutLogger.java b/src/java/org/apache/poi/util/SystemOutLogger.java index e665ba6324..36d96ca038 100644 --- a/src/java/org/apache/poi/util/SystemOutLogger.java +++ b/src/java/org/apache/poi/util/SystemOutLogger.java @@ -24,15 +24,12 @@ package org.apache.poi.util; * developers to write log calls, while simultaneously making those * calls as cheap as possible by performing lazy evaluation of the log * 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 { private String _cat; + @Override public void initialize(final String cat) { this._cat=cat; @@ -44,7 +41,7 @@ public class SystemOutLogger extends POILogger * @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param obj1 The object to log. */ - + @Override public void log(final int level, final Object obj1) { 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 exception An exception to be logged */ + @Override @SuppressForbidden("uses printStackTrace") public void log(final int level, final Object obj1, final Throwable exception) { @@ -78,6 +76,7 @@ public class SystemOutLogger extends POILogger * @see #ERROR * @see #FATAL */ + @Override public boolean check(final int level) { int currentLevel; diff --git a/src/testcases/org/apache/poi/util/DummyPOILogger.java b/src/testcases/org/apache/poi/util/DummyPOILogger.java index 976c7d918e..c8566fe663 100644 --- a/src/testcases/org/apache/poi/util/DummyPOILogger.java +++ b/src/testcases/org/apache/poi/util/DummyPOILogger.java @@ -30,16 +30,20 @@ public class DummyPOILogger extends POILogger { logged = new ArrayList(); } + @Override public boolean check(int level) { return true; } + @Override public void initialize(String cat) {} + @Override public void log(int level, Object obj1) { logged.add(level + " - " + obj1); } + @Override public void log(int level, Object obj1, Throwable exception) { logged.add(level + " - " + obj1 + " - " + exception); } diff --git a/src/testcases/org/apache/poi/util/TestPOILogger.java b/src/testcases/org/apache/poi/util/TestPOILogger.java index a53de44eb4..3914b76436 100644 --- a/src/testcases/org/apache/poi/util/TestPOILogger.java +++ b/src/testcases/org/apache/poi/util/TestPOILogger.java @@ -26,10 +26,6 @@ import org.junit.Test; /** * 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 { private String lastLog = ""; @@ -61,20 +57,26 @@ public final class TestPOILogger extends POILogger { POILogFactory._loggerClassName = oldLCN; } } + + // ---------- POI Logger methods implemented for testing ---------- + @Override public void initialize(String cat) { } + @Override public void log(int level, Object obj1) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = null; } + @Override public void log(int level, Object obj1, Throwable exception) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = exception; } + @Override public boolean check(int level) { return true; } -- 2.39.5