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:eu.optimis.tf.ip.service.utils.PropertiesUtils.java

private static String file4OS(String configFile) {
    if (configFile.equalsIgnoreCase("TRUST")) {
        if (System.getProperty("file.separator").equalsIgnoreCase("/")) {
            return getConfigFilePath(TRUST_CONFIG_FILE);
        } else {//from   w w  w  .  j  a v a2s  .  com
            return getConfigFilePath(TRUST_CONFIG_FILE_WIN);
        }
    }
    if (configFile.equalsIgnoreCase("LOG")) {
        if (System.getProperty("file.separator").equalsIgnoreCase("/")) {
            return getConfigFilePath(LOG4J_CONFIG_FILE);
        } else {
            return getConfigFilePath(LOG4J_CONFIG_FILE_WIN);
        }
    } else {
        if (System.getProperty("file.separator").equalsIgnoreCase("/")) {
            return getConfigFilePath(OPTIMIS_CONFIG_FILE);
        } else {
            return getConfigFilePath(OPTIMIS_CONFIG_FILE_WIN);
        }
    }
}

From source file:Main.java

public static int getNetWorkType(Context context) {
    int netType = NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo(context);
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NETWORK_WIFI;/*from w w  w . j  a  va  2  s  .c  o  m*/
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {

            case NETWORK_TYPE_GSM:
            case TelephonyManager.NETWORK_TYPE_GPRS:
            case TelephonyManager.NETWORK_TYPE_CDMA:
            case TelephonyManager.NETWORK_TYPE_EDGE:
            case TelephonyManager.NETWORK_TYPE_1xRTT:
            case TelephonyManager.NETWORK_TYPE_IDEN:
                netType = NETWORK_2G;
                break;

            case NETWORK_TYPE_TD_SCDMA:
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
            case TelephonyManager.NETWORK_TYPE_UMTS:
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
            case TelephonyManager.NETWORK_TYPE_HSDPA:
            case TelephonyManager.NETWORK_TYPE_HSUPA:
            case TelephonyManager.NETWORK_TYPE_HSPA:
            case TelephonyManager.NETWORK_TYPE_EVDO_B:
            case TelephonyManager.NETWORK_TYPE_EHRPD:
            case TelephonyManager.NETWORK_TYPE_HSPAP:
                netType = NETWORK_3G;
                break;

            case NETWORK_TYPE_IWLAN:
            case TelephonyManager.NETWORK_TYPE_LTE:
                netType = NETWORK_4G;
                break;
            default:

                String subtypeName = info.getSubtypeName();
                if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA")
                        || subtypeName.equalsIgnoreCase("CDMA2000")) {
                    netType = NETWORK_3G;
                } else {
                    netType = NETWORK_UNKNOWN;
                }
                break;
            }
        } else {
            netType = NETWORK_UNKNOWN;
        }
    }
    return netType;
}

From source file:StringUtils.java

/**
 * enlever des caractres de la partie gauche
 * @param str chaine source//from w  w  w.j  av  a2  s .  co m
 * @param patern chaine  enlever
 * @param ignoreCase ignorer MIN/MAJ du patern
 * @return chaine rsultat
 */
public static String ltrim(String toTrim, String patern, boolean ignoreCase) {
    if (!ignoreCase) {
        return fastLtrim(toTrim, patern);
    }
    patern = (patern == null) ? "" : patern;
    String str = (toTrim == null) ? "" : toTrim;
    int start = 0;
    if (!ignoreCase) {
        if (str.equalsIgnoreCase(patern)) {
            return "";
        }
        while (true) {
            if ((str.length() - start) < patern.length()) {
                break;
            }
            if (str.substring(start, start + patern.length()).equalsIgnoreCase(patern)) {
                start += patern.length();
            } else {
                break;
            }
        }
    }
    return str.substring(start);
}

From source file:Main.java

/**
 * Extract a named attribute from a node map.
 *
 * @param map attribute node map/*w w w .j ava  2  s  .c om*/
 * @param attrName name of the attribute to extract from the list
 * @return found node or null if not found
 */
public static Node getAttributeFromList(final NamedNodeMap map, final String attrName) {

    Node node = null;

    if (map != null) {
        for (int i = 0; i < map.getLength(); i++) {
            if (attrName.equalsIgnoreCase(map.item(i).getNodeName())) {
                node = map.item(i);
            }
        }
    }

    return node;
}

