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


Java StringUtils类代码示例

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


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

示例1: process

import liquibase.util.StringUtils; //导入依赖的package包/类
@Override
public ActionFeedback process(ActionRequest actionRequest) throws NotificationClientException {
    String actionId = actionRequest.getActionId();
    log.debug("Entering process with actionId {}", actionId);

    ActionFeedback actionFeedback = null;

    ActionContact actionContact = actionRequest.getContact();
    String phoneNumber = actionContact.getPhoneNumber();
    if (!StringUtils.isEmpty(phoneNumber)) { // TODO Switch used for BRES
      actionFeedback = processSms(actionRequest);
    } else {
      actionFeedback = processEmail(actionRequest);
    }

    return actionFeedback;
}
 
开发者ID:ONSdigital,项目名称:rm-notify-gateway,代码行数:18,代码来源:NotifyServiceImpl.java

示例2: buildMapFromString

import liquibase.util.StringUtils; //导入依赖的package包/类
/**
 * Transform the string built originally by orika into a Map
 *
 * An example is {iac=ABCD-EFGH-IJKL-MNOP, otherfield=other,value} which was built from
 * "personalisation": {"iac":"ABCD-EFGH-IJKL-MNOP", "otherfield":"other,value"}
 *
 * TODO Other option = find a way to define a notifyRequest.xsd so a Map field ends up in NotifyRequest.java
 * TODO http://blog.bdoughan.com/2013/03/jaxb-and-javautilmap.html
 * TODO http://blog.bdoughan.com/2011/08/xml-schema-to-java-generating.html
 *
 * @param personalisation the string built originally by orika
 * @return the Map
 */
private Map<String, String> buildMapFromString(String personalisation) {
    Map<String, String> result = null;

    if (!StringUtils.isEmpty(personalisation)) {
        try {
            result = Splitter.on(", ").withKeyValueSeparator("=").split(personalisation.substring(1,
                    personalisation.length() - 1));
        } catch (java.lang.IllegalArgumentException e) {
            log.error("Unexpected personalisation - message is {} - cause is {}", e.getMessage(), e.getCause());
            log.error("Stack trace: " + e);
        }
    }

    return result;
}
 
开发者ID:ONSdigital,项目名称:rm-notify-gateway,代码行数:29,代码来源:NotifyServiceImpl.java

示例3: generateAlterStatement

import liquibase.util.StringUtils; //导入依赖的package包/类
@Override
public String generateAlterStatement(Database database) {
    StringBuilder alter = new StringBuilder();

    alter.append("ADD ");
    if (StringUtil.isNotEmpty(getConstraintName())) {
        alter.append("CONSTRAINT ");
        alter.append(database.escapeConstraintName(getConstraintName()));
        alter.append(" ");
    }
    alter.append("UNIQUE (");
    List<String> columns = StringUtils.splitAndTrim(getColumnNames(), ",");
    if (columns == null) columns = Collections.emptyList();
    alter.append(database.escapeColumnNameList(StringUtils.join(columns, ", ")));
    alter.append(")");

    return alter.toString();
}
 
开发者ID:adangel,项目名称:liquibase-percona,代码行数:19,代码来源:PerconaAddUniqueConstraintChange.java

示例4: generateSql

import liquibase.util.StringUtils; //导入依赖的package包/类
public Sql[] generateSql(SelectFromDatabaseChangeLogLockStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
  	String liquibaseSchema;
 		liquibaseSchema = database.getLiquibaseSchemaName();

String[] columns = statement.getColumnsToSelect();
int numberOfColumns = columns.length;
String[] escapedColumns = new String[numberOfColumns];
for (int i=0; i<numberOfColumns; i++) {
	escapedColumns[i] = database.escapeColumnName(liquibaseSchema, database.getDatabaseChangeLogLockTableName(), columns[i]);
}

      String sql = "SELECT " + StringUtils.join(escapedColumns, ",") + " FROM " +
              database.escapeTableName(liquibaseSchema, database.getDatabaseChangeLogLockTableName()) +
              " WHERE " + database.escapeColumnName(liquibaseSchema, database.getDatabaseChangeLogLockTableName(), "ID") + "=1";

      if (database instanceof OracleDatabase) {
          sql += " FOR UPDATE";
      }
      return new Sql[] {
              new UnparsedSql(sql)
      };
  }
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:23,代码来源:SelectFromDatabaseChangeLogLockGenerator.java

示例5: generateSql

