Null safe comparison of strings

@param s1         string 1
@param s2         string 2
@param ignoreCase True perform case insensitive comparison, False perform case sensitive comparison
@return as long as neither are null
180095
public static int compare(String s1, String s2, boolean ignoreCase) {
      if (s1 == null && s2 == null) {
         return 0;
      } else if (s1 == null) {
         return -1;
      } else if (s2 == null) {
         return 1;
      }
      return ignoreCase ? s1.compareToIgnoreCase(s2) : s1.compareTo(s2);
   }
15543
public static void doSetIgnoreCaseRecursively(ComparatorItem comparatorItem, boolean ignoreCase) {
    ComparatorItem tmp = comparatorItem;
    while (tmp != null) {
      tmp.setIgnoreCase(ignoreCase);
      tmp = tmp.getNextComparatorItem();
    }
  }
356814
public String isChecked(String value1, String value2) {

        if ((value1 == null) || (value2 == null)) {
            return "";
        }

        if (value1.trim().equalsIgnoreCase(value2.trim())) {
            return "checked";
        }

        return "";
    }
575441
public static boolean isEqualOrNull( List s1,
                                         List s2 ) {
        if ( s1 == null
                && s2 == null ) {
            return true;
        } else if ( s1 != null
                && s2 != null
                && s1.size() == s2.size() ) {
            return true;
        }
        return false;
    }
634187
private static int compareNodes(String node1, String node2) {
        assert node1 != null;
        assert node2 != null;
        
        if (node1.equals(node2)) {
            return 0;
        }
        if (node1.length() > 0 && node1.charAt(0) == '{') {
            if (node2.length() > 0 && node2.charAt(0) == '{') {
                return 0;  // Both nodes are parameters; names are irrelevant
            }
            return 1;  // r1 is a parameter but r2 is not, so r2 should come first
        }
        if (node2.length() > 0 && node2.charAt(0) == '{') {
            return -1;   // r2 is a parameter but r1 is not, so r1 should come first
        }
        return node1.compareTo(node2);  // neither node is a parameter
    }
1025804
public static int compare(CharSequence s1, CharSequence s2)
    {
        return compare(s1, s2, Funcs::same);
    }
319941
@SuppressWarnings("unchecked")
    final int compare(Object k1, Object k2) {
        return comparator==null ? ((Comparable<? super K>)k1).compareTo((K)k2)
            : comparator.compare((K)k1, (K)k2);
    }
1061454
public static function compare($str1, $str2, $ignoreCase = true)
    {
        if ($ignoreCase) {
            if (strcasecmp($str1, $str2) == 0) {
                return true;
            }
        } else {
            if (strcmp($str1, $str2) == 0) {
                return true;
            }
        }

        return false;
    }
184958
private static boolean isEqual(String string1, String string2) {
        return (string1 == null && string2 == null) || (string1 != null && string1.equals(string2));
    }
970374
public static float compare(final int numOfBits, final String str1,
            final String str2) {
        return compare(numOfBits, BaseEncoding.base64().decode(str1),
                BaseEncoding.base64().decode(str2));
    }
1349226
public static int compareVersions(String v1, String v2) {
		String s1 = normalisedVersion(v1);
		String s2 = normalisedVersion(v2);
		return s1 != null ? (s2 != null ? s1.compareTo(s2) : 1)
				: (s2 != null ? -1 : 0);
	}
367043
public static boolean isEqualOrNull( Map s1,
                                         Map s2 ) {
        if ( s1 == null
                && s2 == null ) {
            return true;
        } else if ( s1 != null
                && s2 != null
                && s1.size() == s2.size() ) {
            return true;
        }
        return false;
    }
1316290
public static boolean caseIgnoreMatch(String s1, String s2) {
        if (s1 == s2) {
            return true;
        }

        int len = s1.length();
        if (len != s2.length()) {
            return false;
        }

        for (int i = 0; i < len; i++) {
            char c1 = s1.charAt(i);
            char c2 = s2.charAt(i);
            if (c1 != c2 && toLower(c1) != toLower(c2)) {
                return false;
            }
        }
        return true;
    }
601941
public static String nullIfEmpty(String s) {
      if (s != null && s.length() == 0) {
         return null;
      } else {
         return s;
      }
   }
1277304
public static boolean simpleNameEquals(String s1, String s2) {
		if (isNullOrEmpty(s1)) {
			return isNullOrEmpty(s2);
		}
		return s1.equals(s2);
	}
696275
static private boolean matchPrefix(String s1, String s2) {
    return s1.startsWith(s2) || s2.startsWith(s1);
  }
244955
private static boolean containsIgnoreCase(String str, String searchStr) {
    if (str == null || searchStr == null) {
      return false;
    }
    int len = searchStr.length();
    int max = str.length() - len;
    for (int i = 0; i <= max; i++) {
      if (str.regionMatches(true, i, searchStr, 0, len)) {
        return true;
      }
    }
    return false;
  }