Java String Equal areStringsEqual(String s1, String s2, boolean caseInsensitive, boolean dontDistinctNullAndEmpty)

Here you can find the source of areStringsEqual(String s1, String s2, boolean caseInsensitive, boolean dontDistinctNullAndEmpty)

Description

are Strings Equal

License

Apache License

Declaration

public static boolean areStringsEqual(String s1, String s2, boolean caseInsensitive,
            boolean dontDistinctNullAndEmpty) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static boolean areStringsEqual(String s1, String s2, boolean caseInsensitive,
            boolean dontDistinctNullAndEmpty) {
        if (dontDistinctNullAndEmpty) {
            if (s1 == null || s1.length() == 0)
                return s2 == null || s2.length() == 0;
        }//from   w  ww.  jav  a2 s . c  o m
        return areStringsEqual(s1, s2, caseInsensitive);
    }

    public static boolean areStringsEqual(String s1, String s2, boolean caseInsensitive) {
        if (s1 == null)
            return s2 == null;
        if (caseInsensitive)
            return s1.equalsIgnoreCase(s2);
        else
            return s1.equals(s2);
    }

    public static boolean areStringsEqual(String s1, String s2) {
        return areStringsEqual(s1, s2, false);
    }
}

Related

  1. areEqualXMLValues(String s1, String s2)
  2. areStringEquals(String s1, String s2)
  3. areStringEquals(String string1, String string2)
  4. areStringsEqual(String one, String two)
  5. areStringsEqual(String s1, String s2, boolean caseInsensitive)
  6. areStringsEqual(String str1, String str2)
  7. collapseQualifier(String qualifier, boolean includeDots)
  8. equalsCaseless(String sA_, String sB_)
  9. equalsIgnoreCase(String s1, String s2)