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:io.fabric8.karaf.core.Support.java

/**
 * Returns the string before the given token
 *
 * @param text   the text//from   ww  w  . j  a v  a  2  s . co m
 * @param before the token
 * @return the text before the token, or <tt>null</tt> if text does not contain the token
 */
public static String before(String text, String before) {
    if (!text.contains(before)) {
        return null;
    }
    return text.substring(0, text.indexOf(before));
}

From source file:com.github.stagirs.docextractor.wiki.WikiParser.java

private static Link getLink(Iterator<String> lems, String end) {
    List result = getElems(lems, end);
    String str = StringUtils.join(result, " ");
    if (!str.contains("|")) {
        return new Link(str, str);
    } else {/*from w w w  .j  a v a  2  s . co m*/
        return new Link(str.substring(0, str.lastIndexOf("|")), str.substring(str.lastIndexOf("|") + 1));
    }
}

From source file:Main.java

public static boolean containKeyWords(String objectString, String firMatchString, String secMatchString,
        String thrMatchString) {//from   w w  w.ja v a2  s  .c o m
    if (objectString.contains(firMatchString) || objectString.contains(secMatchString)
            || objectString.contains(thrMatchString)) {
        return true;
    } else {
        return false;
    }

}

From source file:Main.java

public static String getFirstPath(String attributePath) {

    if (attributePath == null) {
        return attributePath;
    } else if (!attributePath.contains("/")) {
        return attributePath;
    } else {//w  w  w.ja va 2 s  . c  o  m
        return attributePath.substring(0, attributePath.indexOf("/"));
    }
}

From source file:cognition.pipeline.Main.java

private static boolean requiresHelp(String[] args) {
    if (args == null) {
        return true;
    }//from   w ww .j  ava2 s.  com

    for (String arg : args) {
        if (arg.contains("help")) {
            return true;
        }
    }

    return false;
}

From source file:Main.java

public static boolean isEmulator()
/*     */ {//from   ww  w  .  j av a  2s.c o  m
    /* 274 */String product = Build.PRODUCT;
    /* 275 */return (product != null)
            && ((product.equals("sdk")) || (product.contains("_sdk")) || (product.contains("sdk_")));
    /*     */}

From source file:org.focusns.common.web.WebUtils.java

public static Map<String, String> getMatrixParameters(HttpServletRequest request) {
    ////  www.j av  a  2s.c  o  m
    Map<String, String> parameterMap = new LinkedHashMap<String, String>();
    //
    String requestUri = request.getRequestURI();
    if (requestUri.contains(";")) {
        String paramsString = requestUri.substring(requestUri.indexOf(";") + 1);
        String[] paramsPair = new String[] { paramsString };
        if (paramsString.contains(",")) {
            paramsPair = StringUtils.tokenizeToStringArray(paramsString, ",");
        }
        for (String paramPair : paramsPair) {
            String[] nameAndValue = StringUtils.split(paramPair, "=");
            parameterMap.put(nameAndValue[0], nameAndValue[1]);
        }
    }
    return parameterMap;
}

From source file:Main.java

public static String getSDRoot() {
    String pre = null;//from w w w .j a  va 2 s  .  c o  m
    String root = null;
    try {
        Runtime r = Runtime.getRuntime();
        Process p = r.exec("ls mnt");
        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String inline;
        while ((inline = br.readLine()) != null) {
            if (inline.contains("mmcblk")) {
                pre = inline;
                break;
            }
        }
        br.close();
        root = "/mnt/" + pre + "/" + pre + "p1";
    } catch (Exception e) {

    }
    return root;
}

From source file:Main.java

public static MediaMetadataRetriever initMetadataRetriever(String URI) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    if (!URI.contains("http:") && URI.endsWith("mp3")) {
        try {//  w w  w  .  ja  v  a  2s  . c o m
            retriever.setDataSource(URI);
        } catch (Exception e) {
            Log.d(LOG_TAG, "Failed: " + URI + " " + e.toString());
            e.printStackTrace();
            return null;
        }
    } else {
        return null;
    }
    return retriever;
}

From source file:Main.java

public static String getFieldValue(String json, String key) {
    if (TextUtils.isEmpty(json))
        return null;
    if (!json.contains(key))
        return "";
    JSONObject jsonObject = null;/*from  w  w w .  ja  va  2s  . c  om*/
    String value = null;
    try {
        jsonObject = new JSONObject(json);
        value = jsonObject.getString(key);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return value;
}