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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) 

Source Link

Document

Checks if CharSequence contains a search CharSequence irrespective of case, handling null .

Usage

From source file:ec.edu.chyc.manejopersonal.managebean.GestorTesis.java

public boolean filtrarProyecto(Object value, Object filter, Locale locale) {
    String filterText = (filter == null) ? null : filter.toString().trim();
    if (filterText == null || filterText.equals("")) {
        return true;
    }/*from   w  w w .  j av a2 s. co  m*/

    if (value == null) {
        return false;
    }

    Set<Proyecto> proyectos = (Set<Proyecto>) value;

    for (Proyecto pro : proyectos) {
        if (StringUtils.containsIgnoreCase(pro.getTitulo(), filterText)) {
            return true;
        }
    }
    return false;

}

From source file:com.blackducksoftware.integration.hub.ScannerSplitStream.java

private void writeToConsole(final String line) {
    if (StringUtils.containsIgnoreCase(line, DEBUG) || StringUtils.containsIgnoreCase(line, TRACE)) {
        // We dont want to print Debug or Trace logs to the logger
        return;/*  ww  w.ja  v a2 s . co  m*/
    }
    final StringBuilder outputBuilder = new StringBuilder();
    outputBuilder.append(output);
    if (StringUtils.containsIgnoreCase(line, EXCEPTION)) {
        // looking for 'Exception in thread' type messages
        outputBuilder.append(line);
        outputBuilder.append(System.getProperty("line.separator"));
        logger.error(line);
    } else if (StringUtils.containsIgnoreCase(line, FINISHED)) {
        outputBuilder.append(line);
        outputBuilder.append(System.getProperty("line.separator"));
        logger.info(line);
    } else if (StringUtils.containsIgnoreCase(line, ERROR)) {
        outputBuilder.append(line);
        outputBuilder.append(System.getProperty("line.separator"));
        logger.error(line);
    } else if (StringUtils.containsIgnoreCase(line, WARN)) {
        outputBuilder.append(line);
        outputBuilder.append(System.getProperty("line.separator"));
        logger.warn(line);
    } else if (StringUtils.containsIgnoreCase(line, INFO)) {
        outputBuilder.append(line);
        outputBuilder.append(System.getProperty("line.separator"));
        logger.info(line);
    }

    output = outputBuilder.toString();
}

From source file:info.magnolia.configuration.app.problem.ProblemSubApp.java

private boolean isMatchedSearchExpression(Problem problem) {
    if (StringUtils.isNotBlank(searchExpression) && problem != null) {
        return StringUtils.containsIgnoreCase(problem.getElement(), searchExpression)
                || StringUtils.containsIgnoreCase(problem.getMessage(), searchExpression)
                || StringUtils.containsIgnoreCase(problem.getSeverityLevel().name(), searchExpression)
                || StringUtils.containsIgnoreCase(problem.getType().name(), searchExpression)
                || StringUtils.containsIgnoreCase(problem.getSourceType().name(), searchExpression);
    }//  w  w  w.j  a v a  2s .com

    return true;
}

From source file:com.sonicle.webtop.core.util.ZPushManager.java

private List<LastsyncRecord> parseLastsyncOutput(List<String> lines) {
    ArrayList<LastsyncRecord> items = new ArrayList<>();

    int lineNo = 0, dataLine = -1;
    for (String line : lines) {
        lineNo++;/*from   www. jav a  2 s  .c o m*/
        if (StringUtils.containsIgnoreCase(line, "Device id")
                && StringUtils.containsIgnoreCase(line, "Synchronized user")
                && StringUtils.containsIgnoreCase(line, "Last sync time")) {
            dataLine = lineNo + 2;
        }
        if ((dataLine != -1) && (lineNo >= dataLine) && !StringUtils.isBlank(StringUtils.trim(line))) {
            String[] tokens = StringUtils.split(line, " ", 3);
            String device = StringUtils.trim(tokens[0]);
            String user = StringUtils.trim(tokens[1]);
            String lastSync = StringUtils.trim(StringUtils.left(tokens[2], 16));
            items.add(new LastsyncRecord(device, user, "never".equalsIgnoreCase(lastSync) ? null : lastSync));
        }
    }
    return items;
}

From source file:com.glaf.oa.assesscontent.web.springmvc.AssesscontentController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Assesscontent assesscontent = assesscontentService
            .getAssesscontent(RequestUtils.getLong(request, "contentid"));
    if (assesscontent != null) {
        request.setAttribute("assesscontent", assesscontent);
        JSONObject rowJSON = assesscontent.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }//  w  w  w .j  av a2s.  c o m

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (assesscontent != null) {
            // if (assesscontent.getStatus() == 0 ||
            // assesscontent.getStatus() == -1) {
            canUpdate = true;
            // }
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("assesscontent.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/assesscontent/edit", modelMap);
}

