Example usage for java.lang String equalsIgnoreCase

List of usage examples for java.lang String equalsIgnoreCase

Introduction

In this page you can find the example usage for java.lang String equalsIgnoreCase.

Prototype

public boolean equalsIgnoreCase(String anotherString) 

Source Link

Document

Compares this String to another String , ignoring case considerations.

Usage

From source file:com.hp.common.Utility.java

public static String getAddress(float lat, float lon) {
    if (lat == 0 || lon == 0) {
        return "";
    }/* ww w .j  a v  a2 s  .  com*/

    String url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon + "&sensor=false";
    JSONObject jsonObj;
    String City = "";
    String address = "";
    try {

        jsonObj = new JSONObject(HttpHelper.makeRequest(url));

        String Status = jsonObj.getString("status");
        if (Status.equalsIgnoreCase("OK")) {
            JSONArray Results = jsonObj.getJSONArray("results");
            JSONObject zero = Results.getJSONObject(0);

            address = zero.getString("formatted_address").toString();

            String[] long_name = address.split(",");

            int number = long_name.length - 2;
            City = long_name[number];
            //System.out.println("CityName _______________________________ --->" + City + "");

            //Toast.makeText(this, "CityName: " + City, Toast.LENGTH_SHORT).show();

            if (!address.equals("")) {
                return address;
                //finish_service();
            }
        }

    } catch (JSONException e) {
        e.printStackTrace();
        return "";
    }
    return "";
}

From source file:com.userhook.hookpoint.UHHookPoint.java

public static UHHookPoint createWithData(JSONObject json) {

    UHHookPoint object = null;/* w ww . ja  v a  2s .  com*/

    try {

        String type = json.getString("type");

        if (type.equalsIgnoreCase(TYPE_ACTION)) {
            object = new UHHookPointAction(json);
        } else if (type.equalsIgnoreCase(TYPE_SURVEY)) {
            object = new UHHookPointSurvey(json);
        } else if (type.equalsIgnoreCase(TYPE_MESSAGE)) {
            object = new UHHookPointMessage(json);
        } else {
            object = new UHHookPoint(json);
        }

    } catch (Exception e) {
        Log.e(UserHook.TAG, "error parsing hook point json", e);
    }

    return object;
}

From source file:Main.java

public static Reader getUri(URL url) throws IOException {
    //Log.d(TAG, "getUri: " + url.toString());

    boolean useGzip = false;
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setReadTimeout(30 * 1000);//from w  w w  . jav  a  2  s  .  c  om
    conn.setRequestProperty("Accept-Encoding", "gzip");
    conn.connect();

    InputStream in = conn.getInputStream();

    final Map<String, List<String>> headers = conn.getHeaderFields();
    // This is a map, but we can't assume the key we're looking for
    // is in normal casing. So it's really not a good map, is it?
    final Set<Map.Entry<String, List<String>>> set = headers.entrySet();
    for (Iterator<Map.Entry<String, List<String>>> i = set.iterator(); i.hasNext();) {
        Map.Entry<String, List<String>> entry = i.next();
        if ("Content-Encoding".equalsIgnoreCase(entry.getKey())) {
            for (Iterator<String> j = entry.getValue().iterator(); j.hasNext();) {
                String str = j.next();
                if (str.equalsIgnoreCase("gzip")) {
                    useGzip = true;
                    break;
                }
            }
            // Break out of outer loop.
            if (useGzip) {
                break;
            }
        }
    }

    if (useGzip) {
        return new BufferedReader(new InputStreamReader(new GZIPInputStream(in)), 8 * 1024);
    } else {
        return new BufferedReader(new InputStreamReader(in), 8 * 1024);
    }
}

From source file:it.attocchi.utils.StringFunc.java

public static boolean equalsIgnoreCase(String string1, String string2) {
    return (string1 != null && string2 != null && string1.equalsIgnoreCase(string2));
}

From source file:Main.java

private static boolean checkForSameGenoTypeAndTreatment(String linegenotype, String linetreatment) {
    if (linegenotype == null || linetreatment == null)
        return false;
    if (linegenotype.equalsIgnoreCase(linetreatment))
        return true;
    else/*from w  ww.j  a v a2s  .  c  om*/
        return false;
}

From source file:$output.java

/**
 * Tell whether the passed role is set?/*ww w.j  a va  2  s .  c  o m*/
 *
 * @return true if the passed role is present, false otherwise.
 */
public static boolean hasRole(String roleName) {
    for (String role : getRoles()) {
        if (role.equalsIgnoreCase(roleName)) {
            return true;
        }
    }

    return false;
}

From source file:com.clicktravel.cheddar.server.runtime.config.RuntimeConfiguration.java

public static boolean isLocalOrDevEnvironment(final Environment environment) {
    for (final String profile : environment.getActiveProfiles()) {
        if (profile.equalsIgnoreCase(LOCAL_PROFILE) || profile.equalsIgnoreCase(DEV_PROFILE)) {
            return true;
        }//ww w .j a va 2s  . c  om
    }
    return false;
}

From source file:com.clicktravel.cheddar.server.runtime.config.RuntimeConfiguration.java

public static boolean isDeployedEnvironment(final Environment environment) {
    for (final String profile : environment.getActiveProfiles()) {
        if (profile.equalsIgnoreCase(CI_PROFILE) || profile.equalsIgnoreCase(UAT_PROFILE)
                || profile.equalsIgnoreCase(PRODUCTION_PROFILE)) {
            return true;
        }/*from   w ww . j  a v  a  2s  .co m*/
    }
    return false;
}

From source file:Utils.java

public static String toHtml(String string) {
    if (StringUtils.isNullOrEmpty(string))
        return "<html><body></body></html>";

    BufferedReader st = new BufferedReader(new StringReader(string));
    StringBuffer buf = new StringBuffer("<html><body>");

    try {// w  w  w  .  j  a  v a2  s.  c o  m
        String str = st.readLine();

        while (str != null) {
            if (str.equalsIgnoreCase("<br/>")) {
                str = "<br>";
            }

            buf.append(str);

            if (!str.equalsIgnoreCase("<br>")) {
                buf.append("<br>");
            }

            str = st.readLine();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    buf.append("</body></html>");
    string = buf.toString();
    return string;
}

From source file:com.technofovea.hl2parse.JxPathUtil.java

/**
 * A convenience function, this performs a *case-insensitive* equality test,
 * unlike the normal [a=b] xpath convention.
 * @param a A string//from  ww  w.  ja  v  a2s .co  m
 * @param b A string
 * @return True if the two strings are equal, ignoring case. False otherwise.
 */
public static boolean equals(String a, String b) {
    if (a == null) {
        return false;
    }
    return a.equalsIgnoreCase(b);
}