mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
规范部分代码
This commit is contained in:
@@ -28,10 +28,10 @@ import java.util.Random;
|
||||
*/
|
||||
public class WxCryptUtil {
|
||||
|
||||
private static final Base64 base64 = new Base64();
|
||||
private static final Base64 BASE64 = new Base64();
|
||||
private static final Charset CHARSET = StandardCharsets.UTF_8;
|
||||
|
||||
private static final ThreadLocal<DocumentBuilder> builderLocal = new ThreadLocal<DocumentBuilder>() {
|
||||
private static final ThreadLocal<DocumentBuilder> BUILDER_LOCAL = new ThreadLocal<DocumentBuilder>() {
|
||||
@Override
|
||||
protected DocumentBuilder initialValue() {
|
||||
try {
|
||||
@@ -65,7 +65,7 @@ public class WxCryptUtil {
|
||||
|
||||
static String extractEncryptPart(String xml) {
|
||||
try {
|
||||
DocumentBuilder db = builderLocal.get();
|
||||
DocumentBuilder db = BUILDER_LOCAL.get();
|
||||
Document document = db.parse(new InputSource(new StringReader(xml)));
|
||||
|
||||
Element root = document.getDocumentElement();
|
||||
@@ -192,7 +192,7 @@ public class WxCryptUtil {
|
||||
byte[] encrypted = cipher.doFinal(unencrypted);
|
||||
|
||||
// 使用BASE64对加密后的字符串进行编码
|
||||
return base64.encodeToString(encrypted);
|
||||
return BASE64.encodeToString(encrypted);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,16 @@ package me.chanjar.weixin.common.util.http;
|
||||
* Created by ecoolper on 2017/4/28.
|
||||
*/
|
||||
public enum HttpType {
|
||||
JODD_HTTP, APACHE_HTTP, OK_HTTP;
|
||||
/**
|
||||
* jodd-http.
|
||||
*/
|
||||
JODD_HTTP,
|
||||
/**
|
||||
* apache httpclient.
|
||||
*/
|
||||
APACHE_HTTP,
|
||||
/**
|
||||
* okhttp.
|
||||
*/
|
||||
OK_HTTP
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ import java.util.*;
|
||||
*/
|
||||
public class StringManager {
|
||||
|
||||
private static final Map<String, Map<Locale, StringManager>> managers =
|
||||
new Hashtable<>();
|
||||
private static final Map<String, Map<Locale, StringManager>> MANAGERS = new Hashtable<>();
|
||||
private static int LOCALE_CACHE_SIZE = 10;
|
||||
/**
|
||||
* The ResourceBundle for this StringManager.
|
||||
@@ -118,16 +117,16 @@ public class StringManager {
|
||||
public static final synchronized StringManager getManager(
|
||||
String packageName, Locale locale) {
|
||||
|
||||
Map<Locale, StringManager> map = managers.get(packageName);
|
||||
Map<Locale, StringManager> map = MANAGERS.get(packageName);
|
||||
if (map == null) {
|
||||
/*
|
||||
* Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE.
|
||||
* Expansion occurs when size() exceeds capacity. Therefore keep
|
||||
* size at or below capacity.
|
||||
* removeEldestEntry() executes after insertion therefore the test
|
||||
* for removal needs to use one less than the maximum desired size
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE.
|
||||
* Expansion occurs when size() exceeds capacity. Therefore keep
|
||||
* size at or below capacity.
|
||||
* removeEldestEntry() executes after insertion therefore the test
|
||||
* for removal needs to use one less than the maximum desired size
|
||||
*
|
||||
*/
|
||||
map = new LinkedHashMap<Locale, StringManager>(LOCALE_CACHE_SIZE, 1, true) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -137,7 +136,7 @@ public class StringManager {
|
||||
return size() > (LOCALE_CACHE_SIZE - 1);
|
||||
}
|
||||
};
|
||||
managers.put(packageName, map);
|
||||
MANAGERS.put(packageName, map);
|
||||
}
|
||||
|
||||
StringManager mgr = map.get(locale);
|
||||
|
||||
Reference in New Issue
Block a user