From source file:eu.operando.proxy.service.ProxyService.java

private HttpFiltersSource getFiltersSource() {

    return new HttpFiltersSourceAdapter() {

        //                @Override
        //                public int getMaximumRequestBufferSizeInBytes() {
        //                    // TODO Auto-generated method stub
        //                    return 10 * 1024 * 1024;
        ////from w  w w .j a  va  2  s.  co  m
        //                }
        //
        //                @Override
        //                public int getMaximumResponseBufferSizeInBytes() {
        //                    // TODO Auto-generated method stub
        //                    return 10 * 1024 * 1024;
        //                }

        @Override
        public HttpFilters filterRequest(HttpRequest originalRequest) {

            return new HttpFiltersAdapter(originalRequest) {

                @Override
                public HttpObject serverToProxyResponse(HttpObject httpObject) {

                    if (MainUtil.isProxyPaused(mainContext))
                        return httpObject;

                    if (httpObject instanceof HttpMessage) {
                        HttpMessage response = (HttpMessage) httpObject;
                        response.headers().set(HttpHeaderNames.CACHE_CONTROL,
                                "no-cache, no-store, must-revalidate");
                        response.headers().set(HttpHeaderNames.PRAGMA, "no-cache");
                        response.headers().set(HttpHeaderNames.EXPIRES, "0");
                    }
                    try {
                        Method content = httpObject.getClass().getMethod("content");
                        if (content != null) {
                            ByteBuf buf = (ByteBuf) content.invoke(httpObject);
                            boolean flag = false;
                            List<ResponseFilter> responseFilters = db.getAllResponseFilters();
                            if (responseFilters.size() > 0) {

                                String contentStr = buf.toString(Charset.forName("UTF-8")); //Charset.forName(Charset.forName("UTF-8")
                                for (ResponseFilter responseFilter : responseFilters) {

                                    String toReplace = responseFilter.getContent();

                                    if (StringUtils.containsIgnoreCase(contentStr, toReplace)) {
                                        contentStr = contentStr.replaceAll("(?i)" + toReplace,
                                                StringUtils.leftPad("", toReplace.length(), '#'));
                                        flag = true;
                                    }

                                }
                                if (flag) {
                                    buf.clear().writeBytes(contentStr.getBytes(Charset.forName("UTF-8")));
                                }
                            }

                        }
                    } catch (IndexOutOfBoundsException ex) {
                        ex.printStackTrace();
                        Log.e("Exception", ex.getMessage());
                    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
                        //ignore
                    }
                    return httpObject;
                }

                @Override
                public HttpResponse clientToProxyRequest(HttpObject httpObject) {

                    if (MainUtil.isProxyPaused(mainContext))
                        return null;

                    String requestURI;
                    Set<RequestFilterUtil.FilterType> exfiltrated = new HashSet<>();
                    String[] locationInfo = requestFilterUtil.getLocationInfo();
                    String[] contactsInfo = requestFilterUtil.getContactsInfo();
                    String[] phoneInfo = requestFilterUtil.getPhoneInfo();

                    if (httpObject instanceof HttpMessage) {
                        HttpMessage request = (HttpMessage) httpObject;
                        if (request.headers().contains(CustomHeaderField)) {
                            applicationInfoStr = request.headers().get(CustomHeaderField);
                            request.headers().remove(CustomHeaderField);
                        }

                        if (request.headers().contains(HttpHeaderNames.ACCEPT_ENCODING)) {
                            request.headers().remove(HttpHeaderNames.ACCEPT_ENCODING);
                        }

                        /*
                        Sanitize Hosts
                        */
                        if (!ProxyUtils.isCONNECT(request)
                                && request.headers().contains(HttpHeaderNames.HOST)) {
                            String hostName = request.headers().get(HttpHeaderNames.HOST).toLowerCase();
                            if (db.isDomainBlocked(hostName))
                                return getBlockedHostResponse(hostName);
                        }

                    }

                    if (httpObject instanceof HttpRequest) {

                        HttpRequest request = (HttpRequest) httpObject;
                        requestURI = request.uri();

                        try {
                            requestURI = URLDecoder.decode(requestURI, "UTF-8");
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }

                        /*
                        Request URI checks
                         */
                        if (StringUtils.containsAny(requestURI, locationInfo)) {
                            exfiltrated.add(RequestFilterUtil.FilterType.LOCATION);
                        }

                        if (StringUtils.containsAny(requestURI, contactsInfo)) {
                            exfiltrated.add(RequestFilterUtil.FilterType.CONTACTS);
                        }

                        if (StringUtils.containsAny(requestURI, phoneInfo)) {
                            exfiltrated.add(RequestFilterUtil.FilterType.PHONEINFO);
                        }

                        if (!exfiltrated.isEmpty()) {
                            mainContext.getNotificationUtil().displayExfiltratedNotification(applicationInfoStr,
                                    exfiltrated);
                            return getForbiddenRequestResponse(applicationInfoStr, exfiltrated);
                        }

                    }

                    try {
                        Method content = httpObject.getClass().getMethod("content");
                        if (content != null) {
                            ByteBuf buf = (ByteBuf) content.invoke(httpObject);

                            String contentStr = buf.toString(Charset.forName("UTF-8"));

                            if (StringUtils.containsAny(contentStr, locationInfo)) {
                                exfiltrated.add(RequestFilterUtil.FilterType.LOCATION);
                            }

                            if (StringUtils.containsAny(contentStr, contactsInfo)) {
                                exfiltrated.add(RequestFilterUtil.FilterType.CONTACTS);
                            }

                            if (StringUtils.containsAny(contentStr, phoneInfo)) {
                                exfiltrated.add(RequestFilterUtil.FilterType.PHONEINFO);
                            }

                            if (!exfiltrated.isEmpty()) {
                                mainContext.getNotificationUtil()
                                        .displayExfiltratedNotification(applicationInfoStr, exfiltrated);
                                return getForbiddenRequestResponse(applicationInfoStr, exfiltrated);
                            }

                        }
                    } catch (IndexOutOfBoundsException ex) {
                        ex.printStackTrace();
                        Log.e("Exception", ex.getMessage());
                    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
                        //ignore
                    }

                    return null;
                }

            };
        }
    };
}

