mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
remove deprecated methods
This commit is contained in:
parent
8b85134c4b
commit
f9b6110042
@ -3,9 +3,13 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.7.1 (2021-06-15)
|
||||
# 5.7.1 (2021-06-17)
|
||||
|
||||
### 🐣新特性
|
||||
* 【db 】 NamedSql支持in操作(issue#1652@Github)
|
||||
* 【all 】 JWT模块加入到all和bom包中(issue#1654@Github)
|
||||
* 【core 】 CollUtil删除所有Map相关操作
|
||||
* 【all 】 **重要!** 删除过期方法
|
||||
|
||||
### 🐞Bug修复
|
||||
|
||||
|
@ -108,6 +108,11 @@
|
||||
<artifactId>hutool-socket</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-jwt</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -106,6 +106,11 @@
|
||||
<artifactId>hutool-socket</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-jwt</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -291,32 +291,6 @@ public class Base64 {
|
||||
return Base64Decoder.decode(base64);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64解码
|
||||
*
|
||||
* @param source 被解码的base64字符串
|
||||
* @param charset 字符集
|
||||
* @return 被加密后的字符串
|
||||
* @deprecated 编码参数无意义,作废
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] decode(CharSequence source, String charset) {
|
||||
return Base64Decoder.decode(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64解码
|
||||
*
|
||||
* @param source 被解码的base64字符串
|
||||
* @param charset 字符集
|
||||
* @return 被加密后的字符串
|
||||
* @deprecated 编码参数无意义,作废
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] decode(CharSequence source, Charset charset) {
|
||||
return Base64Decoder.decode(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码Base64
|
||||
*
|
||||
|
@ -636,48 +636,6 @@ public class CollUtil {
|
||||
return currentAlaDatas;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------- new HashMap
|
||||
|
||||
/**
|
||||
* 新建一个HashMap
|
||||
*
|
||||
* @param <K> Key类型
|
||||
* @param <V> Value类型
|
||||
* @return HashMap对象
|
||||
* @see MapUtil#newHashMap()
|
||||
*/
|
||||
public static <K, V> HashMap<K, V> newHashMap() {
|
||||
return MapUtil.newHashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建一个HashMap
|
||||
*
|
||||
* @param <K> Key类型
|
||||
* @param <V> Value类型
|
||||
* @param size 初始大小,由于默认负载因子0.75,传入的size会实际初始大小为size / 0.75
|
||||
* @param isOrder Map的Key是否有序,有序返回 {@link LinkedHashMap},否则返回 {@link HashMap}
|
||||
* @return HashMap对象
|
||||
* @see MapUtil#newHashMap(int, boolean)
|
||||
* @since 3.0.4
|
||||
*/
|
||||
public static <K, V> HashMap<K, V> newHashMap(int size, boolean isOrder) {
|
||||
return MapUtil.newHashMap(size, isOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建一个HashMap
|
||||
*
|
||||
* @param <K> Key类型
|
||||
* @param <V> Value类型
|
||||
* @param size 初始大小,由于默认负载因子0.75,传入的size会实际初始大小为size / 0.75
|
||||
* @return HashMap对象
|
||||
* @see MapUtil#newHashMap(int)
|
||||
*/
|
||||
public static <K, V> HashMap<K, V> newHashMap(int size) {
|
||||
return MapUtil.newHashMap(size);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------- new HashSet
|
||||
|
||||
/**
|
||||
@ -1043,20 +1001,6 @@ public class CollUtil {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Map<br>
|
||||
* 传入AbstractMap和{@link Map}类将默认创建{@link HashMap}
|
||||
*
|
||||
* @param <K> map键类型
|
||||
* @param <V> map值类型
|
||||
* @param mapType map类型
|
||||
* @return {@link Map}实例
|
||||
* @see MapUtil#createMap(Class)
|
||||
*/
|
||||
public static <K, V> Map<K, V> createMap(Class<?> mapType) {
|
||||
return MapUtil.createMap(mapType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去重集合
|
||||
*
|
||||
@ -1178,8 +1122,8 @@ public class CollUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤,此方法产生一个新集合<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
* 编辑,此方法产生一个新集合<br>
|
||||
* 编辑过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
@ -1191,7 +1135,7 @@ public class CollUtil {
|
||||
* @param editor 编辑器接口
|
||||
* @return 过滤后的集合
|
||||
*/
|
||||
public static <T> Collection<T> filter(Collection<T> collection, Editor<T> editor) {
|
||||
public static <T> Collection<T> edit(Collection<T> collection, Editor<T> editor) {
|
||||
if (null == collection || null == editor) {
|
||||
return collection;
|
||||
}
|
||||
@ -1214,25 +1158,6 @@ public class CollUtil {
|
||||
return collection2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param list 集合
|
||||
* @param editor 编辑器接口
|
||||
* @return 过滤后的数组
|
||||
* @since 4.1.8
|
||||
*/
|
||||
public static <T> List<T> filter(List<T> list, Editor<T> editor) {
|
||||
return ListUtil.filter(list, editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 过滤过程通过传入的Filter实现来过滤返回需要的元素内容,这个Filter实现可以实现以下功能:
|
||||
@ -1248,24 +1173,7 @@ public class CollUtil {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static <T> Collection<T> filterNew(Collection<T> collection, Filter<T> filter) {
|
||||
if (null == collection || null == filter) {
|
||||
return collection;
|
||||
}
|
||||
|
||||
Collection<T> collection2 = ObjectUtil.clone(collection);
|
||||
try {
|
||||
collection2.clear();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// 克隆后的对象不支持清空,说明为不可变集合对象,使用默认的ArrayList保存结果
|
||||
collection2 = new ArrayList<>();
|
||||
}
|
||||
|
||||
for (T t : collection) {
|
||||
if (filter.accept(t)) {
|
||||
collection2.add(t);
|
||||
}
|
||||
}
|
||||
return collection2;
|
||||
return edit(collection, t -> filter.accept(t) ? t : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1283,7 +1191,7 @@ public class CollUtil {
|
||||
* @since 4.1.8
|
||||
*/
|
||||
public static <T> List<T> filterNew(List<T> list, Filter<T> filter) {
|
||||
return ListUtil.filter(list, t -> filter.accept(t) ? t : null);
|
||||
return ListUtil.editNew(list, t -> filter.accept(t) ? t : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1540,47 +1448,6 @@ public class CollUtil {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
*
|
||||
* @param <K> Key类型
|
||||
* @param <V> Value类型
|
||||
* @param map Map
|
||||
* @param editor 编辑器接口
|
||||
* @return 过滤后的Map
|
||||
* @see MapUtil#edit(Map, Editor)
|
||||
*/
|
||||
public static <K, V> Map<K, V> edit(Map<K, V> map, Editor<Entry<K, V>> editor) {
|
||||
return MapUtil.edit(map, editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
*
|
||||
* @param <K> Key类型
|
||||
* @param <V> Value类型
|
||||
* @param map Map
|
||||
* @param filter 编辑器接口
|
||||
* @return 过滤后的Map
|
||||
* @see MapUtil#filter(Map, Filter)
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static <K, V> Map<K, V> filter(Map<K, V> map, Filter<Entry<K, V>> filter) {
|
||||
return MapUtil.filter(map, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 集合中匹配规则的数量
|
||||
*
|
||||
@ -1702,17 +1569,6 @@ public class CollUtil {
|
||||
return isEmpty(collection) ? defaultCollection : collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map是否为空
|
||||
*
|
||||
* @param map 集合
|
||||
* @return 是否为空
|
||||
* @see MapUtil#isEmpty(Map)
|
||||
*/
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return MapUtil.isEmpty(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterable是否为空
|
||||
*
|
||||
@ -1757,17 +1613,6 @@ public class CollUtil {
|
||||
return false == isEmpty(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map是否为非空
|
||||
*
|
||||
* @param map 集合
|
||||
* @return 是否为非空
|
||||
* @see MapUtil#isNotEmpty(Map)
|
||||
*/
|
||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||
return MapUtil.isNotEmpty(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterable是否为空
|
||||
*
|
||||
@ -1870,7 +1715,7 @@ public class CollUtil {
|
||||
}
|
||||
|
||||
int entryCount = Math.min(keys.size(), values.size());
|
||||
final Map<K, V> map = newHashMap(entryCount);
|
||||
final Map<K, V> map = MapUtil.newHashMap(entryCount);
|
||||
|
||||
final Iterator<K> keyIterator = keys.iterator();
|
||||
final Iterator<V> valueIterator = values.iterator();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.lang.Filter;
|
||||
import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
@ -129,24 +130,6 @@ public class IterUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据集合返回一个元素计数的 {@link Map}<br>
|
||||
* 所谓元素计数就是假如这个集合中某个元素出现了n次,那将这个元素做为key,n做为value<br>
|
||||
* 例如:[a,b,c,c,c] 得到:<br>
|
||||
* a: 1<br>
|
||||
* b: 1<br>
|
||||
* c: 3<br>
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iter {@link Iterable},如果为null返回一个空的Map
|
||||
* @return {@link Map}
|
||||
* @deprecated 如果对象同时实现Iterable和Iterator接口会产生歧义,请使用CollUtil.countMap
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> Map<T, Integer> countMap(Iterable<T> iter) {
|
||||
return countMap(null == iter ? null : iter.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据集合返回一个元素计数的 {@link Map}<br>
|
||||
* 所谓元素计数就是假如这个集合中某个元素出现了n次,那将这个元素做为key,n做为value<br>
|
||||
@ -171,23 +154,6 @@ public class IterUtil {
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段值与列表值对应的Map,常用于元素对象中有唯一ID时需要按照这个ID查找对象的情况<br>
|
||||
* 例如:车牌号 =》车
|
||||
*
|
||||
* @param <K> 字段名对应值得类型,不确定请使用Object
|
||||
* @param <V> 对象类型
|
||||
* @param iter 对象列表
|
||||
* @param fieldName 字段名(会通过反射获取其值)
|
||||
* @return 某个字段值与对象对应Map
|
||||
* @since 4.0.4
|
||||
* @deprecated 如果对象同时实现Iterable和Iterator接口会产生歧义,请使用CollUtil.fieldValueMap
|
||||
*/
|
||||
@Deprecated
|
||||
public static <K, V> Map<K, V> fieldValueMap(Iterable<V> iter, String fieldName) {
|
||||
return fieldValueMap(null == iter ? null : iter.iterator(), fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段值与列表值对应的Map,常用于元素对象中有唯一ID时需要按照这个ID查找对象的情况<br>
|
||||
* 例如:车牌号 =》车
|
||||
@ -204,23 +170,6 @@ public class IterUtil {
|
||||
return toMap(iter, new HashMap<>(), (value) -> (K) ReflectUtil.getFieldValue(value, fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 两个字段值组成新的Map
|
||||
*
|
||||
* @param <K> 字段名对应值得类型,不确定请使用Object
|
||||
* @param <V> 值类型,不确定使用Object
|
||||
* @param iterable 对象列表
|
||||
* @param fieldNameForKey 做为键的字段名(会通过反射获取其值)
|
||||
* @param fieldNameForValue 做为值的字段名(会通过反射获取其值)
|
||||
* @return 某个字段值与对象对应Map
|
||||
* @since 4.6.2
|
||||
* @deprecated 如果对象同时实现Iterable和Iterator接口会产生歧义,请使用CollUtil.fieldValueMap
|
||||
*/
|
||||
@Deprecated
|
||||
public static <K, V> Map<K, V> fieldValueAsMap(Iterable<?> iterable, String fieldNameForKey, String fieldNameForValue) {
|
||||
return fieldValueAsMap(null == iterable ? null : iterable.iterator(), fieldNameForKey, fieldNameForValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 两个字段值组成新的Map
|
||||
*
|
||||
@ -274,43 +223,6 @@ public class IterUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 conjunction 为分隔符将集合转换为字符串
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iterable {@link Iterable}
|
||||
* @param conjunction 分隔符
|
||||
* @return 连接后的字符串
|
||||
* @deprecated 如果对象同时实现Iterable和Iterator接口会产生歧义,请使用CollUtil.join
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> String join(Iterable<T> iterable, CharSequence conjunction) {
|
||||
if (null == iterable) {
|
||||
return null;
|
||||
}
|
||||
return join(iterable.iterator(), conjunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 conjunction 为分隔符将集合转换为字符串
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iterable {@link Iterable}
|
||||
* @param conjunction 分隔符
|
||||
* @param prefix 每个元素添加的前缀,null表示不添加
|
||||
* @param suffix 每个元素添加的后缀,null表示不添加
|
||||
* @return 连接后的字符串
|
||||
* @since 4.0.10
|
||||
* @deprecated 如果对象同时实现Iterable和Iterator接口会产生歧义,请使用CollUtil.join
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> String join(Iterable<T> iterable, CharSequence conjunction, String prefix, String suffix) {
|
||||
if (null == iterable) {
|
||||
return null;
|
||||
}
|
||||
return join(iterable.iterator(), conjunction, prefix, suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 conjunction 为分隔符将集合转换为字符串<br>
|
||||
* 如果集合元素为数组、{@link Iterable}或{@link Iterator},则递归组合其为字符串
|
||||
@ -337,11 +249,11 @@ public class IterUtil {
|
||||
* @since 4.0.10
|
||||
*/
|
||||
public static <T> String join(Iterator<T> iterator, CharSequence conjunction, String prefix, String suffix) {
|
||||
return join(iterator, conjunction, (item)->{
|
||||
return join(iterator, conjunction, (item) -> {
|
||||
if (ArrayUtil.isArray(item)) {
|
||||
return ArrayUtil.join(ArrayUtil.wrap(item), conjunction, prefix, suffix);
|
||||
} else if (item instanceof Iterable<?>) {
|
||||
return join((Iterable<?>) item, conjunction, prefix, suffix);
|
||||
return CollUtil.join((Iterable<?>) item, conjunction, prefix, suffix);
|
||||
} else if (item instanceof Iterator<?>) {
|
||||
return join((Iterator<?>) item, conjunction, prefix, suffix);
|
||||
} else {
|
||||
@ -706,6 +618,37 @@ public class IterUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑,此方法产生一个新{@link ArrayList}<br>
|
||||
* 编辑过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iter 集合
|
||||
* @param editor 编辑器接口, {@code null}表示不编辑
|
||||
* @return 过滤后的集合
|
||||
* @since 5.7.1
|
||||
*/
|
||||
public static <T> List<T> edit(Iterable<T> iter, Editor<T> editor) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
if (null == iter) {
|
||||
return result;
|
||||
}
|
||||
|
||||
T modified;
|
||||
for (T t : iter) {
|
||||
modified = (null == editor) ? t : editor.edit(t);
|
||||
if (null != modified) {
|
||||
result.add(t);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤集合,此方法在原集合上直接修改<br>
|
||||
* 通过实现Filter接口,完成元素的过滤,这个Filter实现可以实现以下功能:
|
||||
|
@ -424,13 +424,14 @@ public class ListUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 编辑列表<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
* 注意:此方法会修改原List!!
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param list 集合
|
||||
@ -438,20 +439,41 @@ public class ListUtil {
|
||||
* @return 过滤后的数组
|
||||
* @since 4.1.8
|
||||
*/
|
||||
public static <T> List<T> filter(List<T> list, Editor<T> editor) {
|
||||
public static <T> List<T> editNew(List<T> list, Editor<T> editor) {
|
||||
return (List<T>) CollUtil.edit(list, editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑列表<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、过滤出需要的对象,如果返回null表示这个元素对象抛弃
|
||||
* 2、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
* 注意:此方法会修改原List!!
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param list 集合
|
||||
* @param editor 编辑器接口
|
||||
* @return 过滤后的数组
|
||||
* @since 4.1.8
|
||||
*/
|
||||
public static <T> List<T> edit(List<T> list, Editor<T> editor) {
|
||||
if (null == list || null == editor) {
|
||||
return list;
|
||||
}
|
||||
|
||||
final List<T> list2 = (list instanceof LinkedList) ? new LinkedList<>() : new ArrayList<>(list.size());
|
||||
T modified;
|
||||
for (T t : list) {
|
||||
modified = editor.edit(t);
|
||||
if (null != modified) {
|
||||
list2.add(modified);
|
||||
final int size = list.size();
|
||||
T ele;
|
||||
for (int i = 0; i < size; i++) {
|
||||
ele = list.get(i);
|
||||
ele = editor.edit(ele);
|
||||
if(null != ele){
|
||||
list.set(i, ele);
|
||||
}
|
||||
}
|
||||
return list2;
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -846,20 +846,6 @@ public class Convert {
|
||||
return HexUtil.decodeHex(src.toCharArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制转换字符串
|
||||
*
|
||||
* @param hexStr Byte字符串(Byte之间无分隔符 如:[616C6B])
|
||||
* @param charset 编码 {@link Charset}
|
||||
* @return 对应的字符串
|
||||
* @see HexUtil#decodeHexStr(String, Charset)
|
||||
* @deprecated 请使用 {@link #hexToStr(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String hexStrToStr(String hexStr, Charset charset) {
|
||||
return hexToStr(hexStr, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制转换字符串
|
||||
*
|
||||
|
@ -1,43 +0,0 @@
|
||||
package cn.hutool.core.convert.impl;
|
||||
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
|
||||
/**
|
||||
* 泛型枚举转换器
|
||||
*
|
||||
* @param <E> 枚举类类型
|
||||
* @author Looly
|
||||
* @since 4.0.2
|
||||
* @deprecated 请使用{@link EnumConverter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class GenericEnumConverter<E extends Enum<E>> extends AbstractConverter<E> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Class<E> enumClass;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param enumClass 转换成的目标Enum类
|
||||
*/
|
||||
public GenericEnumConverter(Class<E> enumClass) {
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected E convertInternal(Object value) {
|
||||
E enumValue = (E) EnumConverter.tryConvertEnum(value, this.enumClass);
|
||||
if(null == enumValue && false == value instanceof String){
|
||||
// 最后尝试valueOf转换
|
||||
enumValue = Enum.valueOf(this.enumClass, convertToStr(value));
|
||||
}
|
||||
return enumValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<E> getTargetType() {
|
||||
return this.enumClass;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package cn.hutool.core.date;
|
||||
|
||||
/**
|
||||
* 时长格式化器<br>
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
* @deprecated 拼写错误,请使用{@link BetweenFormatter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BetweenFormater extends BetweenFormatter {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BetweenFormater(long betweenMs, Level level) {
|
||||
super(betweenMs, level);
|
||||
}
|
||||
|
||||
public BetweenFormater(long betweenMs, Level level, int levelMaxCount) {
|
||||
super(betweenMs, level, levelMaxCount);
|
||||
}
|
||||
}
|
@ -161,13 +161,6 @@ public class BetweenFormatter implements Serializable {
|
||||
* 秒
|
||||
*/
|
||||
SECOND("秒"),
|
||||
/**
|
||||
* 毫秒
|
||||
*
|
||||
* @deprecated 拼写错误,请使用{@link #MILLISECOND}
|
||||
*/
|
||||
@Deprecated
|
||||
MILLSECOND("毫秒"),
|
||||
/**
|
||||
* 毫秒
|
||||
*/
|
||||
|
@ -571,17 +571,6 @@ public class DateTime extends Date {
|
||||
return getField(DateField.MILLISECOND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定日期的毫秒数部分<br>
|
||||
*
|
||||
* @return 毫秒数
|
||||
* @deprecated 拼写错误,请使用{@link #millisecond()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int millsecond() {
|
||||
return getField(DateField.MILLISECOND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为上午
|
||||
*
|
||||
|
@ -312,18 +312,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return DateTime.of(date).second();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定日期的毫秒数部分<br>
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 毫秒数
|
||||
* @deprecated 拼写错误,请使用{@link #millisecond(Date)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static int millsecond(Date date) {
|
||||
return DateTime.of(date).millisecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定日期的毫秒数部分<br>
|
||||
*
|
||||
@ -432,15 +420,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return second(date());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 当前日期的毫秒数部分<br>
|
||||
* @deprecated 拼写错误,请使用{@link #thisMillisecond()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static int thisMillsecond() {
|
||||
return millisecond(date());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 当前日期的毫秒数部分<br>
|
||||
*/
|
||||
@ -1326,19 +1305,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return dateNew(date).offset(dateField, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期偏移指定时间后的时间
|
||||
*
|
||||
* @param date 基准日期
|
||||
* @param dateField 偏移的粒度大小(小时、天、月等){@link DateField}
|
||||
* @param offset 偏移量,正数为向后偏移,负数为向前偏移
|
||||
* @return 偏移后的日期
|
||||
* @deprecated please use {@link DateUtil#offset(Date, DateField, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static DateTime offsetDate(Date date, DateField dateField, int offset) {
|
||||
return offset(date, dateField, offset);
|
||||
}
|
||||
// ------------------------------------ Offset end ----------------------------------------------
|
||||
|
||||
/**
|
||||
@ -1585,19 +1551,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return Integer.parseInt(DateUtil.format(date, "yyMMddHHmm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定指定时间区间内的周数
|
||||
*
|
||||
* @param start 开始时间
|
||||
* @param end 结束时间
|
||||
* @return 周数
|
||||
* @deprecated 请使用 {@link #betweenWeek(Date, Date, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static int weekCount(Date start, Date end) {
|
||||
return (int) betweenWeek(start, end, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计时器<br>
|
||||
* 计算某个过程花费的时间,精确到毫秒
|
||||
|
@ -50,17 +50,6 @@ public class LunarInfo {
|
||||
// 支持的最大年限
|
||||
public static final int MAX_YEAR = BASE_YEAR + LUNAR_CODE.length - 1;
|
||||
|
||||
/**
|
||||
* 获取支持的最大年(包括)
|
||||
*
|
||||
* @return 最大年(包括)
|
||||
* @deprecated 使用 {@link #MAX_YEAR}
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getMaxYear() {
|
||||
return MAX_YEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 传回农历 y年的总天数
|
||||
*
|
||||
|
@ -356,32 +356,6 @@ public class Validator {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过正则表达式验证
|
||||
*
|
||||
* @param pattern 正则模式
|
||||
* @param value 值
|
||||
* @return 是否匹配正则
|
||||
* @deprecated 请使用 {@link #isMatchRegex(Pattern, CharSequence)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isMactchRegex(Pattern pattern, CharSequence value) {
|
||||
return ReUtil.isMatch(pattern, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过正则表达式验证
|
||||
*
|
||||
* @param regex 正则
|
||||
* @param value 值
|
||||
* @return 是否匹配正则
|
||||
* @deprecated 拼写错误,请使用{@link #isMatchRegex(String, CharSequence)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isMactchRegex(String regex, CharSequence value) {
|
||||
return ReUtil.isMatch(regex, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过正则表达式验证
|
||||
*
|
||||
|
@ -660,22 +660,7 @@ public class MapUtil {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static <K, V> Map<K, V> filter(Map<K, V> map, Filter<Entry<K, V>> filter) {
|
||||
if (null == map || null == filter) {
|
||||
return map;
|
||||
}
|
||||
|
||||
final Map<K, V> map2 = ObjectUtil.clone(map);
|
||||
if (isEmpty(map2)) {
|
||||
return map2;
|
||||
}
|
||||
|
||||
map2.clear();
|
||||
for (Entry<K, V> entry : map.entrySet()) {
|
||||
if (filter.accept(entry)) {
|
||||
map2.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return map2;
|
||||
return edit(map, t -> filter.accept(t) ? t : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -700,19 +700,6 @@ public class NetUtil {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测给定字符串是否为未知,多用于检测HTTP请求相关<br>
|
||||
*
|
||||
* @param checkString 被检测的字符串
|
||||
* @return 是否未知
|
||||
* @since 4.4.1
|
||||
* @deprecated 拼写错误,请使用{@link #isUnknown(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isUnknow(String checkString) {
|
||||
return isUnknown(checkString);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测给定字符串是否为未知,多用于检测HTTP请求相关<br>
|
||||
*
|
||||
|
@ -1858,19 +1858,6 @@ public class CharSequenceUtil {
|
||||
return StrSplitter.split(str.toString(), separatorStr, limit, isTrim, ignoreEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切分字符串,如果分隔符不存在则返回原字符串
|
||||
*
|
||||
* @param str 被切分的字符串
|
||||
* @param separator 分隔符
|
||||
* @return 字符串
|
||||
* @deprecated 请使用 {@link #splitToArray(CharSequence, char)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String[] split(CharSequence str, CharSequence separator) {
|
||||
return splitToArray(str, separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定长度,将给定字符串截取为多个部分
|
||||
*
|
||||
|
@ -1,11 +0,0 @@
|
||||
package cn.hutool.core.text;
|
||||
|
||||
/**
|
||||
* 字符串切分器
|
||||
*
|
||||
* @author looly
|
||||
* @deprecated 此类拼写错误,请使用 {@link StrSplitter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class StrSpliter extends StrSplitter{
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package cn.hutool.core.thread;
|
||||
|
||||
import cn.hutool.core.exceptions.NotInitedException;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
@ -158,21 +157,6 @@ public class SyncFinisher {
|
||||
clearWorker();
|
||||
}
|
||||
|
||||
/**
|
||||
* 等待所有Worker工作结束,否则阻塞
|
||||
*
|
||||
* @throws InterruptedException 用户中断
|
||||
* @deprecated 使用start方法指定是否阻塞等待
|
||||
*/
|
||||
@Deprecated
|
||||
public void await() throws InterruptedException {
|
||||
if (endLatch == null) {
|
||||
throw new NotInitedException("Please call start() method first!");
|
||||
}
|
||||
|
||||
endLatch.await();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空工作线程对象
|
||||
*/
|
||||
|
@ -2200,38 +2200,6 @@ public class NumberUtil {
|
||||
return StrUtil.isBlank(number) ? BigInteger.ZERO : new BigInteger(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否空白符<br>
|
||||
* 空白符包括空格、制表符、全角空格和不间断空格<br>
|
||||
*
|
||||
* @param c 字符
|
||||
* @return 是否空白符
|
||||
* @see Character#isWhitespace(int)
|
||||
* @see Character#isSpaceChar(int)
|
||||
* @since 3.0.6
|
||||
* @deprecated 请使用{@link CharUtil#isBlankChar(char)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isBlankChar(char c) {
|
||||
return isBlankChar((int) c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否空白符<br>
|
||||
* 空白符包括空格、制表符、全角空格和不间断空格<br>
|
||||
*
|
||||
* @param c 字符
|
||||
* @return 是否空白符
|
||||
* @see Character#isWhitespace(int)
|
||||
* @see Character#isSpaceChar(int)
|
||||
* @since 3.0.6
|
||||
* @deprecated 请使用{@link CharUtil#isBlankChar(int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isBlankChar(int c) {
|
||||
return Character.isWhitespace(c) || Character.isSpaceChar(c) || c == '\ufeff' || c == '\u202a';
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算等份个数
|
||||
*
|
||||
|
@ -453,21 +453,6 @@ public class ObjectUtil {
|
||||
return SerializeUtil.deserialize(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化<br>
|
||||
* 对象必须实现Serializable接口
|
||||
*
|
||||
* @param <T> 对象类型
|
||||
* @param bytes 反序列化的字节码
|
||||
* @return 反序列化后的对象
|
||||
* @see #deserialize(byte[])
|
||||
* @deprecated 请使用 {@link #deserialize(byte[])}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T unserialize(byte[] bytes) {
|
||||
return deserialize(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为基本类型,包括包装类型和非包装类型
|
||||
*
|
||||
|
@ -5,7 +5,6 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.lang.WeightRandom;
|
||||
import cn.hutool.core.lang.WeightRandom.WeightObj;
|
||||
|
||||
@ -605,29 +604,6 @@ public class RandomUtil {
|
||||
return new WeightRandom<>(weightObjs);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------- UUID
|
||||
|
||||
/**
|
||||
* @return 随机UUID
|
||||
* @deprecated 请使用{@link IdUtil#randomUUID()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String randomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 简化的UUID,去掉了横线
|
||||
*
|
||||
* @return 简化的UUID,去掉了横线
|
||||
* @since 3.2.2
|
||||
* @deprecated 请使用{@link IdUtil#simpleUUID()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String simpleUUID() {
|
||||
return UUID.randomUUID().toString(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以当天为基准,随机产生一个日期
|
||||
*
|
||||
|
@ -295,19 +295,6 @@ public class TypeUtil {
|
||||
return null == type || type instanceof TypeVariable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定泛型数组中是否含有泛型变量
|
||||
*
|
||||
* @param types 泛型数组
|
||||
* @return 是否含有泛型变量
|
||||
* @since 4.5.7
|
||||
* @deprecated 拼写错误,请使用{@link #hasTypeVariable(Type...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean hasTypeVeriable(Type... types) {
|
||||
return hasTypeVariable(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定泛型数组中是否含有泛型变量
|
||||
*
|
||||
|
@ -273,20 +273,6 @@ public class URLUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补全相对路径
|
||||
*
|
||||
* @param baseUrl 基准URL
|
||||
* @param relativePath 相对URL
|
||||
* @return 相对路径
|
||||
* @throws UtilException MalformedURLException
|
||||
* @deprecated 拼写错误,请使用{@link #completeUrl(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String complateUrl(String baseUrl, String relativePath) {
|
||||
return completeUrl(baseUrl, relativePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补全相对路径
|
||||
*
|
||||
@ -373,25 +359,6 @@ public class URLUtil {
|
||||
return URLEncoder.DEFAULT.encode(url, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码URL字符为 application/x-www-form-urlencoded<br>
|
||||
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
|
||||
* 此方法用于URL自动编码,类似于浏览器中键入地址自动编码,对于像类似于“/”的字符不再编码
|
||||
*
|
||||
* @param url URL
|
||||
* @param charset 编码
|
||||
* @return 编码后的URL
|
||||
* @throws UtilException UnsupportedEncodingException
|
||||
* @deprecated 请使用 {@link #encode(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String encode(String url, String charset) throws UtilException {
|
||||
if (StrUtil.isEmpty(url)) {
|
||||
return url;
|
||||
}
|
||||
return encode(url, StrUtil.isBlank(charset) ? CharsetUtil.defaultCharset() : CharsetUtil.charset(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码URL,默认使用UTF-8编码<br>
|
||||
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
|
||||
@ -426,22 +393,6 @@ public class URLUtil {
|
||||
return URLEncoder.QUERY.encode(url, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码URL<br>
|
||||
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
|
||||
* 此方法用于POST请求中的请求体自动编码,转义大部分特殊字符
|
||||
*
|
||||
* @param url URL
|
||||
* @param charset 编码
|
||||
* @return 编码后的URL
|
||||
* @throws UtilException UnsupportedEncodingException
|
||||
* @deprecated 请使用 {@link #encodeQuery(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String encodeQuery(String url, String charset) throws UtilException {
|
||||
return encodeQuery(url, StrUtil.isBlank(charset) ? CharsetUtil.defaultCharset() : CharsetUtil.charset(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码URL,默认使用UTF-8编码<br>
|
||||
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
|
||||
|
@ -2,7 +2,6 @@ package cn.hutool.core.collection;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.lang.Filter;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -247,7 +246,7 @@ public class CollUtilTest {
|
||||
public void filterTest() {
|
||||
ArrayList<String> list = CollUtil.newArrayList("a", "b", "c");
|
||||
|
||||
Collection<String> filtered = CollUtil.filter(list, (Editor<String>) t -> t + 1);
|
||||
Collection<String> filtered = CollUtil.edit(list, t -> t + 1);
|
||||
|
||||
Assert.assertEquals(CollUtil.newArrayList("a1", "b1", "c1"), filtered);
|
||||
}
|
||||
|
@ -72,21 +72,4 @@ public class TaskExecutorManager implements Serializable {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止所有TaskExecutor
|
||||
*
|
||||
* @return this
|
||||
* @deprecated 作业执行器只是执行给定的定时任务线程,无法强制关闭,可通过deamon线程方式关闭之
|
||||
*/
|
||||
@Deprecated
|
||||
public TaskExecutorManager destroy() {
|
||||
// synchronized (this.executors) {
|
||||
// for (TaskExecutor taskExecutor : executors) {
|
||||
// ThreadUtil.interupt(taskExecutor, false);
|
||||
// }
|
||||
// }
|
||||
this.executors.clear();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 作业启动管理器
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
@ -16,11 +16,11 @@ public class TaskLauncherManager implements Serializable {
|
||||
protected Scheduler scheduler;
|
||||
/** 启动器列表 */
|
||||
protected final List<TaskLauncher> launchers = new ArrayList<>();
|
||||
|
||||
|
||||
public TaskLauncherManager(Scheduler scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启动 TaskLauncher
|
||||
* @param millis 触发事件的毫秒数
|
||||
@ -37,7 +37,7 @@ public class TaskLauncherManager implements Serializable {
|
||||
this.scheduler.threadExecutor.execute(launcher);
|
||||
return launcher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启动器启动完毕,启动完毕后从执行器列表中移除
|
||||
* @param launcher 启动器 {@link TaskLauncher}
|
||||
@ -47,20 +47,4 @@ public class TaskLauncherManager implements Serializable {
|
||||
launchers.remove(launcher);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止所有TaskLauncher
|
||||
* @return this
|
||||
* @deprecated 作业启动器只是调用定时任务检查,无法强制关闭,可通过deamon线程方式关闭之
|
||||
*/
|
||||
@Deprecated
|
||||
public TaskLauncherManager destroy() {
|
||||
// synchronized (this.launchers) {
|
||||
// for (TaskLauncher taskLauncher : launchers) {
|
||||
// ThreadUtil.interupt(taskLauncher, false);
|
||||
// }
|
||||
// }
|
||||
this.launchers.clear();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.AsymmetricAlgorithm;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
@ -969,19 +968,6 @@ public class SecureUtil {
|
||||
return new Digester(digestAlgorithm).digestHex(MapUtil.sortJoin(params, separator, keyValueSeparator, isIgnoreNull, otherParams));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------- UUID
|
||||
|
||||
/**
|
||||
* 简化的UUID,去掉了横线
|
||||
*
|
||||
* @return 简化的UUID,去掉了横线
|
||||
* @deprecated 请使用 {@link IdUtil#simpleUUID()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String simpleUUID() {
|
||||
return IdUtil.simpleUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加加密解密的算法提供者,默认优先使用,例如:
|
||||
*
|
||||
|
@ -287,17 +287,6 @@ public class AsymmetricCrypto extends AbstractAsymmetricCrypto<AsymmetricCrypto>
|
||||
|
||||
// --------------------------------------------------------------------------------- Getters and Setters
|
||||
|
||||
/**
|
||||
* 获得加密或解密器
|
||||
*
|
||||
* @return 加密或解密
|
||||
* @deprecated 拼写错误,请使用{@link #getCipher()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Cipher getClipher() {
|
||||
return cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得加密或解密器
|
||||
*
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.hutool.crypto.asymmetric;
|
||||
|
||||
import cn.hutool.crypto.CryptoException;
|
||||
import cn.hutool.crypto.GlobalBouncyCastleProvider;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
@ -9,11 +12,6 @@ import java.security.interfaces.RSAKey;
|
||||
import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.CryptoException;
|
||||
import cn.hutool.crypto.GlobalBouncyCastleProvider;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* RSA公钥/私钥/签名加密解密
|
||||
@ -25,7 +23,7 @@ import cn.hutool.crypto.SecureUtil;
|
||||
* 由于非对称加密速度极其缓慢,一般文件不使用它来加密而是使用对称加密,<br>
|
||||
* 非对称加密算法可以用来对对称加密的密钥加密,这样保证密钥的安全也就保证了数据的安全
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@ -37,7 +35,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
// ------------------------------------------------------------------ Static method start
|
||||
/**
|
||||
* 生成RSA私钥
|
||||
*
|
||||
*
|
||||
* @param modulus N特征值
|
||||
* @param privateExponent d特征值
|
||||
* @return {@link PrivateKey}
|
||||
@ -48,7 +46,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
|
||||
/**
|
||||
* 生成RSA公钥
|
||||
*
|
||||
*
|
||||
* @param modulus N特征值
|
||||
* @param publicExponent e特征值
|
||||
* @return {@link PublicKey}
|
||||
@ -68,7 +66,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
|
||||
/**
|
||||
* 构造,生成新的私钥公钥对
|
||||
*
|
||||
*
|
||||
* @param rsaAlgorithm 自定义RSA算法,例如RSA/ECB/PKCS1Padding
|
||||
*/
|
||||
public RSA(String rsaAlgorithm) {
|
||||
@ -79,7 +77,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造<br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param privateKeyStr 私钥Hex或Base64表示
|
||||
* @param publicKeyStr 公钥Hex或Base64表示
|
||||
*/
|
||||
@ -91,7 +89,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造<br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param rsaAlgorithm 自定义RSA算法,例如RSA/ECB/PKCS1Padding
|
||||
* @param privateKeyStr 私钥Hex或Base64表示
|
||||
* @param publicKeyStr 公钥Hex或Base64表示
|
||||
@ -105,7 +103,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造 <br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param privateKey 私钥
|
||||
* @param publicKey 公钥
|
||||
*/
|
||||
@ -117,7 +115,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造 <br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param modulus N特征值
|
||||
* @param privateExponent d特征值
|
||||
* @param publicExponent e特征值
|
||||
@ -131,7 +129,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造 <br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param privateKey 私钥
|
||||
* @param publicKey 公钥
|
||||
* @since 3.1.1
|
||||
@ -144,7 +142,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
* 构造 <br>
|
||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
||||
*
|
||||
*
|
||||
* @param rsaAlgorithm 自定义RSA算法,例如RSA/ECB/PKCS1Padding
|
||||
* @param privateKey 私钥
|
||||
* @param publicKey 公钥
|
||||
@ -155,36 +153,6 @@ public class RSA extends AsymmetricCrypto {
|
||||
}
|
||||
// ------------------------------------------------------------------ Constructor end
|
||||
|
||||
/**
|
||||
* 分组加密
|
||||
*
|
||||
* @param data 数据
|
||||
* @param keyType 密钥类型
|
||||
* @return 加密后的密文
|
||||
* @throws CryptoException 加密异常
|
||||
* @deprecated 请使用 {@link #encryptBcd(String, KeyType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String encryptStr(String data, KeyType keyType) {
|
||||
return encryptBcd(data, keyType, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组加密
|
||||
*
|
||||
* @param data 数据
|
||||
* @param keyType 密钥类型
|
||||
* @param charset 加密前编码
|
||||
* @return 加密后的密文
|
||||
* @throws CryptoException 加密异常
|
||||
* @since 3.1.1
|
||||
* @deprecated 请使用 {@link #encryptBcd(String, KeyType, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String encryptStr(String data, KeyType keyType, Charset charset) {
|
||||
return encryptBcd(data, keyType, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encrypt(byte[] data, KeyType keyType) {
|
||||
// 在非使用BC库情况下,blockSize使用默认的算法
|
||||
@ -204,7 +172,7 @@ public class RSA extends AsymmetricCrypto {
|
||||
}
|
||||
return super.decrypt(bytes, keyType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initCipher() {
|
||||
try {
|
||||
|
@ -52,42 +52,6 @@ public final class DbUtil {
|
||||
return SqlConnRunner.create(DialectFactory.newDialect(conn));
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化一个新的SQL运行对象,使用默认数据源
|
||||
*
|
||||
* @return SQL执行类
|
||||
* @deprecated 请使用 {@link #use()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static SqlRunner newSqlRunner() {
|
||||
return SqlRunner.create(getDs());
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化一个新的SQL运行对象
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @return SQL执行类
|
||||
* @deprecated 请使用 {@link #use(DataSource)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static SqlRunner newSqlRunner(DataSource ds) {
|
||||
return SqlRunner.create(ds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化一个新的SQL运行对象
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @param dialect SQL方言
|
||||
* @return SQL执行类
|
||||
* @deprecated 请使用 {@link #use(DataSource, Dialect)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static SqlRunner newSqlRunner(DataSource ds, Dialect dialect) {
|
||||
return SqlRunner.create(ds, dialect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化一个新的Db,使用默认数据源
|
||||
*
|
||||
|
@ -96,26 +96,6 @@ public class Page implements Segment<Integer>, Serializable {
|
||||
this.pageNumber = Math.max(pageNumber, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 每页结果数
|
||||
* @deprecated 使用 {@link #getPageSize()} 代替
|
||||
*/
|
||||
@Deprecated
|
||||
public int getNumPerPage() {
|
||||
return getPageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置每页结果数
|
||||
*
|
||||
* @param pageSize 每页结果数
|
||||
* @deprecated 使用 {@link #setPageSize(int)} 代替
|
||||
*/
|
||||
@Deprecated
|
||||
public void setNumPerPage(int pageSize) {
|
||||
setPageSize(pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 每页结果数
|
||||
*/
|
||||
|
@ -89,26 +89,6 @@ public class PageResult<T> extends ArrayList<T> {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 每页结果数
|
||||
* @deprecated 请使用{@link #getPageSize()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int getNumPerPage() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置每页结果数
|
||||
*
|
||||
* @param pageSize 每页结果数
|
||||
* @deprecated 请使用 {@link #setPageSize(int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setNumPerPage(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 每页结果数
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@ import java.sql.Savepoint;
|
||||
* 会话通过共用Connection而可以实现JDBC事务<br>
|
||||
* 一个会话只维护一个连接,推荐在执行完后关闭Session,避免重用<br>
|
||||
* 本对象并不是线程安全的,多个线程共用一个Session将会导致不可预知的问题
|
||||
*
|
||||
*
|
||||
* @author loolly
|
||||
*
|
||||
*/
|
||||
@ -30,17 +30,17 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 创建默认数据源会话
|
||||
*
|
||||
*
|
||||
* @return Session
|
||||
* @since 3.2.3
|
||||
*/
|
||||
public static Session create() {
|
||||
return new Session(DSFactory.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建会话
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return Session
|
||||
* @since 4.0.11
|
||||
@ -51,7 +51,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 创建会话
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @return Session
|
||||
*/
|
||||
@ -62,16 +62,16 @@ public class Session extends AbstractDb implements Closeable {
|
||||
// ---------------------------------------------------------------------------- Constructor start
|
||||
/**
|
||||
* 构造,从DataSource中识别方言
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
*/
|
||||
public Session(DataSource ds) {
|
||||
this(ds, DialectFactory.getDialect(ds));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @param driverClassName 数据库连接驱动类名,用于识别方言
|
||||
*/
|
||||
@ -81,7 +81,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @param dialect 方言
|
||||
*/
|
||||
@ -93,7 +93,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
// ---------------------------------------------------------------------------- Getters and Setters end
|
||||
/**
|
||||
* 获得{@link SqlConnRunner}
|
||||
*
|
||||
*
|
||||
* @return {@link SqlConnRunner}
|
||||
*/
|
||||
@Override
|
||||
@ -105,7 +105,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
// ---------------------------------------------------------------------------- Transaction method start
|
||||
/**
|
||||
* 开始事务
|
||||
*
|
||||
*
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public void beginTransaction() throws SQLException {
|
||||
@ -116,7 +116,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 提交事务
|
||||
*
|
||||
*
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public void commit() throws SQLException {
|
||||
@ -133,7 +133,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 回滚事务
|
||||
*
|
||||
*
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public void rollback() throws SQLException {
|
||||
@ -168,7 +168,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 回滚到某个保存点,保存点的设置请使用setSavepoint方法
|
||||
*
|
||||
*
|
||||
* @param savepoint 保存点
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
@ -186,7 +186,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 静默回滚到某个保存点,保存点的设置请使用setSavepoint方法
|
||||
*
|
||||
*
|
||||
* @param savepoint 保存点
|
||||
*/
|
||||
public void quietRollback(Savepoint savepoint) {
|
||||
@ -205,7 +205,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 设置保存点
|
||||
*
|
||||
*
|
||||
* @return 保存点对象
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
@ -215,7 +215,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 设置保存点
|
||||
*
|
||||
*
|
||||
* @param name 保存点的名称
|
||||
* @return 保存点对象
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -226,13 +226,13 @@ public class Session extends AbstractDb implements Closeable {
|
||||
|
||||
/**
|
||||
* 设置事务的隔离级别<br>
|
||||
*
|
||||
*
|
||||
* Connection.TRANSACTION_NONE 驱动不支持事务<br>
|
||||
* Connection.TRANSACTION_READ_UNCOMMITTED 允许脏读、不可重复读和幻读<br>
|
||||
* Connection.TRANSACTION_READ_COMMITTED 禁止脏读,但允许不可重复读和幻读<br>
|
||||
* Connection.TRANSACTION_REPEATABLE_READ 禁止脏读和不可重复读,单运行幻读<br>
|
||||
* Connection.TRANSACTION_SERIALIZABLE 禁止脏读、不可重复读和幻读<br>
|
||||
*
|
||||
*
|
||||
* @param level 隔离级别
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
@ -242,10 +242,10 @@ public class Session extends AbstractDb implements Closeable {
|
||||
}
|
||||
getConnection().setTransactionIsolation(level);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc1}接口的call方法执行多条SQL语句从而完成事务
|
||||
*
|
||||
*
|
||||
* @param func 函数抽象,在函数中执行多个SQL操作,多个操作会被合并为同一事务
|
||||
* @throws SQLException SQL异常
|
||||
* @since 3.2.3
|
||||
@ -261,24 +261,6 @@ public class Session extends AbstractDb implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc1}接口的call方法执行多条SQL语句从而完成事务
|
||||
*
|
||||
* @param func 函数抽象,在函数中执行多个SQL操作,多个操作会被合并为同一事务
|
||||
* @since 3.2.3
|
||||
* @deprecated 请使用{@link #tx(VoidFunc1)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void trans(VoidFunc1<Session> func) {
|
||||
try {
|
||||
beginTransaction();
|
||||
func.call(this);
|
||||
commit();
|
||||
} catch (Exception e) {
|
||||
quietRollback();
|
||||
throw new DbRuntimeException(e);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------- Transaction method end
|
||||
|
||||
// ---------------------------------------------------------------------------- Getters and Setters start
|
||||
@ -291,7 +273,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
public Session setWrapper(Wrapper wrapper) {
|
||||
return (Session) super.setWrapper(wrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Session disableWrapper() {
|
||||
return (Session) super.disableWrapper();
|
||||
@ -313,7 +295,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
} catch (SQLException e) {
|
||||
log.error(e);
|
||||
}
|
||||
|
||||
|
||||
// 普通请求关闭(或归还)连接
|
||||
ThreadLocalConnection.INSTANCE.close(this.ds);
|
||||
}
|
||||
|
@ -111,18 +111,6 @@ public abstract class DSFactory implements Closeable, Serializable{
|
||||
return GlobalDSFactory.get().getDataSource(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Setting获取当前数据源工厂对象
|
||||
*
|
||||
* @param setting 数据源配置文件
|
||||
* @return 当前使用的数据源工厂
|
||||
* @deprecated 此方法容易引起歧义,应使用{@link #create(Setting)} 方法代替之
|
||||
*/
|
||||
@Deprecated
|
||||
public static DSFactory getCurrentDSFactory(Setting setting) {
|
||||
return create(setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置全局的数据源工厂<br>
|
||||
* 在项目中存在多个连接池库的情况下,我们希望使用低优先级的库时使用此方法自定义之<br>
|
||||
|
@ -62,19 +62,6 @@ public class Column implements Serializable, Cloneable {
|
||||
private boolean isPk;
|
||||
// ----------------------------------------------------- Fields end
|
||||
|
||||
/**
|
||||
* 创建列对象
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param columnMetaRs 列元信息的ResultSet
|
||||
* @return 列对象
|
||||
* @deprecated 请使用 {@link #create(Table, ResultSet)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Column create(String tableName, ResultSet columnMetaRs) {
|
||||
return new Column(tableName, columnMetaRs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建列对象
|
||||
*
|
||||
@ -95,22 +82,6 @@ public class Column implements Serializable, Cloneable {
|
||||
public Column() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param columnMetaRs Meta信息的ResultSet
|
||||
* @deprecated 请使用 {@link #Column(Table, ResultSet)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Column(String tableName, ResultSet columnMetaRs) {
|
||||
try {
|
||||
init(tableName, columnMetaRs);
|
||||
} catch (SQLException e) {
|
||||
throw new DbRuntimeException(StrUtil.format("Get table [{}] meta info error!", tableName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
@ -127,19 +98,6 @@ public class Column implements Serializable, Cloneable {
|
||||
}
|
||||
// ----------------------------------------------------- Constructor end
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param columnMetaRs 列的meta ResultSet
|
||||
* @throws SQLException SQL执行异常
|
||||
* @deprecated 请使用 {@link #init(Table, ResultSet)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void init(String tableName, ResultSet columnMetaRs) throws SQLException {
|
||||
init(Table.create(tableName), columnMetaRs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
|
@ -373,7 +373,7 @@ public class Condition extends CloneSupport<Condition> {
|
||||
}
|
||||
|
||||
// 处理 AND y
|
||||
conditionStrBuilder.append(StrUtil.SPACE).append(LogicalOperator.AND.toString());
|
||||
conditionStrBuilder.append(StrUtil.SPACE).append(LogicalOperator.AND);
|
||||
if (isPlaceHolder()) {
|
||||
// 使用条件表达式占位符
|
||||
conditionStrBuilder.append(" ?");
|
||||
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
* 2、@name
|
||||
* 3、?name
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.10
|
||||
*/
|
||||
@ -30,7 +30,7 @@ public class NamedSql {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param namedSql 命名占位符的SQL
|
||||
* @param paramMap 名和参数的对应Map
|
||||
*/
|
||||
@ -41,16 +41,16 @@ public class NamedSql {
|
||||
|
||||
/**
|
||||
* 获取SQL
|
||||
*
|
||||
*
|
||||
* @return SQL
|
||||
*/
|
||||
public String getSql() {
|
||||
return this.sql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取参数列表,按照占位符顺序
|
||||
*
|
||||
*
|
||||
* @return 参数数组
|
||||
*/
|
||||
public Object[] getParams() {
|
||||
@ -59,7 +59,7 @@ public class NamedSql {
|
||||
|
||||
/**
|
||||
* 获取参数列表,按照占位符顺序
|
||||
*
|
||||
*
|
||||
* @return 参数列表
|
||||
*/
|
||||
public List<Object> getParamList() {
|
||||
@ -68,7 +68,7 @@ public class NamedSql {
|
||||
|
||||
/**
|
||||
* 解析命名占位符的SQL
|
||||
*
|
||||
*
|
||||
* @param namedSql 命名占位符的SQL
|
||||
* @param paramMap 名和参数的对应Map
|
||||
*/
|
||||
@ -138,8 +138,20 @@ public class NamedSql {
|
||||
if(paramMap.containsKey(nameStr)) {
|
||||
// 有变量对应值(值可以为null),替换占位符为?,变量值放入相应index位置
|
||||
final Object paramValue = paramMap.get(nameStr);
|
||||
sqlBuilder.append('?');
|
||||
this.params.add(paramValue);
|
||||
if(ArrayUtil.isArray(paramValue) && StrUtil.contains(sqlBuilder, "in")){
|
||||
// 可能为select in (xxx)语句,则拆分参数为多个参数,变成in (?,?,?)
|
||||
final int length = ArrayUtil.length(paramValue);
|
||||
for (int i = 0; i < length; i++) {
|
||||
if(0 != i){
|
||||
sqlBuilder.append(',');
|
||||
}
|
||||
sqlBuilder.append('?');
|
||||
this.params.add(ArrayUtil.get(paramValue, i));
|
||||
}
|
||||
} else{
|
||||
sqlBuilder.append('?');
|
||||
this.params.add(paramValue);
|
||||
}
|
||||
} else {
|
||||
// 无变量对应值,原样输出
|
||||
sqlBuilder.append(nameStartChar).append(name);
|
||||
@ -151,7 +163,7 @@ public class NamedSql {
|
||||
|
||||
/**
|
||||
* 是否为标准的字符,包括大小写字母、下划线和数字
|
||||
*
|
||||
*
|
||||
* @param c 字符
|
||||
* @return 是否标准字符
|
||||
*/
|
||||
|
@ -335,20 +335,6 @@ public class SqlBuilder implements Builder<String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Where语句<br>
|
||||
* 只支持单一的逻辑运算符(例如多个条件之间)
|
||||
*
|
||||
* @param logicalOperator 逻辑运算符
|
||||
* @param conditions 条件,当条件为空时,只添加WHERE关键字
|
||||
* @return 自己
|
||||
* @deprecated logicalOperator放在Condition中了,因此请使用 {@link #where(Condition...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SqlBuilder where(LogicalOperator logicalOperator, Condition... conditions) {
|
||||
return where(conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Where语句<br>
|
||||
*
|
||||
@ -395,19 +381,6 @@ public class SqlBuilder implements Builder<String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Having语句
|
||||
*
|
||||
* @param logicalOperator 逻辑运算符
|
||||
* @param conditions 条件
|
||||
* @return 自己
|
||||
* @deprecated logicalOperator放在Condition中了,因此请使用 {@link #having(Condition...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SqlBuilder having(LogicalOperator logicalOperator, Condition... conditions) {
|
||||
return having(conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Having语句,所有逻辑之间关系使用{@link Condition#setLinkOperator(LogicalOperator)} 定义
|
||||
*
|
||||
@ -498,20 +471,6 @@ public class SqlBuilder implements Builder<String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配合JOIN的 ON语句,多表关联的条件语句<br>
|
||||
* 只支持单一的逻辑运算符(例如多个条件之间)
|
||||
*
|
||||
* @param logicalOperator 逻辑运算符
|
||||
* @param conditions 条件
|
||||
* @return 自己
|
||||
* @deprecated logicalOperator放在Condition中了,因此请使用 {@link #on(Condition...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SqlBuilder on(LogicalOperator logicalOperator, Condition... conditions) {
|
||||
return on(conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配合JOIN的 ON语句,多表关联的条件语句,所有逻辑之间关系使用{@link Condition#setLinkOperator(LogicalOperator)} 定义
|
||||
*
|
||||
@ -602,7 +561,7 @@ public class SqlBuilder implements Builder<String> {
|
||||
* @return this
|
||||
*/
|
||||
public SqlBuilder query(Query query) {
|
||||
return this.select(query.getFields()).from(query.getTableNames()).where(LogicalOperator.AND, query.getWhere());
|
||||
return this.select(query.getFields()).from(query.getTableNames()).where(query.getWhere());
|
||||
}
|
||||
// --------------------------------------------------------------- Builder end
|
||||
|
||||
|
@ -26,19 +26,27 @@ import java.util.Calendar;
|
||||
/**
|
||||
* {@link PreparedStatement} 包装类,用于添加拦截方法功能<br>
|
||||
* 拦截方法包括:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* 1. 提供参数注入
|
||||
* 2. 提供SQL打印日志拦截
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public class StatementWrapper implements PreparedStatement {
|
||||
|
||||
private PreparedStatement rawStatement;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param rawStatement {@link PreparedStatement}
|
||||
*/
|
||||
public StatementWrapper(PreparedStatement rawStatement) {
|
||||
this.rawStatement = rawStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet executeQuery(String sql) throws SQLException {
|
||||
|
@ -2,6 +2,7 @@ package cn.hutool.db;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.db.handler.EntityListHandler;
|
||||
import cn.hutool.db.pojo.User;
|
||||
import cn.hutool.db.sql.Condition;
|
||||
@ -189,4 +190,11 @@ public class CRUDTest {
|
||||
int[] result = db.insert(CollUtil.newArrayList(data1));
|
||||
Console.log(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectInTest() throws SQLException {
|
||||
final List<Entity> results = db.query("select * from user where id in (:ids)",
|
||||
MapUtil.of("ids", new int[]{1, 2, 3}));
|
||||
Assert.assertEquals(2, results.size());
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -27,18 +28,18 @@ public class NamedSqlTest {
|
||||
Assert.assertEquals("张三", namedSql.getParams()[0]);
|
||||
Assert.assertEquals("小豆豆", namedSql.getParams()[1]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void parseTest2() {
|
||||
String sql = "select * from table where id=@id and name = @name1 and nickName = :subName";
|
||||
|
||||
|
||||
Map<String, Object> paramMap = MapUtil
|
||||
.builder("name1", (Object)"张三")
|
||||
.put("age", 12)
|
||||
.put("subName", "小豆豆")
|
||||
.put("id", null)
|
||||
.build();
|
||||
|
||||
|
||||
NamedSql namedSql = new NamedSql(sql, paramMap);
|
||||
Assert.assertEquals("select * from table where id=? and name = ? and nickName = ?", namedSql.getSql());
|
||||
//指定了null参数的依旧替换,参数值为null
|
||||
@ -73,6 +74,18 @@ public class NamedSqlTest {
|
||||
Assert.assertEquals(sql, namedSql.getSql());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseInTest(){
|
||||
String sql = "select * from user where id in (:ids)";
|
||||
final HashMap<String, Object> paramMap = MapUtil.of("ids", new int[]{1, 2, 3});
|
||||
|
||||
NamedSql namedSql = new NamedSql(sql, paramMap);
|
||||
Assert.assertEquals("select * from user where id in (?,?,?)", namedSql.getSql());
|
||||
Assert.assertEquals(1, namedSql.getParams()[0]);
|
||||
Assert.assertEquals(2, namedSql.getParams()[1]);
|
||||
Assert.assertEquals(3, namedSql.getParams()[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTest() throws SQLException {
|
||||
Map<String, Object> paramMap = MapUtil
|
||||
|
@ -112,18 +112,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.isMatch(JSONUtil.toJsonStr(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的第一个敏感词
|
||||
*
|
||||
* @param text 文本
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundFirstSensitive(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getFindedFirstSensitive(String text) {
|
||||
return sensitiveTree.match(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的第一个敏感词
|
||||
*
|
||||
@ -135,18 +123,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.matchWord(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的第一个敏感词
|
||||
*
|
||||
* @param obj bean,会被转为JSON字符串
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundFirstSensitive(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getFindedFirstSensitive(Object obj) {
|
||||
return sensitiveTree.match(JSONUtil.toJsonStr(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的第一个敏感词
|
||||
*
|
||||
@ -157,18 +133,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.matchWord(JSONUtil.toJsonStr(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词
|
||||
*
|
||||
* @param text 文本
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundAllSensitive(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getFindedAllSensitive(String text) {
|
||||
return sensitiveTree.matchAll(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词
|
||||
*
|
||||
@ -180,22 +144,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.matchAllWords(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词<br>
|
||||
* 密集匹配原则:假如关键词有 ab,b,文本是abab,将匹配 [ab,b,ab]<br>
|
||||
* 贪婪匹配(最长匹配)原则:假如关键字a,ab,最长匹配将匹配[a, ab]
|
||||
*
|
||||
* @param text 文本
|
||||
* @param isDensityMatch 是否使用密集匹配原则
|
||||
* @param isGreedMatch 是否使用贪婪匹配(最长匹配)原则
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundAllSensitive(String, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getFindedAllSensitive(String text, boolean isDensityMatch, boolean isGreedMatch) {
|
||||
return sensitiveTree.matchAll(text, -1, isDensityMatch, isGreedMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词<br>
|
||||
* 密集匹配原则:假如关键词有 ab,b,文本是abab,将匹配 [ab,b,ab]<br>
|
||||
@ -210,18 +158,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.matchAllWords(text, -1, isDensityMatch, isGreedMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词
|
||||
*
|
||||
* @param bean 对象,会被转为JSON
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundAllSensitive(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getFindedAllSensitive(Object bean) {
|
||||
return sensitiveTree.matchAll(JSONUtil.toJsonStr(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词
|
||||
*
|
||||
@ -233,22 +169,6 @@ public final class SensitiveUtil {
|
||||
return sensitiveTree.matchAllWords(JSONUtil.toJsonStr(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词<br>
|
||||
* 密集匹配原则:假如关键词有 ab,b,文本是abab,将匹配 [ab,b,ab]<br>
|
||||
* 贪婪匹配(最长匹配)原则:假如关键字a,ab,最长匹配将匹配[a, ab]
|
||||
*
|
||||
* @param bean 对象,会被转为JSON
|
||||
* @param isDensityMatch 是否使用密集匹配原则
|
||||
* @param isGreedMatch 是否使用贪婪匹配(最长匹配)原则
|
||||
* @return 敏感词
|
||||
* @deprecated 请使用 {@link #getFoundAllSensitive(Object, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getFindedAllSensitive(Object bean, boolean isDensityMatch, boolean isGreedMatch) {
|
||||
return sensitiveTree.matchAll(JSONUtil.toJsonStr(bean), -1, isDensityMatch, isGreedMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找敏感词,返回找到的所有敏感词<br>
|
||||
* 密集匹配原则:假如关键词有 ab,b,文本是abab,将匹配 [ab,b,ab]<br>
|
||||
|
@ -1,290 +0,0 @@
|
||||
package cn.hutool.extra.template.engine.beetl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.beetl.core.Configuration;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
import org.beetl.core.ResourceLoader;
|
||||
import org.beetl.core.Template;
|
||||
import org.beetl.core.resource.ClasspathResourceLoader;
|
||||
import org.beetl.core.resource.CompositeResourceLoader;
|
||||
import org.beetl.core.resource.FileResourceLoader;
|
||||
import org.beetl.core.resource.Matcher;
|
||||
import org.beetl.core.resource.StringTemplateResourceLoader;
|
||||
import org.beetl.core.resource.WebAppResourceLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Beetl模板引擎工具类<br>
|
||||
* http://git.oschina.net/xiandafu/beetl2.0 <br>
|
||||
* 文档:http://ibeetl.com/guide/beetl.html
|
||||
*
|
||||
* @author Looly
|
||||
* @deprecated 使用TemplateUtil替代
|
||||
*/
|
||||
@Deprecated
|
||||
public final class BeetlUtil {
|
||||
|
||||
/**
|
||||
* 创建默认模板组{@link GroupTemplate},默认的模板组从ClassPath中读取
|
||||
*
|
||||
* @return {@link GroupTemplate}
|
||||
*/
|
||||
public static GroupTemplate createGroupTemplate() {
|
||||
return new GroupTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建字符串的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createStrGroupTemplate() {
|
||||
return createGroupTemplate(new StringTemplateResourceLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建WebApp的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createWebAppGroupTemplate() {
|
||||
return createGroupTemplate(new WebAppResourceLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建字符串的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @param path 相对ClassPath的路径
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createClassPathGroupTemplate(String path) {
|
||||
return createGroupTemplate(new ClasspathResourceLoader(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件目录的模板组 {@link GroupTemplate},配置文件使用全局默认,使用UTF-8编码<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @param dir 目录路径(绝对路径)
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createFileGroupTemplate(String dir) {
|
||||
return createFileGroupTemplate(dir, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件目录的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @param dir 目录路径(绝对路径)
|
||||
* @param charset 读取模板文件的编码
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createFileGroupTemplate(String dir, Charset charset) {
|
||||
return createGroupTemplate(new FileResourceLoader(dir, charset.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建自定义的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
|
||||
* 此时自定义的配置文件可在ClassPath中放入beetl.properties配置
|
||||
*
|
||||
* @param loader {@link ResourceLoader},资源加载器
|
||||
* @return {@link GroupTemplate}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static GroupTemplate createGroupTemplate(ResourceLoader<?> loader) {
|
||||
try {
|
||||
return createGroupTemplate(loader, Configuration.defaultConfiguration());
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建自定义的 {@link GroupTemplate}
|
||||
*
|
||||
* @param loader {@link ResourceLoader},资源加载器
|
||||
* @param conf {@link Configuration} 配置文件
|
||||
* @return {@link GroupTemplate}
|
||||
*/
|
||||
public static GroupTemplate createGroupTemplate(ResourceLoader<?> loader, Configuration conf) {
|
||||
return new GroupTemplate(loader, conf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得模板
|
||||
*
|
||||
* @param groupTemplate {@link GroupTemplate}
|
||||
* @param source 模板资源,根据不同的 {@link ResourceLoader} 加载不同的模板资源
|
||||
* @return {@link Template}
|
||||
*/
|
||||
public static Template getTemplate(GroupTemplate groupTemplate, String source) {
|
||||
return groupTemplate.getTemplate(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得字符串模板
|
||||
*
|
||||
* @param source 模板内容
|
||||
* @return 模板
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static Template getStrTemplate(String source) {
|
||||
return getTemplate(createStrGroupTemplate(), source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得ClassPath模板
|
||||
*
|
||||
* @param path ClassPath路径
|
||||
* @param templateFileName 模板内容
|
||||
* @return 模板
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static Template getClassPathTemplate(String path, String templateFileName) {
|
||||
return getTemplate(createClassPathGroupTemplate(path), templateFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得本地文件模板
|
||||
*
|
||||
* @param dir 目录绝对路径
|
||||
* @param templateFileName 模板内容
|
||||
* @return 模板
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static Template getFileTemplate(String dir, String templateFileName) {
|
||||
return getTemplate(createFileGroupTemplate(dir), templateFileName);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------- Render
|
||||
/**
|
||||
* 渲染模板
|
||||
*
|
||||
* @param template {@link Template}
|
||||
* @param bindingMap 绑定参数
|
||||
* @return 渲染后的内容
|
||||
*/
|
||||
public static String render(Template template, Map<String, Object> bindingMap) {
|
||||
template.binding(bindingMap);
|
||||
return template.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板,如果为相对路径,则渲染ClassPath模板,否则渲染本地文件模板
|
||||
*
|
||||
* @param path 路径
|
||||
* @param templateFileName 模板文件名
|
||||
* @param bindingMap 绑定参数
|
||||
* @return 渲染后的内容
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static String render(String path, String templateFileName, Map<String, Object> bindingMap) {
|
||||
if (FileUtil.isAbsolutePath(path)) {
|
||||
return render(getFileTemplate(path, templateFileName), bindingMap);
|
||||
} else {
|
||||
return render(getClassPathTemplate(path, templateFileName), bindingMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板
|
||||
*
|
||||
* @param templateContent 模板内容
|
||||
* @param bindingMap 绑定参数
|
||||
* @return 渲染后的内容
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static String renderFromStr(String templateContent, Map<String, Object> bindingMap) {
|
||||
return render(getStrTemplate(templateContent), bindingMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板
|
||||
*
|
||||
* @param templateContent {@link Template}
|
||||
* @param bindingMap 绑定参数
|
||||
* @param writer {@link Writer} 渲染后写入的目标Writer
|
||||
* @return {@link Writer}
|
||||
*/
|
||||
public static Writer render(Template templateContent, Map<String, Object> bindingMap, Writer writer) {
|
||||
templateContent.binding(bindingMap);
|
||||
templateContent.renderTo(writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板
|
||||
*
|
||||
* @param templateContent 模板内容
|
||||
* @param bindingMap 绑定参数
|
||||
* @param writer {@link Writer} 渲染后写入的目标Writer
|
||||
* @return {@link Writer}
|
||||
*/
|
||||
public static Writer renderFromStr(String templateContent, Map<String, Object> bindingMap, Writer writer) {
|
||||
return render(getStrTemplate(templateContent), bindingMap, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始构建 {@link ResourceLoaderBuilder},调用{@link ResourceLoaderBuilder#build()}完成构建
|
||||
*
|
||||
* @return {@link ResourceLoaderBuilder}
|
||||
*/
|
||||
public static ResourceLoaderBuilder resourceLoaderBuilder() {
|
||||
return new ResourceLoaderBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceLoader构建器
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public static class ResourceLoaderBuilder {
|
||||
private final CompositeResourceLoader compositeResourceLoader = new CompositeResourceLoader();
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @return ResourceLoaderBuilder
|
||||
*/
|
||||
public static ResourceLoaderBuilder create() {
|
||||
return new ResourceLoaderBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个资源加载器
|
||||
*
|
||||
* @param matcher {@link Matcher} 匹配器
|
||||
* @param resourceLoader {@link ResourceLoader} 匹配时对应的资源加载器
|
||||
* @return ResourceLoaderBuilder
|
||||
*/
|
||||
public ResourceLoaderBuilder add(Matcher matcher, ResourceLoader<?> resourceLoader) {
|
||||
compositeResourceLoader.addResourceLoader(matcher, resourceLoader);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建
|
||||
*
|
||||
* @return {@link ResourceLoader} 资源加载器
|
||||
*/
|
||||
public ResourceLoader<?> build() {
|
||||
return compositeResourceLoader;
|
||||
}
|
||||
}
|
||||
}
|
@ -63,18 +63,6 @@ public class VelocityEngine implements TemplateEngine {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始的引擎对象
|
||||
*
|
||||
* @return 原始引擎对象
|
||||
* @since 4.3.0
|
||||
* @deprecated 拼写错误了,请使用{@link #getRawEngine()}
|
||||
*/
|
||||
@Deprecated
|
||||
public org.apache.velocity.app.VelocityEngine getRowEngine() {
|
||||
return getRawEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始的引擎对象
|
||||
*
|
||||
|
@ -1,343 +0,0 @@
|
||||
package cn.hutool.extra.template.engine.velocity;
|
||||
|
||||
import cn.hutool.core.exceptions.NotInitedException;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Velocity模板引擎工具类<br>
|
||||
* 使用前必须初始化工具类
|
||||
*
|
||||
* @author xiaoleilu
|
||||
* @deprecated 使用TemplateUtil替代
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 是否初始化了默认引擎
|
||||
*/
|
||||
private static boolean isInited;
|
||||
/**
|
||||
* 全局上下文,当设定值时,对于每个模板都有效
|
||||
*/
|
||||
private static final Map<String, Object> globalContext = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 设置Velocity全局上下文<br>
|
||||
* 当设定值时,对于每个模板都有效
|
||||
*
|
||||
* @param name 名
|
||||
* @param value 值
|
||||
*/
|
||||
public void putGlobalContext(String name, Object value) {
|
||||
globalContext.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Velocity全局属性
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param charset 编码
|
||||
*/
|
||||
synchronized public static void init(String templateDir, String charset) {
|
||||
Velocity.init(_newInitedProp(templateDir, charset));
|
||||
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
|
||||
|
||||
isInited = true; // 标记完成初始化
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化全局属性
|
||||
*
|
||||
* @param templateDir 模板目录
|
||||
* @param charset 字符集编码
|
||||
* @param initedGlobalContext 初始的全局上下文
|
||||
*/
|
||||
public static void init(String templateDir, String charset, Map<String, Object> initedGlobalContext) {
|
||||
globalContext.putAll(initedGlobalContext);
|
||||
init(templateDir, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建Velocity模板引擎
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param charset 编码
|
||||
* @return VelocityEngine
|
||||
*/
|
||||
public static VelocityEngine newEngine(String templateDir, String charset) {
|
||||
final VelocityEngine ve = new VelocityEngine();
|
||||
|
||||
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
|
||||
ve.init(_newInitedProp(templateDir, charset));
|
||||
|
||||
return ve;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param templateFileName 模板名称
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @param charset 字符集
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(String templateDir, String templateFileName, VelocityContext context, String charset) {
|
||||
// 初始化模板引擎
|
||||
final VelocityEngine ve = newEngine(templateDir, charset);
|
||||
|
||||
return getContent(ve, templateFileName, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
* @param templateFileName 模板名称
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(VelocityEngine ve, String templateFileName, VelocityContext context) {
|
||||
final StringWriter writer = new StringWriter(); // StringWriter不需要关闭
|
||||
toWriter(ve, templateFileName, context, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容,使用默认引擎
|
||||
*
|
||||
* @param templateFileName 模板文件
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(String templateFileName, VelocityContext context) {
|
||||
final StringWriter writer = new StringWriter(); // StringWriter不需要关闭
|
||||
toWriter(templateFileName, context, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(VelocityEngine ve, String templateFileName, VelocityContext context, String destPath) {
|
||||
toFile(ve.getTemplate(templateFileName), context, destPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件,使用默认引擎
|
||||
*
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 模板上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
|
||||
assertInit();
|
||||
|
||||
toFile(Velocity.getTemplate(templateFileName), context, destPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param template 模板
|
||||
* @param context 模板上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(Template template, VelocityContext context, String destPath) {
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.INPUT_ENCODING).toString(), false);
|
||||
merge(template, context, writer);
|
||||
} catch (IORuntimeException e) {
|
||||
throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
|
||||
} finally {
|
||||
IoUtil.close(writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成内容写入流<br>
|
||||
* 会自动关闭Writer
|
||||
*
|
||||
* @param ve 引擎
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
*/
|
||||
public static void toWriter(VelocityEngine ve, String templateFileName, VelocityContext context, Writer writer) {
|
||||
final Template template = ve.getTemplate(templateFileName);
|
||||
merge(template, context, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成内容写入流<br>
|
||||
* 会自动关闭Writer
|
||||
*
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
*/
|
||||
public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
|
||||
assertInit();
|
||||
|
||||
final Template template = Velocity.getTemplate(templateFileName);
|
||||
merge(template, context, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成内容写到响应内容中<br>
|
||||
* 模板的变量来自于Request的Attribute对象
|
||||
*
|
||||
* @param templateFileName 模板文件
|
||||
* @param request 请求对象,用于获取模板中的变量值
|
||||
* @param response 响应对象
|
||||
*/
|
||||
public static void toWriter(String templateFileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
|
||||
final VelocityContext context = new VelocityContext();
|
||||
parseRequest(context, request);
|
||||
parseSession(context, request.getSession(false));
|
||||
|
||||
Writer writer = null;
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
toWriter(templateFileName, context, writer);
|
||||
} catch (Exception e) {
|
||||
throw new UtilException(e, "Write Velocity content template by [{}] to response error!", templateFileName);
|
||||
} finally {
|
||||
IoUtil.close(writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合模板和内容
|
||||
*
|
||||
* @param templateContent 模板的内容字符串
|
||||
* @param context 上下文
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String merge(String templateContent, VelocityContext context) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
Velocity.evaluate(context, writer, IdUtil.randomUUID(), templateContent);
|
||||
} catch (Exception e) {
|
||||
throw new UtilException(e);
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合模板和内容并写入到Writer
|
||||
*
|
||||
* @param template 模板
|
||||
* @param context 内容
|
||||
* @param writer Writer
|
||||
*/
|
||||
public static void merge(Template template, VelocityContext context, Writer writer) {
|
||||
if (template == null) {
|
||||
throw new UtilException("Template is null");
|
||||
}
|
||||
if (context == null) {
|
||||
context = new VelocityContext(globalContext);
|
||||
} else {
|
||||
// 加入全局上下文
|
||||
for (Entry<String, Object> entry : globalContext.entrySet()) {
|
||||
context.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
template.merge(context, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Request中的数据转换为模板引擎<br>
|
||||
* 取值包括Session和Request
|
||||
*
|
||||
* @param context 内容
|
||||
* @param request 请求对象
|
||||
* @return VelocityContext
|
||||
*/
|
||||
public static VelocityContext parseRequest(VelocityContext context, javax.servlet.http.HttpServletRequest request) {
|
||||
final Enumeration<String> attrs = request.getAttributeNames();
|
||||
if (attrs != null) {
|
||||
String attrName;
|
||||
while (attrs.hasMoreElements()) {
|
||||
attrName = attrs.nextElement();
|
||||
context.put(attrName, request.getAttribute(attrName));
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Session中的值放入模板上下文
|
||||
*
|
||||
* @param context 模板上下文
|
||||
* @param session Session
|
||||
* @return VelocityContext
|
||||
*/
|
||||
public static VelocityContext parseSession(VelocityContext context, javax.servlet.http.HttpSession session) {
|
||||
if (null != session) {
|
||||
final Enumeration<String> sessionAttrs = session.getAttributeNames();
|
||||
if (sessionAttrs != null) {
|
||||
String attrName;
|
||||
while (sessionAttrs.hasMoreElements()) {
|
||||
attrName = sessionAttrs.nextElement();
|
||||
context.put(attrName, session.getAttribute(attrName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- Private method start
|
||||
|
||||
/**
|
||||
* 新建一个初始化后的属性对象
|
||||
*
|
||||
* @param templateDir 模板所在目录
|
||||
* @return 初始化后的属性对象
|
||||
*/
|
||||
private static Properties _newInitedProp(String templateDir, String charset) {
|
||||
final Properties properties = new Properties();
|
||||
|
||||
properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templateDir);
|
||||
properties.setProperty(Velocity.ENCODING_DEFAULT, charset);
|
||||
properties.setProperty(Velocity.INPUT_ENCODING, charset);
|
||||
// properties.setProperty(Velocity.OUTPUT_ENCODING, charset);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言是否初始化默认引擎,若未初始化抛出 异常
|
||||
*/
|
||||
private static void assertInit() {
|
||||
if (false == isInited) {
|
||||
throw new NotInitedException("Please use VelocityUtil.init() method to init Velocity default engine!");
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------- Private method end
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cn.hutool.extra.template;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.extra.template.engine.beetl.BeetlUtil;
|
||||
import org.beetl.core.Configuration;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
import org.beetl.core.Template;
|
||||
@ -13,7 +12,7 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* BeetlUtil单元测试
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
|
@ -794,19 +794,6 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否对URL中的参数进行编码
|
||||
*
|
||||
* @param isEncodeUrlParams 是否对URL中的参数进行编码
|
||||
* @return this
|
||||
* @since 4.4.1
|
||||
* @deprecated 编码自动完成,无需设置
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpRequest setEncodeUrlParams(boolean isEncodeUrlParams) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否打开重定向,如果打开默认重定向次数为2<br>
|
||||
* 此方法效果与{@link #setMaxRedirectCount(int)} 一致
|
||||
|
@ -563,20 +563,6 @@ public class HttpUtil {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将URL参数解析为Map(也可以解析Post中的键值对参数)
|
||||
*
|
||||
* @param paramsStr 参数字符串(或者带参数的Path)
|
||||
* @param charset 字符集
|
||||
* @return 参数Map
|
||||
* @since 4.0.2
|
||||
* @deprecated 请使用 {@link #decodeParamMap(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Map<String, String> decodeParamMap(String paramsStr, String charset) {
|
||||
return decodeParamMap(paramsStr, CharsetUtil.charset(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将URL参数解析为Map(也可以解析Post中的键值对参数)
|
||||
*
|
||||
|
@ -240,65 +240,6 @@ public class SoapClient extends HttpBase<SoapClient> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SOAP头信息
|
||||
*
|
||||
* @param name 头信息标签名
|
||||
* @return this
|
||||
* @deprecated 为了和Http Hrader区分,请使用{@link #addSOAPHeader(QName)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SoapClient setHeader(QName name) {
|
||||
return setSOAPHeader(name, null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SOAP头信息
|
||||
*
|
||||
* @param name 头信息标签名
|
||||
* @return this
|
||||
* @deprecated 为了便于设置子节点或者value值,请使用{@link #addSOAPHeader(QName)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SoapClient setSOAPHeader(QName name) {
|
||||
addSOAPHeader(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SOAP头信息
|
||||
*
|
||||
* @param name 头信息标签名
|
||||
* @param actorURI 中间的消息接收者
|
||||
* @param roleUri Role的URI
|
||||
* @param mustUnderstand 标题项对于要对其进行处理的接收者来说是强制的还是可选的
|
||||
* @param relay relay属性
|
||||
* @return this
|
||||
* @deprecated 为了和Http Header区分,请使用{@link #addSOAPHeader(QName, String, String, Boolean, Boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SoapClient setHeader(QName name, String actorURI, String roleUri, Boolean mustUnderstand, Boolean relay) {
|
||||
return setSOAPHeader(name, actorURI, roleUri, mustUnderstand, relay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SOAP头信息
|
||||
*
|
||||
* @param name 头信息标签名
|
||||
* @param actorURI 中间的消息接收者
|
||||
* @param roleUri Role的URI
|
||||
* @param mustUnderstand 标题项对于要对其进行处理的接收者来说是强制的还是可选的
|
||||
* @param relay relay属性
|
||||
* @return this
|
||||
* @deprecated 为了便于设置子节点或者value值,请使用{@link #addSOAPHeader(QName, String, String, Boolean, Boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SoapClient setSOAPHeader(QName name, String actorURI, String roleUri, Boolean mustUnderstand, Boolean relay) {
|
||||
addSOAPHeader(name, actorURI, roleUri, mustUnderstand, relay);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加SOAP头信息,方法返回{@link SOAPHeaderElement}可以设置具体属性和子节点
|
||||
*
|
||||
|
@ -151,31 +151,6 @@ public class JSONConfig implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略transient关键字修饰的字段
|
||||
*
|
||||
* @return 是否忽略transient关键字修饰的字段
|
||||
* @since 5.3.11
|
||||
* @deprecated 此方法名称有二义性,请使用{@link #isTransientSupport()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isIgnoreTransient() {
|
||||
return isTransientSupport();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否忽略transient关键字修饰的字段
|
||||
*
|
||||
* @param ignoreTransient 是否忽略transient关键字修饰的字段
|
||||
* @return this
|
||||
* @since 5.3.11
|
||||
* @deprecated 此方法名称有二义性,请使用{@link #setTransientSupport(boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JSONConfig setIgnoreTransient(boolean ignoreTransient) {
|
||||
return setTransientSupport(ignoreTransient);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否支持transient关键字修饰和@Transient注解,如果支持,被修饰的字段或方法对应的字段将被忽略。
|
||||
*
|
||||
|
@ -28,7 +28,6 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* JSON工具类
|
||||
@ -247,29 +246,6 @@ public class JSONUtil {
|
||||
return XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map转化为JSONObject
|
||||
*
|
||||
* @param map {@link Map}
|
||||
* @return JSONObjec
|
||||
* @deprecated 请直接使用 {@link #parseObj(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static JSONObject parseFromMap(Map<?, ?> map) {
|
||||
return new JSONObject(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceBundle转化为JSONObject
|
||||
*
|
||||
* @param bundle ResourceBundle文件
|
||||
* @return JSONObject
|
||||
* @deprecated 请直接使用 {@link #parseObj(Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static JSONObject parseFromResourceBundle(ResourceBundle bundle) {
|
||||
return new JSONObject(bundle);
|
||||
}
|
||||
// -------------------------------------------------------------------- Pause end
|
||||
|
||||
// -------------------------------------------------------------------- Read start
|
||||
|
@ -75,19 +75,6 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
||||
this(WorkbookUtil.createBook(bookFile), sheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetIndex sheet序号,0表示第一个sheet
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public ExcelReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
@ -98,19 +85,6 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetName sheet名,第一个默认是sheet1
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public ExcelReader(InputStream bookStream, String sheetName, boolean closeAfterRead) {
|
||||
this(WorkbookUtil.createBook(bookStream), sheetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
|
@ -8,8 +8,6 @@ import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.PoiChecker;
|
||||
import cn.hutool.poi.excel.cell.CellLocation;
|
||||
import cn.hutool.poi.excel.sax.Excel03SaxReader;
|
||||
import cn.hutool.poi.excel.sax.Excel07SaxReader;
|
||||
import cn.hutool.poi.excel.sax.ExcelSaxReader;
|
||||
import cn.hutool.poi.excel.sax.ExcelSaxUtil;
|
||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
@ -113,120 +111,6 @@ public class ExcelUtil {
|
||||
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
||||
reader.read(in, idOrRid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(InputStream, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(InputStream in, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(in, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param file 文件
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(File, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(File file, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(file, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel07
|
||||
*
|
||||
* @param path 路径
|
||||
* @param rid Sheet rid,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel07SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(String, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel07SaxReader read07BySax(String path, int rid, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel07SaxReader(rowHandler).read(path, rid);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(InputStream, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(in, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param file 文件
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(File, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(File file, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(file, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sax方式读取Excel03
|
||||
*
|
||||
* @param path 路径
|
||||
* @param sheetIndex Sheet索引,-1表示全部Sheet, 0表示第一个Sheet
|
||||
* @param rowHandler 行处理器
|
||||
* @return {@link Excel03SaxReader}
|
||||
* @since 3.2.0
|
||||
* @deprecated 请使用 {@link #readBySax(String, int, RowHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Excel03SaxReader read03BySax(String path, int sheetIndex, RowHandler rowHandler) {
|
||||
try {
|
||||
return new Excel03SaxReader(rowHandler).read(path, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------ Read by Sax end
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ getReader
|
||||
@ -308,24 +192,7 @@ public class ExcelUtil {
|
||||
* @return {@link ExcelReader}
|
||||
*/
|
||||
public static ExcelReader getReader(InputStream bookStream) {
|
||||
return getReader(bookStream, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
||||
* 默认调用第一个sheet
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public static ExcelReader getReader(InputStream bookStream, boolean closeAfterRead) {
|
||||
try {
|
||||
return getReader(bookStream, 0, closeAfterRead);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
return getReader(bookStream, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,25 +211,6 @@ public class ExcelUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetIndex sheet序号,0表示第一个sheet
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @since 4.0.3
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExcelReader getReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) {
|
||||
try {
|
||||
return new ExcelReader(bookStream, sheetIndex);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容<br>
|
||||
* 读取结束自动关闭流
|
||||
@ -379,24 +227,6 @@ public class ExcelUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Excel读取器,通过调用{@link ExcelReader}的read或readXXX方法读取Excel内容
|
||||
*
|
||||
* @param bookStream Excel文件的流
|
||||
* @param sheetName sheet名,第一个默认是sheet1
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link ExcelReader}
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义。
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExcelReader getReader(InputStream bookStream, String sheetName, boolean closeAfterRead) {
|
||||
try {
|
||||
return new ExcelReader(bookStream, sheetName);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ getWriter
|
||||
|
||||
/**
|
||||
|
@ -1039,20 +1039,6 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定单元格创建样式
|
||||
*
|
||||
* @param x X坐标,从0计数,即列号
|
||||
* @param y Y坐标,从0计数,即行号
|
||||
* @return {@link CellStyle}
|
||||
* @since 4.0.9
|
||||
* @deprecated 请使用 {@link #createCellStyle(int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CellStyle createStyleForCell(int x, int y) {
|
||||
return createCellStyle(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置某个单元格的样式<br>
|
||||
* 此方法用于多个单元格共享样式的情况<br>
|
||||
|
@ -19,7 +19,7 @@ import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Excel工作簿{@link Workbook}相关工具类
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.7
|
||||
*
|
||||
@ -28,7 +28,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFilePath Excel文件路径,绝对路径或相对于ClassPath路径
|
||||
* @return {@link Workbook}
|
||||
* @since 3.1.1
|
||||
@ -39,7 +39,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link Workbook}
|
||||
*/
|
||||
@ -49,13 +49,13 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建工作簿,用于Excel写出
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* 1. excelFile为null时直接返回一个空的工作簿,默认xlsx格式
|
||||
* 2. 文件已存在则通过流的方式读取到这个工作簿
|
||||
* 3. 文件不存在则检查传入文件路径是否以xlsx为扩展名,是则创建xlsx工作簿,否则创建xls工作簿
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link Workbook}
|
||||
* @since 4.5.18
|
||||
@ -68,13 +68,13 @@ public class WorkbookUtil {
|
||||
if (excelFile.exists()) {
|
||||
return createBook(FileUtil.getInputStream(excelFile));
|
||||
}
|
||||
|
||||
|
||||
return createBook(StrUtil.endWithIgnoreCase(excelFile.getName(), ".xlsx"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿,只读模式
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @param password Excel工作簿密码,如果无密码传{@code null}
|
||||
* @return {@link Workbook}
|
||||
@ -87,19 +87,6 @@ public class WorkbookUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link Workbook}
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createBook(InputStream)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Workbook createBook(InputStream in, boolean closeAfterRead) {
|
||||
return createBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
@ -110,21 +97,6 @@ public class WorkbookUtil {
|
||||
return createBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param password 密码
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link Workbook}
|
||||
* @since 4.0.3
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createBook(InputStream, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Workbook createBook(InputStream in, String password, boolean closeAfterRead) {
|
||||
return createBook(in, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载工作簿
|
||||
*
|
||||
@ -145,7 +117,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 根据文件类型创建新的工作簿,文件路径
|
||||
*
|
||||
*
|
||||
* @param isXlsx 是否为xlsx格式的Excel
|
||||
* @return {@link Workbook}
|
||||
* @since 4.1.0
|
||||
@ -162,7 +134,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFilePath Excel文件路径,绝对路径或相对于ClassPath路径
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
@ -173,7 +145,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
@ -184,7 +156,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿,只读模式
|
||||
*
|
||||
*
|
||||
* @param excelFile Excel文件
|
||||
* @param password Excel工作簿密码,如果无密码传{@code null}
|
||||
* @return {@link SXSSFWorkbook}
|
||||
@ -196,29 +168,13 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
* @since 5.7.1
|
||||
*/
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in, boolean closeAfterRead) {
|
||||
return createSXSSFBook(in, null, closeAfterRead);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建或加载SXSSFWorkbook工作簿
|
||||
*
|
||||
* @param in Excel输入流
|
||||
* @param password 密码
|
||||
* @param closeAfterRead 读取结束是否关闭流
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
* @deprecated 使用完毕无论是否closeAfterRead,poi会关闭流,此参数无意义,请使用{@link #createSXSSFBook(InputStream, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in, String password, boolean closeAfterRead) {
|
||||
return toSXSSFBook(createBook(in, password, closeAfterRead));
|
||||
public static SXSSFWorkbook createSXSSFBook(InputStream in) {
|
||||
return createSXSSFBook(in, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +191,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建SXSSFWorkbook,用于大批量数据写出
|
||||
*
|
||||
*
|
||||
* @return {@link SXSSFWorkbook}
|
||||
* @since 4.1.13
|
||||
*/
|
||||
@ -245,7 +201,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 创建SXSSFWorkbook,用于大批量数据写出
|
||||
*
|
||||
*
|
||||
* @param rowAccessWindowSize 在内存中的行数
|
||||
* @return {@link Workbook}
|
||||
* @since 4.1.13
|
||||
@ -256,7 +212,7 @@ public class WorkbookUtil {
|
||||
|
||||
/**
|
||||
* 将Excel Workbook刷出到输出流,不关闭流
|
||||
*
|
||||
*
|
||||
* @param book {@link Workbook}
|
||||
* @param out 输出流
|
||||
* @throws IORuntimeException IO异常
|
||||
@ -273,7 +229,7 @@ public class WorkbookUtil {
|
||||
/**
|
||||
* 获取或者创建sheet表<br>
|
||||
* 如果sheet表在Workbook中已经存在,则获取之,否则创建之
|
||||
*
|
||||
*
|
||||
* @param book 工作簿{@link Workbook}
|
||||
* @param sheetName 工作表名
|
||||
* @return 工作表{@link Sheet}
|
||||
@ -315,9 +271,9 @@ public class WorkbookUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* sheet是否为空
|
||||
*
|
||||
*
|
||||
* @param sheet {@link Sheet}
|
||||
* @return sheet是否为空
|
||||
* @since 4.0.1
|
||||
@ -329,7 +285,7 @@ public class WorkbookUtil {
|
||||
// -------------------------------------------------------------------------------------------------------- Private method start
|
||||
/**
|
||||
* 将普通工作簿转换为SXSSFWorkbook
|
||||
*
|
||||
*
|
||||
* @param book 工作簿
|
||||
* @return SXSSFWorkbook
|
||||
* @since 4.1.13
|
||||
|
@ -512,20 +512,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
return this.groupedMap.get(group, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对加入到对应分组中
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 此key之前存在的值,如果没有返回null
|
||||
* @deprecated 此方法与getXXX参数顺序不一致容易造成问题,建议使用{@link #putByGroup(String, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String put(String group, String key, String value) {
|
||||
return this.groupedMap.put(group, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对加入到对应分组中
|
||||
*
|
||||
@ -629,21 +615,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对加入到对应分组中
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 此key之前存在的值,如果没有返回null
|
||||
* @deprecated 此方法与getXXX参数顺序不一致容易引起,请使用{@link #setByGroup(String, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Setting set(String group, String key, String value) {
|
||||
this.put(group, key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对加入到对应分组中<br>
|
||||
* 此方法用于与getXXX统一参数顺序
|
||||
|
@ -317,11 +317,6 @@ public class OsInfo implements Serializable{
|
||||
return IS_OS_WINDOWS_8;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final boolean isWindoows8() {
|
||||
return IS_OS_WINDOWS_8;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前OS的类型。
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user