Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

In this page you can find the example usage for java.lang String contains.

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:Main.java

/**
 * Handle illegal character in result string.
 *
 * @param result/*from   www  . j av a  2  s.  c  om*/
 *     the result
 * @return the string
 */
static String handleIllegalCharacterInResult(final String result) {
    String tempResult = result;
    if (tempResult != null && tempResult.contains(" ")) {
        tempResult = tempResult.replaceAll(" ", "_");
    }
    return tempResult;
}

From source file:Main.java

public static String convertMatchesToStringLength(String test) {

    if (test.contains("matches")) {

        int indexMatches = test.indexOf("matches");
        int firstBracketIndex = test.indexOf("(", indexMatches);
        int lastBracketIndex = test.lastIndexOf(")");

        String matchesContext = test.substring(firstBracketIndex + 1, lastBracketIndex);
        String normalizeSpace = matchesContext.split(" , ")[0];
        String regex = matchesContext.split(" , ")[1];

        if (regex.contains("[0-9]")) {
            int firstParenthesis = regex.indexOf("{");
            int lastParenthesis = regex.indexOf("}", firstParenthesis);

            String lengthRange[] = regex.substring(firstParenthesis + 1, lastParenthesis).split(",");

            if (lengthRange.length > 1) {
                String startOffset = lengthRange[0];
                String endOffset = lengthRange[1];
                //string-length(normalize-space(.)) >= 10 and string-length(normalize-space(.)) <= 11
                test = "string-length" + "(" + normalizeSpace + ")" + " >= " + startOffset + " and "
                        + "string-length" + "(" + normalizeSpace + ")" + " <= " + endOffset;
            } else {
                String length = lengthRange[0];
                test = "string-length" + "(" + normalizeSpace + ")" + " = " + length;
            }//from  ww  w.  j a  v a2 s .  co  m

        }

    }

    return test.trim();
}

From source file:Main.java

public static boolean isAndroid(String paramString) {
    paramString = paramString.toLowerCase();
    return (paramString.contains("dalvik")) || (paramString.contains("lemur"));
}

From source file:Main.java

/**
 * Checks whether a column is numeric/*from  ww  w .j  a  v a 2  s . co  m*/
 * @param column
 * @param dataType
 * @return
 */
public static boolean checkNumeric(final String dataType) {
    boolean numericColumn = false;
    if (dataType.contains("integer") || dataType.contains("real") || dataType.contains("decimal")
            || dataType.contains("unsigned")) {
        numericColumn = true;
    }
    return numericColumn;
}

From source file:io.selendroid.util.JsonXmlUtil.java

private static String extractTagName(String clazz) {
    if (clazz.contains(".")) {
        String[] elements = clazz.split("\\.");
        String simpleClassName = elements[elements.length - 1];
        if (simpleClassName.contains("$")) {
            String[] subElememts = simpleClassName.split("\\$");
            return subElememts[subElememts.length - 1];
        }/*from  www  .ja  v a2 s.c om*/
        return simpleClassName;
    }
    return clazz;
}

From source file:Main.java

public static boolean deviceInFpsBlacklisted() {
    List<String> blackListedModels = Arrays.asList(BLACKLISTED_FPS_MODELS);
    for (String blackModel : blackListedModels) {
        String model = Build.MODEL;
        if (!TextUtils.isEmpty(model) && model.contains(blackModel)) {
            return true;
        }/*from  w w w  .j av a  2s.c o m*/
    }
    return false;
}

From source file:Main.java

public static boolean isValidComment(final String c) {
    assert (c != null) : c;
    if (c.contains("--")) {
        return false;
    }/*  ww  w  . j av  a 2  s . c om*/
    if (c.startsWith("-") || c.endsWith("-")) {
        return false;
    }
    return true;
}

From source file:Main.java

private static int parserColor(String value) {
    String regularExpression = ",";
    if (value.contains(regularExpression)) {
        String[] temp = value.split(regularExpression);

        int color = Color.parseColor(temp[0]);
        int alpha = Integer.valueOf(temp[1]);
        int red = (color & 0xff0000) >> 16;
        int green = (color & 0x00ff00) >> 8;
        int blue = (color & 0x0000ff);

        return Color.argb(alpha, red, green, blue);
    }/*from  w  ww  . j a  va 2  s.  c  om*/
    return Color.parseColor(value);
}

From source file:Main.java

public static String genMarkdown(String text) {
    text = escapeXml(text);/*w  ww  . j  a va2  s.  co  m*/
    while (text.contains("[[")) {
        String left = text.substring(0, text.indexOf("[["));
        String url = text.substring(text.indexOf("[[") + 2, text.indexOf("]]"));
        String right = text.substring(text.indexOf("]]") + 2);
        text = left + "<a href=\"" + url + "\">" + url + "</a>" + right;
    }
    return text;
}

From source file:Main.java

/**
 * Prepends the at (@) symbol to the property name. This is XPath-specific.
 * <p>//  ww  w. j a v  a2s.  c o m
 * Before you start to hate me, please be aware that I created this method
 * because of the way XPath can be used to query the JCR. For example, if you
 * have a query in which you want to evaluate a property of a child node, say
 * "jcr:content/@jcr:title," prepending the @ symbol to the property name
 * would only cause problems, i.e. "@jcr:content/@jcr:title." The issue being
 * that jcr:content is a child node, not a property, thus the query fails
 * miserably. <b>STOP DOING THAT AND I MAY CONSIDER REMOVING THIS METHOD</b>
 * <p>
 * As a measure to avoid the auto-symbol-prepending I'm going to check if the
 * symbol exists in the property name and prepend it if and only if it doesn't
 * exist. Thus, "published" would output "@published" and
 * "jcr:content/@jcr:title" would remain unaltered.
 * <p>
 * As a side-effect, if a property starts with the at (@) symbol, it is not
 * prepended again, but this wouldn't be the right way of using the API, i. e.
 * never prepend the at (@) symbol because it's XPath-specific.
 *
 * @param propertyName
 *          The name of the property that @ will be prepended to
 * @return A new string representing a valid XPath property
 */
public static String prependSymbol(final String propertyName) {
    if (propertyName.contains(xpathPropertySymbol)) {

        return propertyName;

    } else {
        // Performance problems ensue
        return xpathPropertySymbol + propertyName;
    }
}