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 final void openGPS(Context context) {
    Intent intent = new Intent("com.nd.android.starapp.ui.jay.weibo.activity.GPS");
    intent.putExtra("enabled", true);
    context.sendBroadcast(intent);//from  w  w  w  .j av a  2s  .  com

    String provider = Settings.Secure.getString(context.getContentResolver(),
            Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    if (!provider.contains("gps")) { //if gps is disabled
        final Intent poke = new Intent();
        poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
        poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
        poke.setData(Uri.parse("3"));
        context.sendBroadcast(poke);
    }
}

From source file:Main.java

public static String getChannel(Context context) {
    ApplicationInfo appinfo = context.getApplicationInfo();
    String sourceDir = appinfo.sourceDir;
    ZipFile zipfile = null;//from  w ww .j  a  va  2 s.  c o m
    String ret = null;
    try {
        zipfile = new ZipFile(sourceDir);
        Enumeration<?> entries = zipfile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = ((ZipEntry) entries.nextElement());
            String entryName = entry.getName();
            if (entryName.startsWith(FOLDER_NAME) && entryName.contains(CHANNEL_SCHEME)) {
                ret = entryName;
                break;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (zipfile != null) {
            try {
                zipfile.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    try {
        if (ret != null) {
            String[] split = ret.split(CHANNEL_SCHEME_SPIT);
            if (split.length >= 2) {
                return ret.substring(split[0].length() + 1);
            }
        }
    } catch (Exception e) {

    }

    return null;
}

From source file:Main.java

public static Node createAndAppendNode(Node root, String path) {
    if (path == null)
        return root;

    Element node = null;/*ww w  . ja v  a  2s. co  m*/
    if (path.contains("/")) // check if path is complex
    {
        String[] steps = path.split("/");
        Node upper = root;
        Node lower = null;
        for (int i = 0; i < steps.length; i++) {
            // check if element exists
            lower = ifNodeExists(upper, steps[i]);
            if (lower == null) {
                lower = upper.getOwnerDocument().createElement(steps[i]);
                upper.appendChild(lower);
            }
            upper = lower;
        }
        return lower;
    }
    // simple path:
    node = root.getOwnerDocument().createElement(path);
    root.appendChild(node);
    return node;
}

From source file:Main.java

public static boolean checkValidTheme(String title, String description) {
    if (title == null)
        title = "";
    if (description == null)
        description = "";

    return title.contains(EVOLVE) || title.contains(TALON) || description.contains(EVOLVE)
            || description.contains(TALON) || title.contains("Theme") || title.contains("theme");
}

From source file:com.epam.cme.storefront.util.MetaSanitizerUtil.java

/**
 * Takes a string of words, removes duplicates and returns a comma separated list of keywords as
 * a String//from  w  ww.  j  a  va 2 s.co m
 * 
 * @param s
 *            Keywords to be sanitized
 * @return String of comma separated keywords
 */
public static String sanitizeKeywords(final String s) {
    final String clean = (StringUtils.isNotEmpty(s) ? Jsoup.parse(s).text() : ""); // Clean html
    final String[] sa = StringUtils.split(clean.replace("\"", "")); // Clean quotes

    // Remove duplicates
    String noDupes = "";
    for (final String aSa : sa) {
        if (!noDupes.contains(aSa)) {
            noDupes += aSa + ",";
        }
    }
    if (!noDupes.isEmpty()) {
        noDupes = noDupes.substring(0, noDupes.length() - 1);
    }
    return noDupes;
}

From source file:edu.uci.ics.crawler4j.util.Util.java

public static boolean hasBinaryContent(String contentType) {
    if (contentType != null) {
        String typeStr = contentType.toLowerCase();
        if (typeStr.contains("image") || typeStr.contains("audio") || typeStr.contains("video")
                || typeStr.contains("application")) {
            return true;
        }/*from   ww w.ja v a2 s .c o  m*/
    }
    return false;
}

From source file:com.datasalt.utils.commons.URLUtils.java

/**
   Extract parameters from a url so that Ning (or other crawling utilities) 
   can properly encode them if necessary. This was necesssary for facebook requests, 
   which are bundled with "next urls" that have funny characters in them such as this 
           //from   w  w w . j  a  va 2  s.  co  m
   "122524694445860|7fc6dd5fe13b43c09dad009d.1-1056745212|An3Xub_HEDRsGxVPkmy71VdkFhQ"
 * @param url
 */
public static Hashtable<String, String> extractParameters(String url) {
    Hashtable<String, String> pars = new Hashtable<String, String>();
    if (!url.contains("?")) {
        log.warn("WARNING : URL HAS NO PARAMETERS ! " + url);
        return pars;
    }
    String parameters = StringUtils.substringAfter(url, "?");
    for (String pairs : parameters.split("&")) {
        String[] nv = pairs.split("=");
        pars.put(nv[0], nv[1]);
    }
    return pars;
}

From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.io.XcodebuildOutputParser.java

private static String[] parseXcodebuildList(FilePath workspace, String arg, boolean useCache) {
    ArrayList<String> items = new ArrayList<String>();
    boolean found = false;

    String itemsString;//  w w w .j  av  a 2  s  . c om

    if (useCache)
        itemsString = XcodebuildCommandCaller.getInstance().getOutput(workspace, "-list");
    else
        itemsString = XcodebuildCommandCaller.getInstance().getOutputNoCache(workspace, "-list");

    if (StringUtils.isBlank(itemsString))
        return new String[0];

    for (String item : itemsString.split("\n")) {
        if (item.contains(arg)) {
            found = true;
            continue;
        }

        if (!found)
            continue;
        if (item.isEmpty())
            break;

        item = parseXcodeBuildListPattern1.matcher(item).replaceAll("$1");
        items.add(parseXcodeBuildListPattern2.matcher(item).replaceAll("$1"));
    }

    return (String[]) items.toArray(new String[items.size()]);
}

From source file:Main.java

/**
 * Returns a TempFile with given root, filename, and extension.
 * The resulting TempFile is safe for use with Android's MediaRecorder
 * @param c/*from  w w w  .j ava 2 s. c  om*/
 * @param root
 * @param filename
 * @param extension
 * @return
 */
public static File createTempFile(Context c, File root, String filename, String extension) {
    File output = null;
    try {
        if (filename != null) {
            if (!extension.contains("."))
                extension = "." + extension;
            output = new File(root, filename + extension);
            output.createNewFile();
            //output = File.createTempFile(filename, extension, root);
            Log.i(TAG, "Created temp file: " + output.getAbsolutePath());
        }
        return output;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}