logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1501395 - in /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core: appender/db/jdbc/ColumnConfig.java helpers/Strings.java
Date Tue, 09 Jul 2013 17:24:26 GMT
Author: ggregory
Date: Tue Jul  9 17:24:26 2013
New Revision: 1501395

URL: http://svn.apache.org/r1501395
Log:
Refactor duplicate code in the API String.isNotEmpty(String).

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Strings.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java?rev=1501395&r1=1501394&r2=1501395&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
Tue Jul  9 17:24:26 2013
@@ -110,8 +110,8 @@ public final class ColumnConfig {
             return null;
         }
 
-        final boolean isPattern = pattern != null && pattern.length() > 0;
-        final boolean isLiteralValue = literalValue != null && literalValue.length()
> 0;
+        final boolean isPattern = Strings.isNotEmpty(pattern);
+        final boolean isLiteralValue = Strings.isNotEmpty(literalValue);
         final boolean isEventTimestamp = Boolean.parseBoolean(eventTimestamp);
         final boolean isUnicode = Booleans.parseBoolean(unicode, true);
         final boolean isClob = Boolean.parseBoolean(clob);

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Strings.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Strings.java?rev=1501395&r1=1501394&r2=1501395&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Strings.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Strings.java
Tue Jul  9 17:24:26 2013
@@ -42,4 +42,25 @@ public class Strings {
         return cs == null || cs.length() == 0;
     }
 
+    /**
+     * <p>Checks if a CharSequence is not empty ("") and not null.</p>
+     *
+     * <pre>
+     * StringUtils.isNotEmpty(null)      = false
+     * StringUtils.isNotEmpty("")        = false
+     * StringUtils.isNotEmpty(" ")       = true
+     * StringUtils.isNotEmpty("bob")     = true
+     * StringUtils.isNotEmpty("  bob  ") = true
+     * </pre>
+     *
+     * <p>Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.isNotEmpty(CharSequence)</p>
+     * 
+     * @param cs  the CharSequence to check, may be null
+     * @return {@code true} if the CharSequence is not empty and not null
+     * @since 3.0 Changed signature from isNotEmpty(String) to isNotEmpty(CharSequence)
+     */
+    public static boolean isNotEmpty(final CharSequence cs) {
+        return !isEmpty(cs);
+    }
+
 }



Mime
View raw message