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.sammyun.service.impl.MemberServiceImpl.java

/**
 * ????//from  w  w  w. j ava 2 s . c  o  m
 * 
 * @param username ??(?)
 * @return ????
 */
@Transactional(readOnly = true)
public boolean usernameDisabled(String username) {
    Assert.hasText(username);
    Setting setting = SettingUtils.get();
    if (setting.getDisabledUsernames() != null) {
        for (String disabledUsername : setting.getDisabledUsernames()) {
            if (StringUtils.containsIgnoreCase(username, disabledUsername)) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.prowidesoftware.deprecation.DeprecationUtils.java

/**
 * Returns true if the environment variable {@link #PW_DEPRECATED} contains
 * the given key in its value/* w  ww.ja v  a2 s . c o m*/
 */
private static final boolean isSet(final EnvironmentVariableKey key) {
    return StringUtils.containsIgnoreCase(System.getenv(PW_DEPRECATED), key.name());
}

From source file:com.rest4j.impl.ApiResponseImpl.java

public ApiResponseImpl(APIImpl api, ApiRequest request, Resource response) {
    this.prettify = api.getParams().isPrettifyByDefault() == null ? false
            : api.getParams().isPrettifyByDefault();
    String param = api.getParams().getPrettifyParam();
    if (param != null) {
        int pos = param.indexOf('=');
        if (pos == -1 && request.param(param) != null) {
            prettify = !prettify;/*from   w  w  w.  j a  v  a 2  s. com*/
        } else {
            String prettifyParamName = param.substring(0, pos);
            String val = request.param(prettifyParamName);
            if (val != null && val.matches(param.substring(pos + 1))) {
                prettify = !prettify;
            }
        }
    }
    this.response = response;
    if (api.getParams().getJsonpParamName() != null) {
        this.callbackFunctionName = request.param(api.getParams().getJsonpParamName());
    }
    if (response != null && response.headers() != null) {
        for (Header header : response.headers())
            headers.addHeader(header.getName(), header.getValue());
    }
    compress = StringUtils.containsIgnoreCase(request.header("Accept-Encoding"), "gzip");
    addEtag = request.method().equals("GET");
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDataProvider.java

public void filterClasses(String value) {
    if (filteredClasses == null) {
        filteredClasses = new ArrayList<>();
    }// w w  w .  j a  v  a2 s .  c om

    filteredClasses.clear();

    if (StringUtils.isEmpty(value)) {
        filteredClasses.addAll(getAllClasses());
        return;
    }

    for (ObjectClassDto dto : getAllClasses()) {
        if (StringUtils.containsIgnoreCase(dto.getName(), value)) {
            filteredClasses.add(dto);
        }
    }
}

From source file:fr.jetoile.hadoopunit.HadoopBootstrapRemoteUtils.java

public void tailLogFileUntilFind(Path hadoopLogFilePath, String find, Log log) {
    try {//ww  w . j a va 2 s.  com
        BufferedReader reader = new BufferedReader(new FileReader(hadoopLogFilePath.toFile()));
        String line;
        boolean keepReading = true;
        while (keepReading) {
            line = reader.readLine();
            if (line == null) {
                //wait until there is more of the file for us to read
                Thread.sleep(1000);
            } else {
                keepReading = !StringUtils.containsIgnoreCase(line, find);
                //do something interesting with the line
            }
        }
    } catch (IOException | InterruptedException e) {
        log.error("unable to read wrapper.log file", e);
    }
}

From source file:fr.xebia.cocktail.CocktailRepository.java

public Collection<Cocktail> find(@Nullable final String ingredient, @Nullable final String name) {

    Predicate<Cocktail> ingredientPredicate;
    if (Strings.isNullOrEmpty(ingredient)) {
        ingredientPredicate = Predicates.alwaysTrue();
    } else {/*from   ww w.j  a  v a 2 s  .  co m*/
        ingredientPredicate = new Predicate<Cocktail>() {
            @Override
            public boolean apply(@Nullable Cocktail cocktail) {
                for (String cocktailIngredient : cocktail.getIngredientNames()) {
                    if (StringUtils.containsIgnoreCase(cocktailIngredient, ingredient)) {
                        return true;
                    }
                }
                return false;
            }
        };
    }

    Predicate<Cocktail> namePredicate;
    if (Strings.isNullOrEmpty(name)) {
        namePredicate = Predicates.alwaysTrue();
    } else {
        namePredicate = new Predicate<Cocktail>() {
            @Override
            public boolean apply(@Nullable Cocktail cocktail) {
                return StringUtils.containsIgnoreCase(cocktail.getName(), name);
            }
        };
    }

    return Lists.newArrayList(Collections2.filter(cocktails.asMap().values(),
            Predicates.and(namePredicate, ingredientPredicate)));
}

From source file:net.bible.service.format.osistohtml.taghandler.TitleHandler.java

@Override
public void start(Attributes attrs) {
    //JSword adds the chapter no at the top but hide this because the chapter is in the And Bible header
    boolean addedByJSword = attrs.getLength() == 1
            && OSISUtil.GENERATED_CONTENT.equals(attrs.getValue(OSISUtil.OSIS_ATTR_TYPE));
    // otherwise show if user wants Titles or the title is canonical
    isShowTitle = !addedByJSword && (parameters.isShowTitles()
            || "true".equalsIgnoreCase(attrs.getValue(OSISUtil.OSIS_ATTR_CANONICAL)));

    if (isShowTitle) {
        // ESV has subType butNETtext has lower case subtype so concatenate both and search with contains() 
        String subtype = attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE)
                + attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE.toLowerCase(Locale.ENGLISH));
        isMoveBeforeVerse = (StringUtils.containsIgnoreCase(subtype, PREVERSE)
                || (!verseInfo.isTextSinceVerse && verseInfo.currentVerseNo > 0));
        if (isMoveBeforeVerse) {
            // section Titles normally come before a verse, so overwrite the, already written verse, which is rewritten on writer.finishedInserting
            writer.beginInsertAt(verseInfo.positionToInsertBeforeVerse);
        }/*from   w  w  w .ja va 2  s . com*/

        // get title type from level
        String titleClass = "heading" + TagHandlerHelper.getAttribute(OSISUtil.OSIS_ATTR_LEVEL, attrs, "1");

        writer.write("<h1 class='" + titleClass + "'>");
    } else {
        writer.setDontWrite(true);
    }
}

From source file:io.github.mywarp.mywarp.command.util.Matches.java

private Matches(String query, Iterable<E> elements, Function<E, String> stringFunction,
        Comparator<E> comparator) {
    for (E element : elements) {
        String toTest = stringFunction.apply(element);
        if (toTest == null) {
            continue;
        }/*from   ww w .j a  v  a 2 s . co m*/

        if (toTest.equals(query)) {
            equalMatches.add(element);
        } else if (StringUtils.equalsIgnoreCase(toTest, query)) {
            equalIgnoreCaseMatches.add(element);
        } else if (toTest.contains(query)) {
            containsMatches.add(element);
        } else if (StringUtils.containsIgnoreCase(toTest, query)) {
            containsIgnoreCaseMatches.add(element);
        }
    }

    equalMatches.sort(comparator);
    equalIgnoreCaseMatches.sort(comparator);
    containsMatches.sort(comparator);
    containsIgnoreCaseMatches.sort(comparator);
}

From source file:mitm.common.security.ca.RequestUtils.java

/**
 * Returns the requests with a matching email address.
 *///from   w  ww  .  jav  a 2s  . c o  m
public static Collection<RequestParameters> findByEmail(Collection<RequestParameters> requests, String email,
        Match match) {
    Collection<RequestParameters> result = new LinkedList<RequestParameters>();

    if (requests == null || StringUtils.isEmpty(email)) {
        return result;
    }

    for (RequestParameters request : requests) {
        if (match == null || match == Match.EXACT) {
            if (email.equalsIgnoreCase(request.getEmail())) {
                result.add(request);
            }
        } else {
            if (StringUtils.containsIgnoreCase(request.getEmail(), email)) {
                result.add(request);
            }
        }
    }

    return result;
}

From source file:com.tesora.dve.sql.util.PortalDBHelperConnectionResource.java

@Override
public ExceptionClassification classifyException(Throwable t) {
    String msg = t.getMessage().trim();
    if (msg == null)
        return null;
    if (StringUtils.endsWithIgnoreCase(msg, "expected exception"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "No such Table:")
            || StringUtils.containsIgnoreCase(msg, "No such Table(s)")
            || StringUtils.containsIgnoreCase(msg, "No such Column:"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "Unsupported statement kind for planning:")
            && StringUtils.endsWithIgnoreCase(msg, "RollbackTransactionStatement"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(msg, "Data Truncation:"))
        return ExceptionClassification.OUT_OF_RANGE;
    if (StringUtils.containsIgnoreCase(msg, "ParserException")
            || StringUtils.containsIgnoreCase(msg, "Exception: Unable to build plan")
            || StringUtils.containsIgnoreCase(msg, "Parsing Failed:"))
        return ExceptionClassification.SYNTAX;
    if (StringUtils.containsIgnoreCase(msg, "Duplicate entry"))
        return ExceptionClassification.DUPLICATE;
    // this one should be removed ASAP we know we have a parser error when we get this
    if (StringUtils.containsIgnoreCase(msg, "java.lang.NullPointerException"))
        return ExceptionClassification.SYNTAX;
    return super.classifyException(t);
}