change name

This commit is contained in:
Looly 2020-12-07 19:06:23 +08:00
parent 775afa68cc
commit ea070bf83e
7 changed files with 18 additions and 15 deletions

View File

@ -10,6 +10,8 @@
* 【core 】 multipart中int改为long解决大文件上传越界问题issue#I27WZ3@Gitee
* 【core 】 ListUtil.page增加检查pr#224@Gitee
* 【db 】 Db增加使用sql的page方法issue#247@Gitee
* 【cache 】 CacheObj的isExpired()逻辑修改issue#1295@Github
* 【json 】 JSONStrFormater改为JSONStrFormatter
### Bug修复
* 【cache 】 修复Cache中get重复misCount计数问题issue#1281@Github

View File

@ -44,9 +44,8 @@ public class CacheObj<K, V> implements Serializable{
*/
boolean isExpired() {
if(this.ttl > 0) {
final long expiredTime = this.lastAccess + this.ttl;
// expiredTime > 0 杜绝Long类型溢出变负数问题当当前时间超过过期时间表示过期
return expiredTime > 0 && expiredTime < System.currentTimeMillis();
// 此处不考虑时间回拨
return (System.currentTimeMillis() - this.lastAccess) > this.ttl;
}
return false;
}

View File

@ -115,7 +115,8 @@ public class JSONConfig implements Serializable {
}
/**
* 设置日期格式null表示默认的时间戳
* 设置日期格式null表示默认的时间戳<br>
* 此方法设置的日期格式仅对转换为JSON字符串有效对解析JSON为bean无效
*
* @param dateFormat 日期格式null表示默认的时间戳
* @return this

View File

@ -261,7 +261,8 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
}
/**
* 设置转为字符串时的日期格式默认为时间戳null值
* 设置转为字符串时的日期格式默认为时间戳null值<br>
* 此方法设置的日期格式仅对转换为JSON字符串有效对解析JSON为bean无效
*
* @param format 格式null表示使用时间戳
* @return this
@ -341,7 +342,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
}
/**
* PUT 键值对到JSONObject中在忽略null模式下如果值为<code>null</code>将此键移除
* PUT 键值对到JSONObject中在忽略null模式下如果值为{@code null}将此键移除
*
* @param key
* @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
@ -356,7 +357,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
}
/**
* 设置键值对到JSONObject中在忽略null模式下如果值为<code>null</code>将此键移除
* 设置键值对到JSONObject中在忽略null模式下如果值为{@code null}将此键移除
*
* @param key
* @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
@ -426,7 +427,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
* @param key
* @param value 被积累的值
* @return this.
* @throws JSONException 如果给定键为<code>null</code>或者键对应的值存在且为非JSONArray
* @throws JSONException 如果给定键为{@code null}或者键对应的值存在且为非JSONArray
*/
public JSONObject accumulate(String key, Object value) throws JSONException {
InternalJSONUtil.testValidity(value);
@ -447,7 +448,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
* @param key
* @param value
* @return this.
* @throws JSONException 如果给定键为<code>null</code>或者键对应的值存在且为非JSONArray
* @throws JSONException 如果给定键为{@code null}或者键对应的值存在且为非JSONArray
*/
public JSONObject append(String key, Object value) throws JSONException {
InternalJSONUtil.testValidity(value);
@ -545,7 +546,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
/**
* 返回JSON字符串<br>
* 如果解析错误返回<code>null</code>
* 如果解析错误返回{@code null}
*
* @return JSON字符串
*/

View File

@ -9,7 +9,7 @@ import cn.hutool.core.util.StrUtil;
* @author looly
* @since 3.1.2
*/
public class JSONStrFormater {
public class JSONStrFormatter {
/** 单位缩进字符串。*/
private static final String SPACE = " ";

View File

@ -776,7 +776,7 @@ public final class JSONUtil {
* @since 3.1.2
*/
public static String formatJsonStr(String jsonStr) {
return JSONStrFormater.format(jsonStr);
return JSONStrFormatter.format(jsonStr);
}
/**

View File

@ -13,21 +13,21 @@ public class JSONStrFormaterTest {
@Test
public void formatTest() {
String json = "{'age':23,'aihao':['pashan','movies'],'name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies','name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies']}]}}";
String result = JSONStrFormater.format(json);
String result = JSONStrFormatter.format(json);
Assert.assertNotNull(result);
}
@Test
public void formatTest2() {
String json = "{\"abc\":{\"def\":\"\\\"[ghi]\"}}";
String result = JSONStrFormater.format(json);
String result = JSONStrFormatter.format(json);
Assert.assertNotNull(result);
}
@Test
public void formatTest3() {
String json = "{\"id\":13,\"title\":\"《标题》\",\"subtitle\":\"副标题z'c'z'xv'c'xv\",\"user_id\":6,\"type\":0}";
String result = JSONStrFormater.format(json);
String result = JSONStrFormatter.format(json);
Assert.assertNotNull(result);
}
}