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:gov.nih.nci.caintegrator.common.QueryUtil.java

private static boolean checkSubjectAssignmentMatch(ResultRow rowToTest, ResultRow curRow) {
    if (curRow.getSubjectAssignment() == null && rowToTest.getSubjectAssignment() == null) { // both null
        return true;
    }/*w  ww.j a v a  2s.  c  o m*/
    if (curRow.getSubjectAssignment() == null || rowToTest.getSubjectAssignment() == null) { // only one is null
        return false;
    }
    return StringUtils.equalsIgnoreCase(curRow.getSubjectAssignment().getIdentifier(),
            rowToTest.getSubjectAssignment().getIdentifier());
}

From source file:com.glaf.chart.web.springmvc.HighChartsController.java

@RequestMapping("/showChart")
public ModelAndView chart(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    logger.debug("params:" + params);
    String chartId = ParamUtils.getString(params, "chartId");
    String mapping = ParamUtils.getString(params, "mapping");
    String mapping_enc = ParamUtils.getString(params, "mapping_enc");
    String name = ParamUtils.getString(params, "name");
    String name_enc = ParamUtils.getString(params, "name_enc");
    Chart chart = null;//  w  ww  . ja  va2 s.c o  m
    if (StringUtils.isNotEmpty(chartId)) {
        chart = chartService.getChart(chartId);
    } else if (StringUtils.isNotEmpty(name)) {
        chart = chartService.getChartByName(name);
    } else if (StringUtils.isNotEmpty(name_enc)) {
        String str = RequestUtils.decodeString(name_enc);
        chart = chartService.getChartByName(str);
    } else if (StringUtils.isNotEmpty(mapping)) {
        chart = chartService.getChartByMapping(mapping);
    } else if (StringUtils.isNotEmpty(mapping_enc)) {
        String str = RequestUtils.decodeString(mapping_enc);
        chart = chartService.getChartByMapping(str);
    }
    if (chart != null) {
        ChartDataManager manager = new ChartDataManager();
        chart = manager.getChartAndFetchDataById(chart.getId(), params, RequestUtils.getActorId(request));
        logger.debug("chart rows size:" + chart.getColumns().size());
        request.setAttribute("chart", chart);
        request.setAttribute("chartId", chart.getId());
        request.setAttribute("name", chart.getChartName());
        JSONArray result = new JSONArray();
        List<ColumnModel> columns = chart.getColumns();
        if (columns != null && !columns.isEmpty()) {
            double total = 0D;
            List<String> categories = new ArrayList<String>();

            if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie")
                    || StringUtils.equalsIgnoreCase(chart.getChartType(), "pie-donut")) {
                JSONArray array = new JSONArray();
                for (ColumnModel cm : columns) {
                    if (cm.getDoubleValue() != null) {
                        List<Object> rows = new ArrayList<Object>();
                        total += cm.getDoubleValue();
                        rows.add(cm.getSeries());
                        rows.add(cm.getDoubleValue());
                        array.add(rows);
                    }
                }
                request.setAttribute("pie_data", array.toJSONString());
            }

            for (ColumnModel cm : columns) {
                if (cm.getCategory() != null && !categories.contains("'" + cm.getCategory() + "'")) {
                    categories.add("'" + cm.getCategory() + "'");
                }
            }

            request.setAttribute("categories", categories);
            request.setAttribute("categories_scripts", categories.toString());
            logger.debug("categories=" + categories);

            Map<String, List<Double>> seriesMap = new HashMap<String, List<Double>>();

            for (ColumnModel cm : columns) {
                String series = cm.getSeries();
                if (series != null) {
                    List<Double> valueList = seriesMap.get(series);
                    if (valueList == null) {
                        valueList = new ArrayList<Double>();
                    }
                    if (cm.getDoubleValue() != null) {
                        valueList.add(cm.getDoubleValue());
                    } else {
                        valueList.add(0D);
                    }
                    seriesMap.put(series, valueList);
                }
            }

            request.setAttribute("seriesMap", seriesMap);
            if (!seriesMap.isEmpty()) {
                JSONArray array = new JSONArray();
                Set<Entry<String, List<Double>>> entrySet = seriesMap.entrySet();
                for (Entry<String, List<Double>> entry : entrySet) {
                    String key = entry.getKey();
                    List<Double> valueList = entry.getValue();
                    JSONObject json = new JSONObject();
                    json.put("name", key);
                    json.put("data", valueList);
                    array.add(json);
                }
                logger.debug("seriesDataJson:" + array.toJSONString());
                request.setAttribute("seriesDataJson", array.toJSONString());
            }

            for (ColumnModel cm : columns) {
                JSONObject json = new JSONObject();
                json.put("category", cm.getCategory());
                json.put("series", cm.getSeries());
                json.put("doublevalue", cm.getDoubleValue());
                if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie")) {
                    json.put("category", cm.getSeries());
                    json.put("value", Math.round(cm.getDoubleValue() / total * 10000) / 100.0D);
                } else {
                    json.put("value", cm.getDoubleValue());
                }
                result.add(json);
            }
        }
        request.setAttribute("jsonArray", result.toJSONString());
        if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie")) {
            return new ModelAndView("/bi/chart/highcharts/pie", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie-donut")) {
            return new ModelAndView("/bi/chart/highcharts/pie-donut", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "line")) {
            return new ModelAndView("/bi/chart/highcharts/line", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "radarLine")) {
            return new ModelAndView("/bi/chart/highcharts/radarLine", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "area")) {
            return new ModelAndView("/bi/chart/highcharts/area", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "bar")) {
            return new ModelAndView("/bi/chart/highcharts/bar", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "column")) {
            return new ModelAndView("/bi/chart/highcharts/column", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "stacked_area")) {
            return new ModelAndView("/bi/chart/highcharts/stacked_area", modelMap);
        } else if (StringUtils.equalsIgnoreCase(chart.getChartType(), "stackedbar")) {
            return new ModelAndView("/bi/chart/highcharts/stackedbar", modelMap);
        }
    }
    String x_view = ViewProperties.getString("highcharts.chart");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/bi/chart/highcharts/chart", modelMap);
}