import liquibase.util.StringUtils; //导入依赖的package包/类
public Sql[] generateSql(AddPrimaryKeyStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String sql;
    if (statement.getConstraintName() == null  || database instanceof MySQLDatabase || database instanceof SybaseASADatabase) {
        sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " ADD PRIMARY KEY (" + database.escapeColumnNameList(statement.getColumnNames()) + ")";
    } else {
        sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " ADD CONSTRAINT " + database.escapeConstraintName(statement.getConstraintName()) + " PRIMARY KEY (" + database.escapeColumnNameList(statement.getColumnNames()) + ")";
    }

    if (StringUtils.trimToNull(statement.getTablespace()) != null && database.supportsTablespaces()) {
        if (database instanceof MSSQLDatabase) {
            sql += " ON "+statement.getTablespace();
        } else if (database instanceof DB2Database || database instanceof SybaseASADatabase) {
            ; //not supported
        } else {
            sql += " USING INDEX TABLESPACE "+statement.getTablespace();
        }
    }

    return new Sql[] {
            new UnparsedSql(sql)
    };
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:23,代码来源:AddPrimaryKeyGenerator.java

示例6: generateSql

import liquibase.util.StringUtils; //导入依赖的package包/类
public Sql[] generateSql(SelectFromDatabaseChangeLogStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String sql = "SELECT " + StringUtils.join(statement.getColumnsToSelect(), ",").toUpperCase() + " FROM " +
            database.escapeTableName(database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName());

    SelectFromDatabaseChangeLogStatement.WhereClause whereClause = statement.getWhereClause();
    if (whereClause != null) {
        if (whereClause instanceof SelectFromDatabaseChangeLogStatement.ByTag) {
            sql += " WHERE TAG='" + ((SelectFromDatabaseChangeLogStatement.ByTag) whereClause).getTagName() + "'";
        } else if (whereClause instanceof SelectFromDatabaseChangeLogStatement.ByNotNullCheckSum) {
                sql += " WHERE MD5SUM IS NOT NULL";
        } else {
            throw new UnexpectedLiquibaseException("Unknown where clause type: " + whereClause.getClass().getName());
        }
    }

    if (statement.getOrderByColumns() != null && statement.getOrderByColumns().length > 0) {
        sql += " ORDER BY "+StringUtils.join(statement.getOrderByColumns(), ", ").toUpperCase();
    }

    return new Sql[]{
            new UnparsedSql(sql)
    };
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:24,代码来源:SelectFromDatabaseChangeLogGenerator.java

示例7: execute

import liquibase.util.StringUtils; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
    if (StringUtils.trimToNull(getTag()) == null) {
        throw new BuildException("tagDatabase requires tag parameter to be set");
    }

      if (!shouldRun()) {
        return;
    }
    
    super.execute();

    Liquibase liquibase = null;
    try {
        liquibase = createLiquibase();
        liquibase.tag(getTag());

    } catch (Exception e) {
        throw new BuildException(e);
    } finally {
        closeDatabase(liquibase);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:24,代码来源:TagDatabaseTask.java

示例8: execute

import liquibase.util.StringUtils; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
    if (StringUtils.trimToNull(getOutputDirectory()) == null) {
        throw new BuildException("dbDoc requires outputDirectory to be set");
    }

    super.execute();

    Liquibase liquibase = null;
    try {
        liquibase = createLiquibase();
        liquibase.generateDocumentation(getOutputDirectory());

    } catch (Exception e) {
        throw new BuildException(e);
    } finally {
        closeDatabase(liquibase);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:20,代码来源:DBDocTask.java

示例9: compareTo

import liquibase.util.StringUtils; //导入依赖的package包/类
public int compareTo(Index o) {
    int returnValue = this.table.getName().compareTo(o.table.getName());

    if (returnValue == 0) {
        String thisName = StringUtils.trimToEmpty(this.getName());
        String oName = StringUtils.trimToEmpty(o.getName());
        returnValue = thisName.compareTo(oName);
    }

    //We should not have two indexes that have the same name and tablename
    /*if (returnValue == 0) {
    	returnValue = this.getColumnName().compareTo(o.getColumnName());
    }*/


    return returnValue;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:Index.java

示例10: toString

import liquibase.util.StringUtils; //导入依赖的package包/类
@Override
public String toString() {
    String returnString = getDataTypeName();
    if (getFirstParameter() != null) {
        returnString += "("+getFirstParameter();

        if (getSecondParameter() != null) {
            returnString+=","+getSecondParameter();
        }

     if (getUnit() != null) {
      returnString+=" " + getUnit();
     }

        returnString+= ")";
    }

    returnString += " "+ StringUtils.trimToEmpty(additionalInformation);

    return returnString.trim();
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:DataType.java

示例11: getIndexExample

import liquibase.util.StringUtils; //导入依赖的package包/类
/**
 * Generates the {@link Index} example (taken from {@link IndexExistsPrecondition}).
 *
 * @param database
 *           the database instance.
 * @param schema
 *           the schema instance.
 * @param tableName
 *           the table name of the index.
 * @return the index example.
 */
protected Index getIndexExample(final Database database, final Schema schema,
      final String tableName) {
   final Index example = new Index();
   if (tableName != null) {
      example.setTable((Table) new Table().setName(
            database.correctObjectName(getTableName(), Table.class)).setSchema(schema));
   }
   example.setName(database.correctObjectName(getIndexName(), Index.class));
   if (StringUtils.trimToNull(getColumnNames()) != null) {
      for (final String columnName : getColumnNames().split("\\s*,\\s*")) {
         final Column column = new Column(database.correctObjectName(columnName, Column.class));
         example.getColumns().add(column);
      }
   }
   return example;
}
 
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:28,代码来源:SpatialIndexExistsPrecondition.java

示例12: execute

import liquibase.util.StringUtils; //导入依赖的package包/类
public Object execute(StatementCallback action, List<SqlVisitor> sqlVisitors) throws DatabaseException {
    DatabaseConnection con = database.getConnection();
    Statement stmt = null;
    try {
        stmt = ((JdbcConnection) con).getUnderlyingConnection().createStatement();
        Statement stmtToUse = stmt;

        return action.doInStatement(stmtToUse);
    }
    catch (SQLException ex) {
        // Release Connection early, to avoid potential connection pool deadlock
        // in the case when the exception translator hasn't been initialized yet.
        JdbcUtils.closeStatement(stmt);
        stmt = null;
        throw new DatabaseException("Error executing SQL " + StringUtils.join(applyVisitors(action.getStatement(), sqlVisitors), "; on "+ con.getURL())+": "+ex.getMessage(), ex);
    }
    finally {
        JdbcUtils.closeStatement(stmt);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:21,代码来源:JdbcExecutor.java

示例13: readTable

import liquibase.util.StringUtils; //导入依赖的package包/类
private Table readTable(ResultSet rs, Database database) throws SQLException {
	String name = convertFromDatabaseName(rs.getString("TABLE_NAME"));
	String schemaName = convertFromDatabaseName(rs.getString("TABLE_SCHEM"));
	String remarks = rs.getString("REMARKS");
	// hongliangpan add
	if (org.apache.commons.lang.StringUtils.isBlank(remarks)) {
		try {
			remarks = rs.getString("TABLE_COMMENT");
		} catch (Exception e) {
		}
	}

	Table table = new Table(name);
	table.setRemarks(StringUtils.trimToNull(remarks));
	table.setDatabase(database);
	table.setSchema(schemaName);
	table.setRawSchemaName(rs.getString("TABLE_SCHEM"));
	table.setRawCatalogName(rs.getString("TABLE_CAT"));

	return table;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:JdbcDatabaseSnapshotGenerator.java

示例14: check

import liquibase.util.StringUtils; //导入依赖的package包/类
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException {
    try {
        if (!DatabaseSnapshotGeneratorFactory.getInstance().getGenerator(database).hasIndex(getSchemaName(), getTableName(), getIndexName(), database, getColumnNames())) {
            String name = "";

            if (getIndexName() != null) {
                name += database.escapeStringForDatabase(getIndexName());
            }

            if (StringUtils.trimToNull(getTableName()) != null) {
                name += " on "+database.escapeStringForDatabase(getTableName());

                if (StringUtils.trimToNull(getColumnNames()) != null) {
                    name += " columns "+getColumnNames();
                }
            }
            throw new PreconditionFailedException("Index "+ name +" does not exist", changeLog, this);
        }
    } catch (DatabaseException e) {
        throw new PreconditionErrorException(e, changeLog, this);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:23,代码来源:IndexExistsPrecondition.java

示例15: nodeToStringBuffer

import liquibase.util.StringUtils; //导入依赖的package包/类
private void nodeToStringBuffer(Node node, StringBuffer buffer) {
    buffer.append("<").append(node.getNodeName());
    SortedMap<String, String> attributeMap = new TreeMap<String, String>();
    NamedNodeMap attributes = node.getAttributes();
    for (int i = 0; i < attributes.getLength(); i++) {
        Node attribute = attributes.item(i);
        attributeMap.put(attribute.getNodeName(), attribute.getNodeValue());
    }
    for (Map.Entry entry : attributeMap.entrySet()) {
        String value = (String) entry.getValue();
        if (value != null) {
            buffer.append(" ").append(entry.getKey()).append("=\"").append(value).append("\"");
        }
    }
    buffer.append(">").append(StringUtils.trimToEmpty(XMLUtil.getTextContent(node)));
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node childNode = childNodes.item(i);
        if (childNode instanceof Element) {
            nodeToStringBuffer(((Element) childNode), buffer);
        }
    }
    buffer.append("</").append(node.getNodeName()).append(">");
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:25,代码来源:XMLChangeLogSerializer.java


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