Search in sources :

Example 1 with ParseBooleanException

use of org.dbflute.util.DfTypeUtil.ParseBooleanException in project dbflute-core by dbflute.

the class DfAbsractDataWriter method processBoolean.

// -----------------------------------------------------
// Boolean
// -------
protected boolean processBoolean(String tableName, String columnName, String value, Connection conn, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap, int rowNumber) throws SQLException {
    if (value == null || value.trim().length() == 0) {
        // cannot be boolean
        return false;
    }
    final DfColumnMeta columnInfo = columnInfoMap.get(columnName);
    if (columnInfo != null) {
        final Class<?> columnType = getBindType(tableName, columnInfo);
        if (columnType != null) {
            if (!Boolean.class.isAssignableFrom(columnType)) {
                return false;
            }
            bindNotNullValueByColumnType(tableName, columnName, conn, ps, bindCount, value, columnType, rowNumber);
            return true;
        }
    }
    // if meta data is not found (basically no way)
    try {
        final Boolean booleanValue = DfTypeUtil.toBoolean(value);
        ps.setBoolean(bindCount, booleanValue);
        return true;
    } catch (ParseBooleanException ignored) {
        // couldn't parse as boolean
        return false;
    }
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) ParseBooleanException(org.dbflute.util.DfTypeUtil.ParseBooleanException)

Example 2 with ParseBooleanException

use of org.dbflute.util.DfTypeUtil.ParseBooleanException in project dbflute-core by dbflute.

the class DfAbsractDataWriter method processBoolean.

// -----------------------------------------------------
// Boolean
// -------
protected boolean processBoolean(String tableName, String columnName, String value, Connection conn, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap, int rowNumber) throws SQLException {
    if (value == null || value.trim().length() == 0) {
        // cannot be boolean
        return false;
    }
    final DfColumnMeta columnInfo = columnInfoMap.get(columnName);
    if (columnInfo != null) {
        final Class<?> columnType = getBindType(tableName, columnInfo);
        if (columnType != null) {
            if (!Boolean.class.isAssignableFrom(columnType)) {
                return false;
            }
            bindNotNullValueByColumnType(tableName, columnName, conn, ps, bindCount, value, columnType, rowNumber);
            return true;
        }
    }
    // if meta data is not found (basically no way)
    try {
        final Boolean booleanValue = DfTypeUtil.toBoolean(value);
        ps.setBoolean(bindCount, booleanValue);
        return true;
    } catch (ParseBooleanException ignored) {
        // couldn't parse as boolean
        return false;
    }
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) ParseBooleanException(org.dbflute.util.DfTypeUtil.ParseBooleanException)

Aggregations

DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)2 ParseBooleanException (org.dbflute.util.DfTypeUtil.ParseBooleanException)2