Java Code Examples for org.dbunit.dataset.datatype.DataType#UNKNOWN

The following examples show how to use org.dbunit.dataset.datatype.DataType#UNKNOWN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuilderUtil.java    From database-rider with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated use <code>DataType.UNKNOWN</code> instead of this method. See https://github.com/database-rider/database-rider/pull/154#issuecomment-527622138
 * @param value column value
 * @return resolved datatype
 */
public static DataType resolveColumnDataType(Object value) {
    DataType columnType = DataType.UNKNOWN;
    if(value == null) {
        return columnType;
    }
    if (value instanceof Integer) {
        columnType = DataType.INTEGER;
    }
    if (value instanceof Long) {
        columnType = DataType.BIGINT_AUX_LONG;
    }
    if (value instanceof Double) {
        columnType = DataType.DOUBLE;
    }
    if (value instanceof Float) {
        columnType = DataType.FLOAT;
    }
    if (value instanceof Date) {
        columnType = DataType.DATE;
    }
    if (value instanceof Boolean) {
        columnType = DataType.BOOLEAN;
    }
    if (value instanceof BigDecimal) {
        columnType = DataType.DECIMAL;
    }
    if (value instanceof Number) {
        columnType = DataType.NUMERIC;
    }
    return columnType;
}
 
Example 2
Source File: YamlDataSet.java    From database-rider with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: BasicRowBuilder.java    From database-rider with Apache License 2.0 4 votes vote down vote up
protected Column createColumn(String columnName) {
    DataType columnType = DataType.UNKNOWN;
    return new Column(columnName, columnType);
}
 
Example 4
Source File: XlsTable.java    From Leo with Apache License 2.0 4 votes vote down vote up
static ITableMetaData createMetaData(String tableName, HSSFRow sampleRow, HSSFWorkbook workbook) {
    logger.debug("createMetaData(tableName={}, sampleRow={}) - start", tableName, sampleRow);

    List<Column> columnList = new ArrayList<Column>();
    List<String> primaryKeyList = new ArrayList<String>();
    for (int i = 0;; i++) {
        HSSFCell cell = sampleRow.getCell(i);
        if (cell == null) {
            break;
        }

        String columnName = cell.getRichStringCellValue().getString();
        if (columnName != null) {
            columnName = columnName.trim();
        }

        // Bugfix for issue ID 2818981 - if a cell has a formatting but no
        // name also ignore it
        if (columnName.length() <= 0) {
            logger
                    .debug(
                            "The column name of column # {} is empty - will skip here assuming the last column was reached",
                            String.valueOf(i));
            break;
        }

        Column column = new Column(columnName, DataType.UNKNOWN);
        columnList.add(column);
        
        // Unique identification key
        byte underline = cell.getCellStyle().getFont(workbook).getUnderline();
        if (underline == 1) {
            primaryKeyList.add(columnName);
        } 

    }
    Column[] columns = columnList.toArray(new Column[0]);
    
    if(!primaryKeyList.isEmpty()){
    	return new DefaultTableMetaData(tableName, columns,primaryKeyList.toArray(new String[primaryKeyList.size()]));
    }else{
    	return new DefaultTableMetaData(tableName, columns);
    }
    
}