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.hangum.tadpole.rdb.core.util.bander.cubrid.CubridExecutePlanUtils.java

/**
 * cubrid execute plan//from  w  w  w .j  a va  2 s  .  co  m
 * 
 * @param userDB
 * @param sql
 * @return
 * @throws Exception
 */
public static String plan(UserDBDAO userDB, String sql) throws Exception {
    if (!sql.toLowerCase().startsWith("select")) {
        logger.error("[cubrid execute plan ]" + sql);
        throw new Exception("This statment not select. please check.");
    }
    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement pstmt = null;

    try {
        Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
        conn = DriverManager.getConnection(userDB.getUrl(), userDB.getUsers(), userDB.getPasswd());
        conn.setAutoCommit(false); //     auto commit? false  .      

        sql = StringUtils.trim(sql).substring(6);
        if (logger.isDebugEnabled())
            logger.debug("[qubrid modifying query]" + sql);
        sql = "select " + RECOMPILE + sql;

        pstmt = conn.prepareStatement(sql);
        ((CUBRIDStatement) pstmt).setQueryInfo(true);
        rs = pstmt.executeQuery();

        String plan = ((CUBRIDStatement) pstmt).getQueryplan(); //  ?    .
        conn.commit();

        if (logger.isDebugEnabled())
            logger.debug("cubrid plan text : " + plan);

        return plan;

    } finally {
        if (rs != null)
            rs.close();
        if (pstmt != null)
            pstmt.close();
        if (conn != null)
            conn.close();
    }
}

From source file:Main.java

/**
 * Generate a User-Agent used in HTTP request to pick an ad.
 * Source used from Android source code "frameworks/base/core/java/android/webkit/WebSettings.java"
 * /*from  w  w w.  j  av  a 2 s  .c om*/
 * @return
 */
protected static String getUA() {
    if (UA != null)
        return UA;

    StringBuffer arg = new StringBuffer();

    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        arg.append(version);
    } else {
        arg.append("1.0");
    }
    arg.append("; ");

    final Locale l = Locale.getDefault();
    final String language = l.getLanguage();
    if (language != null) {
        arg.append(language.toLowerCase());
        final String country = l.getCountry();
        if (country != null) {
            arg.append("-");
            arg.append(country.toLowerCase());
        }
    } else {
        arg.append("de");
    }
    final String model = Build.MODEL;
    if (model.length() > 0) {
        arg.append("; ");
        arg.append(model);
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        arg.append(" Build/");
        arg.append(id);
    }

    // TODO: add version detection for AppleWebKit, Version and Safari
    final String rawUA = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2";
    UA = String.format(rawUA, arg);

    return UA;
}

From source file:com.cloudera.nav.plugin.client.writer.MetadataWriterFactory.java

/**
 * Return lower cased metadata parent uri scheme. If null then empty
 * string is returned (for easier string comparisons).
 *
 * @param config/*from   ww  w  .j a  v a  2s. co m*/
 * @return
 */
@VisibleForTesting
static String getScheme(PluginConfigurations config) {
    URI uri = config.getMetadataParentUri();
    String scheme = uri.getScheme();
    return scheme == null ? "" : scheme.toLowerCase();
}

From source file:Main.java

/**
 * Returns an integer constant representing the OS.  This can be handy for
 * special case situations such as Mac OS-X (special application
 * registration) or Windows (allow mixed case, etc.).
 *
 * @return An integer constant representing the OS.
 */// www .  j ava2  s  .co  m
private static final int getOSImpl() {
    int os = OS_OTHER;
    String osName = System.getProperty("os.name");
    if (osName != null) { // Should always be true.
        osName = osName.toLowerCase();
        if (osName.indexOf("windows") > -1)
            os = OS_WINDOWS;
        else if (osName.indexOf("mac os x") > -1)
            os = OS_MAC_OSX;
        else if (osName.indexOf("linux") > -1)
            os = OS_LINUX;
        else
            os = OS_OTHER;
    }
    return os;
}

From source file:Main.java

/**
 * Generate a User-Agent used in HTTP request to pick an ad. Source used
 * from Android source code//from   w w  w  .  j  a  va 2s  . c o m
 * "frameworks/base/core/java/android/webkit/WebSettings.java"
 * 
 * @return
 */