From source file:com.moto.miletus.application.tabs.ComponentsAdapter.java

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final ComponentWrapper componentWrapper = mDataSet.get(position);

    holder.componentName.setText(StringUtils.capitalize(componentWrapper.getTraitName().replace("_", "")));

    String value1 = "";
    String value2 = "";
    int count = 0;
    for (StateWrapper stateWrapper : componentWrapper.getStates()) {

        String stateValue = stateWrapper.getValue().getValue();
        String stateName = stateWrapper.getStateName();

        try {//from   w  w  w  .  j  a v  a2  s  .c  om
            if (StringUtils.containsIgnoreCase(stateName, Strings.TEMPERATURE)) {
                stateValue = Precision.round(Float.parseFloat(stateValue), 1) + "";
                stateValue = stateValue + Strings.CELSIUS;
            } else if (StringUtils.containsIgnoreCase(stateName, Strings.LIGHT)) {
                stateValue = stateValue + Strings.LUX;
            } else if (StringUtils.containsIgnoreCase(stateName, Strings.HUMIDITY)) {
                stateValue = Math.round(Precision.round(Float.parseFloat(stateValue), 0)) + "";
                stateValue = stateValue + "%";
            }
        } catch (NumberFormatException nfe) {
            Log.e(TAG, stateName + ": " + Strings.NEW_LINE + stateValue);
        }

        if (count == 0) {
            value1 = value1 + stateName + ": " + stateValue;
        } else {
            value2 = value2 + stateName + ": " + stateValue + Strings.NEW_LINE;
        }

        count++;
    }

    value1 = value1.replace("_", "");
    value2 = value2.replace("_", "");

    holder.stateValue1.setText(value1);
    holder.stateValue2.setText(value2);

    if (value2.isEmpty()) {
        holder.arrow.setVisibility(View.GONE);
        holder.showMore.setVisibility(View.GONE);
    } else {
        holder.arrow.setVisibility(View.VISIBLE);
        holder.showMore.setVisibility(View.VISIBLE);
    }
}

From source file:javax.portlet.tck.portlets.AddlRequestTests_SPEC2_11_ActionReq.java

