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:com.ms.app.web.commons.utils.DeviceUtils.java

/**
 * ?UA??/*from w  ww.  jav a2 s.  com*/
 * 
 * @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:Main.java

public static int colorForString(String color) {
    if (color == null) {
        return (Color.BLACK);
    }//from  w  w w.j  av  a  2  s. c  o  m
    String c = color.toLowerCase();
    if (c.equals("red")) {
        return (Color.argb(150, 255, 0, 0));
    } else if (c.equals("yellow")) {
        //         return(Color.YELLOW);
        return (Color.argb(200, 255, 180, 0));
    } else if (c.equals("green")) {
        return (Color.GREEN);
    } else if (c.equals("blue")) {
        return (Color.BLUE);
    } else if (c.equals("purple")) {
        return (Color.argb(255, 255, 0, 255));
    } else if (c.equals("clear")) {
        return (Color.WHITE);
    } else {
        return (Color.BLACK);
    }
}

From source file:jQuery.PRIMO.Record.java

/**
 * Find out what to return/*  w w  w.j  av a2s  .  com*/
 *
 * @param data the data
 * @return extension type
 */
public static String determineRecordExt(String data) {
    String[] supportedExtensions = { "PNX", "XML", "JSON" };

    for (String e : supportedExtensions) {
        if (e.toLowerCase().equals(getRecordExt(data).toLowerCase())) {
            return e;
        }
    }
    return supportedExtensions[0];
}

From source file:Main.java

public static String getMimetype(String fileName, String def) {
    String mimeType = "application/octet-stream";
    try {/*from   w w  w  .  java  2  s  .  co  m*/
        MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
        int idx = fileName.lastIndexOf('.');
        if (idx != -1) {
            String ext = fileName.substring(idx + 1);
            mimeType = mimeMap.getMimeTypeFromExtension(ext.toLowerCase());
        }
        if (mimeType == null) {
            mimeType = def == null ? "application/octet-stream" : def;
        }
    } catch (Exception e) {
    }
    return mimeType;
}

From source file:Main.java

public static boolean isAidExisit(String apdu, String aid) {
    if (TextUtils.isEmpty(apdu) || TextUtils.isEmpty(aid)) {
        return false;
    }/*ww w . j  a v  a 2s .co  m*/
    return apdu.toLowerCase().contains(aid.toLowerCase());
}

From source file:com.enonic.cms.business.portal.rendering.tracing.TraceMarkerHelper.java

/**
 * This method modifies the markup with extra trace code.
 *///from   w  w w  .  ja  v  a2 s .co m
public static String writePageMarker(RenderTraceInfo traceInfo, String markup, String outputMethod) {
    outputMethod = outputMethod.toLowerCase();
    boolean usePageMarker = outputMethod.contains("html");

    if ((traceInfo != null) && usePageMarker) {
        StringBuffer buffer = new StringBuffer(markup);
        int pos = buffer.indexOf("</head>");
        if (pos > -1) {
            String href = "__info__?type=css&key=" + traceInfo.getKey();
            href = makeXmlCompliantIfNeeded(href, outputMethod);
            buffer.insert(pos, writeCssInclude(href));
        }

        pos = buffer.indexOf("</body>");
        if (pos > -1) {
            String href = "__info__?type=javascript&key=" + traceInfo.getKey();
            href = makeXmlCompliantIfNeeded(href, outputMethod);
            buffer.insert(pos, writeJavaScriptInclude(href));
        }

        return buffer.toString();
    } else {
        return markup;
    }
}

From source file:net.amigocraft.mpt.command.InfoCommand.java

@SuppressWarnings("unchecked")
public static String[] getPackageInfo(String id) throws MPTException {
    id = id.toLowerCase();
    if (Main.packageStore.containsKey("packages")) {
        JSONObject packs = (JSONObject) Main.packageStore.get("packages");
        Object pack = packs.get(id);
        if (pack != null) {
            JSONObject jPack = (JSONObject) pack;
            if (jPack.containsKey("name") && jPack.containsKey("description") && jPack.containsKey("version")
                    && jPack.containsKey("url") && jPack.containsKey("repo")) {
                return new String[] { jPack.get("name").toString(), jPack.get("description").toString(),
                        jPack.get("version").toString(), jPack.get("url").toString(),
                        jPack.get("repo").toString(),
                        jPack.containsKey("sha1") ? jPack.get("sha1").toString() : null,
                        jPack.containsKey("installed") ? jPack.get("installed").toString() : null, };
            } else
                throw new MPTException(ERROR_COLOR + "Package definition for " + ID_COLOR + id + ERROR_COLOR
                        + " is malformed! Running " + COMMAND_COLOR + "/mpt update" + ERROR_COLOR
                        + " may correct" + "this.");
        } else/* w w w . ja  v a  2  s .co m*/
            throw new MPTException(ERROR_COLOR + "Cannot find package " + ID_COLOR + id + ERROR_COLOR + "!");
    } else
        throw new MPTException("Package store is malformed!");
}

From source file:Main.java

/**
 * Escapes the contents a string to be used as a safe scheme name in the URI according to
 * http://tools.ietf.org/html/rfc3986#section-3.1
 *
 * This does not ensure that the first character is a letter (which is required by the RFC).
 *///from  w w  w . ja  va  2s .  c  o  m
@VisibleForTesting
public static String escapeForSchemeName(String s) {
    // According to the RFC, scheme names are case-insensitive.
    s = s.toLowerCase();

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (Character.isLetter(c) || Character.isDigit(c) || ('-' == c) || ('.' == c)) {
            // Safe - use as is.
            sb.append(c);
        } else if ('+' == c) {
            // + is used as our escape character, so double it up.
            sb.append("++");
        } else {
            // Unsafe - escape.
            sb.append('+').append((int) c);
        }
    }
    return sb.toString();
}

From source file:Main.java

public static String capitalize(String string) {
    if (isNullOrEmpty(string))
        return string;
    return string.toUpperCase().substring(0, 1) + string.toLowerCase().substring(1);
}

From source file:MimeType.java

public static String getContentTypeByExt(final String ext) {
    String key = ext.toLowerCase();
    if (mimeMap.containsKey(key)) {
        return mimeMap.get(key);
    }/*w  w  w .  j a  va  2s  .com*/
    return DEFAULT;
}