Example usage for java.lang String toLowerCase

List of usage examples for java.lang String toLowerCase

Introduction

In this page you can find the example usage for java.lang String toLowerCase.

Prototype

public String toLowerCase() 

Source Link

Document

Converts all of the characters in this String to lower case using the rules of the default locale.

Usage

From source file:Main.java

private static boolean isKnownBrowser(Context context, Intent i) {
    ResolveInfo resolvedActivity = context.getPackageManager().resolveActivity(i,
            PackageManager.MATCH_DEFAULT_ONLY);
    if (resolvedActivity == null) {
        // No browser
        return false;
    }//from w ww.  j  a v a  2  s .c o m

    String name = resolvedActivity.activityInfo.name;
    if (name == null) {
        return false;
    }

    name = name.toLowerCase();
    return name.contains("chrome") || name.contains("firefox");
}

From source file:com.google.flightmap.parsing.util.StringUtils.java

/**
 * Returns mixed-case version of {@code text}.
 * <p>/*from w w  w  . ja v a  2 s . com*/
 * The first letter of each word is capitalized, the rest are lower case.
 * Words are delimited by spaces and special characters (except single-quote).
 * "REID-HILLVIEW" becomes "Reid-Hillview".
 * 
 * @return mixed-case version of {@code text} with each word capitalized.
 */
public static String capitalize(final String text) {
    final StringBuilder sb = new StringBuilder(WordUtils.capitalize(text.toLowerCase()));
    boolean makeNextLetterUpper = false;
    for (int i = 0; i < sb.length(); ++i) {
        final char cur = sb.charAt(i);
        if (Character.isWhitespace(cur)) {
            continue; // Skip whitespace
        } else if (Character.isLetterOrDigit(cur)) {
            if (makeNextLetterUpper) {
                sb.setCharAt(i, Character.toUpperCase(cur));
                makeNextLetterUpper = false;
            } else {
                continue; // Skip character if no change is neded
            }
        } else { // Not whitespace, letter or digit:  we assume punctuation.
            makeNextLetterUpper = cur != '\''; // Ignore single quote (John'S, Susie'S, ...)
        }
    }
    return sb.toString();
}

From source file:com.intel.ssg.dcst.panthera.processor.PantheraProcessorFactory.java

public static CommandProcessor get(String cmd, HiveConf conf) {
    String cmdl = cmd.toLowerCase();

    if ("set".equals(cmdl)) {
        return new SetProcessor();
    } else if ("reset".equals(cmdl)) {
        return new ResetProcessor();
    } else if ("dfs".equals(cmdl)) {
        SessionState ss = SessionState.get();
        return new DfsProcessor(ss.getConf());
    } else if ("add".equals(cmdl)) {
        return new AddResourceProcessor();
    } else if ("delete".equals(cmdl)) {
        return new DeleteResourceProcessor();
    } else if (!isBlank(cmd)) {
        if (conf == null) {
            return new SkinDriver();
        }/*from   ww  w .  j  a  v a  2s .  c  om*/

        SkinDriver drv = (SkinDriver) mapDrivers.get(conf);
        if (drv == null) {
            drv = new SkinDriver();
            mapDrivers.put(conf, drv);
        }
        drv.init();
        return drv;
    }

    return null;
}

From source file:Main.java

/**
 * @param http/*ww  w  . j a va 2 s .  c o m*/
 * @return extracted title of page from html.
 * @throws IOException
 */
public static String getPageTitle(String linkUrl) throws IOException {
    URL url = new URL(linkUrl);
    URLConnection conn = null;
    try {

        conn = url.openConnection();

        String type = conn.getContentType();
        if (type != null && !type.toLowerCase().contains("text/html"))
            return null; // if not html, we can't get title. Return from here.
        else {
            // read response stream
            BufferedReader bufReader = new BufferedReader(
                    new InputStreamReader(conn.getInputStream(), Charset.defaultCharset()));
            int n = 0;
            int readCount = 0;
            char[] buf = new char[1024];
            StringBuilder content = new StringBuilder();

            // read till end of file or 8 times the buffer (no need to read
            // all data, assuming we get content in first 8 reads)
            while (readCount < 8 && (n = bufReader.read(buf, 0, buf.length)) != -1) {
                content.append(buf, 0, n);
                readCount++;
            }
            bufReader.close();

            // extract the title
            Matcher matcher = HTML_TITLE_PATTERN.matcher(content);
            if (matcher.find()) {

                // replace whitespaces and HTML brackets

                return matcher.group(1).replaceAll("[\\s\\<>]+", " ").trim();
            } else
                return null;
        }
    } finally {
        //any cleanup?
    }
}