From source file:com.glaf.mail.domain.MailAccount.java

public boolean autoReceive() {
    if (StringUtils.equalsIgnoreCase(autoReceive, "1") || StringUtils.equalsIgnoreCase(autoReceive, "Y")
            || StringUtils.equalsIgnoreCase(autoReceive, "true")) {
        return true;
    }//from   w  w w  . ja v  a  2 s.  com
    return false;
}

From source file:com.xpn.xwiki.internal.store.hibernate.HibernateStore.java

/**
 * Convert wiki name in database/schema name.
 *
 * @param wikiId the wiki name to convert.
 * @param product the database engine type.
 * @return the database/schema name./*  ww w  .  j a va 2  s  . c  om*/
 */
public String getSchemaFromWikiName(String wikiId, DatabaseProduct product) {
    if (wikiId == null) {
        return null;
    }

    String mainWikiId = this.wikis.getMainWikiId();

    String schema;
    if (StringUtils.equalsIgnoreCase(wikiId, mainWikiId)) {
        schema = this.xwikiConfiguration.getProperty("xwiki.db");
        if (schema == null) {
            if (product == DatabaseProduct.DERBY) {
                schema = "APP";
            } else if (product == DatabaseProduct.HSQLDB || product == DatabaseProduct.H2) {
                schema = "PUBLIC";
            } else if (product == DatabaseProduct.POSTGRESQL && isInSchemaMode()) {
                schema = "public";
            } else {
                schema = wikiId.replace('-', '_');
            }
        }
    } else {
        // virtual
        schema = wikiId.replace('-', '_');

        // For HSQLDB/H2 we only support uppercase schema names. This is because Hibernate doesn't properly generate
        // quotes around schema names when it qualifies the table name when it generates the update script.
        if (DatabaseProduct.HSQLDB == product || DatabaseProduct.H2 == product) {
            schema = StringUtils.upperCase(schema);
        }
    }

    // Apply prefix
    String prefix = this.xwikiConfiguration.getProperty("xwiki.db.prefix", "");
    schema = prefix + schema;

    return schema;
}

