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:org.sonar.php.checks.utils.CheckUtils.java

/**
 * Return whether the method is overriding a parent method or not.
 *
 * @param declaration METHOD_DECLARATION
 * @return true if method has tag "@inheritdoc" in it's doc comment.
 *///from   w  w w  .ja v  a  2s.com
public static boolean isOverriding(MethodDeclarationTree declaration) {
    for (SyntaxTrivia comment : ((PHPTree) declaration).getFirstToken().trivias()) {
        if (StringUtils.containsIgnoreCase(comment.text(), "@inheritdoc")) {
            return true;
        }
    }
    return false;
}

From source file:org.sonar.php.checks.utils.CommentContainsPatternChecker.java

public void visitToken(Token token) {
    for (Trivia trivia : token.getTrivia()) {
        String comment = trivia.getToken().getOriginalValue();

        if (StringUtils.containsIgnoreCase(comment, pattern)) {
            String[] lines = comment.split("\r\n?|\n");

            for (int i = 0; i < lines.length; i++) {
                if (StringUtils.containsIgnoreCase(lines[i], pattern) && !isLetterAround(lines[i], pattern)) {
                    check.getContext().createLineViolation(check, message, trivia.getToken().getLine() + i);
                }/*from  w  ww  . j  a v a2s .com*/
            }
        }
    }
}

From source file:org.sonar.php.checks.utils.FunctionUtils.java

/**
 * Return wether the method is overriding a parent method or not.
 *
 * @param methodDec METHOD_DECLARATION//  ww w . j  av a 2  s.c  om
 * @return true if method has tag "@inheritdoc" in it's doc comment.
 */
public static boolean isOverriding(AstNode methodDec) {
    Token functionToken = methodDec.getToken();
    for (Trivia comment : functionToken.getTrivia()) {
        if (StringUtils.containsIgnoreCase(comment.getToken().getValue(), "@inheritdoc")) {
            return true;
        }
    }
    return false;
}

From source file:org.sonar.pickbasic.checks.CommentContainsPatternChecker.java

public void visitToken(SyntaxToken token) {
    for (SyntaxTrivia trivia : token.trivias()) {
        String comment = trivia.text();
        if (StringUtils.containsIgnoreCase(comment, pattern)) {
            String[] lines = comment.split("\r\n?|\n");

            for (int i = 0; i < lines.length; i++) {
                if (StringUtils.containsIgnoreCase(lines[i], pattern) && !isLetterAround(lines[i], pattern)) {
                    check.getContext().addIssue(check, trivia.line() + i, message);
                }/*w  w w. j  a  v  a 2  s  . co  m*/
            }
        }
    }
}

From source file:org.sonar.plugins.delphi.antlr.analyzer.CodeAnalysisCacheResults.java

/**
 * @param unitName       unit where the class is declared
 * @param classInterface class for search by exampe
 * @return cached class if found, null otherwise
 *///from www . j  a  v  a  2 s  .c om
public ClassInterface getCachedClass(String unitName, ClassInterface classInterface) {
    final String fileToSearch = File.pathSeparator + unitName + ".pas";
    Map<String, ClassInterface> unitClasses = null;
    for (String fileName : allClasses.keySet()) {
        if (StringUtils.containsIgnoreCase(fileName, fileToSearch)) {
            unitClasses = allClasses.get(fileName);
            break;
        }
    }
    if (unitClasses != null) {
        return unitClasses.get(classInterface.getName());
    }
    return null;
}

From source file:org.sonar.plugins.web.checks.comments.AvoidCommentedOutCodeCheck.java

@Override
public void comment(CommentNode node) {
    if (node.isHtml()) {
        String comment = node.getCode();

        if (!comment.startsWith("<!--[if") && !StringUtils.containsIgnoreCase(comment, "copyright")
                && CODE_RECOGNIZER.isLineOfCode(comment)) {
            createViolation(node.getStartLinePosition(), "Remove this commented out code.", node);
        }/*from  w ww  . java2s .  c  o  m*/
    }
}

From source file:org.sonar.server.app.StartupLogs.java

void log(Tomcat tomcat) {
    Connector[] connectors = tomcat.getService().findConnectors();
    for (Connector connector : connectors) {
        if (StringUtils.containsIgnoreCase(connector.getProtocol(), "AJP")) {
            logAjp(connector);/* w ww  .  jav a  2 s .com*/
        } else if (StringUtils.equalsIgnoreCase(connector.getScheme(), "https")) {
            logHttps(connector);
        } else if (StringUtils.equalsIgnoreCase(connector.getScheme(), "http")) {
            logHttp(connector);
        } else {
            throw new IllegalArgumentException("Unsupported connector: " + connector);
        }
    }
}

From source file:org.talend.dataprep.api.filter.SimpleFilterService.java

/**
 * Create a predicate that checks if the var contains a value
 *
 * @param node The filter node//www  .  j  a va 2 s.  c  om
 * @param columnId The column id
 * @param value The contained value
 * @return The contains predicate
 */
private Predicate<DataSetRow> createContainsPredicate(final JsonNode node, final String columnId,
        final String value) {
    checkValidValue(node, value);
    return r -> StringUtils.containsIgnoreCase(r.get(columnId), value);
}

From source file:org.talend.dataprep.filter.ObjectPredicateVisitor.java

@Override
public Predicate<Object> visit(FieldContainsExpression fieldContainsExpression) {
    final Method[] methods = getMethods(fieldContainsExpression.getFieldName());
    return o -> {
        try {//from  ww  w. j  a va2 s. com
            return StringUtils.containsIgnoreCase(String.valueOf(invoke(o, methods)),
                    fieldContainsExpression.getValue());
        } catch (Exception e) {
            LOGGER.error("Unable to use CONTAINS for '{}'.", methods, e);
            return false;
        }
    };
}

From source file:org.talend.tql.bean.BeanPredicateVisitor.java

@Override
public Predicate<T> visit(FieldContainsExpression fieldContainsExpression) {
    fieldContainsExpression.getField().accept(this);
    final Method[] methods = currentMethods.pop();

    return unchecked(o -> {
        String invokeResultString = valueOf(invoke(o, methods));
        String expressionValue = fieldContainsExpression.getValue();
        return fieldContainsExpression.isCaseSensitive()
                ? StringUtils.contains(invokeResultString, expressionValue)
                : StringUtils.containsIgnoreCase(invokeResultString, expressionValue);
    });//  w ww  .j  a  v a  2 s  . c  om
}