From source file:au.org.ala.names.util.FileUtils.java

public static Set<String> streamToSet(InputStream source, Set<String> resultSet, boolean toLowerCase)
        throws IOException {
    LineIterator lines = getLineIterator(source, "UTF8");
    while (lines.hasNext()) {
        String line = lines.nextLine().trim();
        if (toLowerCase)
            line = line.toLowerCase();
        // ignore comments
        if (!ignore(line)) {
            resultSet.add(line);/* w w  w . jav  a2s . c  om*/
        }
    }
    return resultSet;
}

From source file:com.qait.automation.samjbehavedemo.utils.FileHandler.java

public static List<String> getFileNames(String filedirpath, final String filenameendswith) {

    List<String> filenames = new ArrayList<>();

    File[] files = getFile(filedirpath).listFiles();

    for (File file : files) {
        String filename = file.getName();
        if (file.isFile() && filename.toLowerCase().endsWith(filenameendswith.toLowerCase())) {
            filenames.add(filename);//from w ww .  j  a  v  a2  s  . c  o  m
        }
    }

    if (filenames.isEmpty()) {
        throw new NullPointerException(
                "There are no files matching the criteria in directoy: " + filedirpath.toUpperCase());
    }

    return filenames;
}

From source file:com.ebay.pulsar.analytics.constants.ConstantsUtils.java

public static Granularity getGranularity(String granularityStr) {
    if (granularityStr != null) {
        return mapGranularity.get(granularityStr.toLowerCase());
    } else {/*from w w  w .  j  a va  2 s  . co m*/
        return Granularity.all;
    }
}

From source file:com.twinsoft.convertigo.engine.enums.HeaderName.java

public static HeaderName parse(String name) {
    HeaderName headerName = cache.get(name.toLowerCase());
    return headerName != null ? headerName : VOID;
}

From source file:com.ngandroid.lib.utils.JsonUtils.java

public static <T> T buildModelFromJson(JSONObject jsonObject, Class<T> clzz) throws JSONException {

    ModelBuilder builder = new ModelBuilder(clzz);
    Iterator<String> jsonkeys = jsonObject.keys();
    while (jsonkeys.hasNext()) {
        String key = jsonkeys.next();
        String keyLower = key.toLowerCase();
        if (builder.hasField(keyLower)) {
            int type = builder.getFieldType(keyLower);
            switch (type) {
            case TypeUtils.BOOLEAN:
                builder.setField(keyLower, type, jsonObject.getBoolean(key));
                break;
            case TypeUtils.INTEGER:
                builder.setField(keyLower, type, jsonObject.getInt(key));
                break;
            case TypeUtils.STRING:
                builder.setField(keyLower, type, jsonObject.getString(key));
                break;
            case TypeUtils.DOUBLE:
                builder.setField(keyLower, type, jsonObject.getDouble(key));
                break;
            case TypeUtils.FLOAT:
                builder.setField(keyLower, type, (float) jsonObject.getDouble(key));
                break;
            case TypeUtils.LONG:
                builder.setField(keyLower, type, jsonObject.getLong(key));
                break;
            case TypeUtils.OBJECT: {
                Class clss = builder.getFieldTypeClass(keyLower);
                if (clss.isInterface()) {
                    builder.setField(keyLower, type, buildModelFromJson(jsonObject.getJSONObject(key), clss));
                }//from   w  ww.j a  v  a2s  . c om
                break;
            }
            }

        }
    }
    return (T) builder.create();
}

From source file:Main.java

/**
 * Normalizes an absolute URI (lower scheme and host part)
 *
 * @param pString The absolute URI to be normalized
 *//*from   w w  w  . j av  a  2s . c  o m*/
/* package protected */static String normalizeAbsoluteURI(String pString) {

    int index = -1;

    /* lower the scheme part */
    if ((index = pString.indexOf(':')) == -1) {
        return pString;
    }
    String scheme = pString.substring(0, index);
    pString = pString.replaceFirst(scheme, scheme.toLowerCase());

    /* check the presence of "//" */
    if ((index = pString.indexOf("//", index)) == -1) {
        /* no // found, return */
        return pString;
    }

    /* lower the host part ( authority : [user@]host[:port] )*/
    index += 2;
    int indexStart = pString.indexOf("@", index);
    indexStart = (indexStart == -1) ? index : indexStart + 1;
    int indexEnd = pString.indexOf(indexStart, ':');
    if (indexEnd == -1) {
        if ((indexEnd = pString.indexOf("/", indexStart)) == -1) {
            indexEnd = pString.length();
        }
    }
    String host = pString.substring(indexStart, indexEnd);

    return pString.replaceFirst(host, host.toLowerCase());
}