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:info.novatec.testit.livingdoc.util.NameUtils.java

/**
 * Tries to convert <code>string</code> to a Java class name by following a
 * few simple steps:/*from   w w  w. j av  a  2s  . c  o m*/
 * <p>
 * <p>
 * <ul>
 * <li>First of all, <code>string</code> gets <i>camel cased</i>, the usual
 * Java class naming convention.
 * <li>Secondly, any whitespace, by virtue of
 * <code>Character.isWhitespace()</code> is removed from the camel cased
 * <code>string</code>.
 * <li>Third, all accented characters (diacritis) are replaced by their
 * non-accented equivalent (ex: \u00e9 -&gt; e)</li>
 * <li>Fourth, all non java identifier characters are removed</li>
 * </ul>
 * <p>
 * The only exception to executing these two steps is when
 * <code>string</code> represents a fully-qualified class name. To check if
 * <code>string</code> represents a fully-qualified class name, a simple
 * validation of the existence of the '.' character is made on
 * <code>string</code>.
 * 
 * @param s The String that may represent a Java class name
 * @return The input string converted by following the documented steps
 */
public static String toClassName(String s) {
    if (StringUtils.isEmpty(s) || s.contains(".")) {
        return s;
    }
    return removeNonJavaIdentifierCharacters(
            StringUtils.stripAccents(StringUtils.deleteWhitespace(WordUtils.capitalizeFully(s))));
}

From source file:me.ineson.demo.app.rest.RestConfig.java

/**
 * @param mediaTypes/*from w  ww. j a  va2s.  c o m*/
 * @return
 */
public static boolean supportedMediaType(String mediaTypes) {
    if (StringUtils.isBlank(mediaTypes)) {
        return false;
    }

    return (mediaTypes.contains(MediaType.APPLICATION_JSON) || mediaTypes.contains(MediaType.APPLICATION_XML)
            || mediaTypes.contains(MediaType.TEXT_XML));
}

From source file:Main.java

public static String[] getMounts(CharSequence path) {
    BufferedReader bufferedReader = null;
    try {/*from   ww  w  .jav  a 2s .com*/
        bufferedReader = new BufferedReader(new FileReader("/proc/mounts"), 256);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            if (line.contains(path)) {
                return line.split(" ");
            }
        }
    } catch (FileNotFoundException ignored) {
        Log.d(TAG, "/proc/mounts does not exist");
    } catch (IOException ignored) {
        Log.d(TAG, "Error reading /proc/mounts");
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException ignored) {
                // ignored
            }
        }
    }
    return null;
}

From source file:com.gargoylesoftware.htmlunit.protocol.data.DataUrlDecoder.java

private static String extractMediaType(final String beforeData) {
    if (beforeData.contains("/")) {
        if (beforeData.contains(";")) {
            return StringUtils.substringBefore(beforeData, ";");
        }/*from w  ww .  java  2s. c  om*/
        return beforeData;
    }
    return DEFAULT_MEDIA_TYPE;
}

From source file:Main.java

private final static String parseObjKey(String path, String url_type) {
    path = URLDecoder.decode(path);
    String objKey = "";
    int p = 0;//  w  ww  .j a va  2 s . c o m
    String str = "";
    String[] tmp = null;
    p = path.indexOf(url_type) + url_type.length();
    str = path.substring(p);
    if (str.contains("?")) {
        tmp = str.split("?");
        objKey = tmp[0];
    } else {
        objKey = str;
    }
    return objKey;
}

From source file:Main.java

