当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils类代码示例

本文整理汇总了Java中org.h2.util.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringUtils类属于org.h2.util包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RecoveryFile

import org.h2.util.StringUtils; //导入依赖的package包/类
public RecoveryFile() throws IOException
{
	if (!StringUtils.isNullOrEmpty(arguments.exportRecoveryFile))
	{
		recoveryFile = new File(arguments.exportRecoveryFile);
		logger.info("Tracking exported metric names in " + recoveryFile.getAbsolutePath());

		if (recoveryFile.exists())
		{
			logger.info("Skipping metrics found in " + recoveryFile.getAbsolutePath());
			List<String> list = Files.readLines(recoveryFile, Charset.defaultCharset());
			metricsExported.addAll(list);
		}

		writer = new PrintWriter(new FileOutputStream(recoveryFile, true));
	}
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:18,代码来源:Main.java

示例2: readPages

import org.h2.util.StringUtils; //导入依赖的package包/类
private void readPages(String dir, File file, int level) throws Exception {
    String name = file.getName();
    String fileName = dir.length() > 0 ? dir + "/" + name : level > 0 ? name : "";
    if (file.isDirectory()) {
        for (File f : file.listFiles()) {
            readPages(fileName, f, level + 1);
        }
        return;
    }
    String lower = StringUtils.toLowerEnglish(name);
    if (!lower.endsWith(".html") && !lower.endsWith(".htm")) {
        return;
    }
    if (lower.contains("_ja.")) {
        return;
    }
    if (!noIndex.contains(fileName)) {
        page = new Page(pages.size(), fileName);
        pages.add(page);
        readPage(file);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:Indexer.java

示例3: quoteIdentifier

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Add double quotes around an identifier if required.
 *
 * @param s the identifier
 * @return the quoted identifier
 */
public static String quoteIdentifier(String s) {
    if (s == null || s.length() == 0) {
        return "\"\"";
    }
    char c = s.charAt(0);
    // lowercase a-z is quoted as well
    if ((!Character.isLetter(c) && c != '_') || Character.isLowerCase(c)) {
        return StringUtils.quoteIdentifier(s);
    }
    for (int i = 1, length = s.length(); i < length; i++) {
        c = s.charAt(i);
        if ((!Character.isLetterOrDigit(c) && c != '_') ||
                Character.isLowerCase(c)) {
            return StringUtils.quoteIdentifier(s);
        }
    }
    if (isKeyword(s, true)) {
        return StringUtils.quoteIdentifier(s);
    }
    return s;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:Parser.java

示例4: getBigDecimal

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Returns the value of the specified column as a BigDecimal.
 *
 * @deprecated use {@link #getBigDecimal(String)}
 *
 * @param columnLabel the column label
 * @param scale the scale of the returned value
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public BigDecimal getBigDecimal(String columnLabel, int scale)
        throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getBigDecimal(" +
                    StringUtils.quoteJavaString(columnLabel)+", "+scale+");");
        }
        if (scale < 0) {
            throw DbException.getInvalidValueException("scale", scale);
        }
        BigDecimal bd = get(columnLabel).getBigDecimal();
        return bd == null ? null : ValueDecimal.setScale(bd, scale);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:29,代码来源:JdbcResultSet.java

示例5: getTimestamp

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Returns the value of the specified column as a java.sql.Timestamp.
 *
 * @param columnLabel the column label
 * @param calendar the calendar
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public Timestamp getTimestamp(String columnLabel, Calendar calendar)
        throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getTimestamp(" +
                    StringUtils.quoteJavaString(columnLabel) +
                    ", calendar)");
        }
        Value value = get(columnLabel);
        return DateTimeUtils.convertTimestamp(value, calendar);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:JdbcResultSet.java

示例6: getSQL

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Create the SQL snippet that describes this sort order.
 * This is the SQL snippet that usually appears after the ORDER BY clause.
 *
 * @param list the expression list
 * @param visible the number of columns in the select list
 * @return the SQL snippet
 */
public String getSQL(Expression[] list, int visible) {
    StatementBuilder buff = new StatementBuilder();
    int i = 0;
    for (int idx : queryColumnIndexes) {
        buff.appendExceptFirst(", ");
        if (idx < visible) {
            buff.append(idx + 1);
        } else {
            buff.append('=').append(StringUtils.unEnclose(list[idx].getSQL()));
        }
        int type = sortTypes[i++];
        if ((type & DESCENDING) != 0) {
            buff.append(" DESC");
        }
        if ((type & NULLS_FIRST) != 0) {
            buff.append(" NULLS FIRST");
        } else if ((type & NULLS_LAST) != 0) {
            buff.append(" NULLS LAST");
        }
    }
    return buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:SortOrder.java

示例7: checkClustering

import org.h2.util.StringUtils; //导入依赖的package包/类
private static void checkClustering(ConnectionInfo ci, Database database) {
    String clusterSession = ci.getProperty(SetTypes.CLUSTER, null);
    if (Constants.CLUSTERING_DISABLED.equals(clusterSession)) {
        // in this case, no checking is made
        // (so that a connection can be made to disable/change clustering)
        return;
    }
    String clusterDb = database.getCluster();
    if (!Constants.CLUSTERING_DISABLED.equals(clusterDb)) {
        if (!Constants.CLUSTERING_ENABLED.equals(clusterSession)) {
            if (!StringUtils.equals(clusterSession, clusterDb)) {
                if (clusterDb.equals(Constants.CLUSTERING_DISABLED)) {
                    throw DbException.get(
                            ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_ALONE);
                }
                throw DbException.get(
                        ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1,
                        clusterDb);
            }
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:Engine.java

示例8: parseDatabaseShortName

import org.h2.util.StringUtils; //导入依赖的package包/类
private String parseDatabaseShortName() {
    String n = databaseName;
    if (n.endsWith(":")) {
        n = null;
    }
    if (n != null) {
        StringTokenizer tokenizer = new StringTokenizer(n, "/\\:,;");
        while (tokenizer.hasMoreTokens()) {
            n = tokenizer.nextToken();
        }
    }
    if (n == null || n.length() == 0) {
        n = "unnamed";
    }
    return dbSettings.databaseToUpper ? StringUtils.toUpperEnglish(n) : n;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:Database.java

示例9: getCreateSQL

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Get the CREATE SQL statement for this object.
 *
 * @param password true if the password (actually the salt and hash) should
 *            be returned
 * @return the SQL statement
 */
public String getCreateSQL(boolean password) {
    StringBuilder buff = new StringBuilder("CREATE USER IF NOT EXISTS ");
    buff.append(getSQL());
    if (comment != null) {
        buff.append(" COMMENT ").append(StringUtils.quoteStringSQL(comment));
    }
    if (password) {
        buff.append(" SALT '").
            append(StringUtils.convertBytesToHex(salt)).
            append("' HASH '").
            append(StringUtils.convertBytesToHex(passwordHash)).
            append('\'');
    } else {
        buff.append(" PASSWORD ''");
    }
    if (admin) {
        buff.append(" ADMIN");
    }
    return buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:User.java

示例10: getHtml

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Generate the HTML for the given syntax.
 *
 * @param bnf the BNF parser
 * @param syntaxLines the syntax
 * @return the HTML
 */
public String getHtml(Bnf bnf, String syntaxLines) {
    syntaxVisitor = new BnfSyntax();
    this.config = bnf;
    syntaxLines = StringUtils.replaceAll(syntaxLines, "\n    ", " ");
    String[] syntaxList = StringUtils.arraySplit(syntaxLines, '\n', true);
    StringBuilder buff = new StringBuilder();
    for (String s : syntaxList) {
        bnf.visit(this, s);
        html = StringUtils.replaceAll(html, "</code></td>" +
                "<td class=\"d\"><code class=\"c\">", " ");
        if (buff.length() > 0) {
            buff.append("<br />");
        }
        buff.append(html);
    }
    return buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:BnfRailroad.java

示例11: DbSchema

import org.h2.util.StringUtils; //导入依赖的package包/类
DbSchema(DbContents contents, String name, boolean isDefault) {
    this.contents = contents;
    this.name = name;
    this.quotedName =  contents.quoteIdentifier(name);
    this.isDefault = isDefault;
    if (name == null) {
        // firebird
        isSystem = true;
    } else if ("INFORMATION_SCHEMA".equals(name)) {
        isSystem = true;
    } else if (!contents.isH2() &&
            StringUtils.toUpperEnglish(name).startsWith("INFO")) {
        isSystem = true;
    } else if (contents.isPostgreSQL() &&
            StringUtils.toUpperEnglish(name).startsWith("PG_")) {
        isSystem = true;
    } else if (contents.isDerby() && name.startsWith("SYS")) {
        isSystem = true;
    } else {
        isSystem = false;
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:DbSchema.java

示例12: getDefaultSchemaName

import org.h2.util.StringUtils; //导入依赖的package包/类
private String getDefaultSchemaName(DatabaseMetaData meta) {
    String defaultSchemaName = "";
    try {
        if (isOracle) {
            return meta.getUserName();
        } else if (isPostgreSQL) {
            return "public";
        } else if (isMySQL) {
            return "";
        } else if (isDerby) {
            return StringUtils.toUpperEnglish(meta.getUserName());
        } else if (isFirebird) {
            return null;
        }
        ResultSet rs = meta.getSchemas();
        int index = rs.findColumn("IS_DEFAULT");
        while (rs.next()) {
            if (rs.getBoolean(index)) {
                defaultSchemaName = rs.getString("TABLE_SCHEM");
            }
        }
    } catch (SQLException e) {
        // IS_DEFAULT not found
    }
    return defaultSchemaName;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:27,代码来源:DbContents.java

示例13: quote

import org.h2.util.StringUtils; //导入依赖的package包/类
private static String quote(Class<?> valueClass, Object value) {
    if (value == null) {
        return null;
    } else if (valueClass == String.class) {
        return StringUtils.quoteJavaString(value.toString());
    } else if (valueClass == BigDecimal.class) {
        return "new BigDecimal(\"" + value.toString() + "\")";
    } else if (valueClass.isArray()) {
        if (valueClass == String[].class) {
            return StringUtils.quoteJavaStringArray((String[]) value);
        } else if (valueClass == int[].class) {
            return StringUtils.quoteJavaIntArray((int[]) value);
        }
    }
    return value.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:Arg.java

示例14: removeAllTriggers

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Remove all triggers that start with the given prefix.
 *
 * @param conn the database connection
 * @param prefix the prefix
 */
protected static void removeAllTriggers(Connection conn, String prefix)
        throws SQLException {
    Statement stat = conn.createStatement();
    ResultSet rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.TRIGGERS");
    Statement stat2 = conn.createStatement();
    while (rs.next()) {
        String schema = rs.getString("TRIGGER_SCHEMA");
        String name = rs.getString("TRIGGER_NAME");
        if (name.startsWith(prefix)) {
            name = StringUtils.quoteIdentifier(schema) + "." +
                    StringUtils.quoteIdentifier(name);
            stat2.execute("DROP TRIGGER " + name);
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:FullText.java

示例15: indexExistingRows

import org.h2.util.StringUtils; //导入依赖的package包/类
/**
 * Add the existing data to the index.
 *
 * @param conn the database connection
 * @param schema the schema name
 * @param table the table name
 */
protected static void indexExistingRows(Connection conn, String schema,
        String table) throws SQLException {
    FullText.FullTextTrigger existing = new FullText.FullTextTrigger();
    existing.init(conn, schema, null, table, false, Trigger.INSERT);
    String sql = "SELECT * FROM " + StringUtils.quoteIdentifier(schema) +
            "." + StringUtils.quoteIdentifier(table);
    ResultSet rs = conn.createStatement().executeQuery(sql);
    int columnCount = rs.getMetaData().getColumnCount();
    while (rs.next()) {
        Object[] row = new Object[columnCount];
        for (int i = 0; i < columnCount; i++) {
            row[i] = rs.getObject(i + 1);
        }
        existing.fire(conn, null, row);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:24,代码来源:FullText.java


注:本文中的org.h2.util.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。