public static String getUA() {
    if (sUA != null)
        return sUA;

    StringBuffer arg = new StringBuffer();

    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        arg.append(version);
    } else {
        arg.append("1.0");
    }
    arg.append("; ");

    final Locale l = Locale.getDefault();
    final String language = l.getLanguage();
    if (language != null) {
        arg.append(language.toLowerCase());
        final String country = l.getCountry();
        if (country != null) {
            arg.append("-");
            arg.append(country.toLowerCase());
        }
    } else {
        arg.append("de");
    }
    final String model = Build.MODEL;
    if (model.length() > 0) {
        arg.append("; ");
        arg.append(model);
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        arg.append(" Build/");
        arg.append(id);
    }

    // TODO: add version detection for AppleWebKit, Version and Safari
    final String rawUA = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2";
    sUA = String.format(rawUA, arg);

    return sUA;
}

From source file:io.sqp.transbase.TBTypeRepository.java

public static DateRangeSpecifier[] parseRangeSpecifiers(String specifier) {
    if (specifier.toLowerCase().startsWith(TB_TYPE_PREFIX)) {
        specifier = specifier.substring(TB_TYPE_PREFIX.length());
    }//www .j  a va  2s .  co m
    if (specifier.toUpperCase().startsWith(TB_DATETIME_NAME)) {
        specifier = specifier.substring(TB_DATETIME_NAME.length());
    }
    if (!specifier.startsWith("[") || !specifier.endsWith("]")) {
        throw new IllegalArgumentException("Range specifier doesn't star with '[' and ends with ']'");
    }
    String[] specifiers = specifier.substring(1, specifier.length() - 1).split(":", 2);
    if (specifiers.length < 2) {
        throw new IllegalArgumentException("Range specifier doesn't contain two valid fields");
    }
    DateRangeSpecifier highField = DateRangeSpecifier.fromSpecifier(specifiers[0]);
    DateRangeSpecifier lowField = DateRangeSpecifier.fromSpecifier(specifiers[1]);
    return new DateRangeSpecifier[] { highField, lowField };
}

From source file:org.opencastproject.remotetest.server.resource.DistributeResources.java

/**
 * // ww  w  .  j  a  va2s.  c o m
 * @param channel
 *          Distribution channel: local, youtube, itunesu
 * 
 */
public static HttpResponse distribute(TrustedHttpClient client, String channel, String mediapackage,
        String... elementId) throws Exception {
    HttpPost post = new HttpPost(getServiceUrl() + channel.toLowerCase() + "/");
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("mediapackage", mediapackage));
    for (String id : elementId) {
        params.add(new BasicNameValuePair("elementId", id));
    }
    post.setEntity(new UrlEncodedFormEntity(params));

    return client.execute(post);
}

From source file:net.sf.util.zip.FileNameUtil.java

/**
 *
 * @param fileName  the file name/*w  ww .j  a v  a 2 s.  co  m*/
 * @return   Compressed file type, as defined in CompressorStreamFactory
 */
public static String[] getCompressFileType(String fileName) {
    String s = fileName.toLowerCase();
    String[] ret = { null, null };
    if (GzipUtils.isCompressedFilename(s)) {
        ret[0] = CompressorStreamFactory.GZIP;
        ret[1] = GzipUtils.getUncompressedFilename(fileName);
    } else if (BZip2Utils.isCompressedFilename(s)) {
        ret[0] = CompressorStreamFactory.BZIP2;
        ret[1] = BZip2Utils.getUncompressedFilename(fileName);
    } else if (XZUtils.isCompressedFilename(s)) {
        ret[0] = CompressorStreamFactory.XZ;
        ret[1] = XZUtils.getUncompressedFilename(fileName);
    }

    return ret;
}

From source file:Main.java

public static String titleCase(String s) {
    StringBuilder rv = new StringBuilder(s.length());
    StringTokenizer strtok = new StringTokenizer(s);

    while (strtok.hasMoreTokens()) {
        String word = strtok.nextToken();
        String firstLetter = word.substring(0, 1);
        String restOfWord = word.substring(1);

        if (rv.length() > 0)
            rv.append(" ");
        rv.append(firstLetter.toUpperCase());
        rv.append(restOfWord.toLowerCase());
    }/*from w  w w .  j a va 2 s .c  o  m*/

    return rv.toString();
}

From source file:com.siberhus.web.ckeditor.utils.MimeUtils.java

public static String getDefaultMimeType(String fileName) {
    String fileExt = FilenameUtils.getExtension(fileName);
    if (fileExt != null) {
        String mimeType = MIME_TYPES.get(fileExt.toLowerCase());
        if (mimeType != null) {
            return mimeType;
        }/*  w ww  .  j  a va 2  s.c o m*/
        return "application/octet-stream";
    } else {
        return "text/plain";
    }
}