本文整理汇总了Java中org.dbunit.dataset.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于org.dbunit.dataset包,在下文中一共展示了Column类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addRow
import org.dbunit.dataset.Column; //导入依赖的package包/类
/**
* Gets column names and row values from the given attribute and adds a new row to the given table.
*
* @param table The table to add the row to, not null
* @param attributes the attributes, not null
*/
protected void addRow(Attributes attributes, DbUnitTable table) {
if (attributes.getLength() == 0) {
return;
}
for (int i = 0; i < attributes.getLength(); i++) {
Column column = new Column(attributes.getQName(i), UNKNOWN);
table.addColumn(column);
}
List<Object> row = new ArrayList<Object>(10);
for (String columnName : table.getColumnNames()) {
Object value = NO_VALUE;
if (attributes.getIndex(columnName) != -1) {
value = attributes.getValue(columnName);
}
row.add(value);
}
table.addRow(row);
}
开发者ID:linux-china,项目名称:unitils,代码行数:25,代码来源:MultiSchemaXmlDataSetReader.java
示例2: createTableMetaData
import org.dbunit.dataset.Column; //导入依赖的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
示例3: getValue
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public Object getValue(int row, String column) throws DataSetException {
if (row < table.getRowCount()) {
return table.getValue(row, column);
} else {
if (columnToBeReplaced.equalsIgnoreCase(column)) {
Column c = null;
ITableMetaData metaData = table.getTableMetaData();
for (Column cl : metaData.getColumns()) {
if (cl.getColumnName().equalsIgnoreCase(column)) {
c = cl;
}
}
return c.getDataType().typeCast(valueToBeReplaced);
}
return table.getValue(row - table.getRowCount(), column);
}
}
开发者ID:Hippoom,项目名称:spring-test-dbunit-template,代码行数:21,代码来源:CreateTemplateTable.java
示例4: createRecodeRules
import org.dbunit.dataset.Column; //导入依赖的package包/类
/**
* Создает коллекцию правил перекодирования на основе таблицы
*
* @param from именованный путь источника
* @param to именованный путь назначения
* @param table таблица
* @return Возвращает коллекцию правил перекодирования
*/
private Collection<RecodeRule> createRecodeRules(DictionaryNamedPath from, DictionaryNamedPath to, ITable table) throws DataSetException {
Collection<RecodeRule> rules = new ArrayList<RecodeRule>(table.getRowCount());
for (int row = 0; row < table.getRowCount(); row++) {
final RecodeRule rule = new RecodeRule();
Column[] columns = table.getTableMetaData().getColumns();
// Поля источника
int columnIndex = 0;
{
rule.injectFromNamedPath(
createFieldNamedPath(from, columns[columnIndex].getColumnName(), table.getValue(row, columns[columnIndex].getColumnName()))
);
}
// Поля назначения
columnIndex++;
{
rule.injectToNamedPath(
createFieldNamedPath(to, columns[columnIndex].getColumnName(), table.getValue(row, columns[columnIndex].getColumnName()))
);
}
rules.add(rule);
}
return rules;
}
开发者ID:hflabs,项目名称:perecoder,代码行数:34,代码来源:RecodeRulesConverter.java
示例5: startTable
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public void startTable(ITableMetaData metaData) throws DataSetException {
// Формируем целевой файл
currentFile = new File(targetDirectory, String.format("%s.%s", metaData.getTableName(), extension));
try {
// Формируем сервис записи файла
currentWriter = createWriter();
// Формируем название колонок
Column[] columns = metaData.getColumns();
currentHeaders = new String[columns.length];
for (int i = 0; i < currentHeaders.length; i++) {
currentHeaders[i] = columns[i].getColumnName();
}
// Записываем название колонок
writeHeader();
} catch (IOException ex) {
throw new DataSetException(ex);
}
}
开发者ID:hflabs,项目名称:perecoder,代码行数:20,代码来源:FilesConsumer.java
示例6: readTable
import org.dbunit.dataset.Column; //导入依赖的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
示例7: testConvert
import org.dbunit.dataset.Column; //导入依赖的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
示例8: assertTable
import org.dbunit.dataset.Column; //导入依赖的package包/类
/**
* Выполняет проверку таблицы
*
* @param table целевая таблица
*/
protected static void assertTable(ITable table) throws Exception {
// Колонки
Column[] columns = table.getTableMetaData().getColumns();
assertEquals(columns.length, COLUMNS.length);
for (int i = 0; i < columns.length; i++) {
assertEquals(columns[i].getColumnName(), COLUMNS[i]);
}
// Строки
assertEquals(table.getRowCount(), ROWS.length);
for (int row = 0; row < table.getRowCount(); row++) {
for (int column = 0; column < columns.length; column++) {
assertEquals(table.getValue(row, columns[column].getColumnName()), ROWS[row][column]);
}
}
}
开发者ID:hflabs,项目名称:perecoder,代码行数:21,代码来源:DataSetTest.java
示例9: compareDbToDataSet
import org.dbunit.dataset.Column; //导入依赖的package包/类
private void compareDbToDataSet(String filename) throws Exception
{
IDataSet afterActualDataSet = getDbUnitconnection().createDataSet();
IDataSet afterExpectedDataSet = loadDataSet(filename);
ITableIterator iter = afterActualDataSet.iterator();
while (iter.next()) {
ITable actualTable = iter.getTable();
ITable expectedTable = afterExpectedDataSet.getTable(actualTable.getTableMetaData().getTableName());
Column[] expectedColumns = expectedTable.getTableMetaData().getColumns();
//Expected table will be sorted by the columns present on expected file
ITable sortedExpectedTable = new SortedTable(expectedTable, expectedColumns);
//Actual table will be sorted by the columns present on *expected* file.
//It will be also filtered to only include tables present on expected file
ITable filteredActualTable = DefaultColumnFilter.includedColumnsTable(actualTable, expectedColumns);
ITable sortedFilteredActualTable = new SortedTable(filteredActualTable, expectedColumns);
Assertion.assertEquals(sortedExpectedTable, sortedFilteredActualTable);
}
}
开发者ID:daniel-a-melo,项目名称:jorm-unit,代码行数:24,代码来源:JPATest.java
示例10: setUpDatabaseConfig
import org.dbunit.dataset.Column; //导入依赖的package包/类
/**
* Configure database.
*
* @param config the database-config.
*/
private void setUpDatabaseConfig(DatabaseConfig config) {
config.setProperty(DatabaseConfig.PROPERTY_BATCH_SIZE, BATCH_SIZE);
config.setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS,
Boolean.TRUE);
config.setProperty(DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER,
new IColumnFilter() {
@Override
public boolean accept(String tableName, Column column) {
if (tableToPrimaryKey.containsKey(tableName)) {
return Arrays.asList(
tableToPrimaryKey.get(tableName)).contains(
column.getColumnName());
} else {
return column.getColumnName()
.equalsIgnoreCase("id");
}
}
});
}
开发者ID:opensource21,项目名称:fuwesta,代码行数:26,代码来源:FuWeStaSampleDatabase.java
示例11: filterColumns
import org.dbunit.dataset.Column; //导入依赖的package包/类
private Column[] filterColumns(Column[] allColumns) {
List<Column> result = new ArrayList<Column>();
for (Column column : allColumns) {
if (!column.getColumnName().equals("moddate")) {
result.add(column);
}
}
return result.toArray(new Column[result.size()]);
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:10,代码来源:SchemaUpgradeTestBase.java
示例12: sortCols
import org.dbunit.dataset.Column; //导入依赖的package包/类
private Column[] sortCols(final Column[] cols) {
Arrays.sort(cols, new Comparator<Column>() {
@Override
public int compare(final Column columnA, final Column columnB) {
if (columnA.getColumnName().toLowerCase().equals("id")) {
return -1;
} else if (columnB.getColumnName().toLowerCase().equals("id")) {
return 1;
} else {
return columnA.getColumnName().compareTo(columnB.getColumnName());
}
}
});
return cols;
}
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:16,代码来源:TableFormatter.java
示例13: accept
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public boolean accept(final String tablename, final Column column) {
final String tablenameUpper = tablename.toUpperCase();
if (TS_TABLE_COLUMNS.containsKey(tablenameUpper)) {
return !TS_TABLE_COLUMNS.get(tablenameUpper).contains(column.getColumnName().toUpperCase());
}
return true;
}
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:9,代码来源:AbstractDBUnitUtil.java
示例14: row
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public void row(Object[] values) throws DataSetException {
rowCount++;
try {
out.write(FOUR_SPACES+"{"+NEW_LINE);
for (int i = 0; i < values.length; i++) {
if(values[i] == null){
continue;
}
Column currentColumn = metaData.getColumns()[i];
out.write(FOUR_SPACES+DOUBLE_SPACES+"\""+metaData.getColumns()[i].getColumnName() + "\": ");
boolean isNumber = currentColumn.getDataType().isNumber();
if (!isNumber) {
out.write("\"");
}
out.write(values[i].toString());
if (!isNumber) {
out.write("\"");
}
if(i != values.length-1){
out.write(",");
}
out.write(NEW_LINE);
}
if(dataSet.getTable(metaData.getTableName()).getRowCount() != rowCount ){
out.write(FOUR_SPACES+"},"+NEW_LINE);
}else {
out.write(FOUR_SPACES+"}"+NEW_LINE);
}
} catch (Exception e) {
logger.warn("Could not write row.", e);
}
}
开发者ID:database-rider,项目名称:database-rider,代码行数:41,代码来源:JSONWriter.java
示例15: row
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public void row(Object[] values) throws DataSetException {
try {
for (int i = 0; i < values.length; i++) {
if(values[i] == null){
continue;
}
if (i == 0) {
out.write(DOUBLE_SPACES + "- ");
} else{
out.write(DOUBLE_SPACES + DOUBLE_SPACES);
}
Column currentColumn = metaData.getColumns()[i];
out.write(metaData.getColumns()[i].getColumnName()+": ");
boolean isNumber = currentColumn.getDataType().isNumber();
if(!isNumber){
out.write("\"");
}
if(values[i] != null){
out.write(values[i].toString());
}
if(!isNumber){
out.write("\"");
}
out.write(NEW_LINE);
}
}catch (Exception e){
logger.warn("Could not write row.",e);
}
}
开发者ID:database-rider,项目名称:database-rider,代码行数:34,代码来源:YMLWriter.java
示例16: createMeta
import org.dbunit.dataset.Column; //导入依赖的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
示例17: addColumn
import org.dbunit.dataset.Column; //导入依赖的package包/类
/**
*
*/
public void addColumn(Column column) {
if (!columns.contains(column)) {
columns.add(column);
}
}
开发者ID:linux-china,项目名称:unitils,代码行数:10,代码来源:Table.java
示例18: produce
import org.dbunit.dataset.Column; //导入依赖的package包/类
@Override
public void produce() throws DataSetException {
consumer.startDataSet();
final Map<String, List<Map<String, String>>> dataset = loadDataSet();
for (final Map.Entry<String, List<Map<String, String>>> entry : dataset.entrySet()) {
// an entry represents a table
final List<Map<String, String>> rows = entry.getValue();
// each row represents a record in a table
final Collection<String> columnNames = extractColumnNames(rows);
final ITableMetaData tableMetaData = new DefaultTableMetaData(entry.getKey(), createColumns(columnNames));
consumer.startTable(tableMetaData);
for (final Map<String, String> row : rows) {
final List<String> values = new ArrayList<>();
for (final Column column : tableMetaData.getColumns()) {
final Object rawValue = row.get(column.getColumnName());
final String value = rawValue == null ? null : String.valueOf(rawValue);
values.add(value);
}
consumer.row(values.toArray());
}
consumer.endTable();
}
consumer.endDataSet();
}
开发者ID:dadrus,项目名称:jpa-unit,代码行数:33,代码来源:DataSetProducer.java
示例19: extractColumnNames
import org.dbunit.dataset.Column; //导入依赖的package包/类
private Collection<String> extractColumnNames(final Column[] columns) {
final List<String> names = new ArrayList<>(columns.length);
for (final Column column : columns) {
names.add(column.getColumnName().toLowerCase());
}
return names;
}
开发者ID:dadrus,项目名称:jpa-unit,代码行数:8,代码来源:DataSetComparator.java
示例20: rebuildRecord
import org.dbunit.dataset.Column; //导入依赖的package包/类
private Map<String, String> rebuildRecord(final List<Column> columns, final Object[] entries) {
final Map<String, String> record = new HashMap<>();
for (int i = 0; i < columns.size(); i++) {
record.put(columns.get(i).getColumnName(), (String) entries[i]);
}
return record;
}
开发者ID:dadrus,项目名称:jpa-unit,代码行数:8,代码来源:JsonDataSetProducerTest.java
注:本文中的org.dbunit.dataset.Column类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论