Search in sources :

Example 21 with DfDataColumn

use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.

the class DfTableXlsReaderTest method test_read_rtrim.

public void test_read_rtrim() throws IOException {
    // ## Arrange ##
    final File xlsFile = prepareTestBasicXlsFile();
    final DfTableXlsReader reader = createTableXlsReader(xlsFile, null, true);
    // ## Act ##
    final DfDataSet dataSet = reader.read();
    // ## Assert ##
    log("[DataSet]:" + ln() + dataSet);
    final int tableSize = dataSet.getTableSize();
    assertTrue(tableSize > 0);
    for (int tableIndex = 0; tableIndex < tableSize; tableIndex++) {
        final DfDataTable table = dataSet.getTable(tableIndex);
        final int columnSize = table.getColumnSize();
        assertTrue(columnSize > 0);
        final int rowSize = table.getRowSize();
        assertTrue(rowSize > 0);
        for (int rowIndex = 0; rowIndex < rowSize; rowIndex++) {
            final DfDataRow row = table.getRow(rowIndex);
            for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
                final DfDataColumn column = table.getColumn(columnIndex);
                final String columnDbName = column.getColumnDbName();
                final Object value = row.getValue(columnDbName);
                if (columnDbName.equals("AAA")) {
                    assertNotNull(value);
                } else if (columnDbName.equals("BBB")) {
                    markHere("nullBBB");
                } else if (columnDbName.equals("CCC")) {
                    assertNotNull(value);
                } else if (columnDbName.equals("DDD")) {
                    assertNotNull(value);
                    String str = (String) value;
                    if (str.length() > str.trim().length()) {
                        fail();
                    }
                } else if (columnDbName.equals("EEE")) {
                    assertNotNull(value);
                    String str = (String) value;
                    if (str.length() > str.trim().length()) {
                        // because of not trimmed column
                        markHere("trimmed_EEE");
                    }
                }
            }
        }
    }
    assertMarked("nullBBB");
    assertMarked("trimmed_EEE");
}
Also used : DfDataSet(org.dbflute.helper.dataset.DfDataSet) DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) DfDataTable(org.dbflute.helper.dataset.DfDataTable) File(java.io.File) DfDataRow(org.dbflute.helper.dataset.DfDataRow)

Example 22 with DfDataColumn

use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.

the class DfXlsDataHandlingWriter method extractColumnNameList.

protected List<String> extractColumnNameList(DfDataTable dataTable) {
    // for small function
    final List<String> columnNameList = new ArrayList<String>();
    for (int i = 0; i < dataTable.getColumnSize(); i++) {
        final DfDataColumn dataColumn = dataTable.getColumn(i);
        if (!dataColumn.isWritable()) {
            continue;
        }
        final String columnName = dataColumn.getColumnDbName();
        columnNameList.add(columnName);
    }
    return columnNameList;
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) ArrayList(java.util.ArrayList)

Aggregations

DfDataColumn (org.dbflute.helper.dataset.DfDataColumn)22 DfDataTable (org.dbflute.helper.dataset.DfDataTable)9 ArrayList (java.util.ArrayList)7 RichTextString (org.apache.poi.ss.usermodel.RichTextString)6 DfDataRow (org.dbflute.helper.dataset.DfDataRow)5 File (java.io.File)3 DfDataSet (org.dbflute.helper.dataset.DfDataSet)3 DfXlsDataEmptyColumnDefException (org.dbflute.exception.DfXlsDataEmptyColumnDefException)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)2 List (java.util.List)1 Cell (org.apache.poi.ss.usermodel.Cell)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 ScopeInfo (org.dbflute.util.Srl.ScopeInfo)1