mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
6b13cb5263
commit
24a300e348
@ -24,6 +24,7 @@
|
||||
### Bug修复
|
||||
* 【extra 】 修复SpringUtil使用devtools重启报错问题
|
||||
* 【http 】 修复HttpUtil.encodeParams针对无参数URL问题(issue#817@Github)
|
||||
* 【extra 】 修复模板中无效引用的问题
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -184,7 +184,6 @@ public abstract class AbstractCache<K, V> implements Cache<K, V> {
|
||||
|
||||
// ---------------------------------------------------------------- get end
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Iterator<V> iterator() {
|
||||
CacheObjIterator<K, V> copiedIterator = (CacheObjIterator<K, V>) this.cacheObjIterator();
|
||||
|
@ -1,17 +1,16 @@
|
||||
package cn.hutool.captcha;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import cn.hutool.core.img.GraphicsUtil;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* 圆圈干扰验证码
|
||||
*
|
||||
@ -73,7 +72,7 @@ public class CircleCaptcha extends AbstractCaptcha {
|
||||
/**
|
||||
* 绘制字符串
|
||||
*
|
||||
* @param g {@link Graphics}画笔
|
||||
* @param g {@link Graphics2D}画笔
|
||||
* @param code 验证码
|
||||
*/
|
||||
private void drawString(Graphics2D g, String code) {
|
||||
|
@ -1,14 +1,5 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
@ -18,6 +9,14 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.TypeUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Bean信息描述做为BeanInfo替代方案,此对象持有JavaBean中的setters和getters等相关信息描述<br>
|
||||
* 查找Getter和Setter方法时会:
|
||||
@ -322,7 +321,7 @@ public class BeanDesc implements Serializable{
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段名,如果存在{@link Alias}注解,读取注解的值作为名称
|
||||
* 获取字段名,如果存在Alias注解,读取注解的值作为名称
|
||||
*
|
||||
* @return 字段名
|
||||
*/
|
||||
|
@ -2,8 +2,6 @@ package cn.hutool.core.bean.copier;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
/**
|
||||
* 值提供者,用于提供Bean注入时参数对应值得抽象接口<br>
|
||||
* 继承或匿名实例化此接口<br>
|
||||
@ -17,7 +15,7 @@ public interface ValueProvider<T>{
|
||||
|
||||
/**
|
||||
* 获取值<br>
|
||||
* 返回值一般需要匹配被注入类型,如果不匹配会调用默认转换 {@link Convert#convert(Type, Object)}实现转换
|
||||
* 返回值一般需要匹配被注入类型,如果不匹配会调用默认转换 Convert#convert(Type, Object)实现转换
|
||||
*
|
||||
* @param key Bean对象中参数名
|
||||
* @param valueType 被注入的值得类型
|
||||
|
@ -25,9 +25,9 @@ public class GenericEnumConverter<E extends Enum<E>> extends AbstractConverter<E
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected E convertInternal(Object value) {
|
||||
//noinspection unchecked
|
||||
E enumValue = (E) EnumConverter.tryConvertEnum(value, this.enumClass);
|
||||
if(null == enumValue && false == value instanceof String){
|
||||
// 最后尝试valueOf转换
|
||||
|
@ -1,5 +1,12 @@
|
||||
package cn.hutool.core.io.file;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.copier.SrcToDestCopier;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.CopyOption;
|
||||
@ -7,12 +14,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.copier.SrcToDestCopier;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 文件拷贝器<br>
|
||||
* 支持以下几种情况:
|
||||
@ -209,25 +210,28 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
//被过滤的目录跳过
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (false == dest.exists()) {
|
||||
//目标为不存在路径,创建为目录
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
dest.mkdirs();
|
||||
} else if (false == dest.isDirectory()) {
|
||||
throw new IORuntimeException(StrUtil.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath()));
|
||||
}
|
||||
|
||||
final String[] files = src.list();
|
||||
File srcFile;
|
||||
File destFile;
|
||||
for (String file : files) {
|
||||
srcFile = new File(src, file);
|
||||
destFile = this.isOnlyCopyFile ? dest : new File(dest, file);
|
||||
// 递归复制
|
||||
if (srcFile.isDirectory()) {
|
||||
internalCopyDirContent(srcFile, destFile);
|
||||
} else {
|
||||
internalCopyFile(srcFile, destFile);
|
||||
if(ArrayUtil.isNotEmpty(files)){
|
||||
File srcFile;
|
||||
File destFile;
|
||||
for (String file : files) {
|
||||
srcFile = new File(src, file);
|
||||
destFile = this.isOnlyCopyFile ? dest : new File(dest, file);
|
||||
// 递归复制
|
||||
if (srcFile.isDirectory()) {
|
||||
internalCopyDirContent(srcFile, destFile);
|
||||
} else {
|
||||
internalCopyFile(srcFile, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,6 +267,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
}
|
||||
}else {
|
||||
//路径不存在则创建父目录
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
dest.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
@ -275,7 +280,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
}
|
||||
|
||||
try {
|
||||
Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[optionList.size()]));
|
||||
Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[0]));
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
package cn.hutool.core.net.multipart;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.setting.Setting;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* 上传文件设定文件
|
||||
*
|
||||
@ -13,10 +7,6 @@ import java.net.URL;
|
||||
*
|
||||
*/
|
||||
public class UploadSetting {
|
||||
private static final Log log = Log.get();
|
||||
|
||||
/** 默认的配置文件路径(相对ClassPath) */
|
||||
public final static String DEFAULT_SETTING_PATH = "config/upload.setting";
|
||||
|
||||
/** 最大文件大小,默认无限制 */
|
||||
protected int maxFileSize = -1;
|
||||
@ -117,32 +107,4 @@ public class UploadSetting {
|
||||
this.isAllowFileExts = isAllowFileExts;
|
||||
}
|
||||
// ---------------------------------------------------------------------- Setters and Getters end
|
||||
|
||||
/**
|
||||
* 加载全局设定<br>
|
||||
* 使用默认的配置文件classpath/config/upload.setting
|
||||
*/
|
||||
public void load() {
|
||||
load(DEFAULT_SETTING_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载全局设定
|
||||
*
|
||||
* @param settingPath 设定文件路径,相对Classpath
|
||||
*/
|
||||
synchronized public void load(String settingPath) {
|
||||
URL url = URLUtil.getURL(settingPath);
|
||||
if (url == null) {
|
||||
log.info("Can not find Upload setting file [{}], use default setting.", settingPath);
|
||||
return;
|
||||
}
|
||||
Setting setting = new Setting(url, Setting.DEFAULT_CHARSET, true);
|
||||
|
||||
maxFileSize = setting.getInt("file.size.max");
|
||||
memoryThreshold = setting.getInt("memory.threshold");
|
||||
tmpUploadPath = setting.getStr("tmp.upload.path");
|
||||
fileExts = setting.getStrings("file.exts");
|
||||
isAllowFileExts = setting.getBool("file.exts.allow");
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package cn.hutool.crypto.asymmetric;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import cn.hutool.core.codec.BCD;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
@ -12,9 +7,13 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.CryptoException;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
|
||||
/**
|
||||
* 抽象的非对称加密对象,包装了加密和解密为Hex和Base64的封装
|
||||
*
|
||||
@ -201,7 +200,6 @@ public abstract class AbstractAsymmetricCrypto<T extends AbstractAsymmetricCrypt
|
||||
* @param data 数据
|
||||
* @param keyType 密钥类型
|
||||
* @return 加密后的密文
|
||||
* @throws CryptoException 加密异常
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public String encryptBcd(String data, KeyType keyType) {
|
||||
@ -215,7 +213,6 @@ public abstract class AbstractAsymmetricCrypto<T extends AbstractAsymmetricCrypt
|
||||
* @param keyType 密钥类型
|
||||
* @param charset 加密前编码
|
||||
* @return 加密后的密文
|
||||
* @throws CryptoException 加密异常
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public String encryptBcd(String data, KeyType keyType, Charset charset) {
|
||||
|
@ -1,16 +1,5 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.db.dialect.Dialect;
|
||||
@ -22,6 +11,11 @@ import cn.hutool.log.LogFactory;
|
||||
import cn.hutool.log.level.Level;
|
||||
import cn.hutool.setting.Setting;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* 数据库操作工具类
|
||||
*
|
||||
@ -156,31 +150,12 @@ public final class DbUtil {
|
||||
*
|
||||
* @param objsToClose 需要关闭的对象
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static void close(Object... objsToClose) {
|
||||
for (Object obj : objsToClose) {
|
||||
if (obj instanceof AutoCloseable) {
|
||||
IoUtil.close((AutoCloseable) obj);
|
||||
} else if (obj instanceof Closeable) {
|
||||
IoUtil.close((Closeable) obj);
|
||||
} else {
|
||||
try {
|
||||
if (obj != null) {
|
||||
if (obj instanceof ResultSet) {
|
||||
((ResultSet) obj).close();
|
||||
} else if (obj instanceof Statement) {
|
||||
((Statement) obj).close();
|
||||
} else if (obj instanceof PreparedStatement) {
|
||||
((PreparedStatement) obj).close();
|
||||
} else if (obj instanceof Connection) {
|
||||
((Connection) obj).close();
|
||||
} else {
|
||||
log.warn("Object {} not a ResultSet or Statement or PreparedStatement or Connection!", obj.getClass().getName());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// ignore
|
||||
}
|
||||
log.warn("Object {} not a ResultSet or Statement or PreparedStatement or Connection!", obj.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,5 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import cn.hutool.core.lang.func.VoidFunc0;
|
||||
import cn.hutool.core.lang.func.VoidFunc1;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.dialect.Dialect;
|
||||
@ -17,6 +9,12 @@ import cn.hutool.db.sql.Wrapper;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.Closeable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
|
||||
/**
|
||||
* 数据库SQL执行会话<br>
|
||||
* 会话通过共用Connection而可以实现JDBC事务<br>
|
||||
@ -246,7 +244,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc0}接口的call方法执行多条SQL语句从而完成事务
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc1}接口的call方法执行多条SQL语句从而完成事务
|
||||
*
|
||||
* @param func 函数抽象,在函数中执行多个SQL操作,多个操作会被合并为同一事务
|
||||
* @throws SQLException SQL异常
|
||||
@ -264,7 +262,7 @@ public class Session extends AbstractDb implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc0}接口的call方法执行多条SQL语句从而完成事务
|
||||
* 在事务中执行操作,通过实现{@link VoidFunc1}接口的call方法执行多条SQL语句从而完成事务
|
||||
*
|
||||
* @param func 函数抽象,在函数中执行多个SQL操作,多个操作会被合并为同一事务
|
||||
* @since 3.2.3
|
||||
|
@ -148,7 +148,6 @@ public class HandleHelper {
|
||||
* @since 3.3.1
|
||||
*/
|
||||
public static <T extends Entity> T handleRow(T row, int columnCount, ResultSetMetaData meta, ResultSet rs, boolean withMetaInfo) throws SQLException {
|
||||
String columnLabel;
|
||||
int type;
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
type = meta.getColumnType(i);
|
||||
|
@ -353,17 +353,6 @@ public class MongoDS implements Closeable {
|
||||
log.debug("MongoDB connectionsPerHost: {}", connectionsPerHost);
|
||||
}
|
||||
|
||||
// multiplier for connectionsPerHost for # of threads that can block if connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5, then 50 threads can block more than
|
||||
// that and an exception will be throw --int
|
||||
Integer threadsAllowedToBlockForConnectionMultiplier = setting.getInt(group + "threadsAllowedToBlockForConnectionMultiplier");
|
||||
if (StrUtil.isBlank(group) == false && threadsAllowedToBlockForConnectionMultiplier == null) {
|
||||
threadsAllowedToBlockForConnectionMultiplier = setting.getInt("threadsAllowedToBlockForConnectionMultiplier");
|
||||
}
|
||||
if (threadsAllowedToBlockForConnectionMultiplier != null) {
|
||||
builder.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
|
||||
log.debug("MongoDB threadsAllowedToBlockForConnectionMultiplier: {}", threadsAllowedToBlockForConnectionMultiplier);
|
||||
}
|
||||
|
||||
// 被阻塞线程从连接池获取连接的最长等待时间(ms) --int
|
||||
Integer connectTimeout = setting.getInt(group + "connectTimeout");
|
||||
if (StrUtil.isBlank(group) == false && connectTimeout == null) {
|
||||
|
@ -265,7 +265,7 @@ public class ServletUtil {
|
||||
public static MultipartFormData getMultipart(ServletRequest request, UploadSetting uploadSetting) throws IORuntimeException {
|
||||
final MultipartFormData formData = new MultipartFormData(uploadSetting);
|
||||
try {
|
||||
formData.parseRequestStream(request.getInputStream(), request.getCharacterEncoding());
|
||||
formData.parseRequestStream(request.getInputStream(), CharsetUtil.charset(request.getCharacterEncoding()));
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
@ -43,8 +42,8 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
* @param name Bean名称
|
||||
* @return Bean
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
//noinspection unchecked
|
||||
return (T) applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
package cn.hutool.extra.template.engine.beetl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
@ -16,9 +14,10 @@ import org.beetl.core.resource.Matcher;
|
||||
import org.beetl.core.resource.StringTemplateResourceLoader;
|
||||
import org.beetl.core.resource.WebAppResourceLoader;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Beetl模板引擎工具类<br>
|
||||
@ -26,7 +25,9 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
* 文档:http://ibeetl.com/guide/beetl.html
|
||||
*
|
||||
* @author Looly
|
||||
* @deprecated 使用TemplateUtil替代
|
||||
*/
|
||||
@Deprecated
|
||||
public final class BeetlUtil {
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,6 @@ import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateConfig.ResourceMode;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import com.jfinal.template.source.FileSourceFactory;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
|
||||
/**
|
||||
* Enjoy库的引擎包装
|
||||
@ -80,7 +79,7 @@ public class EnjoyEngine implements TemplateEngine {
|
||||
* 创建引擎
|
||||
*
|
||||
* @param config 模板配置
|
||||
* @return {@link GroupTemplate}
|
||||
* @return {@link com.jfinal.template.Engine}
|
||||
*/
|
||||
private static com.jfinal.template.Engine createEngine(TemplateConfig config) {
|
||||
final com.jfinal.template.Engine engine = com.jfinal.template.Engine.create("Hutool-Enjoy-Engine-" + IdUtil.fastSimpleUUID());
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.hutool.extra.template.engine.freemarker;
|
||||
|
||||
import java.io.IOException;
|
||||
import freemarker.cache.TemplateLoader;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import freemarker.cache.TemplateLoader;
|
||||
|
||||
/**
|
||||
* {@link TemplateLoader} 字符串实现形式<br>
|
||||
* 用于直接获取字符串模板
|
||||
@ -16,7 +15,7 @@ import freemarker.cache.TemplateLoader;
|
||||
public class SimpleStringTemplateLoader implements TemplateLoader {
|
||||
|
||||
@Override
|
||||
public Object findTemplateSource(String name) throws IOException {
|
||||
public Object findTemplateSource(String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -26,12 +25,12 @@ public class SimpleStringTemplateLoader implements TemplateLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getReader(Object templateSource, String encoding) throws IOException {
|
||||
public Reader getReader(Object templateSource, String encoding) {
|
||||
return new StringReader((String) templateSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTemplateSource(Object templateSource) throws IOException {
|
||||
public void closeTemplateSource(Object templateSource) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package cn.hutool.extra.template.engine.rythm;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
import cn.hutool.extra.template.engine.beetl.BeetlTemplate;
|
||||
|
||||
/**
|
||||
* Rythm模板包装
|
||||
*
|
||||
@ -25,7 +24,7 @@ public class RythmTemplate extends AbstractTemplate implements Serializable {
|
||||
* 包装Rythm模板
|
||||
*
|
||||
* @param template Rythm的模板对象 {@link org.rythmengine.template.ITemplate}
|
||||
* @return {@link BeetlTemplate}
|
||||
* @return {@link RythmTemplate}
|
||||
*/
|
||||
public static RythmTemplate wrap(org.rythmengine.template.ITemplate template) {
|
||||
return (null == template) ? null : new RythmTemplate(template);
|
||||
|
@ -1,5 +1,16 @@
|
||||
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;
|
||||
@ -9,37 +20,30 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Velocity模板引擎工具类<br>
|
||||
* 使用前必须初始化工具类
|
||||
*
|
||||
*
|
||||
* @author xiaoleilu
|
||||
*
|
||||
* @deprecated 使用TemplateUtil替代
|
||||
*/
|
||||
@Deprecated
|
||||
public class VelocityUtil {
|
||||
|
||||
/** 是否初始化了默认引擎 */
|
||||
/**
|
||||
* 是否初始化了默认引擎
|
||||
*/
|
||||
private static boolean isInited;
|
||||
/** 全局上下文,当设定值时,对于每个模板都有效 */
|
||||
/**
|
||||
* 全局上下文,当设定值时,对于每个模板都有效
|
||||
*/
|
||||
private static Map<String, Object> globalContext = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 设置Velocity全局上下文<br>
|
||||
* 当设定值时,对于每个模板都有效
|
||||
*
|
||||
* @param name 名
|
||||
*
|
||||
* @param name 名
|
||||
* @param value 值
|
||||
*/
|
||||
public void putGlobalContext(String name, Object value) {
|
||||
@ -48,9 +52,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 初始化Velocity全局属性
|
||||
*
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param charset 编码
|
||||
* @param charset 编码
|
||||
*/
|
||||
synchronized public static void init(String templateDir, String charset) {
|
||||
Velocity.init(_newInitedProp(templateDir, charset));
|
||||
@ -61,9 +65,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 初始化全局属性
|
||||
*
|
||||
* @param templateDir 模板目录
|
||||
* @param charset 字符集编码
|
||||
*
|
||||
* @param templateDir 模板目录
|
||||
* @param charset 字符集编码
|
||||
* @param initedGlobalContext 初始的全局上下文
|
||||
*/
|
||||
public static void init(String templateDir, String charset, Map<String, Object> initedGlobalContext) {
|
||||
@ -73,9 +77,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 新建Velocity模板引擎
|
||||
*
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param charset 编码
|
||||
* @param charset 编码
|
||||
* @return VelocityEngine
|
||||
*/
|
||||
public static VelocityEngine newEngine(String templateDir, String charset) {
|
||||
@ -89,11 +93,11 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
*
|
||||
* @param templateDir 模板所在目录,绝对路径
|
||||
* @param templateFileName 模板名称
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @param charset 字符集
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @param charset 字符集
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(String templateDir, String templateFileName, VelocityContext context, String charset) {
|
||||
@ -105,10 +109,10 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
* @param templateFileName 模板名称
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(VelocityEngine ve, String templateFileName, VelocityContext context) {
|
||||
@ -119,9 +123,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 获得指定模板填充后的内容,使用默认引擎
|
||||
*
|
||||
*
|
||||
* @param templateFileName 模板文件
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @param context 上下文(变量值的容器)
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String getContent(String templateFileName, VelocityContext context) {
|
||||
@ -132,11 +136,11 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
*
|
||||
* @param ve 模板引擎
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
* @param context 上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(VelocityEngine ve, String templateFileName, VelocityContext context, String destPath) {
|
||||
toFile(ve.getTemplate(templateFileName), context, destPath);
|
||||
@ -144,10 +148,10 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 生成文件,使用默认引擎
|
||||
*
|
||||
*
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 模板上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
* @param context 模板上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
|
||||
assertInit();
|
||||
@ -157,9 +161,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 生成文件
|
||||
*
|
||||
*
|
||||
* @param template 模板
|
||||
* @param context 模板上下文
|
||||
* @param context 模板上下文
|
||||
* @param destPath 目标路径(绝对)
|
||||
*/
|
||||
public static void toFile(Template template, VelocityContext context, String destPath) {
|
||||
@ -177,11 +181,11 @@ public class VelocityUtil {
|
||||
/**
|
||||
* 生成内容写入流<br>
|
||||
* 会自动关闭Writer
|
||||
*
|
||||
* @param ve 引擎
|
||||
*
|
||||
* @param ve 引擎
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
*/
|
||||
public static void toWriter(VelocityEngine ve, String templateFileName, VelocityContext context, Writer writer) {
|
||||
final Template template = ve.getTemplate(templateFileName);
|
||||
@ -191,10 +195,10 @@ public class VelocityUtil {
|
||||
/**
|
||||
* 生成内容写入流<br>
|
||||
* 会自动关闭Writer
|
||||
*
|
||||
*
|
||||
* @param templateFileName 模板文件名
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
* @param context 上下文
|
||||
* @param writer 流
|
||||
*/
|
||||
public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
|
||||
assertInit();
|
||||
@ -206,10 +210,10 @@ public class VelocityUtil {
|
||||
/**
|
||||
* 生成内容写到响应内容中<br>
|
||||
* 模板的变量来自于Request的Attribute对象
|
||||
*
|
||||
*
|
||||
* @param templateFileName 模板文件
|
||||
* @param request 请求对象,用于获取模板中的变量值
|
||||
* @param response 响应对象
|
||||
* @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();
|
||||
@ -229,9 +233,9 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 融合模板和内容
|
||||
*
|
||||
*
|
||||
* @param templateContent 模板的内容字符串
|
||||
* @param context 上下文
|
||||
* @param context 上下文
|
||||
* @return 模板和内容匹配后的内容
|
||||
*/
|
||||
public static String merge(String templateContent, VelocityContext context) {
|
||||
@ -246,10 +250,10 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 融合模板和内容并写入到Writer
|
||||
*
|
||||
*
|
||||
* @param template 模板
|
||||
* @param context 内容
|
||||
* @param writer Writer
|
||||
* @param context 内容
|
||||
* @param writer Writer
|
||||
*/
|
||||
public static void merge(Template template, VelocityContext context, Writer writer) {
|
||||
if (template == null) {
|
||||
@ -270,7 +274,7 @@ public class VelocityUtil {
|
||||
/**
|
||||
* 将Request中的数据转换为模板引擎<br>
|
||||
* 取值包括Session和Request
|
||||
*
|
||||
*
|
||||
* @param context 内容
|
||||
* @param request 请求对象
|
||||
* @return VelocityContext
|
||||
@ -289,7 +293,7 @@ public class VelocityUtil {
|
||||
|
||||
/**
|
||||
* 将Session中的值放入模板上下文
|
||||
*
|
||||
*
|
||||
* @param context 模板上下文
|
||||
* @param session Session
|
||||
* @return VelocityContext
|
||||
@ -309,9 +313,10 @@ public class VelocityUtil {
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- Private method start
|
||||
|
||||
/**
|
||||
* 新建一个初始化后的属性对象
|
||||
*
|
||||
*
|
||||
* @param templateDir 模板所在目录
|
||||
* @return 初始化后的属性对象
|
||||
*/
|
||||
|
@ -49,7 +49,6 @@ public abstract class AbstractResult implements Result{
|
||||
throw new UnsupportedOperationException("Jcseg result not allow to remove !");
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Iterator<Word> iterator() {
|
||||
return this;
|
||||
|
@ -63,7 +63,6 @@ public class JcsegResult implements Result{
|
||||
throw new UnsupportedOperationException("Jcseg result not allow to remove !");
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Iterator<Word> iterator() {
|
||||
return this;
|
||||
|
@ -1,12 +1,6 @@
|
||||
package cn.hutool.extra.tokenizer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.extra.tokenizer.engine.analysis.SmartcnEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.hanlp.HanLPEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.ikanalyzer.IKAnalyzerEngine;
|
||||
@ -15,6 +9,11 @@ import cn.hutool.extra.tokenizer.engine.jieba.JiebaEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.mmseg.MmsegEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.mynlp.MynlpEngine;
|
||||
import cn.hutool.extra.tokenizer.engine.word.WordEngine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* 模板引擎单元测试
|
||||
@ -38,7 +37,7 @@ public class TokenizerUtilTest {
|
||||
public void hanlpTest() {
|
||||
TokenizerEngine engine = new HanLPEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ public class TokenizerUtilTest {
|
||||
public void ikAnalyzerTest() {
|
||||
TokenizerEngine engine = new IKAnalyzerEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@ -61,7 +60,7 @@ public class TokenizerUtilTest {
|
||||
public void jiebaTest() {
|
||||
TokenizerEngine engine = new JiebaEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@ -76,7 +75,7 @@ public class TokenizerUtilTest {
|
||||
public void smartcnTest() {
|
||||
TokenizerEngine engine = new SmartcnEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这 两 个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
@ -84,7 +83,7 @@ public class TokenizerUtilTest {
|
||||
public void wordTest() {
|
||||
TokenizerEngine engine = new WordEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这两个 方法 的 区别 在于 返回值", resultStr);
|
||||
}
|
||||
|
||||
@ -94,12 +93,12 @@ public class TokenizerUtilTest {
|
||||
// 此单元测试需要JDK8,默认忽略
|
||||
TokenizerEngine engine = new MynlpEngine();
|
||||
Result result = engine.parse(text);
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
|
||||
private void checkResult(Result result) {
|
||||
String resultStr = CollUtil.join((Iterator<Word>)result, " ");
|
||||
String resultStr = IterUtil.join((Iterator<Word>)result, " ");
|
||||
Assert.assertEquals("这 两个 方法 的 区别 在于 返回 值", resultStr);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package cn.hutool.http.ssl;
|
||||
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* 证书管理
|
||||
|
@ -1,11 +1,5 @@
|
||||
package cn.hutool.http.test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.lang.Console;
|
||||
@ -13,6 +7,11 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link HttpRequest}单元测试
|
||||
@ -37,6 +36,7 @@ public class HttpRequestTest {
|
||||
HttpResponse res = HttpRequest.get("https://www.oschina.net/").execute();
|
||||
String body = res.body();
|
||||
Console.log(res.getCookies());
|
||||
Console.log(body);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,5 +1,12 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
@ -9,13 +16,6 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 内部JSON工具类,仅用于JSON内部使用
|
||||
*
|
||||
@ -197,11 +197,11 @@ final class InternalJSONUtil {
|
||||
JSONObject nextTarget = target.getJSONObject(segment);
|
||||
if (nextTarget == null) {
|
||||
nextTarget = new JSONObject();
|
||||
target.put(segment, nextTarget);
|
||||
target.set(segment, nextTarget);
|
||||
}
|
||||
target = nextTarget;
|
||||
}
|
||||
target.put(path[last], value);
|
||||
target.set(path[last], value);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
package cn.hutool.log;
|
||||
|
||||
import cn.hutool.log.dialect.commons.ApacheCommonsLogFactory;
|
||||
import cn.hutool.log.dialect.console.ConsoleLogFactory;
|
||||
import cn.hutool.log.dialect.jdk.JdkLogFactory;
|
||||
import cn.hutool.log.dialect.log4j.Log4jLogFactory;
|
||||
import cn.hutool.log.dialect.log4j2.Log4j2LogFactory;
|
||||
import cn.hutool.log.dialect.slf4j.Slf4jLogFactory;
|
||||
|
||||
/**
|
||||
* 全局日志工厂类<br>
|
||||
* 用于减少日志工厂创建,减少日志库探测
|
||||
@ -37,12 +30,12 @@ public class GlobalLogFactory {
|
||||
/**
|
||||
* 自定义日志实现
|
||||
*
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see JdkLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see cn.hutool.log.dialect.slf4j.Slf4jLogFactory
|
||||
* @see cn.hutool.log.dialect.log4j.Log4jLogFactory
|
||||
* @see cn.hutool.log.dialect.log4j2.Log4j2LogFactory
|
||||
* @see cn.hutool.log.dialect.commons.ApacheCommonsLogFactory
|
||||
* @see cn.hutool.log.dialect.jdk.JdkLogFactory
|
||||
* @see cn.hutool.log.dialect.console.ConsoleLogFactory
|
||||
*
|
||||
* @param logFactoryClass 日志工厂类
|
||||
* @return 自定义的日志工厂类
|
||||
@ -57,14 +50,14 @@ public class GlobalLogFactory {
|
||||
|
||||
/**
|
||||
* 自定义日志实现
|
||||
*
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see JdkLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
*
|
||||
*
|
||||
* @see cn.hutool.log.dialect.slf4j.Slf4jLogFactory
|
||||
* @see cn.hutool.log.dialect.log4j.Log4jLogFactory
|
||||
* @see cn.hutool.log.dialect.log4j2.Log4j2LogFactory
|
||||
* @see cn.hutool.log.dialect.commons.ApacheCommonsLogFactory
|
||||
* @see cn.hutool.log.dialect.jdk.JdkLogFactory
|
||||
* @see cn.hutool.log.dialect.console.ConsoleLogFactory
|
||||
*
|
||||
* @param logFactory 日志工厂类对象
|
||||
* @return 自定义的日志工厂类
|
||||
*/
|
||||
|
@ -3,14 +3,8 @@ package cn.hutool.log;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.caller.CallerUtil;
|
||||
import cn.hutool.core.util.ServiceLoaderUtil;
|
||||
import cn.hutool.log.dialect.commons.ApacheCommonsLogFactory;
|
||||
import cn.hutool.log.dialect.console.ConsoleLogFactory;
|
||||
import cn.hutool.log.dialect.jboss.JbossLogFactory;
|
||||
import cn.hutool.log.dialect.jdk.JdkLogFactory;
|
||||
import cn.hutool.log.dialect.log4j.Log4jLogFactory;
|
||||
import cn.hutool.log.dialect.log4j2.Log4j2LogFactory;
|
||||
import cn.hutool.log.dialect.slf4j.Slf4jLogFactory;
|
||||
import cn.hutool.log.dialect.tinylog.TinyLogFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
@ -20,14 +14,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 日志工厂类
|
||||
*
|
||||
* @author Looly
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see TinyLogFactory
|
||||
* @see JbossLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see JdkLogFactory
|
||||
*/
|
||||
public abstract class LogFactory {
|
||||
|
||||
@ -131,14 +117,6 @@ public abstract class LogFactory {
|
||||
*
|
||||
* @param logFactoryClass 日志工厂类
|
||||
* @return 自定义的日志工厂类
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see TinyLogFactory
|
||||
* @see JbossLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see JdkLogFactory
|
||||
*/
|
||||
public static LogFactory setCurrentLogFactory(Class<? extends LogFactory> logFactoryClass) {
|
||||
return GlobalLogFactory.set(logFactoryClass);
|
||||
@ -149,14 +127,6 @@ public abstract class LogFactory {
|
||||
*
|
||||
* @param logFactory 日志工厂类对象
|
||||
* @return 自定义的日志工厂类
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see TinyLogFactory
|
||||
* @see JbossLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see JdkLogFactory
|
||||
*/
|
||||
public static LogFactory setCurrentLogFactory(LogFactory logFactory) {
|
||||
return GlobalLogFactory.set(logFactory);
|
||||
@ -195,14 +165,6 @@ public abstract class LogFactory {
|
||||
* 依次按照顺序检查日志库的jar是否被引入,如果未引入任何日志库,则检查ClassPath下的logging.properties,存在则使用JdkLogFactory,否则使用ConsoleLogFactory
|
||||
*
|
||||
* @return 日志实现类
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see TinyLogFactory
|
||||
* @see JbossLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see JdkLogFactory
|
||||
*/
|
||||
public static LogFactory create() {
|
||||
final LogFactory factory = doCreate();
|
||||
@ -216,18 +178,10 @@ public abstract class LogFactory {
|
||||
* 依次按照顺序检查日志库的jar是否被引入,如果未引入任何日志库,则检查ClassPath下的logging.properties,存在则使用JdkLogFactory,否则使用ConsoleLogFactory
|
||||
*
|
||||
* @return 日志实现类
|
||||
* @see Slf4jLogFactory
|
||||
* @see Log4j2LogFactory
|
||||
* @see Log4jLogFactory
|
||||
* @see ApacheCommonsLogFactory
|
||||
* @see TinyLogFactory
|
||||
* @see JbossLogFactory
|
||||
* @see ConsoleLogFactory
|
||||
* @see JdkLogFactory
|
||||
*/
|
||||
private static LogFactory doCreate() {
|
||||
final LogFactory factory = ServiceLoaderUtil.loadFirstAvailable(LogFactory.class);
|
||||
if(null != factory){
|
||||
if (null != factory) {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,5 @@
|
||||
package cn.hutool.poi.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.extractor.ExcelExtractor;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.IterUtil;
|
||||
@ -25,7 +10,20 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.cell.CellEditor;
|
||||
import cn.hutool.poi.excel.cell.CellUtil;
|
||||
import cn.hutool.poi.excel.editors.TrimEditor;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.extractor.ExcelExtractor;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Excel读取器<br>
|
||||
@ -153,7 +151,6 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
|
||||
*
|
||||
* @param cellEditor 单元格值处理接口
|
||||
* @return this
|
||||
* @see TrimEditor
|
||||
*/
|
||||
public ExcelReader setCellEditor(CellEditor cellEditor) {
|
||||
this.cellEditor = cellEditor;
|
||||
|
@ -15,7 +15,6 @@ import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Excel工具类
|
||||
@ -348,7 +347,7 @@ public class ExcelUtil {
|
||||
// ------------------------------------------------------------------------------------------------ getWriter
|
||||
/**
|
||||
* 获得{@link ExcelWriter},默认写出到第一个sheet<br>
|
||||
* 不传入写出的Excel文件路径,只能调用{@link ExcelWriter#flush(OutputStream)}方法写出到流<br>
|
||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||
* 若写出到文件,还需调用{@link ExcelWriter#setDestFile(File)}方法自定义写出的文件,然后调用{@link ExcelWriter#flush()}方法写出到文件
|
||||
*
|
||||
* @return {@link ExcelWriter}
|
||||
@ -364,7 +363,7 @@ public class ExcelUtil {
|
||||
|
||||
/**
|
||||
* 获得{@link ExcelWriter},默认写出到第一个sheet<br>
|
||||
* 不传入写出的Excel文件路径,只能调用{@link ExcelWriter#flush(OutputStream)}方法写出到流<br>
|
||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||
* 若写出到文件,还需调用{@link ExcelWriter#setDestFile(File)}方法自定义写出的文件,然后调用{@link ExcelWriter#flush()}方法写出到文件
|
||||
*
|
||||
* @param isXlsx 是否为xlsx格式
|
||||
@ -455,7 +454,7 @@ public class ExcelUtil {
|
||||
// ------------------------------------------------------------------------------------------------ getBigWriter
|
||||
/**
|
||||
* 获得{@link BigExcelWriter},默认写出到第一个sheet<br>
|
||||
* 不传入写出的Excel文件路径,只能调用{@link BigExcelWriter#flush(OutputStream)}方法写出到流<br>
|
||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||
* 若写出到文件,还需调用{@link BigExcelWriter#setDestFile(File)}方法自定义写出的文件,然后调用{@link BigExcelWriter#flush()}方法写出到文件
|
||||
*
|
||||
* @return {@link BigExcelWriter}
|
||||
@ -471,7 +470,7 @@ public class ExcelUtil {
|
||||
|
||||
/**
|
||||
* 获得{@link BigExcelWriter},默认写出到第一个sheet<br>
|
||||
* 不传入写出的Excel文件路径,只能调用{@link BigExcelWriter#flush(OutputStream)}方法写出到流<br>
|
||||
* 不传入写出的Excel文件路径,只能调用ExcelWriter#flush(OutputStream)方法写出到流<br>
|
||||
* 若写出到文件,还需调用{@link BigExcelWriter#setDestFile(File)}方法自定义写出的文件,然后调用{@link BigExcelWriter#flush()}方法写出到文件
|
||||
*
|
||||
* @param rowAccessWindowSize 在内存中的行数
|
||||
|
@ -41,10 +41,6 @@ public class Excel07SaxReader extends AbstractExcelSaxReader<Excel07SaxReader> i
|
||||
* Cell中的行列号(Reference),行模式下此为行号属性名,列模式下为列号属性名
|
||||
*/
|
||||
private static final String R_ATTR = "r";
|
||||
/**
|
||||
* Cell类型
|
||||
*/
|
||||
private static final String T_ELEMENT = "t";
|
||||
/**
|
||||
* SST(SharedStringsTable) 的索引,样式index
|
||||
*/
|
||||
|
@ -1,18 +1,18 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 基于分组的Map<br>
|
||||
* 此对象方法线程安全
|
||||
@ -226,7 +226,6 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
readLock.lock();
|
||||
@ -277,7 +276,6 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Set<java.util.Map.Entry<String, LinkedHashMap<String, String>>> entrySet() {
|
||||
readLock.lock();
|
||||
|
@ -1,18 +1,5 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
@ -31,6 +18,19 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.log.StaticLog;
|
||||
import cn.hutool.setting.dialect.Props;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 设置工具类。 用于支持设置(配置)文件<br>
|
||||
* BasicSetting用于替换Properties类,提供功能更加强大的配置文件,同时对Properties文件向下兼容
|
||||
@ -638,7 +638,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @param m Map
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ? extends String> m) {
|
||||
this.groupedMap.putAll(DEFAULT_GROUP, m);
|
||||
@ -657,7 +656,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @return 默认分组(空分组)中的所有键列表
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
return this.groupedMap.keySet(DEFAULT_GROUP);
|
||||
@ -668,7 +666,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @return 默认分组(空分组)中的所有值列表
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Collection<String> values() {
|
||||
return this.groupedMap.values(DEFAULT_GROUP);
|
||||
@ -679,7 +676,6 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @return 默认分组(空分组)中的所有键值对列表
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public Set<Entry<String, String>> entrySet() {
|
||||
return this.groupedMap.entrySet(DEFAULT_GROUP);
|
||||
|
@ -56,7 +56,6 @@ public class SettingUtil {
|
||||
* @since 5.1.3
|
||||
*/
|
||||
public static Setting getFirstFound(String... names) {
|
||||
Setting setting;
|
||||
for (String name : names) {
|
||||
try {
|
||||
return get(name);
|
||||
|
@ -57,7 +57,6 @@ public class PropsUtil {
|
||||
* @return 当前环境下配置文件
|
||||
*/
|
||||
public static Props getFirstFound(String... names) {
|
||||
Props props;
|
||||
for (String name : names) {
|
||||
try {
|
||||
return get(name);
|
||||
|
@ -72,7 +72,6 @@ public class PropsTest {
|
||||
@Test
|
||||
public void toBeanWithNullPrefixTest(){
|
||||
Props configProp = new Props();
|
||||
Boolean isInit = configProp.getBool("isInit");
|
||||
|
||||
configProp.setProperty("createTime", Objects.requireNonNull(DateUtil.parse("2020-01-01")));
|
||||
configProp.setProperty("isInit", true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user