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

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

Introduction

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

Prototype

public static boolean contains(final CharSequence seq, final CharSequence searchSeq) 

Source Link

Document

Checks if CharSequence contains a search CharSequence, handling null .

Usage

From source file:io.wcm.handler.url.suffix.impl.ExcludeSpecificResourceFilter.java

@Override
public boolean includes(String suffixPart) {
    if (StringUtils.contains(suffixPart, UrlSuffixUtil.KEY_VALUE_DELIMITER)) {
        return true;
    }// w  w  w. ja  v a 2  s. c  o m

    // We need to unescape the suffix part before comparing it to the source path to remove
    String unescapedPart = UrlSuffixUtil.decodeResourcePathPart(suffixPart);

    return !unescapedPart.equals(resourcePathToRemove);
}

From source file:de.micromata.genome.tpsb.httpmockup.internaltest.TestServletOne.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String data = req.getParameter("data");
    if (StringUtils.contains(data, "OK") == true) {
        resp.setStatus(200);//from   w  w w .  j  a v  a2s.  c  o m
        resp.getWriter().println("Ja, Kammer ist auch OK");
    } else {
        resp.setStatus(500);
        resp.getWriter().println("Ojeoje");
    }
    resp.getWriter().flush();
}

From source file:com.aestasit.markdown.visitors.TextExtractorTest.java

@Test
public void testExtraction() throws IOException {
    String text = extractText(toAst(allTestData(), DEFAULT_PEGDOWN_OPTIONS));
    Assert.assertFalse(isBlank(text));//w  w w  .ja  va 2  s  .c  o  m
    Assert.assertFalse(StringUtils.contains(text, "#"));
}

From source file:de.blizzy.documentr.util.Util.java

/**
 * Converts a text so that it can be used as a URL component. For example, the text
 * &quot;<code>My Funny Valentine</code>&quot; will be converted to
 * &quot;<code>my-funny-valentine</code>&quot;. This method is useful to convert
 * page titles to page path components./*  w  w  w .ja  v a2 s  . c  o  m*/
 */
public static String simplifyForUrl(String text) {
    PagePathValidator validator = new PagePathValidator();
    StringBuilder buf = new StringBuilder();
    int len = text.length();
    for (int i = 0; i < len; i++) {
        char c = text.charAt(i);
        if (StringUtils.contains(CHARS_TO_DASH, c)) {
            buf.append("-"); //$NON-NLS-1$
        } else {
            buf.append(c);
            if (!validator.isValid(buf.toString(), null)) {
                buf.deleteCharAt(buf.length() - 1);
            }
        }
    }

    String name = buf.toString().replaceAll("--", "-") //$NON-NLS-1$ //$NON-NLS-2$
            .replaceAll("^-", StringUtils.EMPTY) //$NON-NLS-1$
            .replaceAll("-$", StringUtils.EMPTY) //$NON-NLS-1$
            .toLowerCase();
    return name;
}

From source file:com.ppcxy.cyfm.showcase.demos.web.StaticContentServlet.java

/**
 * ???gzip?.//from  w w w .j a  v  a  2  s . c  om
 */
private static boolean checkAccetptGzip(HttpServletRequest request) {
    // Http1.1 header
    String acceptEncoding = request.getHeader("Accept-Encoding");

    return StringUtils.contains(acceptEncoding, "gzip");
}

From source file:ch.cyberduck.core.worker.DefaultExceptionMappingService.java

@Override
public BackgroundException map(final Throwable failure) {
    final StringBuilder buffer = new StringBuilder();
    if (failure instanceof RuntimeException) {
        this.append(buffer, "Unknown application error");
    }//from   w  w  w  .  ja  v a 2  s.c o  m
    this.append(buffer, failure.getMessage());
    for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if (!StringUtils.contains(failure.getMessage(), cause.getMessage())) {
            this.append(buffer, cause.getMessage());
        }
    }
    return this.wrap(failure, LocaleFactory.localizedString("Error", "Error"), buffer);
}

From source file:ch.cyberduck.core.irods.IRODSHomeFinderService.java

@Override
public Path find() throws BackgroundException {
    final Path home = super.find();
    if (home == DEFAULT_HOME) {
        final String user;
        final Credentials credentials = session.getHost().getCredentials();
        if (StringUtils.contains(credentials.getUsername(), ':')) {
            user = StringUtils.splitPreserveAllTokens(credentials.getUsername(), ':')[1];
        } else {//from w  w w.j ava  2 s.  co m
            user = credentials.getUsername();
        }
        return new Path(
                new StringBuilder().append(Path.DELIMITER).append(session.getRegion()).append(Path.DELIMITER)
                        .append("home").append(Path.DELIMITER).append(user).toString(),
                EnumSet.of(Path.Type.directory, Path.Type.volume));
    }
    return home;
}

From source file:com.eryansky.common.orm.core.MatchValue.java

/**
 * andValueSeparatororValueSeparator()/*from  w w w .  ja  v  a 2 s. c o m*/
 * 
 * @param matchValue 
 * @param type 
 * @param andValueSeparator 
 * @param orValueSeparator 
 * 
 * @return {@link com.eryansky.common.orm.core.MatchValue}
 */
public static MatchValue createMatchValueModel(String matchValue, Class<?> type, String andValueSeparator,
        String orValueSeparator) {

    List<Object> values = new ArrayList<Object>();

    if (StringUtils.contains(matchValue, andValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, andValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(false, values);
    } else if (StringUtils.contains(matchValue, orValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, orValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(true, values);
    } else {
        values.add(ConvertUtils.convertToObject(matchValue, type));
        return new MatchValue(false, values);
    }

}

From source file:com.financial.tools.recorderserver.tools.util.DataLoader.java

protected static IDatabaseConnection getConnection(DataSource dataSource)
        throws DatabaseUnitException, SQLException {
    Connection connection = dataSource.getConnection();
    String url = connection.getMetaData().getURL();
    if (StringUtils.contains(url, ":h2:")) {
        return new H2Connection(connection, null);
    } else if (StringUtils.contains(url, ":mysql:")) {
        return new MySqlConnection(connection, null);
    } else if (StringUtils.contains(url, ":oracle:")) {
        return new OracleConnection(connection, null);
    } else {/*ww  w  . j a  v  a  2  s .co m*/
        return new DatabaseConnection(connection);
    }
}

From source file:kenh.expl.functions.Contains.java

public boolean process(String seq, String searchSeq, boolean ignoreCase) {
    if (ignoreCase)
        return StringUtils.containsIgnoreCase(seq, searchSeq);
    else// w  w  w  . j  ava2  s. co m
        return StringUtils.contains(seq, searchSeq);
}