From source file:com.indeed.imhotep.builder.tsv.KerberosUtils.java

private static void checkKnownErrors(final String realPrincipal, final IOException e) throws IOException {
    // if it contains the ip address this is bad
    if (realPrincipal.contains(NetUtils.determineIpAddress())) {
        throw new IOException("Hostname substitution failed, probably because reverse DNS is not setup", e);
    }/*  w  w w  .j ava 2 s. c  o  m*/

    // we did not see the ip address so compare CanonicalHostName to HostName
    final String hostname = NetUtils.determineHostName();
    final String canonicalHostname = getCanonicalHostNameSafe();
    if (!hostname.equalsIgnoreCase(canonicalHostname)) {
        throw new IOException(
                "Unable to match canonicalHostname, maybe reverse DNS is wrong? saw " + canonicalHostname, e);
    }
}

From source file:Main.java

/**
 * Searches throgh the passed NamedNodeMap for an attribute. If it is found, it will try to convert it to a boolean.
 * @param nnm NamedNodeMap/*from  w  w w  . j av a  2  s  .  c  o m*/
 * @param name String
 * @throws RuntimeException on any failure to parse a boolean
 * @return boolean
 */
public static boolean getAttributeBooleanByName(NamedNodeMap nnm, String name) throws RuntimeException {
    for (int i = 0; i < nnm.getLength(); i++) {
        Attr attr = (Attr) nnm.item(i);
        if (attr.getName().equalsIgnoreCase(name)) {
            String tmp = attr.getValue().toLowerCase();
            if (tmp.equalsIgnoreCase("true"))
                return true;
            if (tmp.equalsIgnoreCase("false"))
                return false;
            throw new RuntimeException("Attribute " + name + " value not boolean:" + tmp);
        }
    }
    throw new RuntimeException("Attribute " + name + " not found.");
}

From source file:Main.java

/**
 * //w w w .  ja v  a  2  s .  c  om
 * @param args
 * @param val
 * @param rb
 */
public static void setSelectedRadioButton(String args, String[] val, RadioButton[] rb) {
    try {
        if (val.length == rb.length) {
            for (int i = 0; i < val.length; i++) {
                if (args.equalsIgnoreCase(val[i])) {
                    rb[i].setChecked(true);
                }
            }
        }
    } catch (Exception e) {
        Log.e("ZambelzUtility", "setSelectedRadioButton : " + e.getMessage());
    }
}

From source file:Main.java

public static List<Map<String, String>> searchFromAccNumber(List<Map<String, String>> orders, String acc) {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    if (acc != null) {
        for (Map<String, String> o : orders) {
            if (acc.equalsIgnoreCase(o.get("accountNumber"))) {
                result.add(o);//  www. j  ava 2 s .c  o m
            }
        }
    }
    return result;
}

From source file:com.enonic.cms.core.content.imports.ImportValueFormater.java

public static Boolean getBoolean(final AbstractSourceValue value) {
    final String strValue = getStringValue(value);
    if (strValue.equalsIgnoreCase("true")) {
        return true;
    }/* ww  w.jav a  2  s. c  om*/
    if (strValue.equalsIgnoreCase("false")) {
        return false;
    }
    return null;
}

From source file:Main.java

/**
 * Make sure an element/attribute name is a valid NCname. Note that the name is assumed non-qualified, i.e. no
 * namespaces (hence the Non Colon Name).
 * //from www  .  ja  v  a  2 s.  c  o m
 * @param name Proposed non-qualified name for an element/attribute.
 * @return Same string, with any invalid characters replaced by the underscore '_' character.
 */
public static String makeValidNCName(String name) {
    if (name == null || name.length() <= 0)
        throw new IllegalArgumentException("Invalid NCName: null or empty not allowed!");
    if (name.equalsIgnoreCase("XML"))
        throw new IllegalArgumentException("Invalid NCName: 'XML' name is reserved!");
    StringBuffer s = new StringBuffer(name);
    char c = name.charAt(0);
    if (!Character.isLetter(c) && c != '_')
        s.setCharAt(0, '_');
    for (int i = 1; i < name.length(); i++) {
        c = name.charAt(i);
        if (!Character.isLetter(c) && !Character.isDigit(c) && c != '_' && c != '.' && c != '-')
            s.setCharAt(i, '_');
    }
    return s.toString();
}