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 getBooleanAttributeByName(Node content, String attributeName, boolean defaultTrue) {
    String value = getAttributeByName(content, attributeName);

    if (defaultTrue) {
        return (value == null) || (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"));
    } else {//  w  ww.  j a va  2s .  c  om
        return (value != null) && (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"));
    }
}

From source file:Main.java

public static String decode(char[] cl, String encoding, Resources res) {

    StringBuffer buf = new StringBuffer();
    if (!encoding.equalsIgnoreCase("big5"))
        return decode(cl, encoding);
    /* UAO Patch//from  www . j av a 2  s. co m
     *  We use our own convert table instead of the system's.
     *  Maybe we should implement Charset instead, though it seems complicated.
     */
    try {
        if (big5_to_ucs == null)
            loadUAO(res);
        for (int i = 0; i < cl.length; i++) {
            if (cl[i] >= 0x81 && cl[i] <= 0xfe && i < cl.length - 1 && cl[i + 1] >= 0x40 && cl[i + 1] <= 0xfe) { // Big5 Range                  
                buf.append(big5_to_ucs[(cl[i] << 8 | cl[i + 1]) - Big5TPAD]);
                i++;
            } else
                buf.append(cl[i]);
        }
    } catch (Exception e) {
        return decode(cl, encoding); //Give up UAO
    }
    return buf.toString();
}

From source file:Main.java

public static boolean equal(String s1, String s2, boolean p_ignoreCase) {
    if ((s1 == null) || (s2 == null))
        return false;
    if (p_ignoreCase)
        return s1.equalsIgnoreCase(s2);
    return s1.equals(s2);
}

From source file:Main.java

/**
 * Get a boolean from an XPath expression.
 * //from  w w  w. ja v  a 2  s.  com
 * @param node node
 * @param def default value
 * @param expr XPath expression
 * @return string, or null if empty or not defined
 * @throws XPathExpressionException 
 */
public static boolean getBool(Node node, boolean def, XPathExpression expr) throws XPathExpressionException {
    String s = getStringOrNull(node, expr);
    if (s == null) {
        return def;
    }
    return s.equalsIgnoreCase("true");
}

From source file:com.dattack.dbping.report.MetricName.java

private static boolean isEquals(final String text1, final String text2) {
    return text1.equalsIgnoreCase(text2) || StringUtils.isBlank(text1) || StringUtils.isBlank(text2);
}

From source file:net.chris54721.infinitycubed.Updater.java

public static void checkUpdates() {
    try {//w  w w  .ja  va2s.  c  o  m
        LogHelper.info("Checking for launcher updates");
        String version = Resources.toString(new URL(Reference.FILES_URL + "version.cfg"), Charsets.UTF_8);
        if (!version.equalsIgnoreCase(Launcher.getVersion()))
            downloadUpdate(version);
    } catch (Exception e) {
        LogHelper.error("Failed checking for launcher updates", e);
    }
}

From source file:org.jasig.cas.adaptors.ldap.util.SpringLdapUtils.java

/**
 * Reads a Boolean value from the DirContextAdapter
 *
 * @param ctx       the DirContextAdapter
 * @param attribute the attribute name/*from www  .  jav  a  2s.com*/
 * @param nullValue the value which sould be returing in case of a null value
 * @return <code>true</code> if the attribute's value matches (case-insensitive) <code>"true"</code>, otherwise false
 */
public static Boolean getBoolean(final DirContextOperations ctx, final String attribute,
        final Boolean nullValue) {
    final String v = ctx.getStringAttribute(attribute);
    if (v != null)
        return v.equalsIgnoreCase(LDAP_BOOLEAN_TRUE);
    return nullValue;
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.util.AuthUtil.java

/**
 * Use the information from the request to see if it has the Basic authorization header. If it does
 * validate it./*  w ww  .  j a v a2s.  c  om*/
 * @param request
 * @return true if the user is authorized and false if the user is not authorized.
 * @throws IOException
 */
public static boolean isAuthorized(HttpServletRequest request) throws IOException {
    String username = null;
    String password = null;
    boolean authorized = false;
    String authHeader = request.getHeader(KEY_AUTHORIZATION);
    if (authHeader != null) {
        StringTokenizer st = new StringTokenizer(authHeader);
        if (st.hasMoreTokens()) {
            String basic = st.nextToken();
            if (basic.equalsIgnoreCase(KEY_BASIC)) {
                try {
                    String credentials = new String(
                            org.apache.commons.codec.binary.Base64.decodeBase64(st.nextToken().getBytes()),
                            MMXServerConstants.UTF8_ENCODING);
                    LOGGER.debug("Auth header {} ", authHeader);
                    int p = credentials.indexOf(":");
                    if (p != -1) {
                        username = credentials.substring(0, p).trim();
                        password = credentials.substring(p + 1).trim();
                    } else {
                        LOGGER.warn("Invalid authentication token");
                    }
                } catch (UnsupportedEncodingException e) {
                    LOGGER.warn("Couldn't retrieve authentication", e);
                }
            }
        }
    } else {
        LOGGER.info("Request is missing the authorization header");
    }
    AuthToken token = null;
    if (username != null && password != null) {
        try {
            token = AuthFactory.authenticate(username, password);
        } catch (ConnectionException e) {
            LOGGER.error("isAuthorized : ", e);
        } catch (InternalUnauthenticatedException e) {
            LOGGER.error("isAuthorized : ", e);
        } catch (UnauthorizedException e) {
            LOGGER.error("isAuthorized : ", e);
        }
    }
    if (token != null) {
        AdminManager manager = AdminManager.getInstance();
        authorized = manager.isUserAdmin(username, false);
        if (!authorized) {
            LOGGER.info("User:{} is not an admin. Not granting access", username);
        }
    }
    return authorized;
}

From source file:Main.java

public static long readSubNodeLongValue(Node n, String name, long dflt) {
    if (name == null)
        return dflt;

    for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
        if (name.equalsIgnoreCase(d.getNodeName()))
            return Long.parseLong(d.getNodeValue());

    return dflt;//from  w w w . ja  v  a2 s  .co  m
}

From source file:Main.java

public static boolean equals(String str1, String str2, boolean ignoreCase) {
    if (str1 != null && str2 != null) {
        if (ignoreCase) {
            return str1.equalsIgnoreCase(str2);
        } else {/*  ww  w  .  j  a  v a2 s  .  co m*/
            return str1.equals(str2);
        }
    } else {
        return str1 == null && str2 == null;
    }
}