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:com.glaf.core.util.AnnotationUtils.java

public static Collection<String> findMapper(String packagePrefix) {
    AnnotationDB db = getAnnotationDB(packagePrefix);
    Map<String, Set<String>> annotationIndex = db.getAnnotationIndex();
    Set<String> entities = annotationIndex.get("org.springframework.stereotype.Component");
    Collection<String> sortSet = new TreeSet<String>();
    if (entities != null && !entities.isEmpty()) {
        for (String str : entities) {
            if (packagePrefix != null && str.contains(packagePrefix) && StringUtils.contains(str, ".mapper.")) {
                sortSet.add(str);/*from  ww w  .  ja va  2 s.  c om*/
            }
        }
    }
    return sortSet;
}

From source file:com.msg.wmTestHelper.file.NameExtractor.java

private static boolean isFiltered(String mainPart) {
    for (String filter : filterStrings) {
        if (mainPart.contains(filter)) {
            return true;
        }/*  ww w. j a va  2  s .com*/
    }
    return false;
}

From source file:eu.scape_project.hawarp.utils.StringUtils.java

public static String getStrUntilChar(String str, String c) {
    int index = str.indexOf(c);
    if (str.contains(c)) {
        return str.substring(0, index);
    } else {//from ww w  .j  a v a  2  s.c  om
        return str;
    }
}

From source file:Main.java

public static SpannableString linkifyGid(String gid) {
    if (gid == null) {
        return null;
    }//w  w w. ja v a  2 s. c  o  m
    SpannableString ret = new SpannableString(gid);
    String name = gid.substring(0, gid.lastIndexOf("@"));
    String authority = gid.substring(gid.lastIndexOf("@") + 1);
    String mainAuth = authority.contains("/") ? authority.substring(0, authority.indexOf("/")) : authority;

    if (auths.containsKey(mainAuth)) {

        String link;
        try {
            if (auths.get(mainAuth).length == 1) {
                link = auths.get(mainAuth)[0];
            } else if (auths.get(mainAuth).length == 2) {
                link = auths.get(mainAuth)[0] + URLEncoder.encode(name, "UTF-8") + auths.get(mainAuth)[1];
            } else {
                return ret;
            }
        } catch (UnsupportedEncodingException e) {
            return ret;
        }

        ret = new SpannableString(Html.fromHtml("<a href=\"" + link + "\">" + gid + "</a>"));

    } else if (mainAuth.matches(".*\\..*")) { // if it contains a dot

        // we try a link to the supposed webpage of this auth
        ret = new SpannableString(Html.fromHtml("<a href=\"http://" + mainAuth + "\">" + gid + "</a>"));

    }

    return ret;
}

From source file:Main.java

public static int getContextLanguage(Context context) {
    int ret = CONST_INT_ADLANGUAGE_ALL;

    if (context != null) {
        try {/*from   ww  w  .j a v  a  2 s  .  co m*/
            String langStr = context.getResources().getConfiguration().locale.getLanguage().toLowerCase();
            if (langStr.contains("zh")) {
                ret = CONST_INT_ADLANGUAGE_CHINESE;
            } else {
                ret = CONST_INT_ADLANGUAGE_ENGLISH;
            }
        } catch (Exception e) {
        }
    }
    return ret;
}

From source file:Main.java

/**
 * Checks to see if URL is DuckDuckGo SERP
 * Returns the query if it's a SERP, otherwise null
 * //w w  w.ja va2 s.com
 * @param url
 * @return
 */
static public String getQueryIfSerp(String url) {
    if (!isSerpUrl(url)) {
        return null;
    }

    Uri uri = Uri.parse(url);
    String query = uri.getQueryParameter("q");
    if (query != null)
        return query;

    String lastPath = uri.getLastPathSegment();
    if (lastPath == null)
        return null;

    if (!lastPath.contains(".html")) {
        return lastPath.replace("_", " ");
    }

    return null;
}

From source file:Main.java

public static boolean isPathStringValid(String path) {
    if (null == path || path.length() == 0) {
        return false;
    }/*from   ww w  .  ja  v  a  2 s  .co  m*/

    if (path.contains(":") || path.contains("*") || path.contains("?") || path.contains("\"")
            || path.contains("<") || path.contains(">") || path.contains("|")) {
        Log.w(TAG, "filename can not contains:*:?\"<>|");

        return false;
    }

    return true;
}

From source file:software.uncharted.util.JSONUtil.java

private static JsonNode get(JsonNode obj, String accessor) {
    int keyIdx = accessor.indexOf(".");
    if (keyIdx == -1) {

        String key = accessor;

        if (key.contains("[")) {
            String arrayKey = getArrayKey(key);
            int arrayIdx = getArrayIndex(key);
            JsonNode a = obj.get(arrayKey);
            return a.get(arrayIdx);
        } else {//from w w w  . j  av a 2 s. c om
            return obj.get(key);
        }

    } else {
        String key = accessor.substring(0, keyIdx);
        String remainingAccessor = accessor.substring(keyIdx + 1);

        if (key.contains("[")) {
            String arrayKey = getArrayKey(key);
            int arrayIdx = getArrayIndex(key);
            JsonNode a = obj.get(arrayKey);
            return get(a.get(arrayIdx), remainingAccessor);

        } else {
            return get(obj.get(key), remainingAccessor);
        }
    }
}

From source file:com.comphenix.protocol.metrics.Statistics.java

public static Pair<String, String> splitVersion() {
    String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
    if (version.contains("-b")) {
        String[] split = version.split("-b");
        return Pair.of(split[0], split[1]);
    } else {/*www  .  j a v a  2s .  c o m*/
        return Pair.of(version, "Unknown");
    }
}

From source file:edu.berkeley.sparrow.daemon.util.Resources.java

public static int getSystemMemoryMb(Configuration conf) {
    int systemMemory = -1;
    try {/*from   www.j a v  a2s .  c o m*/
        Process p = Runtime.getRuntime().exec("cat /proc/meminfo");
        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = in.readLine();
        while (line != null) {
            if (line.contains("MemTotal")) {
                String[] parts = line.split("\\s+");
                if (parts.length > 1) {
                    int memory = Integer.parseInt(parts[1]) / 1000;
                    systemMemory = memory;
                }
            }
            line = in.readLine();
        }
    } catch (IOException e) {
    }
    if (conf.containsKey(SparrowConf.SYSTEM_MEMORY)) {
        return conf.getInt(SparrowConf.SYSTEM_MEMORY);
    } else {
        if (systemMemory != -1) {
            return systemMemory;
        } else {
            return SparrowConf.DEFAULT_SYSTEM_MEMORY;
        }
    }
}