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.github.luluvise.droid_utils.http.NetworkConstants.java

/**
 * Attempts to retrieve a "Keep-Alive" header from the passed
 * {@link HttpResponse}./*w  w  w. j  ava  2  s.  c om*/
 * 
 * @return The keep alive time or -1 if not found
 */
public static long getKeepAliveHeader(@Nonnull HttpResponse response) {
    HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        HeaderElement he = it.nextElement();
        String param = he.getName();
        String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch (NumberFormatException ignore) {
                return -1;
            }
        }
    }
    return -1;
}

From source file:org.gvnix.support.dependenciesmanager.VersionInfo.java

/**
 * Extracts the version information from the string. Never throws an
 * exception. <br/>/* w  w w  .  j  ava2s . c o m*/
 * TODO: modify method design for make it smarter when working with several
 * version info formats
 * 
 * @param version to extract from (can be null or empty)
 * @return the version information or null if it was not in a normal form
 */
public static VersionInfo extractVersionInfoFromString(String version) {
    if (version == null || version.length() == 0) {
        return null;
    }

    String[] ver = version.split("\\.");
    try {
        // versions as x.y.z
        if (ver.length == 3) {
            VersionInfo result = new VersionInfo();
            result.major = new Integer(ver[0]);
            result.minor = new Integer(ver[1]);
            // gvNIX versions can be x.y.z (for final versions or release
            // versions) and x.y.z-q (for snapshots versions)
            String[] patchVerQualifier = ver[2].split("-");
            result.patch = new Integer(patchVerQualifier[0]);
            if (patchVerQualifier.length == 2) {
                String qualifier = patchVerQualifier[1];
                if (qualifier.equalsIgnoreCase(Qualifiers.RELEASE.toString())) {
                    result.qualifier = Qualifiers.RELEASE;
                } else if (qualifier.equalsIgnoreCase(Qualifiers.SNAPSHOT.toString())) {
                    result.qualifier = Qualifiers.SNAPSHOT;
                }
            }
            return result;
        }
        // versions as x.y
        if (ver.length == 2) {
            VersionInfo result = new VersionInfo();
            result.major = new Integer(ver[0]);
            result.minor = new Integer(ver[1]);
            return result;
        }
    } catch (RuntimeException e) {
        return null;
    }
    return null;
}

From source file:com.googlecode.mashups.services.generic.impl.FeedReaderImpl.java

private static Object getJSONData(String arrayName, StringBuilder content) throws Exception {
    if (arrayName.equalsIgnoreCase(NONE)) {

        // This means it is not an array, it is a simple dummy object ...
        if (content.indexOf("[") == -1 && content.indexOf("{") == 0) {
            //System.out.println("content: " + content);
            return new JSONObject(content.toString());
        }/*from www.j a  v  a 2 s  .  co m*/

        return new JSONArray(content.toString());
    }

    String searchFor = "\"" + arrayName + "\":[";

    int arrayStartIndex = content.indexOf(searchFor);
    int arrayEndIndex = 0;

    if (arrayStartIndex <= -1) {
        return new JSONArray();
    }

    // TODO optimize.
    int balance = 0;

    for (int i = (arrayStartIndex + searchFor.length()); i < content.length(); ++i) {
        char streamChar = content.charAt(i);

        if (streamChar == '[') {
            ++balance;
        } else if (streamChar == ']') {
            if (balance == 0) {
                arrayEndIndex = i + 1;
                break;
            }

            --balance;
        }
    }

    String arrayContent = "{" + content.substring(arrayStartIndex, arrayEndIndex) + "}";

    // create the JSON array.
    JSONObject json = new JSONObject(arrayContent);

    return json.getJSONArray(arrayName);
}

From source file:StringUtils.java

/**
 *  Returns true, if the string "val" denotes a positive string.  Allowed
 *  values are "yes", "on", and "true".  Comparison is case-insignificant.
 *  Null values are safe.//from  w  w  w  .  j a v  a  2 s .  com
 *
 *  @param val Value to check.
 *  @return True, if val is "true", "on", or "yes"; otherwise false.
 *
 *  @since 2.0.26
 */
public static boolean isPositive(String val) {
    if (val == null)
        return false;

    val = val.trim();

    return val.equalsIgnoreCase("true") || val.equalsIgnoreCase("on") || val.equalsIgnoreCase("yes");
}

From source file:MD5.java

public static boolean checkMD5(String md5, File updateFile) {
    if (md5 == null || md5.equals("") || updateFile == null) {
        return false;
    }/*  w w  w. j  av a 2  s  . c om*/

    String calculatedDigest = calculateMD5(updateFile);

    if (calculatedDigest == null) {
        return false;
    }
    return calculatedDigest.equalsIgnoreCase(md5);
}

