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 isEqual(String str1, String str2, boolean ignoreCase) {
    if (str1 == null && str2 == null) {
        return true;
    }/*w  ww.  j a v  a 2 s  .co m*/

    if (str1 != null && str2 != null) {
        if (ignoreCase) {
            return str1.equalsIgnoreCase(str2);
        } else {
            return str1.equals(str2);
        }
    }

    return false;
}

From source file:com.moviejukebox.model.enumerations.WatchedWithExtension.java

/**
 * Convert a string into an Enum type//  w  w  w  . j av a2 s  . c  o  m
 *
 * @param extensionString
 * @return
 */
public static WatchedWithExtension fromString(String extensionString) {
    if (StringUtils.isNotBlank(extensionString)) {
        for (final WatchedWithExtension extension : EnumSet.allOf(WatchedWithExtension.class)) {
            if (extensionString.equalsIgnoreCase(extension.type)) {
                return extension;
            }
        }
    }
    // We've not found the type, so return both
    return BOTH;
}

From source file:com.codenvy.cas.util.LdapUtils.java

/**
 * Reads a Boolean value from the LdapEntry.
 *
 * @param ctx       the ldap entry//from w w  w  .  j  a  v a  2 s . c o m
 * @param attribute the attribute name
 * @param nullValue the value which should be returning 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 LdapEntry ctx, final String attribute, final Boolean nullValue) {
    final String v = getString(ctx, attribute, nullValue.toString());
    if (v != null) {
        return v.equalsIgnoreCase(Boolean.TRUE.toString());
    }
    return nullValue;
}

From source file:com.nttec.everychan.chans.fourchan.FourchanJsonMapper.java

static PostModel mapPostModel(JSONObject object, String boardName) {
    PostModel model = new PostModel();
    model.number = Long.toString(object.getLong("no"));
    model.name = StringEscapeUtils/*from  w w  w . j  av a 2  s. c o m*/
            .unescapeHtml4(RegexUtils.removeHtmlSpanTags(object.optString("name", "Anonymous")));
    model.subject = StringEscapeUtils.unescapeHtml4(object.optString("sub", ""));
    String comment = object.optString("com", "");
    comment = RegexUtils.replaceAll(comment, S_TAG, "<$1aibspoiler>");
    model.comment = LINKIFY ? RegexUtils.linkify(comment) : comment;
    model.email = null;
    model.trip = object.optString("trip", "");
    String capcode = object.optString("capcode", "none");
    if (!capcode.equals("none"))
        model.trip += "##" + capcode;
    String countryIcon = object.optString("country", "");
    if (!countryIcon.equals("")) {
        BadgeIconModel icon = new BadgeIconModel();
        icon.source = "s.4cdn.org/image/country/"
                + /*(boardName.equals("pol") ? "troll/" : "") + */countryIcon.toLowerCase(Locale.US) + ".gif";
        icon.description = object.optString("country_name");
        model.icons = new BadgeIconModel[] { icon };
    }
    model.op = false;
    String id = object.optString("id", "");
    model.sage = id.equalsIgnoreCase("Heaven");
    if (!id.equals(""))
        model.name += (" ID:" + id);
    if (!id.equals("") && !id.equalsIgnoreCase("Heaven"))
        model.color = CryptoUtils.hashIdColor(id);
    model.timestamp = object.getLong("time") * 1000;
    model.parentThread = object.optString("resto", "0");
    if (model.parentThread.equals("0"))
        model.parentThread = model.number;
    String ext = object.optString("ext", "");
    if (!ext.equals("")) {
        AttachmentModel attachment = new AttachmentModel();
        switch (ext) {
        case ".jpg":
        case ".png":
            attachment.type = AttachmentModel.TYPE_IMAGE_STATIC;
            break;
        case ".gif":
            attachment.type = AttachmentModel.TYPE_IMAGE_GIF;
            break;
        case ".webm":
            attachment.type = AttachmentModel.TYPE_VIDEO;
            break;
        default:
            attachment.type = AttachmentModel.TYPE_OTHER_FILE;
        }
        attachment.size = object.optInt("fsize", -1);
        if (attachment.size > 0)
            attachment.size = Math.round(attachment.size / 1024f);
        attachment.width = object.optInt("w", -1);
        attachment.height = object.optInt("h", -1);
        attachment.originalName = object.optString("filename", "") + ext;
        attachment.isSpoiler = object.optInt("spoiler") == 1;
        long tim = object.optLong("tim");
        if (tim != 0) {
            attachment.thumbnail = "t.4cdn.org/" + boardName + "/" + Long.toString(tim) + "s.jpg";
            attachment.path = "i.4cdn.org/" + boardName + "/" + Long.toString(tim) + ext;
            model.attachments = new AttachmentModel[] { attachment };
        }

    }
    return model;
}

