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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

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

Usage

From source file:com.microsoft.alm.plugin.authentication.AuthHelper.java

public static boolean isNotAuthorizedError(final Throwable throwable) {
    //We get VssServiceResponseException when token is valid but does not have the required scopes
    //statusCode on VssServiceResponseException is set to 401 but that is not accessible, so we have to check the message
    //If the message gets localized, we won't detect the auth error
    if (throwable != null
            && (throwable instanceof NotAuthorizedException || (throwable instanceof VssServiceResponseException
                    && StringUtils.containsIgnoreCase(throwable.getMessage(), "unauthorized")))) {
        return true;
    }//from   w w w  .j  a v  a  2s.c o  m

    if (throwable != null && throwable.getCause() != null
            && (throwable.getCause() instanceof NotAuthorizedException
                    || (throwable.getCause() instanceof VssServiceResponseException
                            && (StringUtils.containsIgnoreCase(throwable.getMessage(), "unauthorized"))))) {
        return true;
    }

    return false;
}

From source file:br.com.utfpr.pb.view.PedidoCompraView.java

private void pesquisa() {
    String query = pesquisa.getText();
    model = (DefaultTableModel) jTable.getModel();
    model.getDataVector().removeAllElements();
    model.fireTableDataChanged();//from   ww w . j  av a2 s.  c  om
    data.stream()
            .filter(e -> StringUtils.containsIgnoreCase(e.getId().toString(), query)
                    || StringUtils.containsIgnoreCase(e.getDescricao(), query)
                    || StringUtils.containsIgnoreCase(e.getCategoria().getDescricao(), query))
            .forEach(item -> add(item));
    model.fireTableDataChanged();
}

From source file:com.akhahaha.giftr.service.data.dao.queryBuilder.ProductQueryBuilder.java

public void setSort(String sort) {
    // Attempt to match up the sorting string to one of the sorting types.
    // If no match, the default sort will be by relevancy.
    if (StringUtils.isNotEmpty(sort)) {
        if (StringUtils.containsIgnoreCase(sort, "price") && StringUtils.containsIgnoreCase(sort, "asc")) {
            this.sort = SORT_BY_LOWEST_PRICE;
        }/*from   ww w  .  ja  v  a  2 s. c o  m*/
        if (StringUtils.containsIgnoreCase(sort, "price") && StringUtils.containsIgnoreCase(sort, "desc")) {
            this.sort = SORT_BY_HIGHEST_PRICE;
        }
    }
}

From source file:hydrograph.ui.expression.editor.evaluate.EvaluateDialog.java

private void createSearchTextBox(Composite fieldTableComposite) {
    searchTextBox = new Text(fieldTableComposite, SWT.BORDER);
    searchTextBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    searchTextBox.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(128, 128, 128));
    searchTextBox.setText(Constants.DEFAULT_SEARCH_TEXT);
    ExpressionEditorUtil.INSTANCE.addFocusListenerToSearchTextBox(searchTextBox);
    searchTextBox.addModifyListener(new ModifyListener() {

        @Override/*from  ww w .  ja v a  2  s.c o m*/
        public void modifyText(ModifyEvent e) {
            evalDialogFieldTable.getTableViewer().resetFilters();
            if (!StringUtils.equals(Constants.DEFAULT_SEARCH_TEXT, searchTextBox.getText())) {
                ViewerFilter filter = new ViewerFilter() {
                    @Override
                    public boolean select(Viewer viewer, Object parentElement, Object element) {
                        if (element != null && element instanceof FieldNameAndValue) {
                            FieldNameAndValue fieldNameAndValue = (FieldNameAndValue) element;
                            if (StringUtils.containsIgnoreCase(fieldNameAndValue.getFieldName(),
                                    searchTextBox.getText())) {
                                return true;
                            }
                        }
                        return false;
                    }
                };
                ViewerFilter[] filters = { filter };
                evalDialogFieldTable.getTableViewer().setFilters(filters);
            }
        }
    });
}

From source file:graphene.web.components.ui.MeaningfulBeanDisplay.java

public String getPropertyStyle() {
    style.getHexColorForNode(className);
    if (StringUtils.containsIgnoreCase(className, "Location")) {
        return "white-space: normal; ";
    } else if (StringUtils.containsIgnoreCase(className, "Address")) {
        return "white-space: normal;  background-color: #b09b5b";
    } else if (StringUtils.containsIgnoreCase(className, "Account")) {
        return "white-space: normal; ";
    } else if (StringUtils.containsIgnoreCase(className, "Subject")) {
        return "white-space: normal; ";
    } else if (StringUtils.containsIgnoreCase(className, "Name")) {
        return "white-space: normal;  background-color: #c79121";
    } else {//from  www .  j a v a  2  s  .c o m
        return "white-space: normal;";
    }

}

From source file:it.serverSystem.HttpsTest.java

/**
 * SSF-13 HttpOnly flag/*  w  ww . j  av  a2  s  .com*/
 * SSF-16 Secure flag
 */