public static String getLocalIpAddress(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo != null && wifiInfo.getIpAddress() != 0) {
        return android.text.format.Formatter.formatIpAddress(wifiInfo.getIpAddress());
    } else {/*from w w  w  . j  a  v a2 s . com*/
        try {
            Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
            while (en.hasMoreElements()) {
                NetworkInterface intf = en.nextElement();
                Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
                while (enumIpAddr.hasMoreElements()) {
                    InetAddress inetAddress = enumIpAddr.nextElement();
                    if (!inetAddress.isLoopbackAddress() && inetAddress.getHostAddress().indexOf(":") == -1) {
                        String ipAddress = inetAddress.getHostAddress();
                        if (!TextUtils.isEmpty(ipAddress) && !ipAddress.contains(":")) {
                            return ipAddress;
                        }
                    }
                }
            }
        } catch (SocketException e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:ninja.template.TemplateEngineJsonP.java

/**
 * Tests whether the given function name is a valid JSONP function
 * name/path./*  w  w  w.ja v  a2  s.c  om*/
 *
 * @param callback Callback value to test.
 * @return Whether the given function name is a valid JSONP function
 * name/path.
 */
public static boolean isThisASecureCallbackName(String callback) {
    return !Strings.isNullOrEmpty(callback) && !callback.contains("..")
            && CALLBACK_SECURITY_VALIDATION_REGEXP.matcher(callback).matches();
}

From source file:io.curly.bloodhound.query.QueryParser.java

@NotNull
static MultiValueMap<String, String> resolveMultiParameter(String query) {
    final MultiValueMap<String, String> multimap = new LinkedMultiValueMap<>();

    convertToMap(query).forEach((key, value) -> {
        if (value.contains(L_CURLY) && value.contains(R_CURLY)) {
            Matcher matcher = Pattern.compile(REGEX_INNER_CURLY).matcher(value);
            if (matcher.find()) {
                String cleaned = cleanDelimiters(matcher.group());
                if (cleaned.contains(COMMA)) {
                    multimap.put(key, getCommaDelimitedValue(cleaned));
                } else {
                    multimap.put(key, getSpaceSplicedValue(cleaned));
                }/*from w ww .j  av a2 s  .  c  om*/
            }
        } else {
            multimap.add(key, unquote(value));
        }
    });

    return multimap;
}

From source file:com.ms.app.web.commons.utils.DeviceUtils.java

/**
 * ?UA??// w ww. ja  v  a2  s  .  c om
 * 
 * @param ua
 * @return
 */
public static WebBrowserEnum getBowser(String ua) {
    if (StringUtils.isEmpty(ua)) {
        return null;
    }
    ua = ua.toLowerCase();
    if (ua.contains("msie")) {
        return WebBrowserEnum.IE;
    }
    if (ua.contains("chrome")) {
        return WebBrowserEnum.CHROME;
    }
    if (ua.contains("firefox")) {
        return WebBrowserEnum.FIREFOX;
    }
    if (ua.contains("safari")) {
        return WebBrowserEnum.SAFARI;
    }
    if (ua.contains("opera")) {
        return WebBrowserEnum.OPERA;
    }
    return null;
}

From source file:com.thinkbiganalytics.server.KyloServerApplication.java

/**
 * Return the database version for Kylo.
 *
 * @return the version of Kylo stored in the database
 *//*from   ww w.  ja v a  2s .co  m*/
private static KyloVersion getDatabaseVersion() {

    try {
        //ensure native profile is there for spring to load
        String profiles = System.getProperty("spring.profiles.active", "");
        if (!profiles.contains("native")) {
            profiles = StringUtils.isEmpty(profiles) ? "native" : profiles + ",native";
            System.setProperty("spring.profiles.active", profiles);
        }
        //Spring is needed to load the Spring Cloud context so we can decrypt the passwords for the database connection
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                "kylo-upgrade-check-application-context.xml");
        ctx.refresh();
        KyloUpgradeDatabaseVersionChecker upgradeDatabaseVersionChecker = (KyloUpgradeDatabaseVersionChecker) ctx
                .getBean("kyloUpgradeDatabaseVersionChecker");
        KyloVersion kyloVersion = upgradeDatabaseVersionChecker.getDatabaseVersion();
        ctx.close();
        return kyloVersion;
    } catch (Exception e) {
        log.error(
                "Failed get the database version prior to upgrade.  The Kylo Upgrade application will load by default. {}",
                e.getMessage());
    }
    return null;

}