mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
remove deprecated
This commit is contained in:
parent
d78219c60c
commit
af1d615ca9
@ -356,52 +356,6 @@ public class BeanUtil {
|
||||
|
||||
// --------------------------------------------------------------------------------------------- mapToBean
|
||||
|
||||
/**
|
||||
* Map转换为Bean对象
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param map {@link Map}
|
||||
* @param beanClass Bean Class
|
||||
* @param isIgnoreError 是否忽略注入错误
|
||||
* @return Bean
|
||||
* @deprecated 请使用 {@link #toBean(Object, Class)} 或 {@link #toBeanIgnoreError(Object, Class)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T mapToBean(Map<?, ?> map, Class<T> beanClass, boolean isIgnoreError) {
|
||||
return fillBeanWithMap(map, ReflectUtil.newInstanceIfPossible(beanClass), isIgnoreError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map转换为Bean对象<br>
|
||||
* 忽略大小写
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param map Map
|
||||
* @param beanClass Bean Class
|
||||
* @param isIgnoreError 是否忽略注入错误
|
||||
* @return Bean
|
||||
* @deprecated 请使用 {@link #toBeanIgnoreCase(Object, Class, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T mapToBeanIgnoreCase(Map<?, ?> map, Class<T> beanClass, boolean isIgnoreError) {
|
||||
return fillBeanWithMapIgnoreCase(map, ReflectUtil.newInstanceIfPossible(beanClass), isIgnoreError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map转换为Bean对象
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param map {@link Map}
|
||||
* @param beanClass Bean Class
|
||||
* @param copyOptions 转Bean选项
|
||||
* @return Bean
|
||||
* @deprecated 请使用 {@link #toBean(Object, Class, CopyOptions)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T mapToBean(Map<?, ?> map, Class<T> beanClass, CopyOptions copyOptions) {
|
||||
return fillBeanWithMap(map, ReflectUtil.newInstanceIfPossible(beanClass), copyOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map转换为Bean对象
|
||||
*
|
||||
|
@ -35,20 +35,6 @@ public class Base64 {
|
||||
java.util.Base64.getEncoder().encode(arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码为Base64,URL安全的
|
||||
*
|
||||
* @param arr 被编码的数组
|
||||
* @param lineSep 在76个char之后是CRLF还是EOF
|
||||
* @return 编码后的bytes
|
||||
* @since 3.0.6
|
||||
* @deprecated 按照RFC2045规范,URL安全的Base64无需换行
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] encodeUrlSafe(byte[] arr, boolean lineSep) {
|
||||
return Base64Encoder.encodeUrlSafe(arr, lineSep);
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码
|
||||
*
|
||||
@ -93,20 +79,6 @@ public class Base64 {
|
||||
return encodeWithoutPadding(StrUtil.bytes(source, charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码,URL安全
|
||||
*
|
||||
* @param source 被编码的base64字符串
|
||||
* @param charset 字符集
|
||||
* @return 被加密后的字符串
|
||||
* @since 3.0.6
|
||||
* @deprecated 请使用 {@link #encodeUrlSafe(CharSequence, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String encodeUrlSafe(CharSequence source, String charset) {
|
||||
return encodeUrlSafe(source, CharsetUtil.charset(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码
|
||||
*
|
||||
|
@ -591,21 +591,6 @@ public class CollUtil {
|
||||
return IterUtil.join(iterable.iterator(), conjunction, prefix, suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 conjunction 为分隔符将集合转换为字符串<br>
|
||||
* 如果集合元素为数组、{@link Iterable}或{@link Iterator},则递归组合其为字符串
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param iterator 集合
|
||||
* @param conjunction 分隔符
|
||||
* @return 连接后的字符串
|
||||
* @deprecated 请使用IterUtil#join(Iterator, CharSequence)
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> String join(Iterator<T> iterator, CharSequence conjunction) {
|
||||
return IterUtil.join(iterator, conjunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切取部分数据<br>
|
||||
* 切取后的栈将减少这些元素
|
||||
@ -1139,25 +1124,6 @@ public class CollUtil {
|
||||
return sub(list, start, end, step);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对集合按照指定长度分段,每一个段为单独的集合,返回这个集合的列表
|
||||
* <p>
|
||||
* 需要特别注意的是,此方法调用{@link List#subList(int, int)}切分List,
|
||||
* 此方法返回的是原List的视图,也就是说原List有变更,切分后的结果也会变更。
|
||||
* </p>
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param list 列表
|
||||
* @param size 每个段的长度
|
||||
* @return 分段列表
|
||||
* @since 5.4.5
|
||||
* @deprecated 请使用 {@link ListUtil#partition(List, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> List<List<T>> splitList(List<T> list, int size) {
|
||||
return ListUtil.partition(list, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对集合按照指定长度分段,每一个段为单独的集合,返回这个集合的列表
|
||||
*
|
||||
@ -2312,34 +2278,6 @@ public class CollUtil {
|
||||
return get(collection, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得{@link Iterable}对象的元素类型(通过第一个非空元素判断)
|
||||
*
|
||||
* @param iterable {@link Iterable}
|
||||
* @return 元素类型,当列表为空或元素全部为null时,返回null
|
||||
* @see IterUtil#getElementType(Iterable)
|
||||
* @since 3.0.8
|
||||
* @deprecated 请使用 {@link IterUtil#getElementType(Iterable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Class<?> getElementType(Iterable<?> iterable) {
|
||||
return IterUtil.getElementType(iterable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得{@link Iterator}对象的元素类型(通过第一个非空元素判断)
|
||||
*
|
||||
* @param iterator {@link Iterator}
|
||||
* @return 元素类型,当列表为空或元素全部为null时,返回null
|
||||
* @see IterUtil#getElementType(Iterator)
|
||||
* @since 3.0.8
|
||||
* @deprecated 请使用 {@link IterUtil#getElementType(Iterator)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Class<?> getElementType(Iterator<?> iterator) {
|
||||
return IterUtil.getElementType(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Map中获取指定键列表对应的值列表<br>
|
||||
* 如果key在map中不存在或key对应值为null,则返回值列表对应位置的值也为null
|
||||
|
@ -1,60 +0,0 @@
|
||||
package cn.hutool.core.comparator;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Bean字段排序器<br>
|
||||
* 参阅feilong-core中的PropertyComparator
|
||||
*
|
||||
* @param <T> 被比较的Bean
|
||||
* @author jiangzeyin
|
||||
* @deprecated 此类不再需要,使用FuncComparator代替更加灵活
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class BaseFieldComparator<T> implements Comparator<T>, Serializable {
|
||||
private static final long serialVersionUID = -3482464782340308755L;
|
||||
|
||||
/**
|
||||
* 比较两个对象的同一个字段值
|
||||
*
|
||||
* @param o1 对象1
|
||||
* @param o2 对象2
|
||||
* @param field 字段
|
||||
* @return 比较结果
|
||||
*/
|
||||
protected int compareItem(T o1, T o2, Field field) {
|
||||
if (o1 == o2) {
|
||||
return 0;
|
||||
} else if (null == o1) {// null 排在后面
|
||||
return 1;
|
||||
} else if (null == o2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Comparable<?> v1;
|
||||
Comparable<?> v2;
|
||||
try {
|
||||
v1 = (Comparable<?>) ReflectUtil.getFieldValue(o1, field);
|
||||
v2 = (Comparable<?>) ReflectUtil.getFieldValue(o2, field);
|
||||
} catch (Exception e) {
|
||||
throw new ComparatorException(e);
|
||||
}
|
||||
|
||||
return compare(o1, o2, v1, v2);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private int compare(T o1, T o2, Comparable fieldValue1, Comparable fieldValue2) {
|
||||
int result = ObjectUtil.compare(fieldValue1, fieldValue2);
|
||||
if (0 == result) {
|
||||
//避免TreeSet / TreeMap 过滤掉排序字段相同但是对象不相同的情况
|
||||
result = CompareUtil.compare(o1, o2, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1633,18 +1633,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return System.currentTimeMillis() - preTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化成yyMMddHHmm后转换为int型
|
||||
*
|
||||
* @param date 日期
|
||||
* @return int
|
||||
* @deprecated 2022年后结果溢出,此方法废弃
|
||||
*/
|
||||
@Deprecated
|
||||
public static int toIntSecond(Date date) {
|
||||
return Integer.parseInt(DateUtil.format(date, "yyMMddHHmm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计时器<br>
|
||||
* 计算某个过程花费的时间,精确到毫秒
|
||||
@ -1774,43 +1762,6 @@ public class DateUtil extends CalendarUtil {
|
||||
return age(birthday.getTime(), dateToCompare.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定给定开始时间经过某段时间后是否过期
|
||||
*
|
||||
* @param startDate 开始时间
|
||||
* @param dateField 时间单位
|
||||
* @param timeLength 实际经过时长
|
||||
* @param endDate 被比较的时间,即有效期的截止时间。如果经过时长后的时间晚于截止时间,就表示过期
|
||||
* @return 是否过期
|
||||
* @since 3.1.1
|
||||
* @deprecated 此方法存在一定的歧义,容易产生误导,废弃。
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isExpired(Date startDate, DateField dateField, int timeLength, Date endDate) {
|
||||
final Date offsetDate = offset(startDate, dateField, timeLength);
|
||||
return offsetDate.after(endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定在指定检查时间是否过期。
|
||||
*
|
||||
* <p>
|
||||
* 以商品为例,startDate即生产日期,endDate即保质期的截止日期,checkDate表示在何时检查是否过期(一般为当前时间)<br>
|
||||
* endDate和startDate的差值即为保质期(按照毫秒计),checkDate和startDate的差值即为实际经过的时长,实际时长大于保质期表示超时。
|
||||
* </p>
|
||||
*
|
||||
* @param startDate 开始时间
|
||||
* @param endDate 被比较的时间,即有效期的截止时间。如果经过时长后的时间晚于被检查的时间,就表示过期
|
||||
* @param checkDate 检查时间,可以是当前时间,既
|
||||
* @return 是否过期
|
||||
* @since 5.1.1
|
||||
* @deprecated 使用isIn方法
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isExpired(Date startDate, Date endDate, Date checkDate) {
|
||||
return betweenMs(startDate, checkDate) > betweenMs(startDate, endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* HH:mm:ss 时间格式字符串转为秒数<br>
|
||||
* 参考:<a href="https://github.com/iceroot">https://github.com/iceroot</a>
|
||||
|
@ -1538,21 +1538,6 @@ public class FileUtil extends PathUtil {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件是否被改动<br>
|
||||
* 如果文件对象为 null 或者文件不存在,被视为改动
|
||||
*
|
||||
* @param file 文件对象
|
||||
* @param lastModifyTime 上次的改动时间
|
||||
* @return 是否被改动
|
||||
* @deprecated 拼写错误,请使用{@link #isModified(File, long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isModifed(File file, long lastModifyTime) {
|
||||
return isModified(file, lastModifyTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断文件是否被改动<br>
|
||||
* 如果文件对象为 null 或者文件不存在,被视为改动
|
||||
@ -1956,20 +1941,6 @@ public class FileUtil extends PathUtil {
|
||||
return getReader(path, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个文件读取器
|
||||
*
|
||||
* @param file 文件
|
||||
* @param charsetName 字符集
|
||||
* @return BufferedReader对象
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #getReader(File, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BufferedReader getReader(File file, String charsetName) throws IORuntimeException {
|
||||
return IoUtil.getReader(getInputStream(file), CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个文件读取器
|
||||
*
|
||||
@ -1982,20 +1953,6 @@ public class FileUtil extends PathUtil {
|
||||
return IoUtil.getReader(getInputStream(file), charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个文件读取器
|
||||
*
|
||||
* @param path 绝对路径
|
||||
* @param charsetName 字符集
|
||||
* @return BufferedReader对象
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #getReader(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BufferedReader getReader(String path, String charsetName) throws IORuntimeException {
|
||||
return getReader(path, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个文件读取器
|
||||
*
|
||||
@ -2057,20 +2014,6 @@ public class FileUtil extends PathUtil {
|
||||
return readString(path, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
* @param file 文件
|
||||
* @param charsetName 字符集
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readString(File, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String readString(File file, String charsetName) throws IORuntimeException {
|
||||
return readString(file, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
@ -2083,20 +2026,6 @@ public class FileUtil extends PathUtil {
|
||||
return FileReader.create(file, charset).readString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @param charsetName 字符集
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readString(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String readString(String path, String charsetName) throws IORuntimeException {
|
||||
return readString(path, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
@ -2109,20 +2038,6 @@ public class FileUtil extends PathUtil {
|
||||
return readString(file(path), charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
* @param url 文件URL
|
||||
* @param charsetName 字符集
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readString(URL, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String readString(URL url, String charsetName) throws IORuntimeException {
|
||||
return readString(url, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
@ -2245,22 +2160,6 @@ public class FileUtil extends PathUtil {
|
||||
return readLines(url, CharsetUtil.CHARSET_UTF_8, collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取每一行数据
|
||||
*
|
||||
* @param <T> 集合类型
|
||||
* @param url 文件的URL
|
||||
* @param charsetName 字符集
|
||||
* @param collection 集合
|
||||
* @return 文件中的每行内容的集合
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readLines(URL, Charset, Collection)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T extends Collection<String>> T readLines(URL url, String charsetName, T collection) throws IORuntimeException {
|
||||
return readLines(url, CharsetUtil.charset(charsetName), collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取每一行数据
|
||||
*
|
||||
@ -2295,20 +2194,6 @@ public class FileUtil extends PathUtil {
|
||||
return readLines(url, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取每一行数据
|
||||
*
|
||||
* @param url 文件的URL
|
||||
* @param charsetName 字符集
|
||||
* @return 文件中的每行内容的集合List
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readLines(URL, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> readLines(URL url, String charsetName) throws IORuntimeException {
|
||||
return readLines(url, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取每一行数据
|
||||
*
|
||||
@ -2579,21 +2464,6 @@ public class FileUtil extends PathUtil {
|
||||
return getOutputStream(touch(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个带缓存的写入对象
|
||||
*
|
||||
* @param path 输出路径,绝对路径
|
||||
* @param charsetName 字符集
|
||||
* @param isAppend 是否追加
|
||||
* @return BufferedReader对象
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #getWriter(String, Charset, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BufferedWriter getWriter(String path, String charsetName, boolean isAppend) throws IORuntimeException {
|
||||
return getWriter(path, Charset.forName(charsetName), isAppend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个带缓存的写入对象
|
||||
*
|
||||
@ -2607,21 +2477,6 @@ public class FileUtil extends PathUtil {
|
||||
return getWriter(touch(path), charset, isAppend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个带缓存的写入对象
|
||||
*
|
||||
* @param file 输出文件
|
||||
* @param charsetName 字符集
|
||||
* @param isAppend 是否追加
|
||||
* @return BufferedReader对象
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #getWriter(File, Charset, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BufferedWriter getWriter(File file, String charsetName, boolean isAppend) throws IORuntimeException {
|
||||
return getWriter(file, Charset.forName(charsetName), isAppend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个带缓存的写入对象
|
||||
*
|
||||
@ -2635,19 +2490,6 @@ public class FileUtil extends PathUtil {
|
||||
return FileWriter.create(file, charset).getWriter(isAppend);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个打印写入对象,可以有print
|
||||
*
|
||||
* @param path 输出路径,绝对路径
|
||||
* @param charset 字符集
|
||||
* @param isAppend 是否追加
|
||||
* @return 打印对象
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IORuntimeException {
|
||||
return new PrintWriter(getWriter(path, charset, isAppend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个打印写入对象,可以有print
|
||||
*
|
||||
@ -2662,19 +2504,6 @@ public class FileUtil extends PathUtil {
|
||||
return new PrintWriter(getWriter(path, charset, isAppend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个打印写入对象,可以有print
|
||||
*
|
||||
* @param file 文件
|
||||
* @param charset 字符集
|
||||
* @param isAppend 是否追加
|
||||
* @return 打印对象
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public static PrintWriter getPrintWriter(File file, String charset, boolean isAppend) throws IORuntimeException {
|
||||
return new PrintWriter(getWriter(file, charset, isAppend));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个打印写入对象,可以有print
|
||||
*
|
||||
|
@ -201,19 +201,6 @@ public class IoUtil extends NioUtil {
|
||||
return getReader(in, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个文件读取器
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param charsetName 字符集名称
|
||||
* @return BufferedReader对象
|
||||
* @deprecated 请使用 {@link #getReader(InputStream, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BufferedReader getReader(InputStream in, String charsetName) {
|
||||
return getReader(in, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从{@link BOMInputStream}中获取Reader
|
||||
*
|
||||
@ -222,7 +209,7 @@ public class IoUtil extends NioUtil {
|
||||
* @since 5.5.8
|
||||
*/
|
||||
public static BufferedReader getReader(BOMInputStream in) {
|
||||
return getReader(in, in.getCharset());
|
||||
return getReader(in, CharsetUtil.charset(in.getCharset()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,19 +285,6 @@ public class IoUtil extends NioUtil {
|
||||
return getWriter(out, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个Writer
|
||||
*
|
||||
* @param out 输入流
|
||||
* @param charsetName 字符集
|
||||
* @return OutputStreamWriter对象
|
||||
* @deprecated 请使用 {@link #getWriter(OutputStream, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static OutputStreamWriter getWriter(OutputStream out, String charsetName) {
|
||||
return getWriter(out, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个Writer
|
||||
*
|
||||
@ -345,21 +319,6 @@ public class IoUtil extends NioUtil {
|
||||
return read(in, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流中读取内容,读取完成后关闭流
|
||||
*
|
||||
* @param in 输入流
|
||||
* @param charsetName 字符集
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #read(InputStream, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String read(InputStream in, String charsetName) throws IORuntimeException {
|
||||
final FastByteArrayOutputStream out = read(in);
|
||||
return StrUtil.isBlank(charsetName) ? out.toString() : out.toString(charsetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流中读取内容,读取完毕后关闭流
|
||||
*
|
||||
@ -638,22 +597,6 @@ public class IoUtil extends NioUtil {
|
||||
return readLines(in, CharsetUtil.CHARSET_UTF_8, collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流中读取内容
|
||||
*
|
||||
* @param <T> 集合类型
|
||||
* @param in 输入流
|
||||
* @param charsetName 字符集
|
||||
* @param collection 返回集合
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #readLines(InputStream, Charset, Collection)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T extends Collection<String>> T readLines(InputStream in, String charsetName, T collection) throws IORuntimeException {
|
||||
return readLines(in, CharsetUtil.charset(charsetName), collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流中读取内容
|
||||
*
|
||||
@ -727,19 +670,6 @@ public class IoUtil extends NioUtil {
|
||||
|
||||
// -------------------------------------------------------------------------------------- read end
|
||||
|
||||
/**
|
||||
* String 转为流
|
||||
*
|
||||
* @param content 内容
|
||||
* @param charsetName 编码
|
||||
* @return 字节流
|
||||
* @deprecated 请使用 {@link #toStream(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static ByteArrayInputStream toStream(String content, String charsetName) {
|
||||
return toStream(content, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* String 转为流
|
||||
*
|
||||
@ -1008,21 +938,6 @@ public class IoUtil extends NioUtil {
|
||||
write(out, CharsetUtil.CHARSET_UTF_8, isCloseOut, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将多部分内容写到流中,自动转换为字符串
|
||||
*
|
||||
* @param out 输出流
|
||||
* @param charsetName 写出的内容的字符集
|
||||
* @param isCloseOut 写入完毕是否关闭输出流
|
||||
* @param contents 写入的内容,调用toString()方法,不包括不会自动换行
|
||||
* @throws IORuntimeException IO异常
|
||||
* @deprecated 请使用 {@link #write(OutputStream, Charset, boolean, Object...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void write(OutputStream out, String charsetName, boolean isCloseOut, Object... contents) throws IORuntimeException {
|
||||
write(out, CharsetUtil.charset(charsetName), isCloseOut, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将多部分内容写到流中,自动转换为字符串
|
||||
*
|
||||
|
@ -53,15 +53,6 @@ public class UrlResource implements Resource, Serializable{
|
||||
this.name = ObjectUtil.defaultIfNull(name, () -> (null != url ? FileUtil.getName(url.getPath()) : null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param file 文件路径
|
||||
* @deprecated Please use {@link FileResource}
|
||||
*/
|
||||
@Deprecated
|
||||
public UrlResource(File file) {
|
||||
this.url = URLUtil.getURL(file);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------- Constructor end
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.lang.Filter;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
@ -27,8 +26,8 @@ import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Map相关工具类
|
||||
@ -280,26 +279,6 @@ public class MapUtil {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定的Pair数组创建Map对象
|
||||
*
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
* @param pairs 键值对
|
||||
* @return Map
|
||||
* @since 5.4.1
|
||||
* @deprecated 方法容易歧义,请使用 {@code #ofEntries(Entry[])}
|
||||
*/
|
||||
@SafeVarargs
|
||||
@Deprecated
|
||||
public static <K, V> Map<K, V> of(Pair<K, V>... pairs) {
|
||||
final Map<K, V> map = new HashMap<>();
|
||||
for (Pair<K, V> pair : pairs) {
|
||||
map.put(pair.getKey(), pair.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定的Pair数组创建Map对象
|
||||
*
|
||||
|
@ -1,407 +0,0 @@
|
||||
package cn.hutool.core.net;
|
||||
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.codec.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* URL编码,数据内容的类型是 application/x-www-form-urlencoded。
|
||||
* TODO 6.x移除此类,使用PercentCodec代替(无法很好区分URL编码和www-form编码)
|
||||
*
|
||||
* <pre>
|
||||
* 1.字符"a"-"z","A"-"Z","0"-"9",".","-","*",和"_" 都不会被编码;
|
||||
* 2.将空格转换为%20 ;
|
||||
* 3.将非文本内容转换成"%xy"的形式,xy是两位16进制的数值;
|
||||
* </pre>
|
||||
*
|
||||
* @author looly
|
||||
* @see cn.hutool.core.codec.PercentCodec
|
||||
* @deprecated 此类中的方法并不规范,请使用 {@link RFC3986}
|
||||
*/
|
||||
@Deprecated
|
||||
public class URLEncoder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// --------------------------------------------------------------------------------------------- Static method start
|
||||
/**
|
||||
* 默认URLEncoder<br>
|
||||
* 默认的编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* default = pchar / "/"
|
||||
* pchar = unreserved(不处理) / pct-encoded / sub-delims(子分隔符) / ":" / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*/
|
||||
public static final URLEncoder DEFAULT = createDefault();
|
||||
|
||||
/**
|
||||
* URL的Path的每一个Segment URLEncoder<br>
|
||||
* 默认的编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* pchar = unreserved / pct-encoded / sub-delims / ":"(非空segment不包含:) / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*
|
||||
* 定义见:https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
|
||||
*/
|
||||
public static final URLEncoder PATH_SEGMENT = createPathSegment();
|
||||
|
||||
/**
|
||||
* URL的Fragment URLEncoder<br>
|
||||
* 默认的编码器针对Fragment,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* fragment = *( pchar / "/" / "?" )
|
||||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*
|
||||
* 具体见:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
|
||||
* @since 5.7.13
|
||||
*/
|
||||
public static final URLEncoder FRAGMENT = createFragment();
|
||||
|
||||
/**
|
||||
* 用于查询语句的URLEncoder<br>
|
||||
* 编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* 0x20 ' ' =》 '+'
|
||||
* 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A as-is
|
||||
* '*', '-', '.', '0' to '9', 'A' to 'Z', '_', 'a' to 'z' Also '=' and '&' 不编码
|
||||
* 其它编码为 %nn 形式
|
||||
* </pre>
|
||||
* <p>
|
||||
* 详细见:https://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm
|
||||
*/
|
||||
public static final URLEncoder QUERY = createQuery();
|
||||
|
||||
/**
|
||||
* 全编码的URLEncoder<br>
|
||||
* <pre>
|
||||
* 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A as-is
|
||||
* '*', '-', '.', '0' to '9', 'A' to 'Z', '_', 'a' to 'z' 不编码
|
||||
* 其它编码为 %nn 形式
|
||||
* </pre>
|
||||
*/
|
||||
public static final URLEncoder ALL = createAll();
|
||||
|
||||
/**
|
||||
* 创建默认URLEncoder<br>
|
||||
* 默认的编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* default = pchar / "/"
|
||||
* pchar = unreserved(不处理) / pct-encoded / sub-delims(子分隔符) / ":" / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*
|
||||
* @return URLEncoder
|
||||
*/
|
||||
public static URLEncoder createDefault() {
|
||||
final URLEncoder encoder = new URLEncoder();
|
||||
encoder.addSafeCharacter('-');
|
||||
encoder.addSafeCharacter('.');
|
||||
encoder.addSafeCharacter('_');
|
||||
encoder.addSafeCharacter('~');
|
||||
|
||||
// Add the sub-delims
|
||||
addSubDelims(encoder);
|
||||
|
||||
// Add the remaining literals
|
||||
encoder.addSafeCharacter(':');
|
||||
encoder.addSafeCharacter('@');
|
||||
|
||||
// Add '/' so it isn't encoded when we encode a path
|
||||
encoder.addSafeCharacter('/');
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL的Path的每一个Segment URLEncoder<br>
|
||||
* 默认的编码器针对URI路径的每一段编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* pchar = unreserved / pct-encoded / sub-delims / ":"(非空segment不包含:) / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*
|
||||
* 定义见:https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
|
||||
*
|
||||
* @return URLEncoder
|
||||
*/
|
||||
public static URLEncoder createPathSegment() {
|
||||
final URLEncoder encoder = new URLEncoder();
|
||||
|
||||
// unreserved
|
||||
encoder.addSafeCharacter('-');
|
||||
encoder.addSafeCharacter('.');
|
||||
encoder.addSafeCharacter('_');
|
||||
encoder.addSafeCharacter('~');
|
||||
|
||||
// Add the sub-delims
|
||||
addSubDelims(encoder);
|
||||
|
||||
// Add the remaining literals
|
||||
//non-zero-length segment without any colon ":"
|
||||
//encoder.addSafeCharacter(':');
|
||||
encoder.addSafeCharacter('@');
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL的Fragment URLEncoder<br>
|
||||
* 默认的编码器针对Fragment,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* fragment = *( pchar / "/" / "?" )
|
||||
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
||||
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
* </pre>
|
||||
*
|
||||
* 具体见:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
|
||||
*
|
||||
* @return URLEncoder
|
||||
* @since 5.7.13
|
||||
*/
|
||||
public static URLEncoder createFragment() {
|
||||
final URLEncoder encoder = new URLEncoder();
|
||||
encoder.addSafeCharacter('-');
|
||||
encoder.addSafeCharacter('.');
|
||||
encoder.addSafeCharacter('_');
|
||||
encoder.addSafeCharacter('~');
|
||||
|
||||
// Add the sub-delims
|
||||
addSubDelims(encoder);
|
||||
|
||||
// Add the remaining literals
|
||||
encoder.addSafeCharacter(':');
|
||||
encoder.addSafeCharacter('@');
|
||||
|
||||
encoder.addSafeCharacter('/');
|
||||
encoder.addSafeCharacter('?');
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建用于查询语句的URLEncoder<br>
|
||||
* 编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* 0x20 ' ' =》 '+'
|
||||
* 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A as-is
|
||||
* '*', '-', '.', '0' to '9', 'A' to 'Z', '_', 'a' to 'z' Also '=' and '&' 不编码
|
||||
* 其它编码为 %nn 形式
|
||||
* </pre>
|
||||
* <p>
|
||||
* 详细见:https://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm
|
||||
*
|
||||
* @return URLEncoder
|
||||
*/
|
||||
public static URLEncoder createQuery() {
|
||||
final URLEncoder encoder = new URLEncoder();
|
||||
// Special encoding for space
|
||||
encoder.setEncodeSpaceAsPlus(true);
|
||||
// Alpha and digit are safe by default
|
||||
// Add the other permitted characters
|
||||
encoder.addSafeCharacter('*');
|
||||
encoder.addSafeCharacter('-');
|
||||
encoder.addSafeCharacter('.');
|
||||
encoder.addSafeCharacter('_');
|
||||
|
||||
encoder.addSafeCharacter('=');
|
||||
encoder.addSafeCharacter('&');
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建URLEncoder<br>
|
||||
* 编码器针对URI路径编码,定义如下:
|
||||
*
|
||||
* <pre>
|
||||
* 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A as-is
|
||||
* '*', '-', '.', '0' to '9', 'A' to 'Z', '_', 'a' to 'z' 不编码
|
||||
* 其它编码为 %nn 形式
|
||||
* </pre>
|
||||
* <p>
|
||||
* 详细见:https://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm
|
||||
*
|
||||
* @return URLEncoder
|
||||
*/
|
||||
public static URLEncoder createAll() {
|
||||
final URLEncoder encoder = new URLEncoder();
|
||||
encoder.addSafeCharacter('*');
|
||||
encoder.addSafeCharacter('-');
|
||||
encoder.addSafeCharacter('.');
|
||||
encoder.addSafeCharacter('_');
|
||||
|
||||
return encoder;
|
||||
}
|
||||
// --------------------------------------------------------------------------------------------- Static method end
|
||||
|
||||
/**
|
||||
* 存放安全编码
|
||||
*/
|
||||
private final BitSet safeCharacters;
|
||||
/**
|
||||
* 是否编码空格为+
|
||||
*/
|
||||
private boolean encodeSpaceAsPlus = false;
|
||||
|
||||
/**
|
||||
* 构造<br>
|
||||
* [a-zA-Z0-9]默认不被编码
|
||||
*/
|
||||
public URLEncoder() {
|
||||
this(new BitSet(256));
|
||||
|
||||
// unreserved
|
||||
addAlpha();
|
||||
addDigit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param safeCharacters 安全字符,安全字符不被编码
|
||||
*/
|
||||
private URLEncoder(BitSet safeCharacters) {
|
||||
this.safeCharacters = safeCharacters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加安全字符<br>
|
||||
* 安全字符不被编码
|
||||
*
|
||||
* @param c 字符
|
||||
*/
|
||||
public void addSafeCharacter(char c) {
|
||||
safeCharacters.set(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除安全字符<br>
|
||||
* 安全字符不被编码
|
||||
*
|
||||
* @param c 字符
|
||||
*/
|
||||
public void removeSafeCharacter(char c) {
|
||||
safeCharacters.clear(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否将空格编码为+
|
||||
*
|
||||
* @param encodeSpaceAsPlus 是否将空格编码为+
|
||||
*/
|
||||
public void setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus) {
|
||||
this.encodeSpaceAsPlus = encodeSpaceAsPlus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将URL中的字符串编码为%形式
|
||||
*
|
||||
* @param path 需要编码的字符串
|
||||
* @param charset 编码, {@code null}返回原字符串,表示不编码
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String encode(String path, Charset charset) {
|
||||
if (null == charset || StrUtil.isEmpty(path)) {
|
||||
return path;
|
||||
}
|
||||
|
||||
final StringBuilder rewrittenPath = new StringBuilder(path.length());
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
OutputStreamWriter writer = new OutputStreamWriter(buf, charset);
|
||||
|
||||
int c;
|
||||
for (int i = 0; i < path.length(); i++) {
|
||||
c = path.charAt(i);
|
||||
if (safeCharacters.get(c)) {
|
||||
rewrittenPath.append((char) c);
|
||||
} else if (encodeSpaceAsPlus && c == CharUtil.SPACE) {
|
||||
// 对于空格单独处理
|
||||
rewrittenPath.append('+');
|
||||
} else {
|
||||
// convert to external encoding before hex conversion
|
||||
try {
|
||||
writer.write((char) c);
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
buf.reset();
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] ba = buf.toByteArray();
|
||||
for (byte toEncode : ba) {
|
||||
// Converting each byte in the buffer
|
||||
rewrittenPath.append('%');
|
||||
HexUtil.appendHex(rewrittenPath, toEncode, false);
|
||||
}
|
||||
buf.reset();
|
||||
}
|
||||
}
|
||||
return rewrittenPath.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加安全字符[a-z][A-Z]
|
||||
*/
|
||||
private void addAlpha() {
|
||||
for (char i = 'a'; i <= 'z'; i++) {
|
||||
addSafeCharacter(i);
|
||||
}
|
||||
for (char i = 'A'; i <= 'Z'; i++) {
|
||||
addSafeCharacter(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加数字1-9
|
||||
*/
|
||||
private void addDigit() {
|
||||
for (char i = '0'; i <= '9'; i++) {
|
||||
addSafeCharacter(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加sub-delims<br>
|
||||
* sub-delims = "!" / "$" / "&" / "'" / "(" / ") / "*" / "+" / "," / ";" / "="
|
||||
* 定义见:https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
*/
|
||||
private static void addSubDelims(URLEncoder encoder){
|
||||
// Add the sub-delims
|
||||
encoder.addSafeCharacter('!');
|
||||
encoder.addSafeCharacter('$');
|
||||
encoder.addSafeCharacter('&');
|
||||
encoder.addSafeCharacter('\'');
|
||||
encoder.addSafeCharacter('(');
|
||||
encoder.addSafeCharacter(')');
|
||||
encoder.addSafeCharacter('*');
|
||||
encoder.addSafeCharacter('+');
|
||||
encoder.addSafeCharacter(',');
|
||||
encoder.addSafeCharacter(';');
|
||||
encoder.addSafeCharacter('=');
|
||||
}
|
||||
}
|
@ -358,18 +358,6 @@ public final class UrlBuilder implements Builder<String> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加path节点
|
||||
*
|
||||
* @param path path节点
|
||||
* @return this
|
||||
* @deprecated 方法重复,请使用{@link #addPath(CharSequence)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UrlBuilder appendPath(CharSequence path) {
|
||||
return addPath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询语句,例如a=1&b=2<br>
|
||||
* 可能为{@code null}
|
||||
|
@ -2,7 +2,6 @@ package cn.hutool.core.text.bloomfilter;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HashUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -38,19 +37,6 @@ public class BitSetBloomFilter implements BloomFilter {
|
||||
this.bitSet = new BitSet(this.bitSetSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过文件初始化过滤器.
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @param charsetName 字符集
|
||||
* @throws IOException IO异常
|
||||
* @deprecated 请使用 {@link #init(String, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void init(String path, String charsetName) throws IOException {
|
||||
init(path, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过文件初始化过滤器.
|
||||
*
|
||||
|
@ -17,7 +17,7 @@ import cn.hutool.core.net.NetUtil;
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* ID相关文章见:http://calvin1978.blogcn.com/articles/uuid.html
|
||||
* ID相关文章见:<a href="http://calvin1978.blogcn.com/articles/uuid.html">http://calvin1978.blogcn.com/articles/uuid.html</a>
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.1.13
|
||||
@ -75,7 +75,7 @@ public class IdUtil {
|
||||
* 4. INC 自增计数器。确保同一秒内产生objectId的唯一性。
|
||||
* </pre>
|
||||
* <p>
|
||||
* 参考:http://blog.csdn.net/qxc1281/article/details/54021882
|
||||
* 参考:<a href="http://blog.csdn.net/qxc1281/article/details/54021882">http://blog.csdn.net/qxc1281/article/details/54021882</a>
|
||||
*
|
||||
* @return ObjectId
|
||||
*/
|
||||
@ -83,37 +83,6 @@ public class IdUtil {
|
||||
return ObjectId.next();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Twitter的Snowflake 算法生成器。
|
||||
* <p>
|
||||
* 特别注意:此方法调用后会创建独立的{@link Snowflake}对象,每个独立的对象ID不互斥,会导致ID重复,请自行保证单例!
|
||||
* </p>
|
||||
* 分布式系统中,有一些需要使用全局唯一ID的场景,有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。
|
||||
*
|
||||
* <p>
|
||||
* snowflake的结构如下(每部分用-分开):<br>
|
||||
*
|
||||
* <pre>
|
||||
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000
|
||||
* </pre>
|
||||
* <p>
|
||||
* 第一位为未使用,接下来的41位为毫秒级时间(41位的长度可以使用69年)<br>
|
||||
* 然后是5位datacenterId和5位workerId(10位的长度最多支持部署1024个节点)<br>
|
||||
* 最后12位是毫秒内的计数(12位的计数顺序号支持每个节点每毫秒产生4096个ID序号)
|
||||
*
|
||||
* <p>
|
||||
* 参考:http://www.cnblogs.com/relucent/p/4955340.html
|
||||
*
|
||||
* @param workerId 终端ID
|
||||
* @param datacenterId 数据中心ID
|
||||
* @return {@link Snowflake}
|
||||
* @deprecated 此方法容易产生歧义:多个Snowflake实例产生的ID会产生重复,此对象在单台机器上必须单例,请使用{@link #getSnowflake(long, long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Snowflake createSnowflake(long workerId, long datacenterId) {
|
||||
return new Snowflake(workerId, datacenterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例的Twitter的Snowflake 算法生成器对象<br>
|
||||
* 分布式系统中,有一些需要使用全局唯一ID的场景,有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。
|
||||
@ -130,7 +99,7 @@ public class IdUtil {
|
||||
* 最后12位是毫秒内的计数(12位的计数顺序号支持每个节点每毫秒产生4096个ID序号)
|
||||
*
|
||||
* <p>
|
||||
* 参考:http://www.cnblogs.com/relucent/p/4955340.html
|
||||
* 参考:<a href="http://www.cnblogs.com/relucent/p/4955340.html">http://www.cnblogs.com/relucent/p/4955340.html</a>
|
||||
*
|
||||
* @param workerId 终端ID
|
||||
* @param datacenterId 数据中心ID
|
||||
@ -157,7 +126,7 @@ public class IdUtil {
|
||||
* 最后12位是毫秒内的计数(12位的计数顺序号支持每个节点每毫秒产生4096个ID序号)
|
||||
*
|
||||
* <p>
|
||||
* 参考:http://www.cnblogs.com/relucent/p/4955340.html
|
||||
* 参考:<a href="http://www.cnblogs.com/relucent/p/4955340.html">http://www.cnblogs.com/relucent/p/4955340.html</a>
|
||||
*
|
||||
* @param workerId 终端ID
|
||||
* @return {@link Snowflake}
|
||||
@ -183,7 +152,7 @@ public class IdUtil {
|
||||
* 最后12位是毫秒内的计数(12位的计数顺序号支持每个节点每毫秒产生4096个ID序号)
|
||||
*
|
||||
* <p>
|
||||
* 参考:http://www.cnblogs.com/relucent/p/4955340.html
|
||||
* 参考:<a href="http://www.cnblogs.com/relucent/p/4955340.html">http://www.cnblogs.com/relucent/p/4955340.html</a>
|
||||
*
|
||||
* @return {@link Snowflake}
|
||||
* @since 5.7.3
|
||||
|
@ -9,7 +9,6 @@ import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.WeightRandom;
|
||||
import cn.hutool.core.lang.WeightRandom.WeightObj;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@ -593,19 +592,6 @@ public class RandomUtil {
|
||||
return baseString.charAt(randomInt(baseString.length()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机颜色
|
||||
*
|
||||
* @return 随机颜色
|
||||
* @since 4.1.5
|
||||
* @deprecated 使用ImgUtil.randomColor()
|
||||
*/
|
||||
@Deprecated
|
||||
public static Color randomColor() {
|
||||
final Random random = getRandom();
|
||||
return new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
||||
}
|
||||
|
||||
/**
|
||||
* 带有权重的随机生成器
|
||||
*
|
||||
|
@ -120,24 +120,6 @@ public class StrUtil extends CharSequenceUtil implements StrPool {
|
||||
return str(obj, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串
|
||||
*
|
||||
* <pre>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组
|
||||
* 2、对象数组会调用Arrays.toString方法
|
||||
* </pre>
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
* @deprecated 请使用 {@link #str(Object, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String str(Object obj, String charsetName) {
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串
|
||||
* <pre>
|
||||
|
@ -280,24 +280,6 @@ public class ZipUtil {
|
||||
ZipWriter.of(out, charset).add(withSrcDir, filter, srcFiles).close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对文件或文件目录进行压缩
|
||||
*
|
||||
* @param zipOutputStream 生成的Zip到的目标流,自动关闭此流
|
||||
* @param withSrcDir 是否包含被打包目录,只针对压缩目录有效。若为false,则只压缩目录下的文件或目录,为true则将本目录也压缩
|
||||
* @param filter 文件过滤器,通过实现此接口,自定义要过滤的文件(过滤掉哪些文件或文件夹不加入压缩)
|
||||
* @param srcFiles 要压缩的源文件或目录。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 5.1.1
|
||||
* @deprecated 请使用 {@link #zip(OutputStream, Charset, boolean, FileFilter, File...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void zip(ZipOutputStream zipOutputStream, boolean withSrcDir, FileFilter filter, File... srcFiles) throws IORuntimeException {
|
||||
try (final ZipWriter zipWriter = new ZipWriter(zipOutputStream)) {
|
||||
zipWriter.add(withSrcDir, filter, srcFiles);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对流中的数据加入到压缩文件,使用默认UTF-8编码
|
||||
*
|
||||
|
@ -869,16 +869,6 @@ public class DateUtilTest {
|
||||
DateUtil.age(DateUtil.parseDate(d1), DateUtil.parseDate(d2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExpiredTest() {
|
||||
DateTime startDate = DateUtil.parse("2019-12-01 17:02:30");
|
||||
DateTime endDate = DateUtil.parse("2019-12-02 17:02:30");
|
||||
int length = 3;
|
||||
//noinspection deprecation
|
||||
boolean expired = DateUtil.isExpired(startDate, DateField.DAY_OF_YEAR, length, endDate);
|
||||
Assert.assertTrue(expired);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void localDateTimeTest() {
|
||||
// 测试字符串与LocalDateTime的互相转换
|
||||
|
@ -255,26 +255,6 @@ public abstract class AbstractDb implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量执行非查询语句
|
||||
*
|
||||
* @param sql SQL
|
||||
* @param paramsBatch 批量的参数
|
||||
* @return 每个SQL执行影响的行数
|
||||
* @throws SQLException SQL执行异常
|
||||
* @deprecated 编译器无法区分重载
|
||||
*/
|
||||
@Deprecated
|
||||
public int[] executeBatch(String sql, Object[]... paramsBatch) throws SQLException {
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
return SqlExecutor.executeBatch(conn, sql, paramsBatch);
|
||||
} finally {
|
||||
this.closeConnection(conn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量执行非查询语句
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ import java.util.Map;
|
||||
* 线程相关的数据库连接持有器<br>
|
||||
* 此对象为单例类,用于存储线程相关的Connection对象。<br>
|
||||
* 在多数据源情况下,由于数据源的不同,连接对象也不同,因此获取连接时需要DataSource关联获取
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
@ -21,7 +21,7 @@ public enum ThreadLocalConnection {
|
||||
|
||||
/**
|
||||
* 获取数据源对应的数据库连接
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @return Connection
|
||||
* @throws SQLException SQL异常
|
||||
@ -37,7 +37,7 @@ public enum ThreadLocalConnection {
|
||||
|
||||
/**
|
||||
* 关闭数据库,并从线程池中移除
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @since 4.1.7
|
||||
*/
|
||||
@ -54,7 +54,7 @@ public enum ThreadLocalConnection {
|
||||
|
||||
/**
|
||||
* 分组连接,根据不同的分组获取对应的连接,用于多数据源情况
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
public static class GroupedConnection {
|
||||
@ -64,7 +64,7 @@ public enum ThreadLocalConnection {
|
||||
|
||||
/**
|
||||
* 获取连接,如果获取的连接为空或者已被关闭,重新创建连接
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @return Connection
|
||||
* @throws SQLException SQL异常
|
||||
@ -81,7 +81,7 @@ public enum ThreadLocalConnection {
|
||||
/**
|
||||
* 关闭并移除Connection<br>
|
||||
* 如果处于事务中,则不进行任何操作
|
||||
*
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @return this
|
||||
*/
|
||||
@ -104,7 +104,7 @@ public enum ThreadLocalConnection {
|
||||
|
||||
/**
|
||||
* 持有的连接是否为空
|
||||
*
|
||||
*
|
||||
* @return 持有的连接是否为空
|
||||
* @since 4.6.4
|
||||
*/
|
||||
|
@ -283,19 +283,6 @@ public class MetaUtil {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取catalog,获取失败返回{@code null}
|
||||
*
|
||||
* @param conn {@link Connection} 数据库连接,{@code null}时返回null
|
||||
* @return catalog,获取失败返回{@code null}
|
||||
* @since 4.6.0
|
||||
* @deprecated 拼写错误,请使用{@link #getCatalog(Connection)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getCataLog(Connection conn) {
|
||||
return getCatalog(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取catalog,获取失败返回{@code null}
|
||||
*
|
||||
|
@ -145,23 +145,6 @@ public class SqlExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量执行非查询语句<br>
|
||||
* 语句包括 插入、更新、删除<br>
|
||||
* 此方法不会关闭Connection
|
||||
*
|
||||
* @param conn 数据库连接对象
|
||||
* @param sql SQL
|
||||
* @param paramsBatch 批量的参数
|
||||
* @return 每个SQL执行影响的行数
|
||||
* @throws SQLException SQL执行异常
|
||||
* @deprecated 重载导致编译器无法区分
|
||||
*/
|
||||
@Deprecated
|
||||
public static int[] executeBatch(Connection conn, String sql, Object[]... paramsBatch) throws SQLException {
|
||||
return executeBatch(conn, sql, new ArrayIter<>(paramsBatch));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量执行非查询语句<br>
|
||||
* 语句包括 插入、更新、删除<br>
|
||||
|
@ -121,19 +121,6 @@ public class QrConfig {
|
||||
return foreColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置前景色,例如:Color.BLUE.getRGB()
|
||||
*
|
||||
* @param foreColor 前景色
|
||||
* @return this
|
||||
* @deprecated 请使用 {@link #setForeColor(Color)}
|
||||
*/
|
||||
@Deprecated
|
||||
public QrConfig setForeColor(int foreColor) {
|
||||
this.foreColor = foreColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置前景色,例如:Color.BLUE.getRGB()
|
||||
*
|
||||
@ -157,19 +144,6 @@ public class QrConfig {
|
||||
return backColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置背景色,例如:Color.BLUE.getRGB()
|
||||
*
|
||||
* @param backColor 背景色
|
||||
* @return this
|
||||
* @deprecated 请使用 {@link #setBackColor(Color)}
|
||||
*/
|
||||
@Deprecated
|
||||
public QrConfig setBackColor(int backColor) {
|
||||
this.backColor = backColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置背景色,例如:Color.BLUE
|
||||
*
|
||||
|
@ -241,17 +241,6 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
*/
|
||||
private int redirectCount;
|
||||
|
||||
/**
|
||||
* 构造,URL编码默认使用UTF-8
|
||||
*
|
||||
* @param url URL
|
||||
* @deprecated 请使用 {@link #of(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpRequest(String url) {
|
||||
this(UrlBuilder.ofHttp(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
|
@ -436,20 +436,6 @@ public class HttpUtil {
|
||||
return toParams(paramMap, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Map形式的Form表单数据转换为Url参数形式<br>
|
||||
* 编码键和值对
|
||||
*
|
||||
* @param paramMap 表单数据
|
||||
* @param charsetName 编码
|
||||
* @return url参数
|
||||
* @deprecated 请使用 {@link #toParams(Map, Charset)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String toParams(Map<String, Object> paramMap, String charsetName) {
|
||||
return toParams(paramMap, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Map形式的Form表单数据转换为Url参数形式<br>
|
||||
* paramMap中如果key为空(null和"")会被忽略,如果value为null,会被做为空白符("")<br>
|
||||
|
@ -1,95 +0,0 @@
|
||||
package cn.hutool.http.ssl;
|
||||
|
||||
import cn.hutool.core.net.SSLContextBuilder;
|
||||
import cn.hutool.core.net.SSLProtocols;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* SSLSocketFactory构建器
|
||||
*
|
||||
* @author Looly
|
||||
* @see SSLContextBuilder
|
||||
* @deprecated 请使用 {@link SSLContextBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SSLSocketFactoryBuilder implements SSLProtocols {
|
||||
|
||||
SSLContextBuilder sslContextBuilder;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public SSLSocketFactoryBuilder() {
|
||||
this.sslContextBuilder = SSLContextBuilder.create();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 SSLSocketFactoryBuilder
|
||||
*
|
||||
* @return SSLSocketFactoryBuilder
|
||||
*/
|
||||
public static SSLSocketFactoryBuilder create() {
|
||||
return new SSLSocketFactoryBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置协议
|
||||
*
|
||||
* @param protocol 协议
|
||||
* @return 自身
|
||||
*/
|
||||
public SSLSocketFactoryBuilder setProtocol(String protocol) {
|
||||
this.sslContextBuilder.setProtocol(protocol);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置信任信息
|
||||
*
|
||||
* @param trustManagers TrustManager列表
|
||||
* @return 自身
|
||||
*/
|
||||
public SSLSocketFactoryBuilder setTrustManagers(TrustManager... trustManagers) {
|
||||
this.sslContextBuilder.setTrustManagers(trustManagers);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 JSSE key managers
|
||||
*
|
||||
* @param keyManagers JSSE key managers
|
||||
* @return 自身
|
||||
*/
|
||||
public SSLSocketFactoryBuilder setKeyManagers(KeyManager... keyManagers) {
|
||||
this.sslContextBuilder.setKeyManagers(keyManagers);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 SecureRandom
|
||||
*
|
||||
* @param secureRandom SecureRandom
|
||||
* @return 自己
|
||||
*/
|
||||
public SSLSocketFactoryBuilder setSecureRandom(SecureRandom secureRandom) {
|
||||
this.sslContextBuilder.setSecureRandom(secureRandom);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建SSLSocketFactory
|
||||
*
|
||||
* @return SSLSocketFactory
|
||||
* @throws NoSuchAlgorithmException 无此算法
|
||||
* @throws KeyManagementException Key管理异常
|
||||
*/
|
||||
public SSLSocketFactory build() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
return this.sslContextBuilder.buildChecked().getSocketFactory();
|
||||
}
|
||||
}
|
@ -53,30 +53,6 @@ public class JSONConfig implements Serializable {
|
||||
return new JSONConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有序,顺序按照加入顺序排序,只针对JSONObject有效
|
||||
*
|
||||
* @return 是否有序
|
||||
* @deprecated 始终返回 {@code true}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOrder() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否有序,顺序按照加入顺序排序,只针对JSONObject有效
|
||||
*
|
||||
* @param order 是否有序
|
||||
* @return this
|
||||
* @deprecated 始终有序,无需设置
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
public JSONConfig setOrder(boolean order) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取键排序规则<br>
|
||||
* 键排序规则,{@code null}表示不排序,不排序情况下,按照加入顺序排序
|
||||
|
@ -62,32 +62,6 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
this(DEFAULT_CAPACITY, isOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param capacity 初始大小
|
||||
* @param isOrder 是否有序
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public JSONObject(int capacity, boolean isOrder) {
|
||||
this(capacity, false, isOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param capacity 初始大小
|
||||
* @param isIgnoreCase 是否忽略KEY大小写
|
||||
* @param isOrder 是否有序
|
||||
* @since 3.3.1
|
||||
* @deprecated isOrder无效
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
public JSONObject(int capacity, boolean isIgnoreCase, boolean isOrder) {
|
||||
this(capacity, JSONConfig.create().setIgnoreCase(isIgnoreCase));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
@ -331,21 +305,6 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
BeanPath.create(expression).set(this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT 键值对到JSONObject中,在忽略null模式下,如果值为{@code null},将此键移除
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
|
||||
* @return this.
|
||||
* @throws JSONException 值是无穷数字抛出此异常
|
||||
* @deprecated 此方法存在歧义,原Map接口返回的是之前的值,重写后返回this了,未来版本此方法会修改,请使用{@link #set(String, Object)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public JSONObject put(String key, Object value) throws JSONException {
|
||||
return set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置键值对到JSONObject中,在忽略null模式下,如果值为{@code null},将此键移除
|
||||
*
|
||||
|
@ -125,22 +125,6 @@ public class JSONUtil {
|
||||
return new JSONObject(obj, ignoreNullValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON字符串转JSONObject对象
|
||||
*
|
||||
* @param obj Bean对象或者Map
|
||||
* @param ignoreNullValue 是否忽略空值,如果source为JSON字符串,不忽略空值
|
||||
* @param isOrder 是否有序
|
||||
* @return JSONObject
|
||||
* @since 4.2.2
|
||||
* @deprecated isOrder参数不再有效
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
public static JSONObject parseObj(Object obj, boolean ignoreNullValue, boolean isOrder) {
|
||||
return new JSONObject(obj, ignoreNullValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON字符串转JSONArray
|
||||
*
|
||||
@ -826,19 +810,6 @@ public class JSONUtil {
|
||||
return JSONStrFormatter.format(jsonStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSON字符串,首尾都为大括号或中括号判定为JSON字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @return 是否为JSON字符串
|
||||
* @since 3.3.0
|
||||
* @deprecated 方法名称有歧义,请使用 {@link #isTypeJSON(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isJson(String str) {
|
||||
return isTypeJSON(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSON类型字符串,首尾都为大括号或中括号判定为JSON字符串
|
||||
*
|
||||
@ -850,19 +821,6 @@ public class JSONUtil {
|
||||
return isTypeJSONObject(str) || isTypeJSONArray(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSONObject字符串,首尾都为大括号判定为JSONObject字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @return 是否为JSON字符串
|
||||
* @since 3.3.0
|
||||
* @deprecated 方法名称有歧义,请使用 {@link #isTypeJSONObject(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isJsonObj(String str) {
|
||||
return isTypeJSONObject(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSONObject类型字符串,首尾都为大括号判定为JSONObject字符串
|
||||
*
|
||||
@ -877,19 +835,6 @@ public class JSONUtil {
|
||||
return StrUtil.isWrap(StrUtil.trim(str), '{', '}');
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSONArray字符串,首尾都为中括号判定为JSONArray字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @return 是否为JSON字符串
|
||||
* @since 3.3.0
|
||||
* @deprecated 方法名称有歧义,请使用 {@link #isTypeJSONArray(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isJsonArray(String str) {
|
||||
return isTypeJSONArray(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为JSONArray类型的字符串,首尾都为中括号判定为JSONArray字符串
|
||||
*
|
||||
|
@ -6,7 +6,7 @@ import cn.hutool.log.level.Level;
|
||||
|
||||
/**
|
||||
* 静态日志类,用于在不引入日志对象的情况下打印日志
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@ -21,7 +21,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Trace等级日志,小于debug<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
*/
|
||||
@ -31,7 +31,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Trace等级日志,小于Debug
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -44,7 +44,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Debug等级日志,小于Info<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
*/
|
||||
@ -54,7 +54,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Debug等级日志,小于Info
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -67,7 +67,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Info等级日志,小于Warn<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
*/
|
||||
@ -77,7 +77,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Info等级日志,小于Warn
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -90,7 +90,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Warn等级日志,小于Error<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
*/
|
||||
@ -101,7 +101,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Warn等级日志,小于Error<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -112,7 +112,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Warn等级日志,小于Error
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -123,7 +123,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Warn等级日志,小于Error
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
* @param format 格式文本,{} 代表变量
|
||||
@ -137,7 +137,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
*/
|
||||
public static void error(Throwable e) {
|
||||
@ -147,7 +147,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
*/
|
||||
@ -158,7 +158,7 @@ public final class StaticLog {
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
* 由于动态获取Log,效率较低,建议在非频繁调用的情况下使用!!
|
||||
*
|
||||
*
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -169,7 +169,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
*/
|
||||
@ -179,7 +179,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param format 格式文本,{} 代表变量
|
||||
* @param arguments 变量对应的参数
|
||||
@ -190,7 +190,7 @@ public final class StaticLog {
|
||||
|
||||
/**
|
||||
* Error等级日志<br>
|
||||
*
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @param e 需在日志中堆栈打印的异常
|
||||
* @param format 格式文本,{} 代表变量
|
||||
@ -203,7 +203,7 @@ public final class StaticLog {
|
||||
// ------------------------ Log
|
||||
/**
|
||||
* 打印日志<br>
|
||||
*
|
||||
*
|
||||
* @param level 日志级别
|
||||
* @param t 需在日志中堆栈打印的异常
|
||||
* @param format 格式文本,{} 代表变量
|
||||
@ -214,37 +214,4 @@ public final class StaticLog {
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------- Log method end
|
||||
|
||||
/**
|
||||
* 获得Log
|
||||
*
|
||||
* @param clazz 日志发出的类
|
||||
* @return Log
|
||||
* @deprecated 请使用 {@link Log#get(Class)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Log get(Class<?> clazz) {
|
||||
return LogFactory.get(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得Log
|
||||
*
|
||||
* @param name 自定义的日志发出者名称
|
||||
* @return Log
|
||||
* @deprecated 请使用 {@link Log#get(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Log get(String name) {
|
||||
return LogFactory.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 获得日志,自动判定日志发出者
|
||||
* @deprecated 请使用 {@link Log#get()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Log get() {
|
||||
return LogFactory.get(CallerUtil.getCallerCaller());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user