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


Java StringUtils.isNullOrEmpty方法代码示例

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


在下文中一共展示了StringUtils.isNullOrEmpty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: translate

import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static String translate(String original, String findChars,
        String replaceChars) {
    if (StringUtils.isNullOrEmpty(original) ||
            StringUtils.isNullOrEmpty(findChars)) {
        return original;
    }
    // if it stays null, then no replacements have been made
    StringBuilder buff = null;
    // if shorter than findChars, then characters are removed
    // (if null, we don't access replaceChars at all)
    int replaceSize = replaceChars == null ? 0 : replaceChars.length();
    for (int i = 0, size = original.length(); i < size; i++) {
        char ch = original.charAt(i);
        int index = findChars.indexOf(ch);
        if (index >= 0) {
            if (buff == null) {
                buff = new StringBuilder(size);
                if (i > 0) {
                    buff.append(original.substring(0, i));
                }
            }
            if (index < replaceSize) {
                ch = replaceChars.charAt(index);
            }
        }
        if (buff != null) {
            buff.append(ch);
        }
    }
    return buff == null ? original : buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:Function.java

示例3: isProperlyFormattedDefaultValue

import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
 * Checks the formatting of JQColumn.defaultValue().
 *
 * @param defaultValue the default value
 * @return true if it is
 */
static boolean isProperlyFormattedDefaultValue(String defaultValue) {
    if (StringUtils.isNullOrEmpty(defaultValue)) {
        return true;
    }
    Pattern literalDefault = Pattern.compile("'.*'");
    Pattern functionDefault = Pattern.compile("[^'].*[^']");
    return literalDefault.matcher(defaultValue).matches()
        || functionDefault.matcher(defaultValue).matches();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:16,代码来源:ModelUtils.java

示例4: existsDepolymentSpecs

import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static boolean existsDepolymentSpecs(Statement stmt) throws SQLException {
    String sql = "select count(*) as count from DEPLOYMENT_SPEC;";
    String existsDS = null;
    try (ResultSet rs = stmt.executeQuery(sql)) {
        if (rs.next()) {
            existsDS = rs.getString(1);
        }
    }

    return !StringUtils.isNullOrEmpty(existsDS) && Integer.parseInt(existsDS) > 0;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:12,代码来源:ReleaseUpgradeMgr.java

示例5: checkAllStaticOrDynamic

import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static boolean checkAllStaticOrDynamic(Statement stmt, boolean flag) throws SQLException {
    String sql = String.format("SELECT (SELECT COUNT(*) FROM DEPLOYMENT_SPEC ) - (SELECT COUNT(*) FROM DEPLOYMENT_SPEC WHERE dynamic=%s) AS Difference;", flag);
    String val = null;
    try (ResultSet rs = stmt.executeQuery(sql)) {
        if (rs.next()) {
            val = rs.getString(1);
        }
    }
    return !StringUtils.isNullOrEmpty(val) && Integer.parseInt(val) == 0;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:11,代码来源:ReleaseUpgradeMgr.java

示例6: getTableName

import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getTableName(String schema, String table) {
    if (StringUtils.isNullOrEmpty(schema)) {
        return table;
    }
    return schema + "." + table;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:8,代码来源:SQLDialect.java

示例7: matches

import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
 * Tests to see if this TableInspector represents schema.table.
 * <p>
 *
 * @param schema the schema name
 * @param table the table name
 * @return true if the table matches
 */
boolean matches(String schema, String table) {
    if (StringUtils.isNullOrEmpty(schema)) {
        // table name matching
        return this.table.equalsIgnoreCase(table);
    } else if (StringUtils.isNullOrEmpty(table)) {
        // schema name matching
        return this.schema.equalsIgnoreCase(schema);
    } else {
        // exact table matching
        return this.schema.equalsIgnoreCase(schema)
                && this.table.equalsIgnoreCase(table);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:TableInspector.java

示例8: upgradeTable

import org.h2.util.StringUtils; //导入方法依赖的package包/类
<T> void upgradeTable(TableDefinition<T> model) {
    if (!upgradeChecked.contains(model.getModelClass())) {
        // flag is checked immediately because calls are nested
        upgradeChecked.add(model.getModelClass());

        if (model.tableVersion > 0) {
            // table is using JaQu version tracking.
            DbVersion v = new DbVersion();
            String schema = StringUtils.isNullOrEmpty(model.schemaName) ? ""
                    : model.schemaName;
            DbVersion dbVersion = from(v).where(v.schema).like(schema)
                    .and(v.table).like(model.tableName).selectFirst();
            if (dbVersion == null) {
                // table has no version registration, but model specifies
                // version: insert DbVersion entry
                DbVersion newTable = new DbVersion(model.tableVersion);
                newTable.schema = schema;
                newTable.table = model.tableName;
                insert(newTable);
            } else {
                // table has a version registration:
                // check if upgrade is required
                if ((model.tableVersion > dbVersion.version)
                        && (dbUpgrader != null)) {
                    // table is an older version than model
                    boolean success = dbUpgrader.upgradeTable(this, schema,
                            model.tableName, dbVersion.version,
                            model.tableVersion);
                    if (success) {
                        dbVersion.version = model.tableVersion;
                        update(dbVersion);
                    }
                }
            }
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:38,代码来源:Db.java

示例9: mapObject

import org.h2.util.StringUtils; //导入方法依赖的package包/类
void mapObject(Object obj) {
    fieldMap.clear();
    initObject(obj, fieldMap);

    if (clazz.isAnnotationPresent(JQSchema.class)) {
        JQSchema schemaAnnotation = clazz.getAnnotation(JQSchema.class);
        // setup schema name mapping, if properly annotated
        if (!StringUtils.isNullOrEmpty(schemaAnnotation.name())) {
            schemaName = schemaAnnotation.name();
        }
    }

    if (clazz.isAnnotationPresent(JQTable.class)) {
        JQTable tableAnnotation = clazz.getAnnotation(JQTable.class);

        // setup table name mapping, if properly annotated
        if (!StringUtils.isNullOrEmpty(tableAnnotation.name())) {
            tableName = tableAnnotation.name();
        }

        // allow control over createTableIfRequired()
        createTableIfRequired = tableAnnotation.createIfRequired();

        // model version
        if (tableAnnotation.version() > 0) {
            tableVersion = tableAnnotation.version();
        }

        // setup the primary index, if properly annotated
        List<String> primaryKey = getColumns(tableAnnotation.primaryKey());
        if (primaryKey != null) {
            setPrimaryKey(primaryKey);
        }
    }

    if (clazz.isAnnotationPresent(JQIndex.class)) {
        JQIndex indexAnnotation = clazz.getAnnotation(JQIndex.class);

        // setup the indexes, if properly annotated
        addIndexes(IndexType.STANDARD, indexAnnotation.standard());
        addIndexes(IndexType.UNIQUE, indexAnnotation.unique());
        addIndexes(IndexType.HASH, indexAnnotation.hash());
        addIndexes(IndexType.UNIQUE_HASH, indexAnnotation.uniqueHash());
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:46,代码来源:TableDefinition.java

示例10: generateColumn

import org.h2.util.StringUtils; //导入方法依赖的package包/类
private StatementBuilder generateColumn(Set<String> imports,
        ColumnInspector col, boolean trimStrings) {
    StatementBuilder sb = new StatementBuilder();
    Class<?> clazz = col.clazz;
    String column = ModelUtils.convertColumnToFieldName(col.name
            .toLowerCase());
    sb.append('\t');
    if (clazz == null) {
        // unsupported type
        clazz = Object.class;
        sb.append("// unsupported type " + col.type);
    } else {
        // @JQColumn
        imports.add(clazz.getCanonicalName());
        sb.append('@').append(JQColumn.class.getSimpleName());

        // JQColumn annotation parameters
        AnnotationBuilder ap = new AnnotationBuilder();

        // JQColumn.name
        if (!col.name.equalsIgnoreCase(column)) {
            ap.addParameter("name", col.name);
        }

        // JQColumn.primaryKey
        // composite primary keys are annotated on the table
        if (col.isPrimaryKey && primaryKeys.size() == 1) {
            ap.addParameter("primaryKey=true");
        }

        // JQColumn.maxLength
        if ((clazz == String.class) && (col.size > 0)
                && (col.size < Integer.MAX_VALUE)) {
            ap.addParameter("maxLength", col.size);

            // JQColumn.trimStrings
            if (trimStrings) {
                ap.addParameter("trimString=true");
            }
        } else {
            // JQColumn.AutoIncrement
            if (col.isAutoIncrement) {
                ap.addParameter("autoIncrement=true");
            }
        }

        // JQColumn.allowNull
        if (!col.allowNull) {
            ap.addParameter("allowNull=false");
        }

        // JQColumn.defaultValue
        if (!StringUtils.isNullOrEmpty(col.defaultValue)) {
            ap.addParameter("defaultValue=\"" + col.defaultValue + "\"");
        }

        // add leading and trailing ()
        if (ap.length() > 0) {
            AnnotationBuilder b = new AnnotationBuilder();
            b.append('(').append(ap.toString()).append(')');
            ap = b;
        }
        sb.append(ap.toString());
    }
    sb.append(EOL);

    // variable declaration
    sb.append("\t" + "public ");
    sb.append(clazz.getSimpleName());
    sb.append(' ');
    sb.append(column);
    sb.append(';');
    sb.append(EOL).append(EOL);
    return sb;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:76,代码来源:TableInspector.java

示例11: validate

import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
 * Validates that a table definition (annotated, interface, or both) matches
 * the current state of the table and indexes in the database. Results are
 * returned as a list of validation remarks which includes recommendations,
 * warnings, and errors about the model. The caller may choose to have
 * validate throw an exception on any validation ERROR.
 *
 * @param <T> the table type
 * @param def the table definition
 * @param throwError whether or not to throw an exception if an error was
 *            found
 * @return a list if validation remarks
 */
<T> List<ValidationRemark> validate(TableDefinition<T> def,
        boolean throwError) {
    List<ValidationRemark> remarks = New.arrayList();

    // model class definition validation
    if (!Modifier.isPublic(def.getModelClass().getModifiers())) {
        remarks.add(error(
                table,
                "SCHEMA",
                MessageFormat.format("Class {0} MUST BE PUBLIC!", def
                        .getModelClass().getCanonicalName())).throwError(
                throwError));
    }

    // Schema Validation
    if (!StringUtils.isNullOrEmpty(schema)) {
        if (StringUtils.isNullOrEmpty(def.schemaName)) {
            remarks.add(consider(
                    table,
                    "SCHEMA",
                    MessageFormat.format("@{0}(name={1})",
                            JQSchema.class.getSimpleName(), schema)));
        } else if (!schema.equalsIgnoreCase(def.schemaName)) {
            remarks.add(error(
                    table,
                    "SCHEMA",
                    MessageFormat.format("@{0}(name={1}) != {2}",
                            JQSchema.class.getSimpleName(), def.schemaName,
                            schema)).throwError(throwError));
        }
    }

    // index validation
    for (IndexInspector index : indexes.values()) {
        validate(remarks, def, index, throwError);
    }

    // field column validation
    for (FieldDefinition fieldDef : def.getFields()) {
        validate(remarks, fieldDef, throwError);
    }
    return remarks;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:57,代码来源:TableInspector.java

示例12: execute

import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
 * Generates models from the database.
 *
 * @param url the database URL
 * @param user the user name
 * @param password the password
 * @param schema the schema to read from. null for all schemas.
 * @param table the table to model. null for all tables within schema.
 * @param packageName the package name of the model classes.
 * @param folder destination folder for model classes (package path not
 *            included)
 * @param annotateSchema includes the schema in the table model annotations
 * @param trimStrings automatically trim strings that exceed maxLength
 */
public static void execute(String url, String user, String password,
        String schema, String table, String packageName, String folder,
        boolean annotateSchema, boolean trimStrings) throws SQLException {
    Connection conn = null;
    try {
        org.h2.Driver.load();
        conn = DriverManager.getConnection(url, user, password);
        Db db = Db.open(url, user, password.toCharArray());
        DbInspector inspector = new DbInspector(db);
        List<String> models = inspector.generateModel(schema, table,
                packageName, annotateSchema, trimStrings);
        File parentFile;
        if (StringUtils.isNullOrEmpty(folder)) {
            parentFile = new File(System.getProperty("user.dir"));
        } else {
            parentFile = new File(folder);
        }
        parentFile.mkdirs();
        Pattern p = Pattern.compile("class ([a-zA-Z0-9]+)");
        for (String model : models) {
            Matcher m = p.matcher(model);
            if (m.find()) {
                String className = m.group().substring("class".length())
                        .trim();
                File classFile = new File(parentFile, className + ".java");
                Writer o = new FileWriter(classFile, false);
                PrintWriter writer = new PrintWriter(new BufferedWriter(o));
                writer.write(model);
                writer.close();
                System.out.println("Generated "
                        + classFile.getAbsolutePath());
            }
        }
    } catch (IOException io) {
        throw DbException
                .convertIOException(io, "could not generate model")
                .getSQLException();
    } finally {
        JdbcUtils.closeSilently(conn);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:56,代码来源:GenerateModels.java


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