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
373c30b9f0
commit
8c3298fed4
@ -1819,6 +1819,18 @@ public class CharSequenceUtil {
|
||||
return StrSplitter.split(str.toString(), separator, limit, isTrim, ignoreEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切分字符串,如果分隔符不存在则返回原字符串
|
||||
*
|
||||
* @param str 被切分的字符串
|
||||
* @param separator 分隔符
|
||||
* @return 字符串
|
||||
* @since 5.7.1
|
||||
*/
|
||||
public static List<String> split(CharSequence str, CharSequence separator) {
|
||||
return split(str, separator, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切分字符串
|
||||
*
|
||||
|
@ -386,7 +386,6 @@ public class IdcardUtil {
|
||||
}
|
||||
|
||||
// 首字母A-Z,A表示1,以此类推
|
||||
char start = idcard.charAt(0);
|
||||
String mid = card.substring(1, 7);
|
||||
String end = card.substring(7, 8);
|
||||
char[] chars = mid.toCharArray();
|
||||
|
@ -73,7 +73,7 @@ public class BeanUtilTest {
|
||||
|
||||
@Test
|
||||
public void fillBeanWithMapIgnoreCaseTest() {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("Name", "Joe");
|
||||
map.put("aGe", 12);
|
||||
map.put("openId", "DFDFSDFWERWER");
|
||||
@ -104,7 +104,7 @@ public class BeanUtilTest {
|
||||
*/
|
||||
@Test
|
||||
public void toBeanIgnoreErrorTest() {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("name", "Joe");
|
||||
// 错误的类型,此处忽略
|
||||
map.put("age", "aaaaaa");
|
||||
@ -117,7 +117,7 @@ public class BeanUtilTest {
|
||||
|
||||
@Test
|
||||
public void mapToBeanIgnoreCaseTest() {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("Name", "Joe");
|
||||
map.put("aGe", 12);
|
||||
|
||||
@ -128,12 +128,12 @@ public class BeanUtilTest {
|
||||
|
||||
@Test
|
||||
public void mapToBeanTest() {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("a_name", "Joe");
|
||||
map.put("b_age", 12);
|
||||
|
||||
// 别名,用于对应bean的字段名
|
||||
HashMap<String, String> mapping = CollUtil.newHashMap();
|
||||
HashMap<String, String> mapping = MapUtil.newHashMap();
|
||||
mapping.put("a_name", "name");
|
||||
mapping.put("b_age", "age");
|
||||
|
||||
@ -147,7 +147,7 @@ public class BeanUtilTest {
|
||||
*/
|
||||
@Test
|
||||
public void mapToBeanTest2() {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("name", "Joe");
|
||||
map.put("age", 12);
|
||||
|
||||
|
@ -38,9 +38,9 @@ public class ListUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterTest(){
|
||||
public void editTest(){
|
||||
List<String> a = ListUtil.toLinkedList("1", "2", "3");
|
||||
final List<String> filter = ListUtil.filter(a, str -> "edit" + str);
|
||||
final List<String> filter = ListUtil.edit(a, str -> "edit" + str);
|
||||
Assert.assertEquals("edit1", filter.get(0));
|
||||
Assert.assertEquals("edit2", filter.get(1));
|
||||
Assert.assertEquals("edit3", filter.get(2));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.hutool.cron;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.thread.ExecutorBuilder;
|
||||
import cn.hutool.core.thread.ThreadFactoryBuilder;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
@ -180,7 +180,7 @@ public class Scheduler implements Serializable {
|
||||
* @return this
|
||||
*/
|
||||
public Scheduler schedule(Setting cronSetting) {
|
||||
if (CollUtil.isNotEmpty(cronSetting)) {
|
||||
if (MapUtil.isNotEmpty(cronSetting)) {
|
||||
String group;
|
||||
for (Entry<String, LinkedHashMap<String, String>> groupedEntry : cronSetting.getGroupedMap().entrySet()) {
|
||||
group = groupedEntry.getKey();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.ds.DSFactory;
|
||||
|
||||
@ -18,14 +18,14 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
public class DaoTemplate {
|
||||
|
||||
|
||||
/** 表名 */
|
||||
protected String tableName;
|
||||
/** 本表的主键字段,请在子类中覆盖或构造方法中指定,默认为id */
|
||||
protected String primaryKeyField = "id";
|
||||
/** SQL运行器 */
|
||||
protected Db db;
|
||||
|
||||
|
||||
//--------------------------------------------------------------- Constructor start
|
||||
/**
|
||||
* 构造,此构造需要自定义SqlRunner,主键默认为id
|
||||
@ -34,7 +34,7 @@ public class DaoTemplate {
|
||||
public DaoTemplate(String tableName) {
|
||||
this(tableName, (String)null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造,使用默认的池化连接池,读取默认配置文件的空分组,适用于只有一个数据库的情况
|
||||
* @param tableName 数据库表名
|
||||
@ -43,11 +43,11 @@ public class DaoTemplate {
|
||||
public DaoTemplate(String tableName, String primaryKeyField) {
|
||||
this(tableName, primaryKeyField, DSFactory.get());
|
||||
}
|
||||
|
||||
|
||||
public DaoTemplate(String tableName, DataSource ds) {
|
||||
this(tableName, null, ds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param tableName 表名
|
||||
@ -57,7 +57,7 @@ public class DaoTemplate {
|
||||
public DaoTemplate(String tableName, String primaryKeyField, DataSource ds) {
|
||||
this(tableName, primaryKeyField, Db.use(ds));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param tableName 表名
|
||||
@ -72,7 +72,7 @@ public class DaoTemplate {
|
||||
this.db = db;
|
||||
}
|
||||
//--------------------------------------------------------------- Constructor end
|
||||
|
||||
|
||||
//------------------------------------------------------------- Add start
|
||||
/**
|
||||
* 添加
|
||||
@ -83,7 +83,7 @@ public class DaoTemplate {
|
||||
public int add(Entity entity) throws SQLException {
|
||||
return db.insert(fixEntity(entity));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param entity 实体对象
|
||||
@ -93,7 +93,7 @@ public class DaoTemplate {
|
||||
public List<Object> addForGeneratedKeys(Entity entity) throws SQLException {
|
||||
return db.insertForGeneratedKeys(fixEntity(entity));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param entity 实体对象
|
||||
@ -104,12 +104,12 @@ public class DaoTemplate {
|
||||
return db.insertForGeneratedKey(fixEntity(entity));
|
||||
}
|
||||
//------------------------------------------------------------- Add end
|
||||
|
||||
|
||||
//------------------------------------------------------------- Delete start
|
||||
/**
|
||||
* 删除
|
||||
* @param <T> 主键类型
|
||||
*
|
||||
*
|
||||
* @param pk 主键
|
||||
* @return 删除行数
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -120,10 +120,10 @@ public class DaoTemplate {
|
||||
}
|
||||
return this.del(Entity.create(tableName).set(primaryKeyField, pk));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
*
|
||||
* @param <T> 主键类型
|
||||
* @param field 字段名
|
||||
* @param value 字段值
|
||||
@ -137,23 +137,23 @@ public class DaoTemplate {
|
||||
|
||||
return this.del(Entity.create(tableName).set(field, value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
*
|
||||
* @param <T> 主键类型
|
||||
* @param where 删除条件,当条件为空时,返回0(防止误删全表)
|
||||
* @return 删除行数
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public <T> int del(Entity where) throws SQLException {
|
||||
if (CollectionUtil.isEmpty(where)) {
|
||||
if (MapUtil.isEmpty(where)) {
|
||||
return 0;
|
||||
}
|
||||
return db.del(fixEntity(where));
|
||||
}
|
||||
//------------------------------------------------------------- Delete end
|
||||
|
||||
|
||||
//------------------------------------------------------------- Update start
|
||||
/**
|
||||
* 按照条件更新
|
||||
@ -163,12 +163,12 @@ public class DaoTemplate {
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public int update(Entity record, Entity where) throws SQLException{
|
||||
if (CollectionUtil.isEmpty(record)) {
|
||||
if (MapUtil.isEmpty(record)) {
|
||||
return 0;
|
||||
}
|
||||
return db.update(fixEntity(record), where);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param entity 实体对象,必须包含主键
|
||||
@ -176,7 +176,7 @@ public class DaoTemplate {
|
||||
* @throws SQLException SQL执行异常
|
||||
*/
|
||||
public int update(Entity entity) throws SQLException {
|
||||
if (CollectionUtil.isEmpty(entity)) {
|
||||
if (MapUtil.isEmpty(entity)) {
|
||||
return 0;
|
||||
}
|
||||
entity = fixEntity(entity);
|
||||
@ -191,7 +191,7 @@ public class DaoTemplate {
|
||||
|
||||
return db.update(record, where);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加或者更新实体
|
||||
* @param entity 实体,当包含主键时更新,否则新增
|
||||
@ -202,11 +202,11 @@ public class DaoTemplate {
|
||||
return null == entity.get(primaryKeyField) ? add(entity) : update(entity);
|
||||
}
|
||||
//------------------------------------------------------------- Update end
|
||||
|
||||
|
||||
//------------------------------------------------------------- Get start
|
||||
/**
|
||||
* 根据主键获取单个记录
|
||||
*
|
||||
*
|
||||
* @param <T> 主键类型
|
||||
* @param pk 主键值
|
||||
* @return 记录
|
||||
@ -215,11 +215,11 @@ public class DaoTemplate {
|
||||
public <T> Entity get(T pk) throws SQLException {
|
||||
return this.get(primaryKeyField, pk);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据某个字段(最好是唯一字段)查询单个记录<br>
|
||||
* 当有多条返回时,只显示查询到的第一条
|
||||
*
|
||||
*
|
||||
* @param <T> 字段值类型
|
||||
* @param field 字段名
|
||||
* @param value 字段值
|
||||
@ -229,10 +229,10 @@ public class DaoTemplate {
|
||||
public <T> Entity get(String field, T value) throws SQLException {
|
||||
return this.get(Entity.create(tableName).set(field, value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件实体查询单个记录,当有多条返回时,只显示查询到的第一条
|
||||
*
|
||||
*
|
||||
* @param where 条件
|
||||
* @return 记录
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -241,11 +241,11 @@ public class DaoTemplate {
|
||||
return db.get(fixEntity(where));
|
||||
}
|
||||
//------------------------------------------------------------- Get end
|
||||
|
||||
|
||||
//------------------------------------------------------------- Find start
|
||||
/**
|
||||
* 根据某个字段值查询结果
|
||||
*
|
||||
*
|
||||
* @param <T> 字段值类型
|
||||
* @param field 字段名
|
||||
* @param value 字段值
|
||||
@ -255,7 +255,7 @@ public class DaoTemplate {
|
||||
public <T> List<Entity> find(String field, T value) throws SQLException {
|
||||
return this.find(Entity.create(tableName).set(field, value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询当前表的所有记录
|
||||
* @return 记录
|
||||
@ -264,10 +264,10 @@ public class DaoTemplate {
|
||||
public List<Entity> findAll() throws SQLException {
|
||||
return this.find(Entity.create(tableName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据某个字段值查询结果
|
||||
*
|
||||
*
|
||||
* @param where 查询条件
|
||||
* @return 记录
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -275,12 +275,12 @@ public class DaoTemplate {
|
||||
public List<Entity> find(Entity where) throws SQLException {
|
||||
return db.find(null, fixEntity(where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据SQL语句查询结果<br>
|
||||
* SQL语句可以是非完整SQL语句,可以只提供查询的条件部分(例如WHERE部分)<br>
|
||||
* 此方法会自动补全SELECT * FROM [tableName] 部分,这样就无需关心表名,直接提供条件即可
|
||||
*
|
||||
*
|
||||
* @param sql SQL语句
|
||||
* @param params SQL占位符中对应的参数
|
||||
* @return 记录
|
||||
@ -293,10 +293,10 @@ public class DaoTemplate {
|
||||
}
|
||||
return db.query(sql, params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
*
|
||||
* @param where 条件
|
||||
* @param page 分页对象
|
||||
* @param selectFields 查询的字段列表
|
||||
@ -306,10 +306,10 @@ public class DaoTemplate {
|
||||
public PageResult<Entity> page(Entity where, Page page, String... selectFields) throws SQLException{
|
||||
return db.page(Arrays.asList(selectFields), fixEntity(where), page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
*
|
||||
* @param where 条件
|
||||
* @param page 分页对象
|
||||
* @return 分页结果集
|
||||
@ -318,10 +318,10 @@ public class DaoTemplate {
|
||||
public PageResult<Entity> page(Entity where, Page page) throws SQLException{
|
||||
return db.page(fixEntity(where), page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 满足条件的数据条目数量
|
||||
*
|
||||
*
|
||||
* @param where 条件
|
||||
* @return 数量
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -329,10 +329,10 @@ public class DaoTemplate {
|
||||
public long count(Entity where) throws SQLException{
|
||||
return db.count(fixEntity(where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 指定条件的数据是否存在
|
||||
*
|
||||
*
|
||||
* @param where 条件
|
||||
* @return 是否存在
|
||||
* @throws SQLException SQL执行异常
|
||||
@ -341,7 +341,7 @@ public class DaoTemplate {
|
||||
return this.count(where) > 0;
|
||||
}
|
||||
//------------------------------------------------------------- Find end
|
||||
|
||||
|
||||
/**
|
||||
* 修正Entity对象,避免null和填充表名
|
||||
* @param entity 实体类
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.dialect.Dialect;
|
||||
@ -99,7 +99,7 @@ public class DialectRunner implements Serializable {
|
||||
*/
|
||||
public <T> T insert(Connection conn, Entity record, RsHandler<T> generatedKeysHandler) throws SQLException {
|
||||
checkConn(conn);
|
||||
if (CollUtil.isEmpty(record)) {
|
||||
if (MapUtil.isEmpty(record)) {
|
||||
throw new SQLException("Empty entity provided!");
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class DialectRunner implements Serializable {
|
||||
*/
|
||||
public int del(Connection conn, Entity where) throws SQLException {
|
||||
checkConn(conn);
|
||||
if (CollUtil.isEmpty(where)) {
|
||||
if (MapUtil.isEmpty(where)) {
|
||||
//不允许做全表删除
|
||||
throw new SQLException("Empty entity provided!");
|
||||
}
|
||||
@ -153,10 +153,10 @@ public class DialectRunner implements Serializable {
|
||||
*/
|
||||
public int update(Connection conn, Entity record, Entity where) throws SQLException {
|
||||
checkConn(conn);
|
||||
if (CollUtil.isEmpty(record)) {
|
||||
if (MapUtil.isEmpty(record)) {
|
||||
throw new SQLException("Empty entity provided!");
|
||||
}
|
||||
if (CollUtil.isEmpty(where)) {
|
||||
if (MapUtil.isEmpty(where)) {
|
||||
//不允许做全表更新
|
||||
throw new SQLException("Empty where provided!");
|
||||
}
|
||||
|
@ -1,130 +0,0 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import cn.hutool.db.dialect.Dialect;
|
||||
import cn.hutool.db.dialect.DialectFactory;
|
||||
import cn.hutool.db.ds.DSFactory;
|
||||
import cn.hutool.db.sql.Wrapper;
|
||||
|
||||
/**
|
||||
* SQL执行类<br>
|
||||
* 通过给定的数据源执行给定SQL或者给定数据源和方言,执行相应的CRUD操作<br>
|
||||
* SqlRunner中每一个方法都会打开和关闭一个链接<br>
|
||||
* 此类为线程安全的对象,可以单例使用
|
||||
*
|
||||
* @author Luxiaolei
|
||||
* @deprecated 请使用{@link Db}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SqlRunner extends AbstractDb{
|
||||
private static final long serialVersionUID = 6626183393926198184L;
|
||||
|
||||
/**
|
||||
* 创建SqlRunner<br>
|
||||
* 使用默认数据源,自动探测数据库连接池
|
||||
* @return SqlRunner
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public static SqlRunner create() {
|
||||
return create(DSFactory.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建SqlRunner<br>
|
||||
* 使用默认数据源,自动探测数据库连接池
|
||||
*
|
||||
* @param group 数据源分组
|
||||
* @return SqlRunner
|
||||
* @since 4.0.11
|
||||
*/
|
||||
public static SqlRunner create(String group) {
|
||||
return create(DSFactory.get(group));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建SqlRunner<br>
|
||||
* 会根据数据源连接的元信息识别目标数据库类型,进而使用合适的数据源
|
||||
* @param ds 数据源
|
||||
* @return SqlRunner
|
||||
*/
|
||||
public static SqlRunner create(DataSource ds) {
|
||||
return ds == null ? null : new SqlRunner(ds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建SqlRunner
|
||||
* @param ds 数据源
|
||||
* @param dialect 方言
|
||||
* @return SqlRunner
|
||||
*/
|
||||
public static SqlRunner create(DataSource ds, Dialect dialect) {
|
||||
return new SqlRunner(ds, dialect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建SqlRunner
|
||||
* @param ds 数据源
|
||||
* @param driverClassName 数据库连接驱动类名
|
||||
* @return SqlRunner
|
||||
*/
|
||||
public static SqlRunner create(DataSource ds, String driverClassName) {
|
||||
return new SqlRunner(ds, DialectFactory.newDialect(driverClassName));
|
||||
}
|
||||
|
||||
//------------------------------------------------------- Constructor start
|
||||
/**
|
||||
* 构造,从DataSource中识别方言
|
||||
* @param ds 数据源
|
||||
*/
|
||||
public SqlRunner(DataSource ds) {
|
||||
this(ds, DialectFactory.getDialect(ds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param ds 数据源
|
||||
* @param driverClassName 数据库连接驱动类名,用于识别方言
|
||||
*/
|
||||
public SqlRunner(DataSource ds, String driverClassName) {
|
||||
this(ds, DialectFactory.newDialect(driverClassName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param ds 数据源
|
||||
* @param dialect 方言
|
||||
*/
|
||||
public SqlRunner(DataSource ds, Dialect dialect) {
|
||||
super(ds, dialect);
|
||||
}
|
||||
//------------------------------------------------------- Constructor end
|
||||
|
||||
//---------------------------------------------------------------------------- Getters and Setters start
|
||||
@Override
|
||||
public SqlRunner setWrapper(Character wrapperChar) {
|
||||
return (SqlRunner) super.setWrapper(wrapperChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlRunner setWrapper(Wrapper wrapper) {
|
||||
return (SqlRunner) super.setWrapper(wrapper);
|
||||
}
|
||||
//---------------------------------------------------------------------------- Getters and Setters end
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException{
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection(Connection conn) {
|
||||
DbUtil.close(conn);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------- Private method start
|
||||
//---------------------------------------------------------------------------- Private method end
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package cn.hutool.db.ds;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.resource.NoResourceException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.DbRuntimeException;
|
||||
import cn.hutool.db.DbUtil;
|
||||
@ -18,13 +18,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 抽象数据源工厂<br>
|
||||
* 此工厂抽象类用于实现数据源的缓存,当用户多次调用{@link #getDataSource(String)} 时,工厂只需创建一次即可。<br>
|
||||
* 数据源是与配置文件中的分组相关的,每个分组的数据源相互独立,也就是每个分组的数据源是单例存在的。
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDSFactory extends DSFactory {
|
||||
private static final long serialVersionUID = -6407302276272379881L;
|
||||
|
||||
|
||||
/** 数据库配置文件可选路径1 */
|
||||
private static final String DEFAULT_DB_SETTING_PATH = "config/db.setting";
|
||||
/** 数据库配置文件可选路径2 */
|
||||
@ -37,7 +37,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param dataSourceName 数据源名称
|
||||
* @param dataSourceClass 数据库连接池实现类,用于检测所提供的DataSource类是否存在,当传入的DataSource类不存在时抛出ClassNotFoundException<br>
|
||||
* 此参数的作用是在detectDSFactory方法自动检测所用连接池时,如果实现类不存在,调用此方法会自动抛出异常,从而切换到下一种连接池的检测。
|
||||
@ -69,7 +69,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
|
||||
/**
|
||||
* 获取配置,用于自定义添加配置项
|
||||
*
|
||||
*
|
||||
* @return Setting
|
||||
* @since 4.0.3
|
||||
*/
|
||||
@ -97,7 +97,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
|
||||
/**
|
||||
* 创建数据源
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return {@link DataSourceWrapper} 数据源包装
|
||||
*/
|
||||
@ -107,7 +107,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
}
|
||||
|
||||
final Setting config = setting.getSetting(group);
|
||||
if (CollectionUtil.isEmpty(config)) {
|
||||
if (MapUtil.isEmpty(config)) {
|
||||
throw new DbRuntimeException("No config for group: [{}]", group);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
|
||||
/**
|
||||
* 创建新的{@link DataSource}<br>
|
||||
*
|
||||
*
|
||||
* @param jdbcUrl JDBC连接字符串
|
||||
* @param driver 数据库驱动类名
|
||||
* @param user 用户名
|
||||
@ -154,7 +154,7 @@ public abstract class AbstractDSFactory extends DSFactory {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (CollectionUtil.isNotEmpty(dsMap)) {
|
||||
if (MapUtil.isNotEmpty(dsMap)) {
|
||||
Collection<DataSourceWrapper> values = dsMap.values();
|
||||
for (DataSourceWrapper ds : values) {
|
||||
ds.close();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.hutool.db.ds.pooled;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.DbRuntimeException;
|
||||
import cn.hutool.db.dialect.DriverUtil;
|
||||
@ -9,7 +9,7 @@ import cn.hutool.setting.Setting;
|
||||
|
||||
/**
|
||||
* 数据库配置文件类,此类对应一个数据库配置文件
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@ -28,7 +28,7 @@ public class DbSetting {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param setting 数据库配置
|
||||
*/
|
||||
public DbSetting(Setting setting) {
|
||||
@ -41,13 +41,13 @@ public class DbSetting {
|
||||
|
||||
/**
|
||||
* 获得数据库连接信息
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return 分组
|
||||
*/
|
||||
public DbConfig getDbConfig(String group) {
|
||||
final Setting config = setting.getSetting(group);
|
||||
if (CollectionUtil.isEmpty(config)) {
|
||||
if (MapUtil.isEmpty(config)) {
|
||||
throw new DbRuntimeException("No Hutool pool config for group: [{}]", group);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.hutool.db.ds.simple;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.DbRuntimeException;
|
||||
@ -16,7 +15,7 @@ import java.util.Properties;
|
||||
|
||||
/***
|
||||
* 简易数据源,没有使用连接池,仅供测试或打开关闭连接非常少的场合使用!
|
||||
*
|
||||
*
|
||||
* @author loolly
|
||||
*
|
||||
*/
|
||||
@ -37,7 +36,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 获得一个数据源
|
||||
*
|
||||
*
|
||||
* @param group 数据源分组
|
||||
* @return {@link SimpleDataSource}
|
||||
*/
|
||||
@ -47,7 +46,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 获得一个数据源,无分组
|
||||
*
|
||||
*
|
||||
* @return {@link SimpleDataSource}
|
||||
*/
|
||||
synchronized public static SimpleDataSource getDataSource() {
|
||||
@ -64,7 +63,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param group 数据库配置文件中的分组
|
||||
*/
|
||||
public SimpleDataSource(String group) {
|
||||
@ -73,7 +72,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param setting 数据库配置
|
||||
* @param group 数据库配置文件中的分组
|
||||
*/
|
||||
@ -82,7 +81,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
setting = new Setting(DEFAULT_DB_CONFIG_PATH);
|
||||
}
|
||||
final Setting config = setting.getSetting(group);
|
||||
if (CollectionUtil.isEmpty(config)) {
|
||||
if (MapUtil.isEmpty(config)) {
|
||||
throw new DbRuntimeException("No DataSource config for group: [{}]", group);
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param url jdbc url
|
||||
* @param user 用户名
|
||||
* @param pass 密码
|
||||
@ -110,7 +109,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param url jdbc url
|
||||
* @param user 用户名
|
||||
* @param pass 密码
|
||||
@ -124,7 +123,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
*
|
||||
* @param url jdbc url
|
||||
* @param user 用户名
|
||||
* @param pass 密码
|
||||
@ -135,7 +134,7 @@ public class SimpleDataSource extends AbstractDataSource {
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
*
|
||||
* @param url jdbc url
|
||||
* @param user 用户名
|
||||
* @param pass 密码
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.hutool.db.nosql.mongo;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
@ -15,10 +15,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*
|
||||
*/
|
||||
public class MongoFactory {
|
||||
|
||||
|
||||
/** 各分组做组合key的时候分隔符 */
|
||||
private final static String GROUP_SEPRATER = ",";
|
||||
|
||||
|
||||
/** 数据源池 */
|
||||
private static final Map<String, MongoDS> DS_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@ -30,7 +30,7 @@ public class MongoFactory {
|
||||
// ------------------------------------------------------------------------ Get DS start
|
||||
/**
|
||||
* 获取MongoDB数据源<br>
|
||||
*
|
||||
*
|
||||
* @param host 主机
|
||||
* @param port 端口
|
||||
* @return MongoDB连接
|
||||
@ -50,7 +50,7 @@ public class MongoFactory {
|
||||
/**
|
||||
* 获取MongoDB数据源<br>
|
||||
* 多个分组名对应的连接组成集群
|
||||
*
|
||||
*
|
||||
* @param groups 分组列表
|
||||
* @return MongoDB连接
|
||||
*/
|
||||
@ -68,7 +68,7 @@ public class MongoFactory {
|
||||
|
||||
/**
|
||||
* 获取MongoDB数据源<br>
|
||||
*
|
||||
*
|
||||
* @param groups 分组列表
|
||||
* @return MongoDB连接
|
||||
*/
|
||||
@ -78,7 +78,7 @@ public class MongoFactory {
|
||||
|
||||
/**
|
||||
* 获取MongoDB数据源<br>
|
||||
*
|
||||
*
|
||||
* @param setting 设定文件
|
||||
* @param groups 分组列表
|
||||
* @return MongoDB连接
|
||||
@ -97,7 +97,7 @@ public class MongoFactory {
|
||||
|
||||
/**
|
||||
* 获取MongoDB数据源<br>
|
||||
*
|
||||
*
|
||||
* @param setting 配置文件
|
||||
* @param groups 分组列表
|
||||
* @return MongoDB连接
|
||||
@ -106,12 +106,12 @@ public class MongoFactory {
|
||||
return getDS(setting, groups.toArray(new String[0]));
|
||||
}
|
||||
// ------------------------------------------------------------------------ Get DS ends
|
||||
|
||||
|
||||
/**
|
||||
* 关闭全部连接
|
||||
*/
|
||||
public static void closeAll() {
|
||||
if(CollectionUtil.isNotEmpty(DS_MAP)){
|
||||
if(MapUtil.isNotEmpty(DS_MAP)){
|
||||
for(MongoDS ds : DS_MAP.values()) {
|
||||
ds.close();
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package cn.hutool.db.sql;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.Entity;
|
||||
|
||||
@ -18,15 +18,15 @@ import java.util.Map.Entry;
|
||||
*
|
||||
*/
|
||||
public class Wrapper {
|
||||
|
||||
|
||||
/** 前置包装符号 */
|
||||
private Character preWrapQuote;
|
||||
/** 后置包装符号 */
|
||||
private Character sufWrapQuote;
|
||||
|
||||
|
||||
public Wrapper() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造
|
||||
* @param wrapQuote 单包装字符
|
||||
@ -35,7 +35,7 @@ public class Wrapper {
|
||||
this.preWrapQuote = wrapQuote;
|
||||
this.sufWrapQuote = wrapQuote;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 包装符号
|
||||
* @param preWrapQuote 前置包装符号
|
||||
@ -45,7 +45,7 @@ public class Wrapper {
|
||||
this.preWrapQuote = preWrapQuote;
|
||||
this.sufWrapQuote = sufWrapQuote;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------- Getters and Setters start
|
||||
/**
|
||||
* @return 前置包装符号
|
||||
@ -60,7 +60,7 @@ public class Wrapper {
|
||||
public void setPreWrapQuote(Character preWrapQuote) {
|
||||
this.preWrapQuote = preWrapQuote;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 后置包装符号
|
||||
*/
|
||||
@ -75,7 +75,7 @@ public class Wrapper {
|
||||
this.sufWrapQuote = sufWrapQuote;
|
||||
}
|
||||
//--------------------------------------------------------------- Getters and Setters end
|
||||
|
||||
|
||||
/**
|
||||
* 包装字段名<br>
|
||||
* 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突
|
||||
@ -86,26 +86,26 @@ public class Wrapper {
|
||||
if(preWrapQuote == null || sufWrapQuote == null || StrUtil.isBlank(field)) {
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
//如果已经包含包装的引号,返回原字符
|
||||
if(StrUtil.isSurround(field, preWrapQuote, sufWrapQuote)){
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
//如果字段中包含通配符或者括号(字段通配符或者函数),不做包装
|
||||
if(StrUtil.containsAnyIgnoreCase(field, "*", "(", " ", " as ")) {
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
//对于Oracle这类数据库,表名中包含用户名需要单独拆分包装
|
||||
if(field.contains(StrUtil.DOT)){
|
||||
final Collection<String> target = CollUtil.filter(StrUtil.split(field, StrUtil.C_DOT, 2), (Editor<String>) t -> StrUtil.format("{}{}{}", preWrapQuote, t, sufWrapQuote));
|
||||
final Collection<String> target = CollUtil.edit(StrUtil.split(field, CharUtil.DOT, 2), t -> StrUtil.format("{}{}{}", preWrapQuote, t, sufWrapQuote));
|
||||
return CollectionUtil.join(target, StrUtil.DOT);
|
||||
}
|
||||
|
||||
|
||||
return StrUtil.format("{}{}{}", preWrapQuote, field, sufWrapQuote);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 包装字段名<br>
|
||||
* 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突
|
||||
@ -116,15 +116,15 @@ public class Wrapper {
|
||||
if(ArrayUtil.isEmpty(fields)) {
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
String[] wrappedFields = new String[fields.length];
|
||||
for(int i = 0; i < fields.length; i++) {
|
||||
wrappedFields[i] = wrap(fields[i]);
|
||||
}
|
||||
|
||||
|
||||
return wrappedFields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 包装字段名<br>
|
||||
* 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突
|
||||
@ -135,10 +135,10 @@ public class Wrapper {
|
||||
if(CollectionUtil.isEmpty(fields)) {
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
return Arrays.asList(wrap(fields.toArray(new String[0])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 包装字段名<br>
|
||||
* 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突
|
||||
@ -149,20 +149,20 @@ public class Wrapper {
|
||||
if(null == entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final Entity wrapedEntity = new Entity();
|
||||
|
||||
|
||||
//wrap table name
|
||||
wrapedEntity.setTableName(wrap(entity.getTableName()));
|
||||
|
||||
|
||||
//wrap fields
|
||||
for (Entry<String, Object> entry : entity.entrySet()) {
|
||||
wrapedEntity.set(wrap(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
return wrapedEntity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 包装字段名<br>
|
||||
* 有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突
|
||||
@ -179,7 +179,7 @@ public class Wrapper {
|
||||
clonedConditions[i] = clonedCondition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return clonedConditions;
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,19 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SqlBuilderTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void queryNullTest() {
|
||||
SqlBuilder builder = SqlBuilder.create().select().from("user").where(new Condition("name", "= null"));
|
||||
Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder.build());
|
||||
|
||||
|
||||
SqlBuilder builder2 = SqlBuilder.create().select().from("user").where(new Condition("name", "is null"));
|
||||
Assert.assertEquals("SELECT * FROM user WHERE name IS NULL", builder2.build());
|
||||
|
||||
SqlBuilder builder3 = SqlBuilder.create().select().from("user").where(LogicalOperator.AND, new Condition("name", "!= null"));
|
||||
|
||||
SqlBuilder builder3 = SqlBuilder.create().select().from("user").where(new Condition("name", "!= null"));
|
||||
Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder3.build());
|
||||
|
||||
SqlBuilder builder4 = SqlBuilder.create().select().from("user").where(LogicalOperator.AND, new Condition("name", "is not null"));
|
||||
|
||||
SqlBuilder builder4 = SqlBuilder.create().select().from("user").where(new Condition("name", "is not null"));
|
||||
Assert.assertEquals("SELECT * FROM user WHERE name IS NOT NULL", builder4.build());
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package cn.hutool.extra.pinyin;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拼音引擎接口,具体的拼音实现通过实现此接口,完成具体实现功能
|
||||
*
|
||||
@ -47,7 +49,7 @@ public interface PinyinEngine {
|
||||
*/
|
||||
default String getFirstLetter(String str, String separator) {
|
||||
final String splitSeparator = StrUtil.isEmpty(separator) ? "#" : separator;
|
||||
final String[] split = StrUtil.split(getPinyin(str, splitSeparator), splitSeparator);
|
||||
return ArrayUtil.join(split, separator, (s)->String.valueOf(s.length() > 0 ? s.charAt(0) : ""));
|
||||
final List<String> split = StrUtil.split(getPinyin(str, splitSeparator), splitSeparator);
|
||||
return CollUtil.join(split, separator, (s)->String.valueOf(s.length() > 0 ? s.charAt(0) : StrUtil.EMPTY));
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +570,8 @@ public class ServletUtil {
|
||||
*/
|
||||
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
|
||||
final String charset = ObjectUtil.defaultIfNull(response.getCharacterEncoding(), CharsetUtil.UTF_8);
|
||||
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename={}", URLUtil.encode(fileName, charset)));
|
||||
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename={}",
|
||||
URLUtil.encode(fileName, CharsetUtil.charset(charset))));
|
||||
response.setContentType(contentType);
|
||||
write(response, in);
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package cn.hutool.extra.template;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import org.beetl.core.Configuration;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
import org.beetl.core.Template;
|
||||
import org.beetl.core.resource.StringTemplateResourceLoader;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* BeetlUtil单元测试
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BeetlUtilTest {
|
||||
|
||||
@Test
|
||||
public void renderStrTest() throws IOException {
|
||||
GroupTemplate groupTemplate = BeetlUtil.createGroupTemplate(new StringTemplateResourceLoader(), Configuration.defaultConfiguration());
|
||||
Template template = BeetlUtil.getTemplate(groupTemplate, "hello,${name}");
|
||||
String result = BeetlUtil.render(template, Dict.create().set("name", "hutool"));
|
||||
|
||||
Assert.assertEquals("hello,hutool", result);
|
||||
|
||||
String renderFromStr = BeetlUtil.renderFromStr("hello,${name}", Dict.create().set("name", "hutool"));
|
||||
Assert.assertEquals("hello,hutool", renderFromStr);
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -7,13 +11,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 全局头部信息<br>
|
||||
* 所有Http请求将共用此全局头部信息,除非在{@link HttpRequest}中自定义头部信息覆盖之
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
@ -32,7 +33,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 加入默认的头部信息
|
||||
*
|
||||
*
|
||||
* @param isReset 是否重置所有头部信息(删除自定义保留默认)
|
||||
* @return this
|
||||
*/
|
||||
@ -40,7 +41,7 @@ public enum GlobalHeaders {
|
||||
// 解决HttpURLConnection中无法自定义Host等头信息的问题
|
||||
// https://stackoverflow.com/questions/9096987/how-to-overwrite-http-header-host-in-a-httpurlconnection/9098440
|
||||
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
|
||||
|
||||
|
||||
if (isReset) {
|
||||
this.headers.clear();
|
||||
}
|
||||
@ -57,7 +58,7 @@ public enum GlobalHeaders {
|
||||
// ---------------------------------------------------------------- Headers start
|
||||
/**
|
||||
* 根据name获取头信息
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @return Header值
|
||||
*/
|
||||
@ -71,7 +72,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 根据name获取头信息列表
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @return Header值
|
||||
* @since 3.1.1
|
||||
@ -86,7 +87,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 根据name获取头信息
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @return Header值
|
||||
*/
|
||||
@ -100,7 +101,7 @@ public enum GlobalHeaders {
|
||||
/**
|
||||
* 设置一个header<br>
|
||||
* 如果覆盖模式,则替换之前的值,否则加入到值列表中
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @param value Header值
|
||||
* @param isOverride 是否覆盖已有值
|
||||
@ -123,7 +124,7 @@ public enum GlobalHeaders {
|
||||
/**
|
||||
* 设置一个header<br>
|
||||
* 如果覆盖模式,则替换之前的值,否则加入到值列表中
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @param value Header值
|
||||
* @param isOverride 是否覆盖已有值
|
||||
@ -136,7 +137,7 @@ public enum GlobalHeaders {
|
||||
/**
|
||||
* 设置一个header<br>
|
||||
* 覆盖模式,则替换之前的值
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @param value Header值
|
||||
* @return this
|
||||
@ -148,7 +149,7 @@ public enum GlobalHeaders {
|
||||
/**
|
||||
* 设置一个header<br>
|
||||
* 覆盖模式,则替换之前的值
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @param value Header值
|
||||
* @return this
|
||||
@ -160,12 +161,12 @@ public enum GlobalHeaders {
|
||||
/**
|
||||
* 设置请求头<br>
|
||||
* 不覆盖原有请求头
|
||||
*
|
||||
*
|
||||
* @param headers 请求头
|
||||
* @return this
|
||||
*/
|
||||
public GlobalHeaders header(Map<String, List<String>> headers) {
|
||||
if (CollectionUtil.isEmpty(headers)) {
|
||||
if (MapUtil.isEmpty(headers)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -181,7 +182,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 移除一个头信息
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @return this
|
||||
*/
|
||||
@ -194,7 +195,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 移除一个头信息
|
||||
*
|
||||
*
|
||||
* @param name Header名
|
||||
* @return this
|
||||
*/
|
||||
@ -204,7 +205,7 @@ public enum GlobalHeaders {
|
||||
|
||||
/**
|
||||
* 获取headers
|
||||
*
|
||||
*
|
||||
* @return Headers Map
|
||||
*/
|
||||
public Map<String, List<String>> headers() {
|
||||
|
@ -3,6 +3,7 @@ package cn.hutool.http;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
@ -144,7 +145,7 @@ public abstract class HttpBase<T> {
|
||||
* @since 4.6.3
|
||||
*/
|
||||
public T headerMap(Map<String, String> headers, boolean isOverride) {
|
||||
if(CollectionUtil.isEmpty(headers)) {
|
||||
if(MapUtil.isEmpty(headers)) {
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
@ -174,7 +175,7 @@ public abstract class HttpBase<T> {
|
||||
* @since 4.0.8
|
||||
*/
|
||||
public T header(Map<String, List<String>> headers, boolean isOverride) {
|
||||
if(CollectionUtil.isEmpty(headers)) {
|
||||
if(MapUtil.isEmpty(headers)) {
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
@ -197,7 +198,7 @@ public abstract class HttpBase<T> {
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public T addHeaders(Map<String, String> headers) {
|
||||
if(CollectionUtil.isEmpty(headers)) {
|
||||
if(MapUtil.isEmpty(headers)) {
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class JSONUtilTest {
|
||||
a2.setName("AAAA222Name");
|
||||
|
||||
ArrayList<UserA> list = CollectionUtil.newArrayList(a1, a2);
|
||||
HashMap<String, Object> map = CollectionUtil.newHashMap();
|
||||
HashMap<String, Object> map = MapUtil.newHashMap();
|
||||
map.put("total", 13);
|
||||
map.put("rows", list);
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class TransientTest {
|
||||
detailBill.setBizNo("bizNo");
|
||||
|
||||
final JSONObject jsonObject = new JSONObject(detailBill,
|
||||
JSONConfig.create().setIgnoreTransient(true));
|
||||
JSONConfig.create().setTransientSupport(false));
|
||||
Assert.assertEquals("{\"bizNo\":\"bizNo\"}", jsonObject.toString());
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.bean.copier.ValueProvider;
|
||||
@ -14,6 +11,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Setting抽象类
|
||||
*
|
||||
@ -156,7 +156,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
return StrUtil.split(value, delimiter);
|
||||
return StrUtil.splitToArray(value, delimiter);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- Get int
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.hutool.setting.dialect;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.getter.BasicTypeGetter;
|
||||
import cn.hutool.core.getter.OptBasicTypeGetter;
|
||||
@ -17,6 +16,7 @@ import cn.hutool.core.io.watch.SimpleWatcher;
|
||||
import cn.hutool.core.io.watch.WatchMonitor;
|
||||
import cn.hutool.core.io.watch.WatchUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -39,7 +39,7 @@ import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Properties文件读取封装类
|
||||
*
|
||||
*
|
||||
* @author loolly
|
||||
*/
|
||||
public final class Props extends Properties implements BasicTypeGetter<String>, OptBasicTypeGetter<String> {
|
||||
@ -70,7 +70,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 获得Classpath下的Properties文件
|
||||
*
|
||||
*
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @return Props
|
||||
*/
|
||||
@ -80,7 +80,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 获得Classpath下的Properties文件
|
||||
*
|
||||
*
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @param charsetName 字符集
|
||||
* @return Properties
|
||||
@ -91,7 +91,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 获得Classpath下的Properties文件
|
||||
*
|
||||
*
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @param charset 字符集
|
||||
* @return Properties
|
||||
@ -109,7 +109,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用相对于Class文件根目录的相对路径
|
||||
*
|
||||
*
|
||||
* @param path 配置文件路径,相对于ClassPath,或者使用绝对路径
|
||||
*/
|
||||
public Props(String path) {
|
||||
@ -118,7 +118,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用相对于Class文件根目录的相对路径
|
||||
*
|
||||
*
|
||||
* @param path 相对或绝对路径
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
@ -128,7 +128,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用相对于Class文件根目录的相对路径
|
||||
*
|
||||
*
|
||||
* @param path 相对或绝对路径
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@ -142,7 +142,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param propertiesFile 配置文件对象
|
||||
*/
|
||||
public Props(File propertiesFile) {
|
||||
@ -151,7 +151,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param propertiesFile 配置文件对象
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
@ -161,7 +161,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param propertiesFile 配置文件对象
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@ -173,7 +173,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,相对于classes读取文件
|
||||
*
|
||||
*
|
||||
* @param path 相对路径
|
||||
* @param clazz 基准类
|
||||
*/
|
||||
@ -183,7 +183,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,相对于classes读取文件
|
||||
*
|
||||
*
|
||||
* @param path 相对路径
|
||||
* @param clazz 基准类
|
||||
* @param charsetName 字符集
|
||||
@ -194,7 +194,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,相对于classes读取文件
|
||||
*
|
||||
*
|
||||
* @param path 相对路径
|
||||
* @param clazz 基准类
|
||||
* @param charset 字符集
|
||||
@ -209,7 +209,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用URL读取
|
||||
*
|
||||
*
|
||||
* @param propertiesUrl 属性文件路径
|
||||
*/
|
||||
public Props(URL propertiesUrl) {
|
||||
@ -218,7 +218,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用URL读取
|
||||
*
|
||||
*
|
||||
* @param propertiesUrl 属性文件路径
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
@ -228,7 +228,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用URL读取
|
||||
*
|
||||
*
|
||||
* @param propertiesUrl 属性文件路径
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@ -242,11 +242,11 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 构造,使用URL读取
|
||||
*
|
||||
*
|
||||
* @param properties 属性文件路径
|
||||
*/
|
||||
public Props(Properties properties) {
|
||||
if (CollectionUtil.isNotEmpty(properties)) {
|
||||
if (MapUtil.isNotEmpty(properties)) {
|
||||
this.putAll(properties);
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 初始化配置文件
|
||||
*
|
||||
*
|
||||
* @param resource {@link Resource}
|
||||
*/
|
||||
public void load(Resource resource) {
|
||||
@ -290,7 +290,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 在配置文件变更时自动加载
|
||||
*
|
||||
*
|
||||
* @param autoReload 是否自动加载
|
||||
*/
|
||||
public void autoLoad(boolean autoReload) {
|
||||
@ -478,7 +478,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 获取并删除键值对,当指定键对应值非空时,返回并删除这个值,后边的键对应的值不再查找
|
||||
*
|
||||
*
|
||||
* @param keys 键列表,常用于别名
|
||||
* @return 字符串值
|
||||
* @since 4.1.21
|
||||
@ -493,11 +493,11 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
}
|
||||
return (String) value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将配置文件转换为Bean,支持嵌套Bean<br>
|
||||
* 支持的表达式:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* persion
|
||||
* persion.name
|
||||
@ -518,7 +518,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
/**
|
||||
* 将配置文件转换为Bean,支持嵌套Bean<br>
|
||||
* 支持的表达式:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* persion
|
||||
* persion.name
|
||||
@ -537,11 +537,11 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
final T bean = ReflectUtil.newInstanceIfPossible(beanClass);
|
||||
return fillBean(bean, prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将配置文件转换为Bean,支持嵌套Bean<br>
|
||||
* 支持的表达式:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* persion
|
||||
* persion.name
|
||||
@ -582,7 +582,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
// ----------------------------------------------------------------------- Set start
|
||||
/**
|
||||
* 设置值,无给定键创建之。设置后未持久化
|
||||
*
|
||||
*
|
||||
* @param key 属性键
|
||||
* @param value 属性值
|
||||
*/
|
||||
@ -592,7 +592,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 持久化当前设置,会覆盖掉之前的设置
|
||||
*
|
||||
*
|
||||
* @param absolutePath 设置文件的绝对路径
|
||||
* @throws IORuntimeException IO异常,可能为文件未找到
|
||||
*/
|
||||
@ -610,7 +610,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
/**
|
||||
* 存储当前设置,会覆盖掉以前的设置
|
||||
*
|
||||
*
|
||||
* @param path 相对路径
|
||||
* @param clazz 相对的类
|
||||
*/
|
||||
|
@ -47,9 +47,9 @@ public class SettingTest {
|
||||
public void settingTestForCustom() {
|
||||
Setting setting = new Setting();
|
||||
|
||||
setting.put("group1", "user", "root");
|
||||
setting.put("group2", "user", "root2");
|
||||
setting.put("group3", "user", "root3");
|
||||
setting.setByGroup("user", "group1", "root");
|
||||
setting.setByGroup("user", "group2", "root2");
|
||||
setting.setByGroup("user", "group3", "root3");
|
||||
setting.set("user", "root4");
|
||||
|
||||
Assert.assertEquals("root", setting.getByGroup("user", "group1"));
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.hutool.system;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 代表当前运行的JRE的信息。
|
||||
*/
|
||||
@ -29,7 +29,7 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* JVM is 32M <code>or</code> 64M
|
||||
*
|
||||
*
|
||||
* @return 32 <code>or</code> 64
|
||||
*/
|
||||
public final String getSunArchDataModel() {
|
||||
@ -38,13 +38,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的名称(取自系统属性:<code>java.runtime.name</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2: <code>"Java(TM) 2 Runtime Environment, Standard Edition"</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.3
|
||||
*/
|
||||
public final String getName() {
|
||||
@ -53,13 +53,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的版本(取自系统属性:<code>java.runtime.version</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"1.4.2-b28"</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.3
|
||||
*/
|
||||
public final String getVersion() {
|
||||
@ -68,13 +68,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的安装目录(取自系统属性:<code>java.home</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"/opt/jdk1.4.2/jre"</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.1
|
||||
*/
|
||||
public final String getHomeDir() {
|
||||
@ -83,13 +83,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的扩展目录列表(取自系统属性:<code>java.ext.dirs</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"/opt/jdk1.4.2/jre/lib/ext:..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.3
|
||||
*/
|
||||
public final String getExtDirs() {
|
||||
@ -98,13 +98,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的endorsed目录列表(取自系统属性:<code>java.endorsed.dirs</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"/opt/jdk1.4.2/jre/lib/endorsed:..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.4
|
||||
*/
|
||||
public final String getEndorsedDirs() {
|
||||
@ -113,13 +113,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的系统classpath(取自系统属性:<code>java.class.path</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如:<code>"/home/admin/myclasses:/home/admin/..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.1
|
||||
*/
|
||||
public final String getClassPath() {
|
||||
@ -128,28 +128,28 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的系统classpath(取自系统属性:<code>java.class.path</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如:<code>"/home/admin/myclasses:/home/admin/..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.1
|
||||
*/
|
||||
public final String[] getClassPathArray() {
|
||||
return StrUtil.split(getClassPath(), SystemUtil.get("path.separator", false));
|
||||
return StrUtil.splitToArray(getClassPath(), SystemUtil.get("path.separator", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得当前JRE的class文件格式的版本(取自系统属性:<code>java.class.version</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"48.0"</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
* @since Java 1.1
|
||||
*/
|
||||
public final String getClassVersion() {
|
||||
@ -158,13 +158,13 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的library搜索路径(取自系统属性:<code>java.library.path</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"/opt/jdk1.4.2/bin:..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final String getLibraryPath() {
|
||||
return JAVA_LIBRARY_PATH;
|
||||
@ -172,29 +172,29 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 取得当前JRE的library搜索路径(取自系统属性:<code>java.library.path</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"/opt/jdk1.4.2/bin:..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final String[] getLibraryPathArray() {
|
||||
return StrUtil.split(getLibraryPath(), SystemUtil.get("path.separator", false));
|
||||
return StrUtil.splitToArray(getLibraryPath(), SystemUtil.get("path.separator", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得当前JRE的URL协议packages列表(取自系统属性:<code>java.library.path</code>)。
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 例如Sun JDK 1.4.2:<code>"sun.net.www.protocol|..."</code>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回<code>null</code>。
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final String getProtocolPackages() {
|
||||
return SystemUtil.get("java.protocol.handler.pkgs", true);
|
||||
@ -202,7 +202,7 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 将当前运行的JRE信息转换成字符串。
|
||||
*
|
||||
*
|
||||
* @return JRE信息的字符串表示
|
||||
*/
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user