From source file:Main.java

public static boolean collectionContainsIgnoringCase(Collection<String> collection, String val) {
    if (collection.contains(val)) {
        return true;
    }//from   w w  w.j a v  a 2 s . co m
    for (String f : collection) {
        if (f == val) {
            return true;
        }
        if (f == null) {
            return false;
        }
        if (f.equalsIgnoreCase(val)) {
            return true;
        }
    }
    return false;
}

From source file:com.wso2telco.hub.workflow.extensions.util.WorkflowProperties.java

public static Map<String, String> loadWorkflowPropertiesFromXML() {
    if (propertiesMap == null) {
        try {/*from w  w  w. j a va  2  s  . com*/
            propertiesMap = new HashMap<String, String>();

            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

            String carbonHome = System.getProperty("carbon.home");
            String workflowPropertiesFile = carbonHome + "/repository/conf/" + WORKFLOW_PROPERTIES_XML_FILE;

            Document document = builder.parse(new File(workflowPropertiesFile));
            Element rootElement = document.getDocumentElement();

            NodeList nodeList = rootElement.getElementsByTagName("Property");
            if (nodeList != null && nodeList.getLength() > 0) {
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    String nodeName = node.getAttributes().getNamedItem("name").getNodeValue();
                    if (nodeName.equalsIgnoreCase(SERVICE_HOST)
                            || nodeName.equalsIgnoreCase(KEY_WORKFLOW_EMAIL_NOTIFICATION_HOST)
                            || nodeName.equalsIgnoreCase(KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_ADDRESS)
                            || nodeName.equalsIgnoreCase(KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_PASSWORD)
                            || nodeName.equalsIgnoreCase(PUBLISHER_ROLE_START_WITH)
                            || nodeName.equalsIgnoreCase(PUBLISHER_ROLE_END_WITH)
                            || nodeName.equalsIgnoreCase(MANDATE_SERVICE_HOST)) {
                        String value = ((Element) node).getTextContent();
                        propertiesMap.put(nodeName, value);
                    } else {
                        //Not a matching property
                    }
                }
            }
        } catch (Exception e) {
            String errorMessage = "Error in WorkflowProperties.loadWorkflowPropertiesFromXML";
            log.error(errorMessage, e);
        }
    } else {
        //Return already loaded propertiesMap
    }
    return propertiesMap;
}

From source file:edu.wisc.web.util.JstlUtil.java

public static boolean equalsIgnoreCase(String s1, String s2) {
    if (s1 == s2) {
        return true;
    }/*from   w  w  w.ja  va  2  s  .  c om*/
    if (s1 == null) {
        return false;
    }
    return s1.equalsIgnoreCase(s2);
}

From source file:com.gst.infrastructure.documentmanagement.contentrepository.ContentRepositoryUtils.java

/**
 * Validates that passed in Mime type maps to known image mime types
 * //w w  w  .jav  a  2s  .c  om
 * @param mimeType
 */
public static void validateImageMimeType(final String mimeType) {
    if (!(mimeType.equalsIgnoreCase(IMAGE_MIME_TYPE.GIF.getValue())
            || mimeType.equalsIgnoreCase(IMAGE_MIME_TYPE.JPEG.getValue())
            || mimeType.equalsIgnoreCase(IMAGE_MIME_TYPE.PNG.getValue()))) {
        throw new ImageUploadException();
    }
}

From source file:com.lr.backer.controller.Pay.java

/**
 * ??//  ww w  .  java2 s  .c  o m
 * @param timestamp
 * @param noncestr
 * @param openid
 * @param issubscribe
 * @param appsignature
 * @return
 * @throws UnsupportedEncodingException 
 */
public static boolean verifySign(long timestamp, String noncestr, String openid, int issubscribe,
        String appsignature) throws UnsupportedEncodingException {
    Map<String, String> paras = new HashMap<String, String>();
    paras.put("appid", ConfKit.get("AppId"));
    paras.put("appkey", ConfKit.get("paySignKey"));
    paras.put("timestamp", String.valueOf(timestamp));
    paras.put("noncestr", noncestr);
    paras.put("openid", openid);
    paras.put("issubscribe", String.valueOf(issubscribe));
    // appid?appkey?productid?timestamp?noncestr?openid?issubscribe
    String string1 = createSign(paras, false);
    String paySign = DigestUtils.sha1Hex(string1);
    return paySign.equalsIgnoreCase(appsignature);
}