private void checkCookieFlags(HttpsURLConnection connection) {
    List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
    boolean foundSessionCookie = false;
    for (String cookie : cookies) {
        if (StringUtils.containsIgnoreCase(cookie, "JSESSIONID")) {
            foundSessionCookie = true;
            assertThat(cookie).containsIgnoringCase("Secure").containsIgnoringCase("HttpOnly");
        }
    }
    if (!foundSessionCookie) {
        fail("Session cookie not found");
    }
}

From source file:au.org.ala.biocache.dao.QueryFormatTest.java

/**
 * Run the tests//from  w w w. ja  va2s .co m
 *
 * @param queryTest
 */
@Theory
public void testQueryFormatting(SearchQueryTester queryTest) {
    SpatialSearchRequestParams ssrp = new SpatialSearchRequestParams();
    ssrp.setQ(queryTest.query);
    searchDAO.formatSearchQuery(ssrp);
    logger.info("Testing query \"" + queryTest + "\" -> " + ssrp.getFormattedQuery());
    if (queryTest.exactMatch) {
        assertEquals("formattedQuery does not have expected exact match. ", ssrp.getFormattedQuery(),
                queryTest.formattedQuery);
        assertEquals("displayString does not have expected exact match. " + ssrp.getDisplayString(),
                ssrp.getDisplayString(), queryTest.displayString);
    } else {
        assertTrue("formattedQuery does not have expected 'contains' match. " + ssrp.getFormattedQuery(),
                StringUtils.containsIgnoreCase(ssrp.getFormattedQuery(), queryTest.formattedQuery));
        assertTrue("display query does not have expected 'contains' match. ",
                StringUtils.containsIgnoreCase(ssrp.getDisplayString(), queryTest.displayString));
    }
}

From source file:io.kahu.hawaii.cucumber.glue.html.HtmlSteps.java

@Before("@web")
public void beforeScenario() throws Exception {
    WebDriver driver;/*from   ww w. j a va  2  s . c o m*/
    if (StringUtils.containsIgnoreCase(browser, "chrome")) {
        if (remote) {
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            driver = createRemoteWebDriverForCapabilities(capabilities);
        } else {
            driver = new ChromeDriver();
        }
    } else if (StringUtils.containsIgnoreCase(browser, "opera")) {
        if (remote) {
            DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
            driver = createRemoteWebDriverForCapabilities(capabilities);
        } else {
            driver = new OperaDriver();
        }
    } else if (StringUtils.containsIgnoreCase(browser, "firefox")) {
        if (remote) {
            DesiredCapabilities capabilities = DesiredCapabilities.firefox();
            driver = createRemoteWebDriverForCapabilities(capabilities);
        } else {
            driver = new FirefoxDriver();
        }
    } else if (StringUtils.containsIgnoreCase(browser, "htmlunit")) {
        driver = new HtmlUnitDriver(BrowserVersion.CHROME);
    } else if (StringUtils.containsIgnoreCase(browser, "iexplore")) {
        if (remote) {
            DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
            driver = createRemoteWebDriverForCapabilities(capabilities);
        } else {
            driver = new InternetExplorerDriver();
        }

    } else if (StringUtils.containsIgnoreCase(browser, "phantom")) {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
                getOsSpecificPhantomDriverPath());
        Proxy proxy = getHttpProxy();
        if (proxy != null) {
            capabilities.setCapability(CapabilityType.PROXY, getHttpProxy());
        }
        driver = new PhantomJSDriver(capabilities);
    } else if (StringUtils.containsIgnoreCase(browser, "safari")) {
        if (remote) {
            DesiredCapabilities capabilities = DesiredCapabilities.safari();
            driver = createRemoteWebDriverForCapabilities(capabilities);
        } else {
            driver = new SafariDriver();
        }
    } else {
        throw new IllegalStateException("Unsupported browser specified");
    }
    webDriver = new EventFiringWebDriver(driver);
    webDriver.manage().deleteAllCookies();
    turnOnImplicitWaits();
}

From source file:com.tesora.dve.sql.SQLVariableTest.java

@Test
public void testShowVariables() throws Throwable {
    ResourceResponse rr = conn.fetch("show variables");
    List<ResultRow> results = rr.getResults();
    for (ResultRow row : results) {
        assertFalse(row.getResultColumn(1).getColumnValue() + " should have a value",
                row.getResultColumn(2).isNull());
    }//  w  w  w  .jav a2  s . co m

    // PE-668 needs this for reports to work
    rr = conn.fetch("show /*!50000 global */ variables");
    results = rr.getResults();
    for (ResultRow row : results) {
        //skip the aws ones
        if (!StringUtils.containsIgnoreCase((String) row.getResultColumn(1).getColumnValue(), "aws")) {
            assertFalse(row.getResultColumn(1).getColumnValue() + " should have a value",
                    row.getResultColumn(2).isNull());
        }
    }
}

