You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2012/03/12 14:37:13 UTC

svn commit: r1299673 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java

Author: doebele
Date: Mon Mar 12 13:37:12 2012
New Revision: 1299673

URL: http://svn.apache.org/viewvc?rev=1299673&view=rev
Log:
EMPIREDB-126
tiny improvement to StringUtils

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java?rev=1299673&r1=1299672&r2=1299673&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java Mon Mar 12 13:37:12 2012
@@ -195,6 +195,21 @@ public class StringUtils
     }
     
     /**
+     * Compares two Strings with each other - either with or without character case. Both arguments may be null.
+     * @param s1 the first String
+     * @param s2 the second String
+     * @param ignoreCase whether to ignore the character casing or not
+     * @return true if the two strings supplied are equal 
+     */
+    public static boolean compareEqual(String s1, String s2, boolean ignoreCase)
+    {
+        if (s1==null || s2==null)
+            return (s1==s2);
+        // Compare 
+        return (ignoreCase) ? s1.equalsIgnoreCase(s2) : s1.equals(s2);
+    }
+    
+    /**
      * Validates a given string. If the string is empty then null is returned. 
      * Otherwise the trimmed string is returned.
      *