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:Main.java

public static boolean parseStringValueAsBoolean(String Value) {
    if (Value == null) {
        return false;
    }/*from www .j a  v  a  2  s .co m*/
    if ((Value.equals("1")) || (Value.equalsIgnoreCase("true"))) {
        return true;
    }
    return false;

}

From source file:Main.java

/**
 * This used when a double ends in 0 (IE 100.0) and you want to remove the significant figures
 * after the decimal point (assuming they end in zero)
 * @param value The double to convert//from ww  w  . java2  s .  c  o m
 * @param addDollarSign boolean, if null passed, nothing, if true passed, will add
 *                      a $ to the beginning
 * @return A String, formatted correctly. Will look like this: 104.44 or $99.
 *         if the last 2 are 00, it will remove the significant figures after
 *         the decimal as well as the decimal itself
 */
public static String convertDoubleToStringAddZero(double value, Boolean addDollarSign) {
    String str = Double.toString(value);
    if (str == null) {
        return null;
    }
    //String ending = str.substring((str.length()-2));
    String ending = str.substring((str.length() - 2), (str.length() - 1));
    if (ending.equalsIgnoreCase(".")) {
        str = str + "0";
    }
    if (addDollarSign != null) {
        if (addDollarSign) {
            str = "$" + str;
        }
    }
    ending = str.substring((str.length() - 3));
    if (ending.equalsIgnoreCase(".00")) {
        str = str.replace(".00", "");
    }

    return str;
}

From source file:com.granita.icloudcalsync.DateUtils.java

public static String findAndroidTimezoneID(String tzID) {
    String localTZ = null;// w  ww . jav a  2s  .  c  om
    String availableTZs[] = SimpleTimeZone.getAvailableIDs();

    // first, try to find an exact match (case insensitive)
    for (String availableTZ : availableTZs)
        if (availableTZ.equalsIgnoreCase(tzID)) {
            localTZ = availableTZ;
            break;
        }

    // if that doesn't work, try to find something else that matches
    if (localTZ == null) {
        Log.w(TAG, "Coulnd't find time zone with matching identifiers, trying to guess");
        for (String availableTZ : availableTZs)
            if (StringUtils.indexOfIgnoreCase(tzID, availableTZ) != -1) {
                localTZ = availableTZ;
                break;
            }
    }

    // if that doesn't work, use UTC as fallback
    if (localTZ == null) {
        Log.e(TAG, "Couldn't identify time zone, using UTC as fallback");
        localTZ = Time.TIMEZONE_UTC;
    }

    Log.d(TAG, "Assuming time zone " + localTZ + " for " + tzID);
    return localTZ;
}

From source file:com.wso2telco.dep.mediator.impl.credit.CreditHandlerFactory.java

public static CreditHandler createCreditHandler(String resourceURL, CreditExecutor executor) {

    CreditHandler creditHandler = null;/* w  w  w  .j  a v a2s  .com*/
    String transactionOperationStatus = null;
    log.debug("createCreditHandler -> Json string : " + executor.getJsonBody().toString());

    String httpMethod = executor.getHttpMethod();

    if (httpMethod.equalsIgnoreCase("post")) {
        if (resourceURL.contains("apply")) {
            log.debug("createCreditHandler ->Credit API type : apply");
            creditHandler = new CreditApplyHandler(executor);

        } else if (resourceURL.contains("refund")) {
            log.debug("createCreditHandler ->Credit API type : refund");
            creditHandler = new CreditRefundHandler(executor);
        }
    } else {
        log.debug("createCreditHandler -> API Type Not found");
        throw new CustomException("SVC0002", "", new String[] { null });
    }

    return creditHandler;
}

From source file:com.basetechnology.s0.agentserver.goals.Goal.java

public static Goal fromJson(JSONObject goalJson) throws AgentServerException {
    if (!goalJson.has("type"))
        throw new AgentServerException("Missing type in goal JSON");
    String type = goalJson.optString("type");
    if (type.equalsIgnoreCase(BooleanGoal.type))
        return BooleanGoal.fromJson(goalJson);
    else if (type.equalsIgnoreCase(GreaterGoal.type))
        return GreaterGoal.fromJson(goalJson);
    else if (type.equalsIgnoreCase(PercentageGoal.type))
        return PercentageGoal.fromJson(goalJson);
    else {//  w w  w . j  a v a  2 s. c o m
        String name = goalJson.optString("name");
        String description = goalJson.optString("description");
        JsonUtils.validateKeys(goalJson, "Goal",
                new ArrayList<String>(Arrays.asList("type", "name", "description")));
        return new Goal(name, description);
    }
}

From source file:Main.java

/**
 * convert latitude from DMS (Degrees, Minutes, Seconds) to DD (Decimal Degrees)
 *
 * @param int latDeg - latitude degree value
 * @param int latMin - latitude minute value
 * @param double latSec - latitude second value
 * @param String latDir - latitude direction (north or south)
 * @return double - double value for given latitude
 *//*from  w w w.jav  a 2  s  . c  o  m*/
public static double convertLatDMStoDD(int latDeg, int latMin, double latSec, String latDir) {
    double latitude = latDeg + (latMin / new Double(60)) + (latSec / new Double(3600));
    if (latDir.equalsIgnoreCase("s"))
        latitude = -latitude;
    return latitude;
}

From source file:Main.java

private static String getLauncherClassName(Context context) {
    PackageManager pm = context.getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0);
    for (ResolveInfo resolveInfo : resolveInfos) {
        String pkgName = resolveInfo.activityInfo.applicationInfo.packageName;
        if (pkgName.equalsIgnoreCase(context.getPackageName())) {
            String className = resolveInfo.activityInfo.name;
            return className;
        }//from w  ww .  j  a  v a2s .  c om
    }
    return null;
}

From source file:Main.java

/**
 * Checks if String in fields match one another. Does NOT compare case
 * @param et1/*w ww.ja  v  a  2s  .  co m*/
 * @param et2
 * @return
 */
public static boolean doFieldsMatch(EditText et1, EditText et2) {
    String str1 = getFromEditText(et1);
    String str2 = getFromEditText(et2);
    if (str1.equalsIgnoreCase(str2)) {
        return true;
    }
    if (str1 == null && str2 == null) {
        return false;
    }
    return false;
}

From source file:Main.java

/**
 * <p>Compares two Strings, returning <code>true</code> if they are equal ignoring
 * the case.</p>/*from  w ww. j  av  a2  s  .co m*/
 *
 * <p><code>null</code>s are handled without exceptions. Two <code>null</code>
 * references are considered equal. Comparison is case insensitive.</p>
 *
 * <pre>
 * StringUtils.equalsIgnoreCase(null, null)   = true
 * StringUtils.equalsIgnoreCase(null, "abc")  = false
 * StringUtils.equalsIgnoreCase("abc", null)  = false
 * StringUtils.equalsIgnoreCase("abc", "abc") = true
 * StringUtils.equalsIgnoreCase("abc", "ABC") = true
 * </pre>
 *
 * @see java.lang.String#equalsIgnoreCase(String)
 * @param str1  the first String, may be null
 * @param str2  the second String, may be null
 * @return <code>true</code> if the Strings are equal, case insensitive, or
 *  both <code>null</code>
 */
public static boolean equalsIgnoreCase(String str1, String str2) {
    return str1 == null ? str2 == null : str1.equalsIgnoreCase(str2);
}

From source file:Main.java

public static boolean equalsIgnoreCase(String str1, String str2) {
    if (str1 == null) {
        return str2 == null;
    }/*  w w  w.  ja va  2  s. c  om*/

    return str1.equalsIgnoreCase(str2);
}