From source file:Main.java

/**
 * Checks if the passed String is null or empty
 * @param str String to check/*from w  w  w . j  av a2 s.  com*/
 * @return Boolean, true if it is null or empty, false if it is not.
 */
public static boolean isNullOrEmpty(String str) {
    if (str == null) {
        return true;
    }
    if (str.isEmpty()) {
        return true;
    }
    if (str.length() == 0) {
        return true;
    }
    if (str.equalsIgnoreCase(" ")) {
        return true;
    }
    return false;
}

From source file:Main.java

/**
 * check if given name is equal to name of the element (with and without namespace)
 * @param node//from  w  w w. jav  a2 s .c om
 * @param k
 * @param caseSensitive
 * @return
 */
public static boolean nameEqual(Node node, String name, boolean caseSensitive) {
    if (name == null)
        return false;
    if (caseSensitive) {
        return name.equals(node.getNodeName()) || name.equals(node.getLocalName());
    }
    return name.equalsIgnoreCase(node.getNodeName()) || name.equalsIgnoreCase(node.getLocalName());
}

From source file:com.boyuanitsm.pay.alipay.util.AlipayCore.java

/** 
 * ???/*from  w w  w .j a  v a2  s .c  o  m*/
 * @param sArray ???
 * @return ???????
 */
public static Map<String, String> paraFilter(Map<String, String> sArray) {

    Map<String, String> result = new HashMap<String, String>();

    if (sArray == null || sArray.size() <= 0) {
        return result;
    }

    for (String key : sArray.keySet()) {
        String value = sArray.get(key);
        if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
                || key.equalsIgnoreCase("sign_type")) {
            continue;
        }
        result.put(key, value);
    }

    return result;
}

From source file:controllers.api.v1.AdvSearch.java

public static Result search() {
    ObjectNode result = Json.newObject();
    String searchOptStr = request().getQueryString("searchOpts");
    JsonNode searchOpt = Json.parse(searchOptStr);
    int page = 1;
    int size = 10;
    String pageStr = request().getQueryString("page");
    if (StringUtils.isBlank(pageStr)) {
        page = 1;//from w w  w .  ja va2 s.  com
    } else {
        try {
            page = Integer.parseInt(pageStr);
        } catch (NumberFormatException e) {
            Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage());
            page = 1;
        }
    }

    String sizeStr = request().getQueryString("size");
    if (StringUtils.isBlank(sizeStr)) {
        size = 10;
    } else {
        try {
            size = Integer.parseInt(sizeStr);
        } catch (NumberFormatException e) {
            Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage());
            size = 10;
        }
    }
    result.put("status", "ok");
    String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE__KEY);

    if (searchOpt != null && searchOpt.has("category")) {
        String category = searchOpt.get("category").asText();
        if (category.equalsIgnoreCase("flow")) {
            if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
                result.set("result", Json.toJson(AdvSearchDAO.elasticSearchFlowJobs(searchOpt, page, size)));
            } else {
                result.set("result", Json.toJson(AdvSearchDAO.searchFlows(searchOpt, page, size)));
            }
            return ok(result);
        } else if (category.equalsIgnoreCase("metric")) {
            if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
                result.set("result", Json.toJson(AdvSearchDAO.elasticSearchMetric(searchOpt, page, size)));
            } else {
                result.set("result", Json.toJson(AdvSearchDAO.searchMetrics(searchOpt, page, size)));
            }
            return ok(result);
        }

    }

    if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) {
        result.set("result", Json.toJson(AdvSearchDAO.elasticSearch(searchOpt, page, size)));
    } else {
        result.set("result", Json.toJson(AdvSearchDAO.search(searchOpt, page, size)));
    }

    return ok(result);
}

From source file:fr.certu.chouette.command.CommandParser.java

public static List<CommandArgument> parseFile(String filename) throws Exception {
    File f = new File(filename);
    List<String> lines = FileUtils.readLines(f);
    List<CommandArgument> commands = new ArrayList<CommandArgument>();
    int linenumber = 1;
    for (int i = 0; i < lines.size(); i++) {
        String line = lines.get(i).trim();
        if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit"))
            break;
        if (!line.isEmpty() && !line.startsWith("#")) {
            int number = linenumber++;
            while (line.endsWith("\\")) {
                line = line.substring(0, line.length() - 1);
                i++;//  ww w  .j a v a  2  s  . c  om
                if (i < lines.size())
                    line += lines.get(i).trim();
            }
            CommandArgument command = parseLine(number, line);
            if (command != null) {
                if (command.getName().equalsIgnoreCase("include")) {

                } else {
                    commands.add(command);
                }
            }

        }
    }
    return commands;

}