This commit is contained in:
Looly 2020-08-16 11:55:30 +08:00
parent ef235aab5d
commit a444d00e98
6 changed files with 56 additions and 25 deletions

View File

@ -23,6 +23,7 @@
* 【core 】 BooleanConverter增加数字转换规则issue#I1R2AB@Gitee
* 【poi 】 sax方式读取增加一个sheet结束的回调issue#155@Gitee
* 【db 】 增加BeeCP连接池支持
* 【core 】 改进Img.pressImage方法避免变色问题issue#1001@Github
### Bug修复#
* 【core 】 修复原始类型转换时,转换失败没有抛出异常的问题

View File

@ -507,7 +507,7 @@ public class Img implements Serializable {
public Img pressImage(Image pressImg, Rectangle rectangle, float alpha) {
final Image targetImg = getValidSrcImg();
this.targetImage = draw(ImgUtil.toBufferedImage(targetImg), pressImg, rectangle, alpha);
this.targetImage = draw(ImgUtil.toBufferedImage(targetImg, this.targetImageType), pressImg, rectangle, alpha);
return this;
}

View File

@ -33,6 +33,11 @@ public class BeeDSFactory extends AbstractDSFactory {
final BeeDataSourceConfig beeConfig = new BeeDataSourceConfig(driver, jdbcUrl, user, pass);
poolSetting.toBean(beeConfig);
// 修复BeeCP默认参数无效问题
if(beeConfig.getBorrowConcurrentSize() > beeConfig.getMaxActive()){
beeConfig.setMaxActive(beeConfig.getBorrowConcurrentSize() + 1);
}
// remarks等特殊配置since 5.3.8
String connValue;
for (String key : KEY_CONN_PROPS) {

View File

@ -2,6 +2,7 @@ package cn.hutool.db;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.db.ds.DSFactory;
import cn.hutool.db.ds.bee.BeeDSFactory;
import cn.hutool.db.ds.c3p0.C3p0DSFactory;
import cn.hutool.db.ds.dbcp.DbcpDSFactory;
import cn.hutool.db.ds.druid.DruidDSFactory;
@ -59,6 +60,15 @@ public class DsTest {
Assert.assertTrue(CollUtil.isNotEmpty(all));
}
@Test
public void beeCPDsTest() throws SQLException {
DSFactory.setCurrentDSFactory(new BeeDSFactory());
DataSource ds = DSFactory.get("test");
Db db = Db.use(ds);
List<Entity> all = db.findAll("user");
Assert.assertTrue(CollUtil.isNotEmpty(all));
}
@Test
public void dbcpDsTest() throws SQLException {
DSFactory.setCurrentDSFactory(new DbcpDSFactory());

View File

@ -511,12 +511,12 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
* @return 转换别名列表
*/
private List<String> aliasHeader(List<Object> headerList) {
final int size = headerList.size();
final ArrayList<String> result = new ArrayList<>(size);
if (CollUtil.isEmpty(headerList)) {
return result;
if(CollUtil.isEmpty(headerList)){
return new ArrayList<>(0);
}
final int size = headerList.size();
final ArrayList<String> result = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
result.add(aliasHeader(headerList.get(i), i));
}

View File

@ -1,27 +1,27 @@
package cn.hutool.poi.excel;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.cell.CellEditor;
import cn.hutool.poi.excel.cell.CellUtil;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.cell.CellEditor;
import cn.hutool.poi.excel.cell.CellUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Excel中的行{@link Row}封装工具类
*
*
* @author looly
* @since 4.0.7
*/
public class RowUtil {
/**
* 获取已有行或创建新行
*
* @param sheet Excel表
*
* @param sheet Excel表
* @param rowIndex 行号
* @return {@link Row}
* @since 4.0.2
@ -36,23 +36,38 @@ public class RowUtil {
/**
* 读取一行
*
* @param row
*
* @param row
* @param cellEditor 单元格编辑器
* @return 单元格值列表
*/
public static List<Object> readRow(Row row, CellEditor cellEditor) {
return readRow(row, 0, Short.MAX_VALUE, cellEditor);
}
/**
* 读取一行
*
* @param row
* @param startCellNumInclude 起始单元格号0开始包含
* @param endCellNumInclude 结束单元格号0开始包含
* @param cellEditor 单元格编辑器
* @return 单元格值列表
*/
public static List<Object> readRow(Row row, int startCellNumInclude, int endCellNumInclude, CellEditor cellEditor) {
if (null == row) {
return new ArrayList<>(0);
}
final short length = row.getLastCellNum();
if (length < 0) {
return new ArrayList<>(0);
final short rowLength = row.getLastCellNum();
if (rowLength < 0) {
return ListUtil.empty();
}
final List<Object> cellValues = new ArrayList<>(length);
final int size = Math.min(endCellNumInclude + 1, rowLength);
final List<Object> cellValues = new ArrayList<>(size);
Object cellValue;
boolean isAllNull = true;
for (short i = 0; i < length; i++) {
for (int i = startCellNumInclude; i < size; i++) {
cellValue = CellUtil.getCellValue(row.getCell(i), cellEditor);
isAllNull &= StrUtil.isEmptyIfStr(cellValue);
cellValues.add(cellValue);
@ -60,16 +75,16 @@ public class RowUtil {
if (isAllNull) {
// 如果每个元素都为空则定义为空行
return new ArrayList<>(0);
return ListUtil.empty();
}
return cellValues;
}
/**
* 写一行数据
*
* @param row
* @param rowData 一行的数据
*
* @param row
* @param rowData 一行的数据
* @param styleSet 单元格样式集包括日期等样式
* @param isHeader 是否为标题行
*/