@SuppressWarnings("deprecation")
@Override/* w  w w  . j  av  a  2 s  .  c  o  m*/
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
        throws PortletException, IOException {

    portletResp.setRenderParameters(portletReq.getParameterMap());
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    StringWriter writer = new StringWriter();

    JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

    // Create result objects for the tests

    /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType1 */
    /* Details: "The getResponseContentType method returns a String */
    /* representing the default content type the portlet container */
    /* assumes for the output" */
    TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE1);
    if (portletReq.getResponseContentType() != null && !portletReq.getResponseContentType().isEmpty())
        tr0.setTcSuccess(true);
    tr0.writeTo(writer);

    /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType2 */
    /* Details: "The getResponseContentTypes method returns an */
    /* Enumeration of String elements representing the acceptable content */
    /* types for the output in order of preference" */
    TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE2);
    Enumeration<String> contentTypesTr1 = portletReq.getResponseContentTypes();
    if (contentTypesTr1 != null) {
        List<String> list = Collections.list(contentTypesTr1);
        if (list.isEmpty()) {
            tr1.appendTcDetail("Enumeration was empty.");
        } else {
            if (list.get(0).isEmpty()) {
                tr1.appendTcDetail("First content type string is empty.");
            } else {
                tr1.setTcSuccess(true);
            }
        }
    } else {
        tr1.appendTcDetail("Enumeration was null.");
    }
    tr1.writeTo(writer);

    /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType3 */
    /* Details: "The first element of the Enumeration returned by the */
    /* getResponseContentTypes method must equal the value returned by */
    /* the getResponseContentType method" */
    TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE3);
    Enumeration<String> contentTypesTr2 = portletReq.getResponseContentTypes();
    if (contentTypesTr2 != null) {
        List<String> list = Collections.list(contentTypesTr2);
        if (list.isEmpty()) {
            tr2.appendTcDetail("Enumeration was empty.");
        } else {
            if (!list.get(0).equals(portletReq.getResponseContentType())) {
                tr2.appendTcDetail(
                        "First content type string does not equal PortletRequest#getResponseContentType().");
            } else {
                tr2.setTcSuccess(true);
            }
        }
    } else {
        tr2.appendTcDetail("Enumeration was null.");
    }
    tr2.writeTo(writer);

    /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_windowId4 */
    /* Details: "The string returned by getWindowID method must be the */
    /* same ID used for scoping portlet-scope session attributes" */
    TestResult tr5 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_WINDOWID4);
    String tr5SessionAttribute = (String) portletReq.getPortletSession()
            .getAttribute("javax.portlet.p." + portletReq.getWindowID() + "?tr5", APPLICATION_SCOPE);
    if (tr5SessionAttribute != null && tr5SessionAttribute.equals(portletReq.getWindowID())) {
        tr5.setTcSuccess(true);
    } else {
        tr5.appendTcDetail("Couldn't find javax.portlet.p." + portletReq.getWindowID() + ".tr5 attribute");
    }
    tr5.writeTo(writer);

    /* TestCase: V2AddlRequestTests_SPEC2_11_ActionReq_contentType6 */
    /* Details: "Within the processAction method, the content type must */
    /* include only the MIME type, not the character set" */
    TestResult tr6 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONREQ_CONTENTTYPE6);
    if (!StringUtils.containsIgnoreCase(portletReq.getResponseContentType(), portletReq.getCharacterEncoding()))
        tr6.setTcSuccess(true);
    tr6.writeTo(writer);

    portletReq.getPortletSession().setAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionReq",
            writer.toString(), APPLICATION_SCOPE);
}

From source file:ec.edu.chyc.manejopersonal.managebean.GestorPersona.java

public boolean filtrarPorFirma(Object value, Object filter, Locale locale) {
    String filterText = (filter == null) ? null : filter.toString().trim();
    if (filterText == null || filterText.equals("")) {
        return true;
    }//from w  w w.  j ava  2  s  .c o m
    if (value == null) {
        return false;
    }

    Collection<PersonaFirma> autores = (Collection) value;
    for (PersonaFirma per : autores) {
        if (StringUtils.containsIgnoreCase(per.getFirma().getNombre(), filterText)) {
            return true;
        }
    }
    return false;
}

From source file:com.glaf.oa.assessquestion.web.springmvc.AssessquestionController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    Assessquestion assessquestion = assessquestionService
            .getAssessquestion(RequestUtils.getLong(request, "qustionid"));

    List<BaseDataInfo> isValidList = AQUtils.getBaseInfoByCode("ASSESS_ISVALID");
    Map<String, BaseDataInfo> validMap = AQUtils.baseList2MapByCode(isValidList);
    if (assessquestion != null) {
        assessquestion.setIseffectiveText(validMap.get(assessquestion.getIseffective() + "").getName());
        modelMap.put("isValidList", isValidList);
        modelMap.put("assessquestion", assessquestion);
    }//from w w w .  j  a v a 2  s  .c  om
    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (assessquestion != null) {
            canUpdate = true;
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("assessquestion.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/assessquestion/assessquestionEdit", modelMap);
}