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;
}
}
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;
}
}
Aggregations