Example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.

null s are handled without exceptions.

Usage

From source file:com.glaf.core.domain.ColumnDefinition.java

public boolean isResizable() {
    if (StringUtils.equalsIgnoreCase(resizableField, "1") || StringUtils.equalsIgnoreCase(resizableField, "Y")
            || StringUtils.equalsIgnoreCase(resizableField, "true")) {
        return true;
    }//from  w  ww. j  ava2s . c o  m
    return false;
}

From source file:com.nridge.ds.solr.SolrResponseBuilder.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private void populateHeader(QueryResponse aQueryResponse, long anOffset, long aLimit) {
    Logger appLogger = mAppMgr.getLogger(this, "populateHeader");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    Relationship headerRelationship = mDocument.getFirstRelationship(Solr.RESPONSE_HEADER);
    if (headerRelationship != null) {
        DataBag headerBag = headerRelationship.getBag();
        headerBag.resetValues();//ww w.  j a v  a  2 s.  c o m

        headerBag.setValueByName("page_size", aLimit);
        headerBag.setValueByName("offset_start", anOffset);
        headerBag.setValueByName("query_time", aQueryResponse.getQTime());

        String propertyName = getCfgPropertyPrefix() + ".request_handler";
        String requestHandler = mAppMgr.getString(propertyName);
        if (StringUtils.isNotEmpty(requestHandler)) {
            if (requestHandler.charAt(0) == StrUtl.CHAR_FORWARDSLASH)
                headerBag.setValueByName("request_handler", requestHandler);
            else
                headerBag.setValueByName("request_handler", StrUtl.CHAR_FORWARDSLASH + requestHandler);
        }

        int statusCode = aQueryResponse.getStatus();
        headerBag.setValueByName("status_code", statusCode);
        if (statusCode == Solr.RESPONSE_STATUS_SUCCESS)
            headerBag.setValueByName("status_message", "Success");
        else
            headerBag.setValueByName("status_message", "Failure");

        SolrDocumentList solrDocumentList = aQueryResponse.getResults();
        if (solrDocumentList != null) {
            Float maxScore = solrDocumentList.getMaxScore();
            if (maxScore == null)
                maxScore = (float) 0.0;
            headerBag.setValueByName("max_score", maxScore);
            headerBag.setValueByName("fetch_count", solrDocumentList.size());
            long totalCount = solrDocumentList.getNumFound();
            headerBag.setValueByName("total_count", totalCount);
        }

        NamedList<Object> headerList = aQueryResponse.getHeader();
        if (headerList != null) {
            NamedList<Object> paramList = (NamedList<Object>) aQueryResponse.getResponseHeader().get("params");
            if (paramList != null) {
                Object paramObject = paramList.get("fl");
                if (paramObject != null) {
                    DataField dataField = headerBag.getFieldByName("field_list");
                    if (paramObject instanceof String)
                        dataField.addValue(paramObject.toString());
                    else if (paramObject instanceof List) {
                        List fieldList = (List) paramObject;
                        int fieldCount = fieldList.size();
                        if (fieldCount > 0) {
                            for (int i = 0; i < fieldCount; i++)
                                dataField.addValue(fieldList.get(i).toString());
                        }
                    }
                }
                paramObject = paramList.get("hl");
                if (paramObject != null) {
                    DataField dataField = headerBag.getFieldByName("is_highlighted");
                    if (paramObject instanceof String) {
                        if (StringUtils.equalsIgnoreCase(paramObject.toString(), "on"))
                            dataField.setValue(true);
                    }
                }
            }
        }
    }

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:com.glaf.core.domain.ColumnDefinition.java

public boolean isSearchable() {
    if (StringUtils.equalsIgnoreCase(searchableField, "1") || StringUtils.equalsIgnoreCase(searchableField, "Y")
            || StringUtils.equalsIgnoreCase(searchableField, "true")) {
        return true;
    }//from  ww  w . ja v a2  s. c  o m
    return false;
}

From source file:com.glaf.core.domain.ColumnDefinition.java

public boolean isSortable() {
    if (StringUtils.equalsIgnoreCase(sortableField, "1") || StringUtils.equalsIgnoreCase(sortableField, "Y")
            || StringUtils.equalsIgnoreCase(sortableField, "true")) {
        return true;
    }/*from   w  w w.  ja v  a2s  . c  o  m*/
    return false;
}

From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionParser.java

protected SearchResultComparatorBase consumeThisComparator(TokenResultList tks) {
    SearchExpression se = consumeCommand(tks);
    if ((se instanceof SearchExpressionFieldSelektor) == false) {
        throw new InvalidMatcherGrammar("Need text selector. Got: " + se);
    }// www  .j  a v  a 2  s.c  om
    SearchExpressionFieldSelektor fs = (SearchExpressionFieldSelektor) se;
    if (se instanceof SearchExpressionTextContains) {
        String criteria = ((SearchExpressionTextContains) se).getText();
        if (StringUtils.equalsIgnoreCase(criteria, "relevance") == true) {
            return new SearchResultComparatorRelevance();
        }
        throw new InvalidMatcherGrammar("Unknown order criteria: " + criteria);
    } else {
        return new SearchResultComparatorField(fs);
    }
}

From source file:com.glaf.core.domain.ColumnDefinition.java

public boolean isUnique() {
    if (StringUtils.equalsIgnoreCase(uniqueField, "1") || StringUtils.equalsIgnoreCase(uniqueField, "Y")
            || StringUtils.equalsIgnoreCase(uniqueField, "true")) {
        return true;
    }/*ww  w  . j  av a 2s  . c  om*/
    return false;
}

From source file:com.moviejukebox.plugin.TheMovieDbPlugin.java

/**
 * Search for a movie title.//  ww  w  .j a  v  a  2 s  .  c  o  m
 *
 * Use a title that may be different to the actual title of the movie, but match against the full title.
 *
 * @param fullTitle
 * @param year
 * @param searchTitle
 */
private MovieInfo searchMovieTitle(Movie movie, int movieYear, final String searchTitle) {
    LOG.debug(LOG_LOCATE_MOVIE_INFORMATION, movie.getBaseName(), searchTitle, movieYear);
    MovieInfo movieDb = null;
    ResultList<MovieInfo> result;
    try {
        result = tmdb.searchMovie(searchTitle, 0, languageCode, INCLUDE_ADULT, movieYear, null,
                SearchType.PHRASE);
    } catch (MovieDbException ex) {
        LOG.warn("Error scanning movie '{}': {}", movie.getTitle(), ex.getMessage(), ex);
        return movieDb;
    }
    LOG.debug("{}: Found {} potential matches", movie.getBaseName(), result.getResults().size());

    List<MovieInfo> movieList = result.getResults();
    // Are the title and original title the same (used for performance)
    boolean sameTitle = StringUtils.equalsIgnoreCase(movie.getTitle(), movie.getOriginalTitle());

    // Iterate over the list until we find a match
    for (MovieInfo movieInfo : movieList) {
        String movieInfoYear = StringUtils.isBlank(movieInfo.getReleaseDate()) ? "UNKNOWN"
                : movieInfo.getReleaseDate().substring(0, 4);
        LOG.debug("Checking {} ({})", movieInfo.getTitle(), movieInfoYear);

        if (Compare.movies(movieInfo, movie.getTitle(), movieYear > 0 ? String.valueOf(movieYear) : "",
                SEARCH_MATCH, false)) {
            LOG.debug("Matched to '{}'", movie.getTitle());
            movieDb = movieInfo;
            break;
        } else if (!sameTitle && Compare.movies(movieInfo, movie.getOriginalTitle(), String.valueOf(movieYear),
                SEARCH_MATCH, false)) {
            // See if the original title is different and then compare it too
            LOG.debug("Matched to '{}'", movie.getOriginalTitle());
            movieDb = movieInfo;
            break;
        }
    }
    return movieDb;
}

From source file:com.glaf.core.domain.ColumnDefinition.java

public boolean isUpdatable() {
    if (StringUtils.equalsIgnoreCase(updatableField, "1") || StringUtils.equalsIgnoreCase(updatableField, "Y")
            || StringUtils.equalsIgnoreCase(updatableField, "true")) {
        return true;
    }//from   w  w w. j a  v a  2 s  .  c  o  m
    return false;
}

From source file:com.utdallas.s3lab.smvhunter.monkey.MonkeyMe.java

@Override
public void run() {
    if (logDebug)
        logger.debug("starting thread");
    while (!apkQueue.isEmpty()) {
        File apkFile = apkQueue.poll();
        String apkName = apkFile.getName();

        //check if the apk has been tested already
        if (completedApps.contains(apkName) || seenApks.contains(apkName)) {
            logger.info(String.format("app %s already tested. Skipping ============", apkName));
            continue;
        }//from  w w w.  ja  v  a  2 s  .  c o m

        //add it to the seen apks
        seenApks.add(apkName);

        IDevice device = null;
        try {

            //get the package name from the apk name
            String[] nameArr = apkName.split("-");
            String packageName = nameArr[0];

            List<StaticResultBean> staticResultBeans = resultFromStaticAnalysis.get(apkName);

            //install only if interested 
            if (staticResultBeans != null && !staticResultBeans.isEmpty()) {
                //get a device from pool
                device = DevicePool.getinstance().getDeviceFromPool();

                if (logDebug)
                    logger.debug(String.format("%s installing apk %s", device.getSerialNumber(), apkFile));
                //install the apk
                installApk(apkName, device, packageName, 0);
            } else { //not interested
                continue;
            }

            logger.info("No of screens to traverse " + staticResultBeans.size());

            //start the app and attach strace
            //strace will run for the whole lifetime of the app
            //e.g. start the app  adb shell am start -n ao.bai.https
            execCommand(String.format("%s shell am start -n %s", getDeviceString(device),
                    apkName.replace("-", "/").replace(".apk", "")));
            Future<?> networkFuture = executors.submit(new NetworkMonitor(device, packageName));

            //for each vulnerable entry point from static analysis
            for (StaticResultBean resBean : staticResultBeans) {
                String seed = resBean.getSeedName();
                String seedType = resBean.getSeedType();

                //reset the window before proceeding
                //press enter two times
                execCommand(String.format("%s %s", getDeviceString(device), "shell input keyevent 66"));
                execCommand(String.format("%s %s", getDeviceString(device), "shell input keyevent 66"));

                //seed type can be either activity or service
                //dont process if it is not of the type activity
                if (StringUtils.equalsIgnoreCase(seedType, "activity")) {
                    //start activity
                    //format adb shell am start -n com.ifs.banking.fiid1027/com.banking.activities.ContactUsActivity
                    String result = execCommand(String.format("%s %s %s/%s", getDeviceString(device),
                            " shell am start -n ", packageName, seed));
                    logger.info("Activity started with result : " + result);
                    Thread.sleep(5000);

                    //get smart input for this method
                    List<SmartInputBean> smart = resultFromSmartInputGeneration.get(seed);

                    //perform UI automation
                    enumerateCurrentWindow(device, apkName, smart);

                } else if (StringUtils.equalsIgnoreCase(seedType, "service")) {
                    //ignore
                } else {
                    logger.debug(String.format("Did not process seed %s for apk %s ", seed, seedType, apkFile));
                }
            }

            //interrupt the network monitor
            networkFuture.cancel(true);

            //completed 
            writeCompleted(apkName);

            //uninstall the apk
            uninstallApk(packageName, device);

        } catch (Exception e) {
            logger.error("exception occured " + apkName, e);
            //            apkQueue.add(apkFile);
        } finally {
            //return the device to pool
            if (device != null) {
                DevicePool.getinstance().returnDeviceToPool(device);
            }
        }
    }

    //release the latch
    cdl.countDown();
}

From source file:com.mirth.connect.cli.CommandLineInterface.java

private void executeStatement(String command) {
    try {/*from  www .  ja va 2  s  .c om*/
        Token[] arguments = tokenizeCommand(command);

        if (arguments.length >= 1) {
            Token arg1 = arguments[0];
            if (arg1 == Token.HELP) {
                commandHelp(arguments);
                return;
            } else if (arg1 == Token.USER) {
                if (arguments.length < 2) {
                    error("invalid number of arguments.", null);
                    return;
                }
                Token arg2 = arguments[1];
                if (arg2 == Token.LIST) {
                    commandUserList(arguments);
                } else if (arg2 == Token.ADD) {
                    commandUserAdd(arguments);
                } else if (arg2 == Token.REMOVE) {
                    commandUserRemove(arguments);
                } else if (arg2 == Token.CHANGEPW) {
                    commandUserChangePassword(arguments);
                }
            } else if (arg1 == Token.DEPLOY) {
                commandDeploy(arguments);
            } else if (arg1 == Token.EXPORTCFG) {
                commandExportConfig(arguments);
            } else if (arg1 == Token.IMPORTCFG) {
                commandImportConfig(arguments);
            } else if (arg1 == Token.IMPORT) {
                commandImport(arguments);
            } else if (arg1 == Token.IMPORTALERTS) {
                commandImportAlerts(arguments);
            } else if (arg1 == Token.EXPORTALERTS) {
                commandExportAlerts(arguments);
            } else if (arg1 == Token.IMPORTSCRIPTS) {
                commandImportScripts(arguments);
            } else if (arg1 == Token.EXPORTSCRIPTS) {
                commandExportScripts(arguments);
            } else if (arg1 == Token.IMPORTCODETEMPLATES) {
                // Deprecated, remove in 3.4
                error("The importcodetemplates command is deprecated. Please use \"codetemplate [library] import path [force]\" instead.",
                        null);
                if (!hasInvalidNumberOfArguments(arguments, 2)) {
                    commandImportCodeTemplates(arguments[1].getText(), true);
                }
            } else if (arg1 == Token.EXPORTCODETEMPLATES) {
                // Deprecated, remove in 3.4
                error("The exportcodetemplates command is deprecated. Please use \"codetemplate [library] export id|name|* path\" instead.",
                        null);
                if (!hasInvalidNumberOfArguments(arguments, 2)) {
                    commandExportCodeTemplateLibraries("*", arguments[1].getText());
                }
            } else if (arg1 == Token.IMPORTMESSAGES) {
                commandImportMessages(arguments);
            } else if (arg1 == Token.EXPORTMESSAGES) {
                commandExportMessages(arguments);
            } else if (arg1 == Token.IMPORTMAP) {
                commandImportMap(arguments);
            } else if (arg1 == Token.EXPORTMAP) {
                commandExportMap(arguments);
            } else if (arg1 == Token.STATUS) {
                commandStatus(arguments);
            } else if (arg1 == Token.EXPORT) {
                commandExport(arguments);
            } else if (arg1 == Token.CHANNEL) {
                String syntax = "invalid number of arguments. Syntax is: channel start|stop|pause|resume|stats|remove|enable|disable <id|name>, channel rename <id|name> newname, or channel list|stats";
                if (arguments.length < 2) {
                    error(syntax, null);
                    return;
                } else if (arguments.length < 3 && arguments[1] != Token.LIST && arguments[1] != Token.STATS) {
                    error(syntax, null);
                    return;
                }

                Token comm = arguments[1];

                if (comm == Token.STATS && arguments.length < 3) {
                    commandAllChannelStats(arguments);
                } else if (comm == Token.LIST) {
                    commandChannelList(arguments);
                } else if (comm == Token.DISABLE) {
                    commandChannelDisable(arguments);
                } else if (comm == Token.ENABLE) {
                    commandChannelEnable(arguments);
                } else if (comm == Token.REMOVE) {
                    commandChannelRemove(arguments);
                } else if (comm == Token.START) {
                    commandChannelStart(arguments);
                } else if (comm == Token.STOP) {
                    commandChannelStop(arguments);
                } else if (comm == Token.HALT) {
                    commandChannelHalt(arguments);
                } else if (comm == Token.PAUSE) {
                    commandChannelPause(arguments);
                } else if (comm == Token.RESUME) {
                    commandChannelResume(arguments);
                } else if (comm == Token.STATS) {
                    commandChannelStats(arguments);
                } else if (comm == Token.RENAME) {
                    commandChannelRename(arguments);
                } else if (comm == Token.DEPLOY) {
                    commandChannelDeploy(arguments);
                } else if (comm == Token.UNDEPLOY) {
                    commandChannelUndeploy(arguments);
                } else {
                    error("unknown channel command " + comm, null);
                }
            } else if (arg1 == Token.CODE_TEMPLATE) {
                if (arguments.length < 2) {
                    error("Invalid number of arguments. Syntax is: codetemplate library list [includecodetemplates], codetemplate list, codetemplate [library] import path [force], codetemplate export id|name path, codetemplate library export id|name|* path, codetemplate remove id|name, or codetemplate library remove id|name|*",
                            null);
                    return;
                }

                Token arg2 = arguments[1];

                if (arg2 == Token.LIBRARY) {
                    if (arguments.length < 3) {
                        error("Invalid number of arguments. Syntax is: codetemplate library list [includecodetemplates], codetemplate library import path [force], codetemplate library export id|name|* path, or codetemplate library remove id|name|*",
                                null);
                        return;
                    }

                    Token arg3 = arguments[2];

                    if (arg3 == Token.LIST) {
                        commandListCodeTemplateLibraries(arguments.length > 3 && StringUtils
                                .equalsIgnoreCase(arguments[3].getText(), "includecodetemplates"));
                    } else if (arg3 == Token.IMPORT) {
                        if (arguments.length < 4) {
                            error("Invalid number of arguments. Syntax is: codetemplate library import path [force]",
                                    null);
                            return;
                        }
                        commandImportCodeTemplateLibraries(arguments[3].getText(), arguments.length > 4
                                && StringUtils.equalsIgnoreCase(arguments[4].getText(), "force"));
                    } else if (arg3 == Token.EXPORT) {
                        if (arguments.length < 5) {
                            error("Invalid number of arguments. Syntax is: codetemplate library export id|name|* path",
                                    null);
                            return;
                        }
                        commandExportCodeTemplateLibraries(arguments[3].getText(), arguments[4].getText());
                    } else if (arg3 == Token.REMOVE) {
                        if (arguments.length < 4) {
                            error("Invalid number of arguments. Syntax is: codetemplate library remove id|name|*",
                                    null);
                            return;
                        }
                        commandRemoveCodeTemplateLibraries(arguments[3].getText());
                    } else {
                        error("Unknown code template library command " + arg3
                                + ". Syntax is: codetemplate library list [includecodetemplates], codetemplate library import path [force], codetemplate library export id|name|* path, or codetemplate library remove id|name|*",
                                null);
                        return;
                    }
                } else if (arg2 == Token.LIST) {
                    commandListCodeTemplates();
                } else if (arg2 == Token.IMPORT) {
                    if (arguments.length < 3) {
                        error("Invalid number of arguments. Syntax is: codetemplate import path [force]", null);
                        return;
                    }
                    commandImportCodeTemplates(arguments[2].getText(), arguments.length > 3
                            && StringUtils.equalsIgnoreCase(arguments[3].getText(), "force"));
                } else if (arg2 == Token.EXPORT) {
                    if (arguments.length < 4) {
                        error("Invalid number of arguments. Syntax is: codetemplate export id|name path", null);
                        return;
                    }
                    commandExportCodeTemplate(arguments[2].getText(), arguments[3].getText());
                } else if (arg2 == Token.REMOVE) {
                    if (arguments.length < 3) {
                        error("Invalid number of arguments. Syntax is: codetemplate remove id|name", null);
                        return;
                    }
                    commandRemoveCodeTemplate(arguments[2].getText());
                } else {
                    error("Unknown code template command " + arg2
                            + ". Syntax is: codetemplate library list [includecodetemplates], codetemplate list, codetemplate [library] import path [force], codetemplate export id|name path, codetemplate library export id|name|* path, codetemplate remove id|name, or codetemplate library remove id|name|*",
                            null);
                    return;
                }
            } else if (arg1 == Token.CLEARALLMESSAGES) {
                commandClearAllMessages(arguments);
            } else if (arg1 == Token.RESETSTATS) {
                commandResetstats(arguments);
            } else if (arg1 == Token.DUMP) {
                if (arguments.length >= 2) {
                    Token arg2 = arguments[1];

                    if (arg2 == Token.STATS) {
                        commandDumpStats(arguments);
                    } else if (arg2 == Token.EVENTS) {
                        commandDumpEvents(arguments);
                    } else {
                        error("unknown dump command: " + arg2, null);
                    }
                } else {
                    error("missing dump commands.", null);
                }
            } else if (arg1 == Token.QUIT) {
                throw new Quit();
            } else {
                error("unknown command: " + command, null);
            }
        }
    } catch (ClientException e) {
        e.printStackTrace(err);
    }
}