From source file:com.egt.core.util.EA.java

private static void clipConfigurationProperties() {
    Bitacora.trace(EA.class, "clipConfigurationProperties");
    String key;//from   w  ww  . j a  v a  2s  .c om
    String sep = System.getProperties().getProperty("file.separator");
    String osname1 = System.getProperties().getProperty("os.name");
    String osname2 = StringUtils.containsIgnoreCase(osname1, "windows") ? "windows" : "linux";
    String glassRoot = System.getProperties().getProperty("com.sun.aas.instanceRoot");
    String jbossHome = System.getProperties().getProperty("jboss.home.dir");
    String jbossBase = System.getProperties().getProperty("jboss.server.base.dir");
    String somedir;
    boolean glassfish = StringUtils.isNotBlank(glassRoot);
    boolean jboss = StringUtils.isNotBlank(jbossHome);
    if (StringUtils.isBlank(content_root_dir)) {
        key = StringUtils.removeStart(SEV.ENT_APP_CONTENT_ROOT_DIR, SEV.ENT_APP_VAR_PREFFIX);
        somedir = coalesceToUserDir(glassRoot, jbossHome);
        if (glassfish) {
            content_root_dir = somedir + sep + "docroot";
        } else if (jboss) {
            content_root_dir = somedir + sep + "welcome-content";
        } else {
            content_root_dir = somedir + sep + "ROOT";
        }
        show(key, content_root_dir);
        isDirectory(content_root_dir);
    }
    if (StringUtils.isBlank(home_dir)) {
        key = StringUtils.removeStart(SEV.ENT_APP_HOME_DIR, SEV.ENT_APP_VAR_PREFFIX);
        somedir = coalesceToUserDir(glassRoot, jbossBase);
        home_dir = somedir + sep + lower_case_code;
        show(key, home_dir);
        isDirectory(home_dir);
    }
    if (StringUtils.isBlank(configuration_properties_file)) {
        key = StringUtils.removeStart(SEV.ENT_APP_CONFIGURATION_PROPERTIES_FILE, SEV.ENT_APP_VAR_PREFFIX);
        configuration_properties_file = home_dir + sep + "resources" + sep + "config" + sep + osname2 + sep
                + lower_case_code + ".properties";
        show(key, configuration_properties_file);
        isFile(configuration_properties_file);
    }
    if (StringUtils.isBlank(jdbc_driver)) {
        key = StringUtils.removeStart(SEV.ENT_APP_JDBC_DRIVER, SEV.ENT_APP_VAR_PREFFIX);
        jdbc_driver = "org.postgresql.Driver";
        show(key, jdbc_driver);
    }
    if (StringUtils.isBlank(jdbc_url)) {
        key = StringUtils.removeStart(SEV.ENT_APP_JDBC_URL, SEV.ENT_APP_VAR_PREFFIX);
        jdbc_url = "jdbc:postgresql://localhost:5432/" + upper_case_code;
        show(key, jdbc_url);
    }
    if (StringUtils.isBlank(jdbc_user)) {
        key = StringUtils.removeStart(SEV.ENT_APP_JDBC_USER, SEV.ENT_APP_VAR_PREFFIX);
        jdbc_user = lower_case_code;
        show(key, jdbc_user);
    }
    if (StringUtils.isBlank(jdbc_password)) {
        key = StringUtils.removeStart(SEV.ENT_APP_JDBC_PASSWORD, SEV.ENT_APP_VAR_PREFFIX);
        jdbc_password = lower_case_code;
        show(key, jdbc_password);
    }
    if (StringUtils.isBlank(jndi_ejb_persistence_pattern)) {
        key = StringUtils.removeStart(SEV.ENT_APP_JNDI_EJB_PERSISTENCE_PATTERN, SEV.ENT_APP_VAR_PREFFIX);
        jndi_ejb_persistence_pattern = "java:global" + "/" + lower_case_code + "/" + lower_case_code
                + "-ejb-persistence/{0}";
        show(key, jndi_ejb_persistence_pattern);
    }
    if (StringUtils.isBlank(velocity_properties_file)) {
        key = StringUtils.removeStart(SEV.ENT_APP_VELOCITY_PROPERTIES_FILE, SEV.ENT_APP_VAR_PREFFIX);
        velocity_properties_file = home_dir + sep + "resources" + sep + "velocity" + sep
                + "velocity.properties";
        show(key, velocity_properties_file);
        isFile(velocity_properties_file);
    }
    if (StringUtils.isBlank(velocity_file_resource_loader_path)) {
        key = StringUtils.removeStart(SEV.ENT_APP_VELOCITY_FILE_RESOURCE_LOADER_PATH, SEV.ENT_APP_VAR_PREFFIX);
        velocity_file_resource_loader_path = home_dir + sep + "resources" + sep + "velocity" + sep
                + "templates";
        show(key, velocity_file_resource_loader_path);
        isDirectory(velocity_file_resource_loader_path);
    }
}