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 boolean isQiniu(String url) {
    boolean isQiniu = false;
    if (TextUtils.isEmpty(url)) {
        return false;
    }// w w  w  .ja  v a  2  s .c o m
    isQiniu = url.contains(QINIU_WWW) || url.contains(QINIU_TEST) || url.contains(QINIU_TEST2)
            || url.contains("?imageMogr2") || url.contains("?imageView2") || url.contains("?imageView");
    return isQiniu;

}

From source file:Main.java

private static boolean validIP(String ip) {
    if (ip == null || ip.length() < 7 || ip.length() > 15)
        return false;
    if (ip.contains("-"))
        return false;

    try {//from  w ww  .j  a  va2s.  com
        int x = 0;
        int y = ip.indexOf('.');

        if (y != -1 && Integer.parseInt(ip.substring(x, y)) > 255)
            return false;

        x = ip.indexOf('.', ++y);
        if (x != -1 && Integer.parseInt(ip.substring(y, x)) > 255)
            return false;

        y = ip.indexOf('.', ++x);
        return !(y != -1 && Integer.parseInt(ip.substring(x, y)) > 255
                && Integer.parseInt(ip.substring(++y, ip.length() - 1)) > 255
                && ip.charAt(ip.length() - 1) != '.');

    } catch (NumberFormatException e) {
        return false;
    }
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining
 * to a particular class.//from www . j av a  2 s .co  m
 * 
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(final String className) {
    final UIDefaults retVal = new UIDefaults();
    final UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    final List<?> listKeys = Collections.list(defaults.keys());
    for (final Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            final String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) {
                property = stringKey.substring(stringKey.indexOf(".") + 1);
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:Main.java

/**
 * Try to pick the app to handle this intent.
 * @param context//from ww w. j  a v a2s . c o  m
 * @param intent
 * @param matchMe E.g. "twitter" Pick the first app whose name contains this.
 * Can be null for pick-anything.
 * @return true if a match was found
 */
public static boolean pickIntentHandler(Context context, Intent intent, String matchMe) {
    final PackageManager pm = context.getPackageManager();
    final List<ResolveInfo> activityList = pm.queryIntentActivities(intent, 0);
    List<String> handlers = new ArrayList(activityList.size());
    for (ResolveInfo app : activityList) {
        String name = app.activityInfo.name;
        handlers.add(name);
        if (matchMe == null || name.contains(matchMe)) {
            ActivityInfo activity = app.activityInfo;
            ComponentName compname = new ComponentName(activity.applicationInfo.packageName, activity.name);
            //               intent.addCategory(Intent.CATEGORY_LAUNCHER);
            //               intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            intent.setComponent(compname);
            return true;
        }
    }
    Log.d("pick-intent", "No match for " + matchMe + " in " + handlers);
    return false;
}

From source file:Main.java

public static double str2num(String s, double defVal) {
    if (s.equals("N/A"))
        return defVal;
    try {//from  w w  w .  jav  a 2  s.com
        s = s.trim();
        s = s.contains(" ") ? s.split(" ")[0] : s;
        return Double.parseDouble(s);
    } catch (Exception err) {
        Log.e("str2num", s, err);
        return defVal;
    }
}

From source file:InlineTestStringsProvider.java

public static boolean isFileOrFolderName(String s) {
    if (s.contains(File.separator))
        return true;
    if (s.contains(":"))
        return true;
    return false;
}

From source file:com.amalto.webapp.core.util.XmlUtil.java

public static String escapeXml(String value) {
    if (value == null)
        return null;
    boolean isEscaped = false;
    if (value.contains("&quot;") || //$NON-NLS-1$
            value.contains("&amp;") || //$NON-NLS-1$
            value.contains("&lt;") || //$NON-NLS-1$
            value.contains("&gt;")) { //$NON-NLS-1$
        isEscaped = true;// w  w  w  . ja v a 2 s. c om
    }
    if (!isEscaped) {
        value = StringEscapeUtils.escapeXml(value);
    }
    return value;
}

From source file:com.crosstreelabs.cognitio.gumshoe.format.HtmlFormatHandler.java

protected static String stripURLFragmentIdentifier(final String url) {
    if (!url.contains("#")) {
        return url;
    }/*w  w w  .j a v a2 s .  c  om*/

    int pos = url.indexOf("#");
    int pos2 = url.indexOf("#!");
    if (pos == pos2) {
        return url;
    }

    return url.substring(0, pos);
}

From source file:Main.java

public static int str2int(String s, int defVal) {
    if (s.equals("N/A"))
        return defVal;
    try {//from   w  w  w.  j  av a 2  s  .  co m
        s = s.trim();
        s = s.contains(" ") ? s.split(" ")[0] : s;
        return NumberFormat.getInstance(Locale.ENGLISH).parse(s).intValue();
    } catch (Exception err) {
        Log.e("str2int", s, err);
        return defVal;
    }
}

From source file:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findJPAEntity(String packagePrefix) {
    AnnotationDB db = getAnnotationDB(packagePrefix);
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get("javax.persistence.Entity");
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            if (packagePrefix != null && str.contains(packagePrefix)) {
                sortSet.add(str);//from  www  . ja v  a2 s  . c o  m
            }
        }
    }
    return sortSet;
}