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

public static List<String> parse(String input) {
    List<String> term = new ArrayList<>();
    for (String part : input.replace('"', ' ').split("\\s+")) {
        if (part.isEmpty()) {
            continue;
        }/*  ww w .  j  a  v a2s. c  om*/
        final String cleaned = clean(part);
        if (isKeyword(cleaned) || cleaned.contains("*")) {
            term.add(part);
        } else if (!cleaned.isEmpty()) {
            term.add(cleaned);
        }
    }
    return term;
}

From source file:Main.java

/**
 * //from w  ww.j a  v  a2s. co  m
 * @param predicateStr
 * @return
 */
public static String safeQuotePredicate(String predicateStr) {
    // Check if starts with file name
    final String fileExtension = ".owl";
    if (predicateStr.contains(fileExtension)) {
        int startingIndex = predicateStr.indexOf(fileExtension) + fileExtension.length();
        return predicateStr.substring(startingIndex, predicateStr.length());
    }

    return predicateStr;
}

From source file:com.thoughtworks.go.util.TestUtils.java

public static TypeSafeMatcher<String> contains(final String toMatch) {
    return new TypeSafeMatcher<String>() {
        public boolean matchesSafely(String underTest) {
            return underTest.contains(toMatch);
        }//from w w  w.  j a  v  a 2s  .  com

        public void describeTo(Description description) {
            description.appendText("The actual string does not contain the expected string.");
        }
    };
}

From source file:io.ssc.trackthetrackers.extraction.resources.URLHandler.java

public static boolean couldBeUrl(String url) {

    if (!url.contains(".") || url.contains(" ") || url.contains("\t") || url.contains("\r")
            || url.contains("\n")) {
        return false;
    }/*  w  w  w  . j av a 2 s  .co m*/

    //TODO: check this condition
    //this doesnt work for something like localhost:80/...
    int colonIndex = url.indexOf(':');
    if (colonIndex != -1) {
        if (colonIndex < url.length() - 1 && url.charAt(colonIndex + 1) != '/') {
            return false;
        }
    }

    return true;
}

From source file:com.dianping.lion.util.UrlUtils.java

public static String resolveUrl(String url, String paramStr) {
    return url + (url.contains("?") ? "&" : "?") + paramStr;
}

From source file:com.moki.touch.util.UrlUtil.java

public static String addHttp(String url) {
    if (!url.contains("http://") && !url.contains("https://")) {
        url = "http://" + url;
    }//from ww w . j  a  v  a2 s . c  o  m
    return url;
}

From source file:Main.java

private static String justifyOperation(String s, float width, Paint p) {
    float holder = (float) (COMPLEXITY * Math.random());
    while (s.contains(Float.toString(holder))) {
        holder = (float) (COMPLEXITY * Math.random());
    }/* ww  w.  jav  a 2 s . com*/
    String holder_string = Float.toString(holder);
    float lessThan = width;
    int timeOut = 100;
    int current = 0;
    while ((p.measureText(s) < lessThan) && (current < timeOut)) {
        s = s.replaceFirst(" ([^" + holder_string + "])", " " + holder_string + "$1");
        lessThan = (p.measureText(holder_string) + lessThan) - p.measureText(" ");
        current++;
    }
    String cleaned = s.replaceAll(holder_string, " ");
    return cleaned;
}

From source file:org.runway.utils.TextUtils.java

public static boolean isValidEmail(String email) {
    boolean result = false;
    if (email.length() > 2 && email.contains("@") && email.contains(".")) {
        result = true;//from w  ww  . j  a v  a2 s  .  c o m
    }
    return result;
}

From source file:co.marcin.novaguilds.util.LoggerUtils.java

private static String space(String s) {
    return s.contains("Manager]") ? "" : " ";
}

From source file:core.SHA256Hash.java

public static String getHashAlgType(String url) throws Exception {
    if (url.contains(SHA256_16)) {
        return SHA256_16;
    }//  www  . j  a v a 2 s.c o  m
    if (url.contains(SHA256)) {
        return SHA256;
    }
    throw new Exception("Unknown hash alg type");
}