mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix code
This commit is contained in:
parent
b22dbac8f7
commit
34f49fc916
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.4.0 (2020-08-01)
|
||||
# 5.4.0 (2020-08-04)
|
||||
|
||||
### 新特性
|
||||
* 【socket】 对NioServer和NioClient改造(pr#992@Github)
|
||||
@ -11,6 +11,7 @@
|
||||
* 【core 】 DateUtil增加beginOfWeek重载
|
||||
* 【core 】 将有歧义的BeanUtil.mapToBean方法置为过期(使用toBean方法)
|
||||
* 【core 】 添加WatchAction(对Watcher的抽象)
|
||||
* 【core 】 修改UUID正则,更加严谨(issue#I1Q1IW@Gitee)
|
||||
|
||||
### Bug修复#
|
||||
* 【core 】 修复原始类型转换时,转换失败没有抛出异常的问题
|
||||
|
@ -83,11 +83,11 @@ public class PatternPool {
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
public final static Pattern UUID = Pattern.compile("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$");
|
||||
public final static Pattern UUID = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", Pattern.CASE_INSENSITIVE);
|
||||
/**
|
||||
* 不带横线的UUID
|
||||
*/
|
||||
public final static Pattern UUID_SIMPLE = Pattern.compile("^[0-9a-z]{32}$");
|
||||
public final static Pattern UUID_SIMPLE = Pattern.compile("^[0-9a-f]{32}$", Pattern.CASE_INSENSITIVE);
|
||||
/**
|
||||
* MAC地址正则
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.lang;
|
||||
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -142,4 +143,13 @@ public class ValidatorTest {
|
||||
Assert.assertTrue(Validator.isChinese("全都是中文"));
|
||||
Assert.assertFalse(Validator.isChinese("not全都是中文"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isUUIDTest(){
|
||||
Assert.assertTrue(Validator.isUUID(IdUtil.randomUUID()));
|
||||
Assert.assertTrue(Validator.isUUID(IdUtil.fastSimpleUUID()));
|
||||
|
||||
Assert.assertTrue(Validator.isUUID(IdUtil.randomUUID().toUpperCase()));
|
||||
Assert.assertTrue(Validator.isUUID(IdUtil.fastSimpleUUID().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cn.hutool.poi.excel;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.poi.excel.cell.CellLocation;
|
||||
import cn.hutool.poi.excel.cell.CellUtil;
|
||||
import cn.hutool.poi.excel.style.StyleUtil;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@ -12,10 +12,9 @@ import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.poi.excel.cell.CellUtil;
|
||||
import cn.hutool.poi.excel.style.StyleUtil;
|
||||
import java.io.Closeable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Excel基础类,用于抽象ExcelWriter和ExcelReader中共用部分的对象和方法
|
||||
@ -281,11 +280,22 @@ public class ExcelBase<T extends ExcelBase<T>> implements Closeable {
|
||||
*/
|
||||
public CellStyle createCellStyle(int x, int y) {
|
||||
final Cell cell = getOrCreateCell(x, y);
|
||||
final CellStyle cellStyle = this.workbook.createCellStyle();
|
||||
final CellStyle cellStyle = this.workbook.createCellStyle();
|
||||
cell.setCellStyle(cellStyle);
|
||||
return cellStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单元格样式
|
||||
*
|
||||
* @return {@link CellStyle}
|
||||
* @see Workbook#createCellStyle()
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public CellStyle createCellStyle(){
|
||||
return StyleUtil.createCellStyle(this.workbook);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取或创建某一行的样式,返回样式后可以设置样式内容<br>
|
||||
* 需要注意,此方法返回行样式,设置背景色在单元格设置值后会被覆盖,需要单独设置其单元格的样式。
|
||||
|
@ -39,7 +39,7 @@ public class StyleUtil {
|
||||
* @return {@link CellStyle}
|
||||
*/
|
||||
public static CellStyle cloneCellStyle(Workbook workbook, CellStyle cellStyle) {
|
||||
final CellStyle newCellStyle = workbook.createCellStyle();
|
||||
final CellStyle newCellStyle = createCellStyle(workbook);
|
||||
newCellStyle.cloneStyleFrom(cellStyle);
|
||||
return newCellStyle;
|
||||
}
|
||||
@ -144,6 +144,21 @@ public class StyleUtil {
|
||||
return font;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单元格样式
|
||||
*
|
||||
* @param workbook {@link Workbook} 工作簿
|
||||
* @return {@link CellStyle}
|
||||
* @see Workbook#createCellStyle()
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public static CellStyle createCellStyle(Workbook workbook) {
|
||||
if(null == workbook){
|
||||
return null;
|
||||
}
|
||||
return workbook.createCellStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建默认普通单元格样式
|
||||
*
|
||||
@ -156,7 +171,7 @@ public class StyleUtil {
|
||||
* @return {@link CellStyle}
|
||||
*/
|
||||
public static CellStyle createDefaultCellStyle(Workbook workbook) {
|
||||
final CellStyle cellStyle = workbook.createCellStyle();
|
||||
final CellStyle cellStyle = createCellStyle(workbook);
|
||||
setAlign(cellStyle, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
setBorder(cellStyle, BorderStyle.THIN, IndexedColors.BLACK);
|
||||
return cellStyle;
|
||||
@ -169,7 +184,7 @@ public class StyleUtil {
|
||||
* @return {@link CellStyle}
|
||||
*/
|
||||
public static CellStyle createHeadCellStyle(Workbook workbook) {
|
||||
final CellStyle cellStyle = workbook.createCellStyle();
|
||||
final CellStyle cellStyle = createCellStyle(workbook);
|
||||
setAlign(cellStyle, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
setBorder(cellStyle, BorderStyle.THIN, IndexedColors.BLACK);
|
||||
setColor(cellStyle, IndexedColors.GREY_25_PERCENT, FillPatternType.SOLID_FOREGROUND);
|
||||
|
Loading…
Reference in New Issue
Block a user