diff --git a/CHANGELOG.md b/CHANGELOG.md index db857215e..55470af25 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,37 @@ # 🚀Changelog +------------------------------------------------------------------------------------------------------------- +# 5.8.24(2023-12-23) + +### 🐣新特性 +* 【cache 】 Cache增加get重载,可自定义超时时间(issue#I8G0DL@Gitee) +* 【cache 】 JWT#sign增加重载,可选是否增加默认的typ参数(issue#3386@Github) +* 【db 】 增加识别OpenGauss的驱动类(issue#I8K6C0@Gitee) +* 【core 】 修复CharSequenceUtil注释和引用,避免循环引用 +* 【extra 】 SpringUtil增加getProperty重载(pr#1122@Gitee) +* 【core 】 FileTypeUtil增加null判断(issue#3419@Github) +* 【core 】 DateUtil.parse支持毫秒时间戳(issue#I8NMP7@Gitee) +* 【extra 】 优化TokenizerEngine使用IK分词器支持并发(pr#3427@Github) +* 【core 】 Opt.ofEmptyAble支持更多类型(issue#I8OOSY@Gitee) +* 【http 】 HTMLFilter保留p标签(issue#3433@Gitee) + +### 🐞Bug修复 +* 【core 】 修复LocalDateTime#parseDate未判断空问题问题(issue#I8FN7F@Gitee) +* 【http 】 修复RootAction send404 抛异常问题(pr#1107@Gitee) +* 【extra 】 修复Archiver 最后一个 Entry 为空文件夹时未关闭 Entry问题(pr#1123@Gitee) +* 【core 】 修复ImgUtil.convert png转jpg在jdk9+中失败问题(issue#I8L8UA@Gitee) +* 【cache 】 修复StampedCache的get方法非原子问题(issue#I8MEIX@Gitee) +* 【core 】 修复StrSplitter.splitByRegex使用空参数导致的OOM问题(issue#3421@Github) +* 【db 】 修复嵌套SQL中order by子句错误截断问题(issue#I89RXV@Gitee) +* 【http 】 修复graalvm编译后,未读取Content-Length可能导致的读取时间过长问题(issue#I6Q30X@Gitee) +* 【core 】 修复JavaSourceCompiler.addSource目录处理错误问题(issue#3425@Github) +* 【core 】 修复时间戳转Bean时异常问题(issue#I8NMP7@Gitee) +* 【core 】 修复PostgreSQL使用upsert字段大小写问题问题(issue#I8PB4X@Gitee) +* 【extra 】 修复TinyPinyinEngine可能的空指针问题(issue#3437@Github) +* 【core 】 修复graalvm原生打包使用http工具被转为file协议问题(issue#I8PY3Y@Gitee) +* 【poi 】 修复cloneSheet参数错误导致非XSSFWorkbook错误命名问题(issue#I8QIBB@Gitee) + ------------------------------------------------------------------------------------------------------------- # 5.8.23(2023-11-12) diff --git a/README-EN.md b/README-EN.md index 12c571594..2f7cc2c31 100755 --- a/README-EN.md +++ b/README-EN.md @@ -47,8 +47,7 @@ -------------------------------------------------------------------------------
-
-
+
-
-
+
+ * 调用此方法时,会检查上次调用时间,如果与当前时间差值大于超时时间返回{@code null},否则返回值。 + *
+ * 每次调用此方法会可选是否刷新最后访问时间,{@code true}表示会重新计算超时时间。
+ *
+ * @param key 键
+ * @param isUpdateLastAccess 是否更新最后访问时间,即重新计算超时时间。
+ * @param timeout 自定义超时时间
+ * @param supplier 如果不存在回调方法,用于生产值对象
+ * @return 值对象
+ */
+ V get(K key, boolean isUpdateLastAccess, long timeout, Func0
diff --git a/hutool-cache/src/main/java/cn/hutool/cache/impl/AbstractCache.java b/hutool-cache/src/main/java/cn/hutool/cache/impl/AbstractCache.java
index 4ea05b1ff..56f4675e2 100755
--- a/hutool-cache/src/main/java/cn/hutool/cache/impl/AbstractCache.java
+++ b/hutool-cache/src/main/java/cn/hutool/cache/impl/AbstractCache.java
@@ -109,6 +109,11 @@ public abstract class AbstractCache 例: 注意:该方法与 {@link #isEmpty(CharSequence)} 的区别是:
@@ -111,10 +105,10 @@ public class CharSequenceUtil {
*
* 例: 注意:该方法与 {@link #isNotEmpty(CharSequence)} 的区别是:
@@ -136,10 +130,10 @@ public class CharSequenceUtil {
*
* 例: 注意:该方法与 {@link #isAllBlank(CharSequence...)} 的区别在于: 例: 注意:该方法与 {@link #hasBlank(CharSequence...)} 的区别在于: 例: 注意:该方法与 {@link #isBlank(CharSequence)} 的区别是:该方法不校验空白字符。 例: 注意:该方法与 {@link #isNotBlank(CharSequence)} 的区别是:该方法不校验空白字符。 例: 注意:该方法与 {@link #isAllEmpty(CharSequence...)} 的区别在于: 例: 注意:该方法与 {@link #hasEmpty(CharSequence...)} 的区别在于: 例: 注意:该方法与 {@link #isAllEmpty(CharSequence...)} 的区别在于: a a a a
- * 参考:https://github.com/TakWolf/Java-MorseCoder
+ * 参考:https://github.com/TakWolf-Deprecated/Java-MorseCoder
*
* @author looly, TakWolf
* @since 4.4.1
diff --git a/hutool-core/src/main/java/cn/hutool/core/compiler/JavaSourceCompiler.java b/hutool-core/src/main/java/cn/hutool/core/compiler/JavaSourceCompiler.java
index b14907160..5a9f84b53 100644
--- a/hutool-core/src/main/java/cn/hutool/core/compiler/JavaSourceCompiler.java
+++ b/hutool-core/src/main/java/cn/hutool/core/compiler/JavaSourceCompiler.java
@@ -244,7 +244,7 @@ public class JavaSourceCompiler {
for (Resource resource : this.sourceList) {
if (resource instanceof FileResource) {
final File file = ((FileResource) resource).getFile();
- FileUtil.walkFiles(file, (subFile) -> list.addAll(JavaFileObjectUtil.getJavaFileObjects(file)));
+ FileUtil.walkFiles(file, (subFile) -> list.addAll(JavaFileObjectUtil.getJavaFileObjects(subFile)));
} else {
list.add(new JavaSourceFileObject(resource.getName(), resource.getStream()));
}
diff --git a/hutool-core/src/main/java/cn/hutool/core/convert/NumberWordFormatter.java b/hutool-core/src/main/java/cn/hutool/core/convert/NumberWordFormatter.java
index e835593e4..e93978015 100644
--- a/hutool-core/src/main/java/cn/hutool/core/convert/NumberWordFormatter.java
+++ b/hutool-core/src/main/java/cn/hutool/core/convert/NumberWordFormatter.java
@@ -5,7 +5,8 @@ import cn.hutool.core.util.StrUtil;
/**
* 将浮点数类型的number转换成英语的表达方式
- * 参考博客:http://blog.csdn.net/eric_sunah/article/details/8713226
+ * 参考博客:http://blog.csdn.net/eric_sunah/article/details/8713226
+ * 本质上此类为金额转英文表达,因此没有四舍五入考虑,小数点超过两位直接忽略。
*
* @author Looly,totalo
* @since 3.0.9
diff --git a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java
index a29962c3a..91badecb4 100755
--- a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java
@@ -28,7 +28,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
/**
- * 时间工具类
+ * 日期时间工具类
*
* @author xiaoleilu
* @see LocalDateTimeUtil java8日志工具类
@@ -981,6 +981,9 @@ public class DateUtil extends CalendarUtil {
return parse(dateStr, DatePattern.PURE_DATE_FORMAT);
} else if (length == DatePattern.PURE_TIME_PATTERN.length()) {
return parse(dateStr, DatePattern.PURE_TIME_FORMAT);
+ }else if(length == 13){
+ // 时间戳
+ return date(NumberUtil.parseLong(dateStr));
}
} else if (ReUtil.isMatch(PatternPool.TIME, dateStr)) {
// HH:mm:ss 或者 HH:mm 时间格式匹配单独解析
diff --git a/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java b/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java
index bdc7de543..6a08abf9d 100755
--- a/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java
@@ -318,7 +318,7 @@ public class LocalDateTimeUtil {
* @since 5.3.10
*/
public static LocalDate parseDate(CharSequence text, DateTimeFormatter formatter) {
- if (null == text) {
+ if (StrUtil.isBlank(text)) {
return null;
}
if (null == formatter) {
diff --git a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java b/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java
index a27238a39..6c9a5e0f8 100755
--- a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java
@@ -531,13 +531,7 @@ public class ImgUtil {
FileUtil.copy(srcImageFile, destImageFile, true);
}
- ImageOutputStream imageOutputStream = null;
- try {
- imageOutputStream = getImageOutputStream(destImageFile);
- convert(read(srcImageFile), destExtName, imageOutputStream, StrUtil.equalsIgnoreCase(IMAGE_TYPE_PNG, srcExtName));
- } finally {
- IoUtil.close(imageOutputStream);
- }
+ Img.from(srcImageFile).write(destImageFile);
}
/**
@@ -560,16 +554,25 @@ public class ImgUtil {
* @param srcImage 源图像流
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destImageStream 目标图像输出流
- * @param isSrcPng 源图片是否为PNG格式
* @since 4.1.14
*/
+ public static void convert(Image srcImage, String formatName, ImageOutputStream destImageStream) {
+ Img.from(srcImage).setTargetImageType(formatName).write(destImageStream);
+ }
+
+ /**
+ * 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
+ * 此方法并不关闭流
+ *
+ * @param srcImage 源图像流
+ * @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
+ * @param destImageStream 目标图像输出流
+ * @param isSrcPng 源图片是否为PNG格式(参数无效)
+ * @since 4.1.14
+ */
+ @Deprecated
public static void convert(Image srcImage, String formatName, ImageOutputStream destImageStream, boolean isSrcPng) {
- final BufferedImage src = toBufferedImage(srcImage, isSrcPng ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);
- try {
- ImageIO.write(src, formatName, destImageStream);
- } catch (IOException e) {
- throw new IORuntimeException(e);
- }
+ convert(srcImage, formatName, destImageStream);
}
// ---------------------------------------------------------------------------------------------------------------------- grey
diff --git a/hutool-core/src/main/java/cn/hutool/core/io/FileTypeUtil.java b/hutool-core/src/main/java/cn/hutool/core/io/FileTypeUtil.java
index 99bf5a9c9..cc2a83883 100644
--- a/hutool-core/src/main/java/cn/hutool/core/io/FileTypeUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/io/FileTypeUtil.java
@@ -53,7 +53,7 @@ public class FileTypeUtil {
* @return 文件类型,未找到为{@code null}
*/
public static String getType(String fileStreamHexHead) {
- if(MapUtil.isNotEmpty(FILE_TYPE_MAP)){
+ if (MapUtil.isNotEmpty(FILE_TYPE_MAP)) {
for (final Entry
* 注意此方法会读取头部一些bytes,造成此流接下来读取时缺少部分bytes
* 因此如果想复用此流,流需支持{@link InputStream#reset()}方法。
- * @param in {@link InputStream}
+ *
+ * @param in {@link InputStream}
* @param isExact 是否精确匹配,如果为false,使用前64个bytes匹配,如果为true,使用前8192bytes匹配
- * @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取流引起的异常
+ * @return 类型,文件的扩展名,提供的in为{@code null}或未找到为{@code null}
+ * @throws IORuntimeException 读取流引起的异常
*/
- public static String getType(InputStream in,boolean isExact) throws IORuntimeException {
+ public static String getType(InputStream in, boolean isExact) throws IORuntimeException {
+ if (null == in) {
+ return null;
+ }
return isExact
- ?getType(IoUtil.readHex8192Upper(in))
- :getType(IoUtil.readHex64Upper(in));
+ ? getType(IoUtil.readHex8192Upper(in))
+ : getType(IoUtil.readHex64Upper(in));
}
/**
* 根据文件流的头部信息获得文件类型
* 注意此方法会读取头部64个bytes,造成此流接下来读取时缺少部分bytes
* 因此如果想复用此流,流需支持{@link InputStream#reset()}方法。
+ *
* @param in {@link InputStream}
* @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取流引起的异常
+ * @throws IORuntimeException 读取流引起的异常
*/
- public static String getType(InputStream in) throws IORuntimeException {
- return getType(in,false);
+ public static String getType(InputStream in) throws IORuntimeException {
+ return getType(in, false);
}
/**
@@ -116,10 +121,10 @@ public class FileTypeUtil {
* @param in {@link InputStream}
* @param filename 文件名
* @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取流引起的异常
+ * @throws IORuntimeException 读取流引起的异常
*/
- public static String getType(InputStream in, String filename) throws IORuntimeException {
- return getType(in,filename,false);
+ public static String getType(InputStream in, String filename) throws IORuntimeException {
+ return getType(in, filename, false);
}
/**
@@ -132,14 +137,15 @@ public class FileTypeUtil {
* 2、xls、doc、msi头信息无法区分,按照扩展名区分
* 3、zip可能为docx、xlsx、pptx、jar、war、ofd头信息无法区分,按照扩展名区分
*
+ *
* @param in {@link InputStream}
* @param filename 文件名
- * @param isExact 是否精确匹配,如果为false,使用前64个bytes匹配,如果为true,使用前8192bytes匹配
+ * @param isExact 是否精确匹配,如果为false,使用前64个bytes匹配,如果为true,使用前8192bytes匹配
* @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取流引起的异常
+ * @throws IORuntimeException 读取流引起的异常
*/
- public static String getType(InputStream in, String filename,boolean isExact) throws IORuntimeException {
- String typeName = getType(in,isExact);
+ public static String getType(InputStream in, String filename, boolean isExact) throws IORuntimeException {
+ String typeName = getType(in, isExact);
if (null == typeName) {
// 未成功识别类型,扩展名辅助识别
typeName = FileUtil.extName(filename);
@@ -190,19 +196,19 @@ public class FileTypeUtil {
* 3、zip可能为jar、war头信息无法区分,按照扩展名区分
*
*
- * @param file 文件 {@link File}
+ * @param file 文件 {@link File}
* @param isExact 是否精确匹配,如果为false,使用前64个bytes匹配,如果为true,使用前8192bytes匹配
* @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取文件引起的异常
+ * @throws IORuntimeException 读取文件引起的异常
*/
- public static String getType(File file,boolean isExact) throws IORuntimeException {
- if(false == FileUtil.isFile(file)){
+ public static String getType(File file, boolean isExact) throws IORuntimeException {
+ if (false == FileUtil.isFile(file)) {
throw new IllegalArgumentException("Not a regular file!");
}
FileInputStream in = null;
try {
in = IoUtil.toStream(file);
- return getType(in, file.getName(),isExact);
+ return getType(in, file.getName(), isExact);
} finally {
IoUtil.close(in);
}
@@ -219,22 +225,22 @@ public class FileTypeUtil {
*
* @param file 文件 {@link File}
* @return 类型,文件的扩展名,未找到为{@code null}
- * @throws IORuntimeException 读取文件引起的异常
+ * @throws IORuntimeException 读取文件引起的异常
*/
- public static String getType(File file) throws IORuntimeException {
- return getType(file,false);
+ public static String getType(File file) throws IORuntimeException {
+ return getType(file, false);
}
/**
* 通过路径获得文件类型
*
- * @param path 路径,绝对路径或相对ClassPath的路径
+ * @param path 路径,绝对路径或相对ClassPath的路径
* @param isExact 是否精确匹配,如果为false,使用前64个bytes匹配,如果为true,使用前8192bytes匹配
* @return 类型
- * @throws IORuntimeException 读取文件引起的异常
+ * @throws IORuntimeException 读取文件引起的异常
*/
- public static String getTypeByPath(String path,boolean isExact) throws IORuntimeException {
- return getType(FileUtil.file(path),isExact);
+ public static String getTypeByPath(String path, boolean isExact) throws IORuntimeException {
+ return getType(FileUtil.file(path), isExact);
}
/**
@@ -242,10 +248,10 @@ public class FileTypeUtil {
*
* @param path 路径,绝对路径或相对ClassPath的路径
* @return 类型
- * @throws IORuntimeException 读取文件引起的异常
+ * @throws IORuntimeException 读取文件引起的异常
*/
- public static String getTypeByPath(String path) throws IORuntimeException {
- return getTypeByPath(path,false);
+ public static String getTypeByPath(String path) throws IORuntimeException {
+ return getTypeByPath(path, false);
}
diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/Opt.java b/hutool-core/src/main/java/cn/hutool/core/lang/Opt.java
index 4dd92e76a..562bd8fc6 100644
--- a/hutool-core/src/main/java/cn/hutool/core/lang/Opt.java
+++ b/hutool-core/src/main/java/cn/hutool/core/lang/Opt.java
@@ -1,8 +1,8 @@
package cn.hutool.core.lang;
-import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.func.Func0;
import cn.hutool.core.lang.func.VoidFunc0;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import java.util.Collection;
@@ -80,12 +80,12 @@ public class Opt
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- *
*
*
- * StrUtil.trimToEmpty(null) = ""
- * StrUtil.trimToEmpty("") = ""
- * StrUtil.trimToEmpty(" ") = ""
- * StrUtil.trimToEmpty("abc") = "abc"
- * StrUtil.trimToEmpty(" abc ") = "abc"
+ * CharSequenceUtil.trimToEmpty(null) = ""
+ * CharSequenceUtil.trimToEmpty("") = ""
+ * CharSequenceUtil.trimToEmpty(" ") = ""
+ * CharSequenceUtil.trimToEmpty("abc") = "abc"
+ * CharSequenceUtil.trimToEmpty(" abc ") = "abc"
*
*
* @param str 字符串
@@ -553,11 +547,11 @@ public class CharSequenceUtil {
* 除去字符串头尾部的空白,如果字符串是{@code null}或者"",返回{@code null}。
*
*
- * StrUtil.trimToNull(null) = null
- * StrUtil.trimToNull("") = null
- * StrUtil.trimToNull(" ") = null
- * StrUtil.trimToNull("abc") = "abc"
- * StrUtil.trimToEmpty(" abc ") = "abc"
+ * CharSequenceUtil.trimToNull(null) = null
+ * CharSequenceUtil.trimToNull("") = null
+ * CharSequenceUtil.trimToNull(" ") = null
+ * CharSequenceUtil.trimToNull("abc") = "abc"
+ * CharSequenceUtil.trimToEmpty(" abc ") = "abc"
*
*
* @param str 字符串
@@ -1169,17 +1163,17 @@ public class CharSequenceUtil {
* 指定范围内查找字符串,忽略大小写
*
*
- * StrUtil.indexOfIgnoreCase(null, *, *) = -1
- * StrUtil.indexOfIgnoreCase(*, null, *) = -1
- * StrUtil.indexOfIgnoreCase("", "", 0) = 0
- * StrUtil.indexOfIgnoreCase("aabaabaa", "A", 0) = 0
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 0) = 2
- * StrUtil.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 3) = 5
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 9) = -1
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
- * StrUtil.indexOfIgnoreCase("aabaabaa", "", 2) = 2
- * StrUtil.indexOfIgnoreCase("abc", "", 9) = -1
+ * CharSequenceUtil.indexOfIgnoreCase(null, *, *) = -1
+ * CharSequenceUtil.indexOfIgnoreCase(*, null, *) = -1
+ * CharSequenceUtil.indexOfIgnoreCase("", "", 0) = 0
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "A", 0) = 0
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 0) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 3) = 5
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 9) = -1
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "", 2) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("abc", "", 9) = -1
*
*
* @param str 字符串
@@ -1195,17 +1189,17 @@ public class CharSequenceUtil {
* 指定范围内查找字符串
*
*
- * StrUtil.indexOfIgnoreCase(null, *, *) = -1
- * StrUtil.indexOfIgnoreCase(*, null, *) = -1
- * StrUtil.indexOfIgnoreCase("", "", 0) = 0
- * StrUtil.indexOfIgnoreCase("aabaabaa", "A", 0) = 0
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 0) = 2
- * StrUtil.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 3) = 5
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", 9) = -1
- * StrUtil.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
- * StrUtil.indexOfIgnoreCase("aabaabaa", "", 2) = 2
- * StrUtil.indexOfIgnoreCase("abc", "", 9) = -1
+ * CharSequenceUtil.indexOfIgnoreCase(null, *, *) = -1
+ * CharSequenceUtil.indexOfIgnoreCase(*, null, *) = -1
+ * CharSequenceUtil.indexOfIgnoreCase("", "", 0) = 0
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "A", 0) = 0
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 0) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 3) = 5
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", 9) = -1
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("aabaabaa", "", 2) = 2
+ * CharSequenceUtil.indexOfIgnoreCase("abc", "", 9) = -1
*
*
* @param str 字符串
@@ -1230,7 +1224,7 @@ public class CharSequenceUtil {
*/
public static int indexOf(CharSequence text, CharSequence searchStr, int from, boolean ignoreCase) {
if (isEmpty(text) || isEmpty(searchStr)) {
- if (StrUtil.equals(text, searchStr)) {
+ if (CharSequenceUtil.equals(text, searchStr)) {
return 0;
} else {
return INDEX_NOT_FOUND;
@@ -1278,7 +1272,7 @@ public class CharSequenceUtil {
*/
public static int lastIndexOf(CharSequence text, CharSequence searchStr, int from, boolean ignoreCase) {
if (isEmpty(text) || isEmpty(searchStr)) {
- if (StrUtil.equals(text, searchStr)) {
+ if (CharSequenceUtil.equals(text, searchStr)) {
return 0;
} else {
return INDEX_NOT_FOUND;
@@ -1298,17 +1292,17 @@ public class CharSequenceUtil {
* 例子(*代表任意字符):
*
*
- * StrUtil.ordinalIndexOf(null, *, *) = -1
- * StrUtil.ordinalIndexOf(*, null, *) = -1
- * StrUtil.ordinalIndexOf("", "", *) = 0
- * StrUtil.ordinalIndexOf("aabaabaa", "a", 1) = 0
- * StrUtil.ordinalIndexOf("aabaabaa", "a", 2) = 1
- * StrUtil.ordinalIndexOf("aabaabaa", "b", 1) = 2
- * StrUtil.ordinalIndexOf("aabaabaa", "b", 2) = 5
- * StrUtil.ordinalIndexOf("aabaabaa", "ab", 1) = 1
- * StrUtil.ordinalIndexOf("aabaabaa", "ab", 2) = 4
- * StrUtil.ordinalIndexOf("aabaabaa", "", 1) = 0
- * StrUtil.ordinalIndexOf("aabaabaa", "", 2) = 0
+ * CharSequenceUtil.ordinalIndexOf(null, *, *) = -1
+ * CharSequenceUtil.ordinalIndexOf(*, null, *) = -1
+ * CharSequenceUtil.ordinalIndexOf("", "", *) = 0
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "a", 1) = 0
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "a", 2) = 1
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "b", 1) = 2
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "b", 2) = 5
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "ab", 1) = 1
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "ab", 2) = 4
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "", 1) = 0
+ * CharSequenceUtil.ordinalIndexOf("aabaabaa", "", 2) = 0
*
*
* @param str 被检查的字符串,可以为null
@@ -2106,13 +2100,13 @@ public class CharSequenceUtil {
* 切割指定长度的后部分的字符串
*
*
- * StrUtil.subSufByLength("abcde", 3) = "cde"
- * StrUtil.subSufByLength("abcde", 0) = ""
- * StrUtil.subSufByLength("abcde", -5) = ""
- * StrUtil.subSufByLength("abcde", -1) = ""
- * StrUtil.subSufByLength("abcde", 5) = "abcde"
- * StrUtil.subSufByLength("abcde", 10) = "abcde"
- * StrUtil.subSufByLength(null, 3) = null
+ * CharSequenceUtil.subSufByLength("abcde", 3) = "cde"
+ * CharSequenceUtil.subSufByLength("abcde", 0) = ""
+ * CharSequenceUtil.subSufByLength("abcde", -5) = ""
+ * CharSequenceUtil.subSufByLength("abcde", -1) = ""
+ * CharSequenceUtil.subSufByLength("abcde", 5) = "abcde"
+ * CharSequenceUtil.subSufByLength("abcde", 10) = "abcde"
+ * CharSequenceUtil.subSufByLength(null, 3) = null
*
*
* @param string 字符串
@@ -2156,14 +2150,14 @@ public class CharSequenceUtil {
* 如果分隔字符串为空串"",则返回空串,如果分隔字符串未找到,返回原字符串,举例如下:
*
*
- * StrUtil.subBefore(null, *, false) = null
- * StrUtil.subBefore("", *, false) = ""
- * StrUtil.subBefore("abc", "a", false) = ""
- * StrUtil.subBefore("abcba", "b", false) = "a"
- * StrUtil.subBefore("abc", "c", false) = "ab"
- * StrUtil.subBefore("abc", "d", false) = "abc"
- * StrUtil.subBefore("abc", "", false) = ""
- * StrUtil.subBefore("abc", null, false) = "abc"
+ * CharSequenceUtil.subBefore(null, *, false) = null
+ * CharSequenceUtil.subBefore("", *, false) = ""
+ * CharSequenceUtil.subBefore("abc", "a", false) = ""
+ * CharSequenceUtil.subBefore("abcba", "b", false) = "a"
+ * CharSequenceUtil.subBefore("abc", "c", false) = "ab"
+ * CharSequenceUtil.subBefore("abc", "d", false) = "abc"
+ * CharSequenceUtil.subBefore("abc", "", false) = ""
+ * CharSequenceUtil.subBefore("abc", null, false) = "abc"
*
*
* @param string 被查找的字符串
@@ -2198,12 +2192,12 @@ public class CharSequenceUtil {
* 如果分隔字符串未找到,返回原字符串,举例如下:
*
*
- * StrUtil.subBefore(null, *, false) = null
- * StrUtil.subBefore("", *, false) = ""
- * StrUtil.subBefore("abc", 'a', false) = ""
- * StrUtil.subBefore("abcba", 'b', false) = "a"
- * StrUtil.subBefore("abc", 'c', false) = "ab"
- * StrUtil.subBefore("abc", 'd', false) = "abc"
+ * CharSequenceUtil.subBefore(null, *, false) = null
+ * CharSequenceUtil.subBefore("", *, false) = ""
+ * CharSequenceUtil.subBefore("abc", 'a', false) = ""
+ * CharSequenceUtil.subBefore("abcba", 'b', false) = "a"
+ * CharSequenceUtil.subBefore("abc", 'c', false) = "ab"
+ * CharSequenceUtil.subBefore("abc", 'd', false) = "abc"
*
*
* @param string 被查找的字符串
@@ -2234,14 +2228,14 @@ public class CharSequenceUtil {
* 如果分隔字符串为空串(null或""),则返回空串,如果分隔字符串未找到,返回空串,举例如下:
*
*
- * StrUtil.subAfter(null, *, false) = null
- * StrUtil.subAfter("", *, false) = ""
- * StrUtil.subAfter(*, null, false) = ""
- * StrUtil.subAfter("abc", "a", false) = "bc"
- * StrUtil.subAfter("abcba", "b", false) = "cba"
- * StrUtil.subAfter("abc", "c", false) = ""
- * StrUtil.subAfter("abc", "d", false) = ""
- * StrUtil.subAfter("abc", "", false) = "abc"
+ * CharSequenceUtil.subAfter(null, *, false) = null
+ * CharSequenceUtil.subAfter("", *, false) = ""
+ * CharSequenceUtil.subAfter(*, null, false) = ""
+ * CharSequenceUtil.subAfter("abc", "a", false) = "bc"
+ * CharSequenceUtil.subAfter("abcba", "b", false) = "cba"
+ * CharSequenceUtil.subAfter("abc", "c", false) = ""
+ * CharSequenceUtil.subAfter("abc", "d", false) = ""
+ * CharSequenceUtil.subAfter("abc", "", false) = "abc"
*
*
* @param string 被查找的字符串
@@ -2272,12 +2266,12 @@ public class CharSequenceUtil {
* 如果分隔字符串为空串(null或""),则返回空串,如果分隔字符串未找到,返回空串,举例如下:
*
*
- * StrUtil.subAfter(null, *, false) = null
- * StrUtil.subAfter("", *, false) = ""
- * StrUtil.subAfter("abc", 'a', false) = "bc"
- * StrUtil.subAfter("abcba", 'b', false) = "cba"
- * StrUtil.subAfter("abc", 'c', false) = ""
- * StrUtil.subAfter("abc", 'd', false) = ""
+ * CharSequenceUtil.subAfter(null, *, false) = null
+ * CharSequenceUtil.subAfter("", *, false) = ""
+ * CharSequenceUtil.subAfter("abc", 'a', false) = "bc"
+ * CharSequenceUtil.subAfter("abcba", 'b', false) = "cba"
+ * CharSequenceUtil.subAfter("abc", 'c', false) = ""
+ * CharSequenceUtil.subAfter("abc", 'd', false) = ""
*
*
* @param string 被查找的字符串
@@ -2304,16 +2298,16 @@ public class CharSequenceUtil {
* 栗子:
*
*
- * StrUtil.subBetween("wx[b]yz", "[", "]") = "b"
- * StrUtil.subBetween(null, *, *) = null
- * StrUtil.subBetween(*, null, *) = null
- * StrUtil.subBetween(*, *, null) = null
- * StrUtil.subBetween("", "", "") = ""
- * StrUtil.subBetween("", "", "]") = null
- * StrUtil.subBetween("", "[", "]") = null
- * StrUtil.subBetween("yabcz", "", "") = ""
- * StrUtil.subBetween("yabcz", "y", "z") = "abc"
- * StrUtil.subBetween("yabczyabcz", "y", "z") = "abc"
+ * CharSequenceUtil.subBetween("wx[b]yz", "[", "]") = "b"
+ * CharSequenceUtil.subBetween(null, *, *) = null
+ * CharSequenceUtil.subBetween(*, null, *) = null
+ * CharSequenceUtil.subBetween(*, *, null) = null
+ * CharSequenceUtil.subBetween("", "", "") = ""
+ * CharSequenceUtil.subBetween("", "", "]") = null
+ * CharSequenceUtil.subBetween("", "[", "]") = null
+ * CharSequenceUtil.subBetween("yabcz", "", "") = ""
+ * CharSequenceUtil.subBetween("yabcz", "y", "z") = "abc"
+ * CharSequenceUtil.subBetween("yabczyabcz", "y", "z") = "abc"
*
*
* @param str 被切割的字符串
@@ -2347,12 +2341,12 @@ public class CharSequenceUtil {
* 栗子:
*
*
- * StrUtil.subBetween(null, *) = null
- * StrUtil.subBetween("", "") = ""
- * StrUtil.subBetween("", "tag") = null
- * StrUtil.subBetween("tagabctag", null) = null
- * StrUtil.subBetween("tagabctag", "") = ""
- * StrUtil.subBetween("tagabctag", "tag") = "abc"
+ * CharSequenceUtil.subBetween(null, *) = null
+ * CharSequenceUtil.subBetween("", "") = ""
+ * CharSequenceUtil.subBetween("", "tag") = null
+ * CharSequenceUtil.subBetween("tagabctag", null) = null
+ * CharSequenceUtil.subBetween("tagabctag", "") = ""
+ * CharSequenceUtil.subBetween("tagabctag", "tag") = "abc"
*
*
* @param str 被切割的字符串
@@ -2370,17 +2364,17 @@ public class CharSequenceUtil {
* 栗子:
*
*
- * StrUtil.subBetweenAll("wx[b]y[z]", "[", "]") = ["b","z"]
- * StrUtil.subBetweenAll(null, *, *) = []
- * StrUtil.subBetweenAll(*, null, *) = []
- * StrUtil.subBetweenAll(*, *, null) = []
- * StrUtil.subBetweenAll("", "", "") = []
- * StrUtil.subBetweenAll("", "", "]") = []
- * StrUtil.subBetweenAll("", "[", "]") = []
- * StrUtil.subBetweenAll("yabcz", "", "") = []
- * StrUtil.subBetweenAll("yabcz", "y", "z") = ["abc"]
- * StrUtil.subBetweenAll("yabczyabcz", "y", "z") = ["abc","abc"]
- * StrUtil.subBetweenAll("[yabc[zy]abcz]", "[", "]"); = ["zy"] 重叠时只截取内部,
+ * CharSequenceUtil.subBetweenAll("wx[b]y[z]", "[", "]") = ["b","z"]
+ * CharSequenceUtil.subBetweenAll(null, *, *) = []
+ * CharSequenceUtil.subBetweenAll(*, null, *) = []
+ * CharSequenceUtil.subBetweenAll(*, *, null) = []
+ * CharSequenceUtil.subBetweenAll("", "", "") = []
+ * CharSequenceUtil.subBetweenAll("", "", "]") = []
+ * CharSequenceUtil.subBetweenAll("", "[", "]") = []
+ * CharSequenceUtil.subBetweenAll("yabcz", "", "") = []
+ * CharSequenceUtil.subBetweenAll("yabcz", "y", "z") = ["abc"]
+ * CharSequenceUtil.subBetweenAll("yabczyabcz", "y", "z") = ["abc","abc"]
+ * CharSequenceUtil.subBetweenAll("[yabc[zy]abcz]", "[", "]"); = ["zy"] 重叠时只截取内部,
*
*
* @param str 被切割的字符串
@@ -2425,15 +2419,15 @@ public class CharSequenceUtil {
* 栗子:
*
*
- * StrUtil.subBetweenAll(null, *) = []
- * StrUtil.subBetweenAll(*, null) = []
- * StrUtil.subBetweenAll(*, *) = []
- * StrUtil.subBetweenAll("", "") = []
- * StrUtil.subBetweenAll("", "#") = []
- * StrUtil.subBetweenAll("gotanks", "") = []
- * StrUtil.subBetweenAll("#gotanks#", "#") = ["gotanks"]
- * StrUtil.subBetweenAll("#hello# #world#!", "#") = ["hello", "world"]
- * StrUtil.subBetweenAll("#hello# world#!", "#"); = ["hello"]
+ * CharSequenceUtil.subBetweenAll(null, *) = []
+ * CharSequenceUtil.subBetweenAll(*, null) = []
+ * CharSequenceUtil.subBetweenAll(*, *) = []
+ * CharSequenceUtil.subBetweenAll("", "") = []
+ * CharSequenceUtil.subBetweenAll("", "#") = []
+ * CharSequenceUtil.subBetweenAll("gotanks", "") = []
+ * CharSequenceUtil.subBetweenAll("#gotanks#", "#") = ["gotanks"]
+ * CharSequenceUtil.subBetweenAll("#hello# #world#!", "#") = ["hello", "world"]
+ * CharSequenceUtil.subBetweenAll("#hello# world#!", "#"); = ["hello"]
*
*
* @param str 被切割的字符串
@@ -2452,9 +2446,9 @@ public class CharSequenceUtil {
* 重复某个字符
*
*
- * StrUtil.repeat('e', 0) = ""
- * StrUtil.repeat('e', 3) = "eee"
- * StrUtil.repeat('e', -2) = ""
+ * CharSequenceUtil.repeat('e', 0) = ""
+ * CharSequenceUtil.repeat('e', 3) = "eee"
+ * CharSequenceUtil.repeat('e', -2) = ""
*
*
* @param c 被重复的字符
@@ -2522,7 +2516,7 @@ public class CharSequenceUtil {
return null;
}
if (padLen <= 0) {
- return StrUtil.EMPTY;
+ return CharSequenceUtil.EMPTY;
}
final int strLen = str.length();
if (strLen == padLen) {
@@ -2543,9 +2537,9 @@ public class CharSequenceUtil {
* 重复某个字符串并通过分界符连接
*
*
- * StrUtil.repeatAndJoin("?", 5, ",") = "?,?,?,?,?"
- * StrUtil.repeatAndJoin("?", 0, ",") = ""
- * StrUtil.repeatAndJoin("?", 5, null) = "?????"
+ * CharSequenceUtil.repeatAndJoin("?", 5, ",") = "?,?,?,?,?"
+ * CharSequenceUtil.repeatAndJoin("?", 0, ",") = ""
+ * CharSequenceUtil.repeatAndJoin("?", 5, null) = "?????"
*
*
* @param str 被重复的字符串
@@ -3071,10 +3065,10 @@ public class CharSequenceUtil {
* 同:leftPad (org.apache.commons.lang3.leftPad)
*
*
- * StrUtil.padPre(null, *, *);//null
- * StrUtil.padPre("1", 3, "ABC");//"AB1"
- * StrUtil.padPre("123", 2, "ABC");//"12"
- * StrUtil.padPre("1039", -1, "0");//"103"
+ * CharSequenceUtil.padPre(null, *, *);//null
+ * CharSequenceUtil.padPre("1", 3, "ABC");//"AB1"
+ * CharSequenceUtil.padPre("123", 2, "ABC");//"12"
+ * CharSequenceUtil.padPre("1039", -1, "0");//"103"
*
*
* @param str 字符串
@@ -3102,9 +3096,9 @@ public class CharSequenceUtil {
* 同:leftPad (org.apache.commons.lang3.leftPad)
*
*
- * StrUtil.padPre(null, *, *);//null
- * StrUtil.padPre("1", 3, '0');//"001"
- * StrUtil.padPre("123", 2, '0');//"12"
+ * CharSequenceUtil.padPre(null, *, *);//null
+ * CharSequenceUtil.padPre("1", 3, '0');//"001"
+ * CharSequenceUtil.padPre("123", 2, '0');//"12"
*
*
* @param str 字符串
@@ -3131,10 +3125,10 @@ public class CharSequenceUtil {
* 补充字符串以满足最小长度,如果提供的字符串大于指定长度,截断之
*
*
- * StrUtil.padAfter(null, *, *);//null
- * StrUtil.padAfter("1", 3, '0');//"100"
- * StrUtil.padAfter("123", 2, '0');//"23"
- * StrUtil.padAfter("123", -1, '0')//"" 空串
+ * CharSequenceUtil.padAfter(null, *, *);//null
+ * CharSequenceUtil.padAfter("1", 3, '0');//"100"
+ * CharSequenceUtil.padAfter("123", 2, '0');//"23"
+ * CharSequenceUtil.padAfter("123", -1, '0')//"" 空串
*
*
* @param str 字符串,如果为{@code null},直接返回null
@@ -3161,9 +3155,9 @@ public class CharSequenceUtil {
* 补充字符串以满足最小长度
*
*
- * StrUtil.padAfter(null, *, *);//null
- * StrUtil.padAfter("1", 3, "ABC");//"1AB"
- * StrUtil.padAfter("123", 2, "ABC");//"23"
+ * CharSequenceUtil.padAfter(null, *, *);//null
+ * CharSequenceUtil.padAfter("1", 3, "ABC");//"1AB"
+ * CharSequenceUtil.padAfter("123", 2, "ABC");//"23"
*
*
* @param str 字符串,如果为{@code null},直接返回null
@@ -3193,12 +3187,12 @@ public class CharSequenceUtil {
* 居中字符串,两边补充指定字符串,如果指定长度小于字符串,则返回原字符串
*
*
- * StrUtil.center(null, *) = null
- * StrUtil.center("", 4) = " "
- * StrUtil.center("ab", -1) = "ab"
- * StrUtil.center("ab", 4) = " ab "
- * StrUtil.center("abcd", 2) = "abcd"
- * StrUtil.center("a", 4) = " a "
+ * CharSequenceUtil.center(null, *) = null
+ * CharSequenceUtil.center("", 4) = " "
+ * CharSequenceUtil.center("ab", -1) = "ab"
+ * CharSequenceUtil.center("ab", 4) = " ab "
+ * CharSequenceUtil.center("abcd", 2) = "abcd"
+ * CharSequenceUtil.center("a", 4) = " a "
*
*
* @param str 字符串
@@ -3214,14 +3208,14 @@ public class CharSequenceUtil {
* 居中字符串,两边补充指定字符串,如果指定长度小于字符串,则返回原字符串
*
*
- * StrUtil.center(null, *, *) = null
- * StrUtil.center("", 4, ' ') = " "
- * StrUtil.center("ab", -1, ' ') = "ab"
- * StrUtil.center("ab", 4, ' ') = " ab "
- * StrUtil.center("abcd", 2, ' ') = "abcd"
- * StrUtil.center("a", 4, ' ') = " a "
- * StrUtil.center("a", 4, 'y') = "yayy"
- * StrUtil.center("abc", 7, ' ') = " abc "
+ * CharSequenceUtil.center(null, *, *) = null
+ * CharSequenceUtil.center("", 4, ' ') = " "
+ * CharSequenceUtil.center("ab", -1, ' ') = "ab"
+ * CharSequenceUtil.center("ab", 4, ' ') = " ab "
+ * CharSequenceUtil.center("abcd", 2, ' ') = "abcd"
+ * CharSequenceUtil.center("a", 4, ' ') = " a "
+ * CharSequenceUtil.center("a", 4, 'y') = "yayy"
+ * CharSequenceUtil.center("abc", 7, ' ') = " abc "
*
*
* @param str 字符串
@@ -3248,15 +3242,15 @@ public class CharSequenceUtil {
* 居中字符串,两边补充指定字符串,如果指定长度小于字符串,则返回原字符串
*
*
- * StrUtil.center(null, *, *) = null
- * StrUtil.center("", 4, " ") = " "
- * StrUtil.center("ab", -1, " ") = "ab"
- * StrUtil.center("ab", 4, " ") = " ab "
- * StrUtil.center("abcd", 2, " ") = "abcd"
- * StrUtil.center("a", 4, " ") = " a "
- * StrUtil.center("a", 4, "yz") = "yayz"
- * StrUtil.center("abc", 7, null) = " abc "
- * StrUtil.center("abc", 7, "") = " abc "
+ * CharSequenceUtil.center(null, *, *) = null
+ * CharSequenceUtil.center("", 4, " ") = " "
+ * CharSequenceUtil.center("ab", -1, " ") = "ab"
+ * CharSequenceUtil.center("ab", 4, " ") = " ab "
+ * CharSequenceUtil.center("abcd", 2, " ") = "abcd"
+ * CharSequenceUtil.center("a", 4, " ") = " a "
+ * CharSequenceUtil.center("a", 4, "yz") = "yayz"
+ * CharSequenceUtil.center("abc", 7, null) = " abc "
+ * CharSequenceUtil.center("abc", 7, "") = " abc "
*
*
* @param str 字符串
@@ -3300,13 +3294,13 @@ public class CharSequenceUtil {
* 参数为 {@code null} 或者 "" 返回 {@code 0}.
*
*
- * StrUtil.count(null, *) = 0
- * StrUtil.count("", *) = 0
- * StrUtil.count("abba", null) = 0
- * StrUtil.count("abba", "") = 0
- * StrUtil.count("abba", "a") = 2
- * StrUtil.count("abba", "ab") = 1
- * StrUtil.count("abba", "xxx") = 0
+ * CharSequenceUtil.count(null, *) = 0
+ * CharSequenceUtil.count("", *) = 0
+ * CharSequenceUtil.count("abba", null) = 0
+ * CharSequenceUtil.count("abba", "") = 0
+ * CharSequenceUtil.count("abba", "a") = 2
+ * CharSequenceUtil.count("abba", "ab") = 1
+ * CharSequenceUtil.count("abba", "xxx") = 0
*
*
* @param content 被查找的字符串
@@ -3356,16 +3350,16 @@ public class CharSequenceUtil {
* 比较两个字符串,用于排序
*
*
- * StrUtil.compare(null, null, *) = 0
- * StrUtil.compare(null , "a", true) < 0
- * StrUtil.compare(null , "a", false) > 0
- * StrUtil.compare("a", null, true) > 0
- * StrUtil.compare("a", null, false) < 0
- * StrUtil.compare("abc", "abc", *) = 0
- * StrUtil.compare("a", "b", *) < 0
- * StrUtil.compare("b", "a", *) > 0
- * StrUtil.compare("a", "B", *) > 0
- * StrUtil.compare("ab", "abc", *) < 0
+ * CharSequenceUtil.compare(null, null, *) = 0
+ * CharSequenceUtil.compare(null , "a", true) < 0
+ * CharSequenceUtil.compare(null , "a", false) > 0
+ * CharSequenceUtil.compare("a", null, true) > 0
+ * CharSequenceUtil.compare("a", null, false) < 0
+ * CharSequenceUtil.compare("abc", "abc", *) = 0
+ * CharSequenceUtil.compare("a", "b", *) < 0
+ * CharSequenceUtil.compare("b", "a", *) > 0
+ * CharSequenceUtil.compare("a", "B", *) > 0
+ * CharSequenceUtil.compare("ab", "abc", *) < 0
*
*
* @param str1 字符串1
@@ -3390,18 +3384,18 @@ public class CharSequenceUtil {
* 比较两个字符串,用于排序,大小写不敏感
*
*
- * StrUtil.compareIgnoreCase(null, null, *) = 0
- * StrUtil.compareIgnoreCase(null , "a", true) < 0
- * StrUtil.compareIgnoreCase(null , "a", false) > 0
- * StrUtil.compareIgnoreCase("a", null, true) > 0
- * StrUtil.compareIgnoreCase("a", null, false) < 0
- * StrUtil.compareIgnoreCase("abc", "abc", *) = 0
- * StrUtil.compareIgnoreCase("abc", "ABC", *) = 0
- * StrUtil.compareIgnoreCase("a", "b", *) < 0
- * StrUtil.compareIgnoreCase("b", "a", *) > 0
- * StrUtil.compareIgnoreCase("a", "B", *) < 0
- * StrUtil.compareIgnoreCase("A", "b", *) < 0
- * StrUtil.compareIgnoreCase("ab", "abc", *) < 0
+ * CharSequenceUtil.compareIgnoreCase(null, null, *) = 0
+ * CharSequenceUtil.compareIgnoreCase(null , "a", true) < 0
+ * CharSequenceUtil.compareIgnoreCase(null , "a", false) > 0
+ * CharSequenceUtil.compareIgnoreCase("a", null, true) > 0
+ * CharSequenceUtil.compareIgnoreCase("a", null, false) < 0
+ * CharSequenceUtil.compareIgnoreCase("abc", "abc", *) = 0
+ * CharSequenceUtil.compareIgnoreCase("abc", "ABC", *) = 0
+ * CharSequenceUtil.compareIgnoreCase("a", "b", *) < 0
+ * CharSequenceUtil.compareIgnoreCase("b", "a", *) > 0
+ * CharSequenceUtil.compareIgnoreCase("a", "B", *) < 0
+ * CharSequenceUtil.compareIgnoreCase("A", "b", *) < 0
+ * CharSequenceUtil.compareIgnoreCase("ab", "abc", *) < 0
*
*
* @param str1 字符串1
@@ -3427,14 +3421,14 @@ public class CharSequenceUtil {
* null版本排在最小:即:
*
*
- * StrUtil.compareVersion(null, "v1") < 0
- * StrUtil.compareVersion("v1", "v1") = 0
- * StrUtil.compareVersion(null, null) = 0
- * StrUtil.compareVersion("v1", null) > 0
- * StrUtil.compareVersion("1.0.0", "1.0.2") < 0
- * StrUtil.compareVersion("1.0.2", "1.0.2a") < 0
- * StrUtil.compareVersion("1.13.0", "1.12.1c") > 0
- * StrUtil.compareVersion("V0.0.20170102", "V0.0.20170101") > 0
+ * CharSequenceUtil.compareVersion(null, "v1") < 0
+ * CharSequenceUtil.compareVersion("v1", "v1") = 0
+ * CharSequenceUtil.compareVersion(null, null) = 0
+ * CharSequenceUtil.compareVersion("v1", null) > 0
+ * CharSequenceUtil.compareVersion("1.0.0", "1.0.2") < 0
+ * CharSequenceUtil.compareVersion("1.0.2", "1.0.2a") < 0
+ * CharSequenceUtil.compareVersion("1.13.0", "1.12.1c") > 0
+ * CharSequenceUtil.compareVersion("V0.0.20170102", "V0.0.20170101") > 0
*
*
* @param version1 版本1
@@ -3828,13 +3822,13 @@ public class CharSequenceUtil {
* 俗称:脱敏功能,后面其他功能,可以见:DesensitizedUtil(脱敏工具类)
*
*
- * StrUtil.hide(null,*,*)=null
- * StrUtil.hide("",0,*)=""
- * StrUtil.hide("jackduan@163.com",-1,4) ****duan@163.com
- * StrUtil.hide("jackduan@163.com",2,3) ja*kduan@163.com
- * StrUtil.hide("jackduan@163.com",3,2) jackduan@163.com
- * StrUtil.hide("jackduan@163.com",16,16) jackduan@163.com
- * StrUtil.hide("jackduan@163.com",16,17) jackduan@163.com
+ * CharSequenceUtil.hide(null,*,*)=null
+ * CharSequenceUtil.hide("",0,*)=""
+ * CharSequenceUtil.hide("jackduan@163.com",-1,4) ****duan@163.com
+ * CharSequenceUtil.hide("jackduan@163.com",2,3) ja*kduan@163.com
+ * CharSequenceUtil.hide("jackduan@163.com",3,2) jackduan@163.com
+ * CharSequenceUtil.hide("jackduan@163.com",16,16) jackduan@163.com
+ * CharSequenceUtil.hide("jackduan@163.com",16,17) jackduan@163.com
*
*
* @param str 字符串
@@ -3851,16 +3845,16 @@ public class CharSequenceUtil {
* 脱敏,使用默认的脱敏策略
*
*
- * StrUtil.desensitized("100", DesensitizedUtil.DesensitizedType.USER_ID)) = "0"
- * StrUtil.desensitized("段正淳", DesensitizedUtil.DesensitizedType.CHINESE_NAME)) = "段**"
- * StrUtil.desensitized("51343620000320711X", DesensitizedUtil.DesensitizedType.ID_CARD)) = "5***************1X"
- * StrUtil.desensitized("09157518479", DesensitizedUtil.DesensitizedType.FIXED_PHONE)) = "0915*****79"
- * StrUtil.desensitized("18049531999", DesensitizedUtil.DesensitizedType.MOBILE_PHONE)) = "180****1999"
- * StrUtil.desensitized("北京市海淀区马连洼街道289号", DesensitizedUtil.DesensitizedType.ADDRESS)) = "北京市海淀区马********"
- * StrUtil.desensitized("duandazhi-jack@gmail.com.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.com.cn"
- * StrUtil.desensitized("1234567890", DesensitizedUtil.DesensitizedType.PASSWORD)) = "**********"
- * StrUtil.desensitized("苏D40000", DesensitizedUtil.DesensitizedType.CAR_LICENSE)) = "苏D4***0"
- * StrUtil.desensitized("11011111222233333256", DesensitizedType.BANK_CARD)) = "1101 **** **** **** 3256"
+ * CharSequenceUtil.desensitized("100", DesensitizedUtil.DesensitizedType.USER_ID)) = "0"
+ * CharSequenceUtil.desensitized("段正淳", DesensitizedUtil.DesensitizedType.CHINESE_NAME)) = "段**"
+ * CharSequenceUtil.desensitized("51343620000320711X", DesensitizedUtil.DesensitizedType.ID_CARD)) = "5***************1X"
+ * CharSequenceUtil.desensitized("09157518479", DesensitizedUtil.DesensitizedType.FIXED_PHONE)) = "0915*****79"
+ * CharSequenceUtil.desensitized("18049531999", DesensitizedUtil.DesensitizedType.MOBILE_PHONE)) = "180****1999"
+ * CharSequenceUtil.desensitized("北京市海淀区马连洼街道289号", DesensitizedUtil.DesensitizedType.ADDRESS)) = "北京市海淀区马********"
+ * CharSequenceUtil.desensitized("duandazhi-jack@gmail.com.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.com.cn"
+ * CharSequenceUtil.desensitized("1234567890", DesensitizedUtil.DesensitizedType.PASSWORD)) = "**********"
+ * CharSequenceUtil.desensitized("苏D40000", DesensitizedUtil.DesensitizedType.CAR_LICENSE)) = "苏D4***0"
+ * CharSequenceUtil.desensitized("11011111222233333256", DesensitizedType.BANK_CARD)) = "1101 **** **** **** 3256"
*
*
* @param str 字符串
@@ -4005,7 +3999,7 @@ public class CharSequenceUtil {
*/
@SuppressWarnings("unchecked")
public static
- * StrUtil.swapCase(null) = null
- * StrUtil.swapCase("") = ""
- * StrUtil.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
+ * CharSequenceUtil.swapCase(null) = null
+ * CharSequenceUtil.swapCase("") = ""
+ * CharSequenceUtil.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
*
*
* @param str 字符串
@@ -4257,7 +4251,7 @@ public class CharSequenceUtil {
* @return 是否包围,空串不包围
*/
public static boolean isSurround(CharSequence str, CharSequence prefix, CharSequence suffix) {
- if (StrUtil.isBlank(str)) {
+ if (CharSequenceUtil.isBlank(str)) {
return false;
}
if (str.length() < (prefix.length() + suffix.length())) {
@@ -4277,7 +4271,7 @@ public class CharSequenceUtil {
* @return 是否包围,空串不包围
*/
public static boolean isSurround(CharSequence str, char prefix, char suffix) {
- if (StrUtil.isBlank(str)) {
+ if (CharSequenceUtil.isBlank(str)) {
return false;
}
if (str.length() < 2) {
@@ -4462,7 +4456,7 @@ public class CharSequenceUtil {
* @since 3.2.3
*/
public static boolean isAllCharMatch(CharSequence value, Matcher
+ * 此方法用于截取总bytes数不超过指定长度,如果字符出没有超出原样输出,如果超出了,则截取掉超出部分,并可选添加...,
+ * 但是添加“...”后总长度也不超过限制长度。
*
* @param str 原始字符串
* @param charset 指定编码
diff --git a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java
index a66463e67..f4d384a61 100644
--- a/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java
+++ b/hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java
@@ -147,6 +147,14 @@ public class URLUtil extends URLEncodeUtil {
try {
return new URL(null, url, handler);
} catch (MalformedURLException e) {
+ // issue#I8PY3Y
+ if(e.getMessage().contains("Accessing an URL protocol that was not enabled")){
+ // Graalvm打包需要手动指定参数开启协议:
+ // --enable-url-protocols=http
+ // --enable-url-protocols=https
+ throw new UtilException(e);
+ }
+
// 尝试文件路径
try {
return new File(url).toURI().toURL();
diff --git a/hutool-core/src/test/java/cn/hutool/core/annotation/TestIssueI8CLBJ.java b/hutool-core/src/test/java/cn/hutool/core/annotation/TestIssueI8CLBJ.java
index 04c2a9267..fd80af15d 100644
--- a/hutool-core/src/test/java/cn/hutool/core/annotation/TestIssueI8CLBJ.java
+++ b/hutool-core/src/test/java/cn/hutool/core/annotation/TestIssueI8CLBJ.java
@@ -30,7 +30,7 @@ public class TestIssueI8CLBJ {
Thread thread = new Thread(() -> {
try {
String valueFieldName = annotation.valueFieldName();
- System.out.println("valueFieldName:" + valueFieldName);
+ //Console.log("valueFieldName:" + valueFieldName);
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/hutool-core/src/test/java/cn/hutool/core/bean/IssueI8JASOTest.java b/hutool-core/src/test/java/cn/hutool/core/bean/IssueI8JASOTest.java
new file mode 100644
index 000000000..93bc9753d
--- /dev/null
+++ b/hutool-core/src/test/java/cn/hutool/core/bean/IssueI8JASOTest.java
@@ -0,0 +1,33 @@
+package cn.hutool.core.bean;
+
+import cn.hutool.core.annotation.Alias;
+import lombok.Data;
+import lombok.Setter;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class IssueI8JASOTest {
+
+ @Test
+ public void copyTest() {
+ final UserOne userOne = new UserOne();
+ userOne.setEmail("123@qq.com");
+ final UserTwo userTwo = new UserTwo();
+ BeanUtil.copyProperties(userOne, userTwo);
+ Assert.assertEquals(userOne.getEmail(), userTwo.getEmail());
+ }
+
+ @Data
+ public static class UserOne {
+ private Long id;
+ @Alias("邮箱")
+ private String email;
+ }
+
+ @Data
+ public static class UserTwo {
+ private Long id;
+ @Alias("邮箱")
+ private String email;
+ }
+}
diff --git a/hutool-core/src/test/java/cn/hutool/core/date/DateUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/date/DateUtilTest.java
index 776615120..02c72ae41 100755
--- a/hutool-core/src/test/java/cn/hutool/core/date/DateUtilTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/date/DateUtilTest.java
@@ -1126,8 +1126,8 @@ public class DateUtilTest {
@Test
public void isLastDayTest() {
- DateTime dateTime = DateUtil.parse("2022-09-30");
- int dayOfMonth = DateUtil.getLastDayOfMonth(dateTime);
+ final DateTime dateTime = DateUtil.parse("2022-09-30");
+ final int dayOfMonth = DateUtil.getLastDayOfMonth(dateTime);
Assert.assertEquals(dayOfMonth, dateTime.dayOfMonth());
Assert.assertTrue("not is last day of this month !!", DateUtil.isLastDayOfMonth(dateTime));
}
@@ -1167,4 +1167,11 @@ public class DateUtilTest {
Assert.assertNotNull(parse);
Assert.assertEquals("2019-10-22 09:56:03", parse.toString());
}
+
+ @Test
+ public void issueI8NMP7Test() {
+ final String str = "1702262524444";
+ final DateTime parse = DateUtil.parse(str);
+ Assert.assertEquals("2023-12-11 10:42:04", Objects.requireNonNull(parse).toString());
+ }
}
diff --git a/hutool-core/src/test/java/cn/hutool/core/img/IssueI8L8UATest.java b/hutool-core/src/test/java/cn/hutool/core/img/IssueI8L8UATest.java
new file mode 100644
index 000000000..70fcc059c
--- /dev/null
+++ b/hutool-core/src/test/java/cn/hutool/core/img/IssueI8L8UATest.java
@@ -0,0 +1,15 @@
+package cn.hutool.core.img;
+
+import cn.hutool.core.io.FileUtil;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class IssueI8L8UATest {
+ @Test
+ @Ignore
+ public void convertTest() {
+ ImgUtil.convert(
+ FileUtil.file("d:/test/1.png"),
+ FileUtil.file("d:/test/1.jpg"));
+ }
+}
diff --git a/hutool-core/src/test/java/cn/hutool/core/text/split/StrSplitterTest.java b/hutool-core/src/test/java/cn/hutool/core/text/split/StrSplitterTest.java
index 16f812f69..8498bf479 100644
--- a/hutool-core/src/test/java/cn/hutool/core/text/split/StrSplitterTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/text/split/StrSplitterTest.java
@@ -1,5 +1,6 @@
package cn.hutool.core.text.split;
+import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.text.StrSplitter;
import org.junit.Assert;
import org.junit.Test;
@@ -15,8 +16,8 @@ public class StrSplitterTest {
@Test
public void splitByCharTest(){
- String str1 = "a, ,efedsfs, ddf";
- List
* 项目地址:https://github.com/yozhao/IKAnalyzer
- *
- * @author looly
*
+ * @author looly
*/
public class IKAnalyzerEngine implements TokenizerEngine {
- private final IKSegmenter seg;
-
/**
* 构造
- *
*/
public IKAnalyzerEngine() {
- this(new IKSegmenter(null, true));
}
/**
* 构造
- *
+ *
* @param seg {@link IKSegmenter}
+ * @deprecated 并发问题,导致无法共用IKSegmenter,因此废弃
*/
+ @Deprecated
public IKAnalyzerEngine(IKSegmenter seg) {
- this.seg = seg;
}
@Override
public Result parse(CharSequence text) {
- this.seg.reset(StrUtil.getReader(text));
- return new IKAnalyzerResult(this.seg);
+ final IKSegmenter copySeg = new IKSegmenter(null, true);
+ copySeg.reset(StrUtil.getReader(text));
+ return new IKAnalyzerResult(copySeg);
}
}
diff --git a/hutool-extra/src/test/java/cn/hutool/extra/compress/ArchiverTest.java b/hutool-extra/src/test/java/cn/hutool/extra/compress/ArchiverTest.java
index 8ba8d499a..3175efc3e 100644
--- a/hutool-extra/src/test/java/cn/hutool/extra/compress/ArchiverTest.java
+++ b/hutool-extra/src/test/java/cn/hutool/extra/compress/ArchiverTest.java
@@ -72,4 +72,36 @@ public class ArchiverTest {
})
.finish().close();
}
+
+ /**
+ * Add: D:\disk-all
+ * Add: D:\disk-all\els-app
+ * Add: D:\disk-all\els-app\db-backup
+ * Add: D:\disk-all\els-app\新建 文本文档.txt
+ * Add: D:\disk-all\新建 文本文档.txt
+ * Add: D:\disk-all\新建文件夹
+ */
+ @Test
+ @Ignore
+ public void emptyTest(){
+ final File file = FileUtil.file("d:/disk-all.tgz");
+ CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, "tgz", file)
+ .add(FileUtil.file("D:\\disk-all"), (f)->{
+ Console.log("Add: {}", f.getPath());
+ return true;
+ })
+ .finish().close();
+ }
+
+ @Test
+ @Ignore
+ public void emptyZTest(){
+ final File file = FileUtil.file("d:/disk-all.7z");
+ CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, "7z", file)
+ .add(FileUtil.file("D:\\disk-all"), (f)->{
+ Console.log("Add: {}", f.getPath());
+ return true;
+ })
+ .finish().close();
+ }
}
diff --git a/hutool-http/pom.xml b/hutool-http/pom.xml
index 94271dac0..b55ae1617 100755
--- a/hutool-http/pom.xml
+++ b/hutool-http/pom.xml
@@ -9,7 +9,7 @@