This commit is contained in:
Looly 2022-04-16 12:05:50 +08:00
parent 6acf0854d8
commit 08da23b3d4
4 changed files with 19 additions and 10 deletions

View File

@ -17,6 +17,7 @@ public enum GlobalInterceptor {
* 设置拦截器用于在请求前重新编辑请求
*
* @param interceptor 拦截器实现
* @return this
*/
synchronized public GlobalInterceptor addRequestInterceptor(HttpInterceptor<HttpRequest> interceptor) {
this.requestInterceptors.addChain(interceptor);
@ -27,6 +28,7 @@ public enum GlobalInterceptor {
* 设置拦截器用于在响应读取后完成编辑或读取
*
* @param interceptor 拦截器实现
* @return this
*/
synchronized public GlobalInterceptor addResponseInterceptor(HttpInterceptor<HttpResponse> interceptor) {
this.responseInterceptors.addChain(interceptor);

View File

@ -244,6 +244,7 @@ public class HttpConfig {
* 如果服务端未遵循这个规范或响应没有正常结束会报EOF异常此选项用于是否忽略这个异常
*
* @param ignoreEOFError 是否忽略响应读取时可能的EOF异常
* @return this
* @since 5.7.20
*/
public HttpConfig setIgnoreEOFError(boolean ignoreEOFError) {
@ -257,6 +258,7 @@ public class HttpConfig {
* 按照RFC3986规范在发送请求时全部编码之如果为{@code false}则不会解码已经编码的内容在请求时只编码需要编码的部分
*
* @param decodeUrl 是否忽略解码URL
* @return this
*/
public HttpConfig setDecodeUrl(boolean decodeUrl) {
this.decodeUrl = decodeUrl;
@ -267,6 +269,7 @@ public class HttpConfig {
* 设置拦截器用于在请求前重新编辑请求
*
* @param interceptor 拦截器实现
* @return this
*/
public HttpConfig addRequestInterceptor(HttpInterceptor<HttpRequest> interceptor) {
this.requestInterceptors.addChain(interceptor);

View File

@ -369,9 +369,10 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
/**
* 设置键值对到JSONObject中在忽略null模式下如果值为{@code null}将此键移除
*
* @param key
* @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对键值对的过滤和修改操作{@code null}表示不过滤
* @param key
* @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对键值对的过滤和修改操作{@code null}表示不过滤
* @param checkDuplicate 是否检查重复键如果为{@code true}则出现重复键时抛出{@link JSONException}异常
* @return this.
* @throws JSONException 值是无穷数字抛出此异常
* @since 5.8.0
@ -388,7 +389,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
// 使用修改后的键值对
key = pair.getKey();
value = pair.getValue();
}else{
} else {
// 键值对被过滤
return this;
}
@ -399,7 +400,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
// 忽略值模式下如果值为空清除key
this.remove(key);
} else {
if(checkDuplicate && containsKey(key)){
if (checkDuplicate && containsKey(key)) {
throw new JSONException("Duplicate key \"{}\"", key);
}
@ -423,9 +424,10 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
/**
* 一次性Put 键值对如果key已经存在抛出异常如果键值中有null值忽略
*
* @param key
* @param value 值对象可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
* @return this.
* @param key
* @param value 值对象可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对键值对的过滤和修改操作{@code null}表示不过滤
* @return this
* @throws JSONException 值是无穷数字键重复抛出异常
* @since 5.8.0
*/

View File

@ -34,11 +34,12 @@ public class JSONParser {
}
// region parseTo
/**
* 解析{@link JSONTokener}中的字符到目标的{@link JSONObject}
*
* @param jsonObject {@link JSONObject}
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对键值对的过滤和修改操作{@code null}表示不过滤
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对键值对的过滤和修改操作{@code null}表示不过滤
*/
public void parseTo(JSONObject jsonObject, Filter<MutablePair<String, Object>> filter) {
final JSONTokener tokener = this.tokener;
@ -91,7 +92,8 @@ public class JSONParser {
/**
* 解析JSON字符串到{@link JSONArray}
*
* @param jsonArray {@link JSONArray}
* @param jsonArray {@link JSONArray
* @param filter 键值对过滤编辑器可以通过实现此接口完成解析前对值的过滤和修改操作{@code null}表示不过滤
*/
public void parseTo(JSONArray jsonArray, Filter<Mutable<Object>> filter) {
final JSONTokener x = this.tokener;