From source file:hammingcode.HammingCode.java

Boolean checkParity(String parityString, String parityKind) {
    int ones = StringUtils.countMatches(parityString, "1");
    if (StringUtils.equalsIgnoreCase(parityKind, "even")) {
        if (ones % 2 == 0) {
            return true;
        }//from ww  w .  j  a v a  2s .com
        return false;
    } else if (StringUtils.equalsIgnoreCase(parityKind, "odd")) {
        if (ones % 2 == 1) {
            return true;
        }
        return false;
    }
    return null;
}

From source file:com.glaf.mail.domain.MailTask.java

public boolean isBack() {
    if (StringUtils.equalsIgnoreCase(isBack, "1") || StringUtils.equalsIgnoreCase(isBack, "Y")
            || StringUtils.equalsIgnoreCase(isBack, "true")) {
        return true;
    }//from ww w  . jav a  2  s.co m
    return false;
}

From source file:com.github.lburgazzoli.quickfixj.osgi.FIXConnection.java

/**
 *
 * @param settings//from  ww  w . j  a  v  a2 s  .  c  om
 * @return
 */
private boolean isInitiator(final SessionSettings settings) throws Exception {
    return StringUtils.equalsIgnoreCase(SessionFactory.INITIATOR_CONNECTION_TYPE,
            settings.getString(SessionFactory.SETTING_CONNECTION_TYPE));
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter.java

@SuppressWarnings("unchecked")
protected boolean accepts(final HttpServletRequest request) {

    Enumeration<String> agentsEnum = request.getHeaders(SERVER_AGENT_NAME);
    List<String> serverAgents = agentsEnum != null ? Collections.list(agentsEnum)
            : Collections.<String>emptyList();

    // Only inject when:
    // - GET request
    // - No Params
    // - From Dispatcher
    if (StringUtils.equalsIgnoreCase("get", request.getMethod()) && request.getParameterMap().isEmpty()
            && serverAgents.contains(DISPATCHER_AGENT_HEADER_VALUE)) {

        return true;
    }/*from   w w w  . java  2  s.c o m*/
    return false;
}

From source file:$.UserAction.java

public void showRoles(ActionResult actionResult, String username) {
        Page<? extends Role> roles = roleManager.findActiveRoleByKeyword("", null);
        actionResult.addToModel("roles", roles);

        if (!StringUtils.equalsIgnoreCase(username, "-")) {
            User user = userManager.getUserByUsername(username);
            actionResult.addToModel("user", user);

            Page<? extends Role> userRoles = userManager.findRoleByUser(user, null);
            actionResult.addToModel("userRoles", userRoles);
        }//from w w  w .j  a  v  a2  s .co  m
    }

From source file:com.ottogroup.bi.spqr.operator.json.filter.JsonContentFilter.java

/**
 * @see com.ottogroup.bi.spqr.pipeline.component.MicroPipelineComponent#initialize(java.util.Properties)
 *//*  w  w  w  .j  av  a 2 s .  c o m*/
public void initialize(Properties properties)
        throws RequiredInputMissingException, ComponentInitializationFailedException {

    if (properties == null)
        throw new RequiredInputMissingException("Missing required properties");

    for (int i = 1; i < Integer.MAX_VALUE; i++) {
        String expression = properties.getProperty(CFG_FIELD_PREFIX + i + ".expression");
        if (StringUtils.isBlank(expression))
            break;

        String path = properties.getProperty(CFG_FIELD_PREFIX + i + ".path");
        String valueType = properties.getProperty(CFG_FIELD_PREFIX + i + ".type");

        try {
            this.fields.add(new JsonContentFilterFieldSetting(path.split("\\."), Pattern.compile(expression),
                    StringUtils.equalsIgnoreCase("STRING", valueType) ? JsonContentType.STRING
                            : JsonContentType.NUMERICAL));
        } catch (PatternSyntaxException e) {
            throw new ComponentInitializationFailedException(
                    "Failed to parse '" + expression + "' into a valid pattern expression");
        }
    }

    if (logger.isDebugEnabled())
        logger.debug("json content filter [id=" + id + "] initialized");
}