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


Java DataType类代码示例

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


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

示例1: getMetaData

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * Gets the table meta data based on the rows for a table
 * 
 * @param tableName
 *            The name of the table
 * @param rows
 *            The rows of the table
 * @return The table metadata for the table
 */
private ITableMetaData getMetaData(String tableName,
		List<Map<String, Object>> rows) {
	Set<String> columns = new LinkedHashSet<String>();
	// iterate through the dataset and add the column names to a set
	for (Map<String, Object> row : rows) {
		for (Map.Entry<String, Object> column : row.entrySet()) {
			columns.add(column.getKey());
		}
	}
	List<Column> list = new ArrayList<Column>(columns.size());
	// create a list of DBUnit columns based on the column name set
	for (String s : columns) {
		list.add(new Column(s, DataType.UNKNOWN));
	}
	return new DefaultTableMetaData(tableName,
			list.toArray(new Column[list.size()]));
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:27,代码来源:JSONDataSet.java

示例2: addRows

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * Adds the rows of the DbUnit table to the given table.
 *
 * @param dbUnitTable           The DbUnit table containing the rows, not null
 * @param table                 The table to add the rows to, not null
 * @param primaryKeyColumnNames The names of the pk columns, empty if there are none
 */
protected void addRows(ITable dbUnitTable, Table table, List<String> primaryKeyColumnNames) throws DataSetException {
    org.dbunit.dataset.Column[] columns = dbUnitTable.getTableMetaData().getColumns();
    int rowCount = dbUnitTable.getRowCount();
    for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
        Row row = new Row();
        table.addRow(row);

        for (org.dbunit.dataset.Column dbUnitColumn : columns) {
            String columnName = dbUnitColumn.getColumnName();
            DataType columnType = dbUnitColumn.getDataType();
            Object value = dbUnitTable.getValue(rowIndex, columnName);

            Column column = new Column(columnName, columnType, value);
            if (primaryKeyColumnNames.contains(columnName)) {
                row.addPrimaryKeyColumn(column);
            } else {
                row.addColumn(column);
            }
        }
    }
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:29,代码来源:SchemaFactory.java

示例3: createTableMetaData

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
private ITableMetaData createTableMetaData() throws DataSetException {
    if (beans.isEmpty()) {
        return new DefaultTableMetaData(tableName, new Column[0]);
    } else {
        try {
            List<Column> columns = new ArrayList<Column>();
            BeanInfo info = Introspector.getBeanInfo(beans.get(0).getClass());
            PropertyDescriptor[] descs = info.getPropertyDescriptors();
            for (PropertyDescriptor desc : descs) {
                if (!isIgnoreProperty(desc)) {
                    System.out.println(desc.getName());
                    columns.add(new Column(desc.getName(), DataType.UNKNOWN));
                }
            }

            Column[] c = (Column[]) columns.toArray(new Column[columns.size()]);
            return new DefaultTableMetaData(tableName, c);
        } catch (IntrospectionException e) {
            throw new DataSetException(e);
        }
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:23,代码来源:BeanTable.java

示例4: getMetaData

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * Gets the table meta data based on the rows for a table
 *
 * @param tableName
 *            The name of the table
 * @param rows
 *            The rows of the table
 * @return The table metadata for the table
 */
private ITableMetaData getMetaData(String tableName,
                                   List<Map<String, Object>> rows) {
    Set<String> columns = new LinkedHashSet<String>();
    // iterate through the dataset and add the column names to a set
    for (Map<String, Object> row : rows) {
        for (Map.Entry<String, Object> column : row.entrySet()) {
            columns.add(column.getKey());
        }
    }
    List<Column> list = new ArrayList<Column>(columns.size());
    // create a list of DBUnit columns based on the column name set
    for (String s : columns) {
        list.add(new Column(s, DataType.UNKNOWN));
    }
    return new DefaultTableMetaData(tableName,
            list.toArray(new Column[list.size()]));
}
 
开发者ID:lbitonti,项目名称:deltaspike-dbunit,代码行数:27,代码来源:AbstractDataSetParser.java

示例5: readTable

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * Выполняет формирование таблицы из файла
 *
 * @param tableName название таблицы
 * @param reader сервис чтения файла
 */
protected void readTable(String tableName, ICsvListReader reader) throws DataSetException, IOException {
    String[] headers = reader.getHeader(true);
    if (headers == null) {
        throw new DataSetException(String.format("Table '%s' must contains headers", tableName));
    }
    Column[] columns = new Column[headers.length];
    for (int i = 0; i < headers.length; i++) {
        columns[i] = new Column(headers[i], DataType.UNKNOWN);
    }

    consumer.startTable(new DefaultTableMetaData(tableName, columns));
    List<String> row;
    while ((row = reader.read()) != null) {
        consumer.row(row.toArray());
    }
    consumer.endTable();
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:24,代码来源:CsvProducer.java

示例6: testConvert

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
public void testConvert() throws Exception {
    ITableMetaData tableMetaData = new DefaultTableMetaData(
            "testDictionary",
            new Column[]{new Column("column1", DataType.UNKNOWN), new Column("column2", DataType.UNKNOWN)}
    );

    Dictionary dictionary = converter.convert(tableMetaData);
    assertNotNull(dictionary);
    assertEquals(dictionary.getName(), "testDictionary");
    // check META-fields
    List<MetaField> metaFields = ModelUtils.sortMetaFieldsByOrdinal(dictionary.getDescendants());
    assertEquals(metaFields.size(), 2);
    for (int i = 0; i < metaFields.size(); i++) {
        assertMetaField(metaFields.get(i), tableMetaData.getColumns(), i, i == 0);
    }
    // check serialize
    assertObjectSerialization(dictionary);
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:19,代码来源:DictionaryStructureConverterTest.java

示例7: testConvert

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
public void testConvert() throws Exception {
    DefaultTable table = new DefaultTable(new DefaultTableMetaData(
            "testDictionary" + MetaFieldsConverter.DEFAULT_TABLE_POSTFIX,
            new Column[]{
                    new Column(MetaField.NAME, DataType.UNKNOWN),
                    new Column(MetaField.DESCRIPTION, DataType.UNKNOWN),
                    new Column(MetaField.FLAG_PRIMARY_NAME, DataType.UNKNOWN),
                    new Column(MetaField.FLAG_UNIQUE_NAME, DataType.UNKNOWN),
                    new Column(MetaField.FLAG_HIDDEN_NAME, DataType.UNKNOWN)
            }
    ));
    table.addRow(new Object[]{"mf1", "meta_field_1", true, true, false});
    table.addRow(new Object[]{"mf2", "meta_field_2", false, true, false});
    table.addRow(new Object[]{"mf3", "meta_field_3", false, false, true});

    Dictionary dictionary = converter.convert(table);
    assertEquals(dictionary.getName(), "testDictionary");
    List<MetaField> metaFields = ModelUtils.sortMetaFieldsByOrdinal(dictionary.getDescendants());
    // check meta fields
    assertEquals(metaFields.size(), 3);
    for (int i = 0; i < table.getRowCount(); i++) {
        assertMetaField(metaFields.get(i), table, i);
    }
    // check serialize
    assertObjectSerialization(dictionary);
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:27,代码来源:MetaFieldsConverterTest.java

示例8: createDataType

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
@Override
public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException {
    if (sqlType == 1111) {
        if ("jsonb".equals(sqlTypeName)) {
            return new JsonbDataType();
        }
    }

    return super.createDataType(sqlType, sqlTypeName);
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:11,代码来源:DWPostgresqlDataTypeFactory.java

示例9: createMeta

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
ITableMetaData createMeta(String name, List<String> columnNames) {
    Column[] columns = null;
    if (columnNames != null) {
        columns = new Column[columnNames.size()];
        for (int i = 0; i < columnNames.size(); i++)
            columns[i] = new Column(columnNames.get(i), DataType.UNKNOWN);
    } else {
        columns = new Column[0];
    }
    return new DefaultTableMetaData(name, columns);
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:12,代码来源:YamlDataSet.java

示例10: addTable

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
private void addTable(Schema schema, String tableName, String value) {
    Row row = new Row();
    row.addColumn(new Column("column", DataType.VARCHAR, value));

    Table table = new Table(tableName);
    table.addRow(row);
    schema.addTable(table);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:9,代码来源:SchemaComparisonTest.java

示例11: getCastedValue

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * Gets the value casted to the given type.
 *
 * @param castType The type to cast the value to, not null
 * @return The casted value
 * @throws UnitilsException When the value cannot be cast
 */
public Object getCastedValue(DataType castType) {
    try {
        return castType.typeCast(value);
    } catch (TypeCastException e) {
        throw new UnitilsException("Unable to convert \"" + value + "\" to " + castType.toString() + ". Column name: " + name + ", current type: " + type.toString(), e);
    }
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:15,代码来源:Column.java

示例12: relosveDataType

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
/**
 * clazzに対応するデータベースの型を返す.
 * @param clazz class
 * @return データベースの型
 */
public DataType relosveDataType(Class<?> clazz) {
    if (String.class == clazz) {
        return DataType.VARCHAR;
    } else if (Integer.class == clazz) {
        return DataType.NUMERIC;
    } else if (Long.class == clazz) {
        return DataType.NUMERIC;
    } else if (Date.class == clazz) {
        return DataType.TIMESTAMP;
    }
    return null;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:18,代码来源:BeanDataTypeResolver.java

示例13: createDataType

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
@Override
public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException {
  logger.debug("createDataType(sqlType={}, sqlTypeName={}) - start", new Integer(sqlType),
      sqlTypeName);

  DataType customDataType = customDataTypeMap.get(sqlTypeName);
  if (customDataType != null) {
    logger.debug("use custom dataType(sqlTypeName={}, dataType=)", sqlTypeName, customDataType);
    return customDataType;
  } else {
    return super.createDataType(sqlType, sqlTypeName);
  }
}
 
开发者ID:frank780117,项目名称:dbunit-ext,代码行数:14,代码来源:CustomableDataTypeFactory.java

示例14: addCustomType

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
public void addCustomType(String sqlTypeName, DataType dataType) {
  if (sqlTypeName == null || "".equals(sqlTypeName)) {
    throw new NullPointerException("sqlType is null or empty.");
  }

  if (dataType == null) {
    throw new NullPointerException("dataType is null or empty.");
  }

  logger.debug("add custom type ('{}' is {})", sqlTypeName, dataType.getClass());
  customDataTypeMap.put(sqlTypeName, dataType);

}
 
开发者ID:frank780117,项目名称:dbunit-ext,代码行数:14,代码来源:CustomableDataTypeFactory.java

示例15: addValue

import org.dbunit.dataset.datatype.DataType; //导入依赖的package包/类
@Override
public void addValue(Object value, DataType dataType) throws TypeCastException, SQLException {
  logger.debug("addValue(value={}, dataType={}) - start", value, dataType);
  if(value instanceof SqlDefaultValueObject) {
    value = SqlDefaultValueObject.getDefaultValue(dataType.getSqlType());
  }
  
  super.addValue(value, dataType);
}
 
开发者ID:frank780117,项目名称:dbunit-ext,代码行数:10,代码来源:SimplePreparedDefaultValueStatement.java


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