修复更多的warning,尤其是导致打包warning的不规范或不必要的javadoc

This commit is contained in:
BinaryWang
2016-07-12 10:02:26 +08:00
parent 5d957582e3
commit 55e0653521
19 changed files with 77 additions and 181 deletions

View File

@ -1,14 +1,14 @@
package me.chanjar.weixin.common.bean;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import org.apache.commons.codec.Charsets;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
/**
* 企业号菜单
* @author Daniel Qian
@ -45,8 +45,6 @@ public class WxMenu implements Serializable {
/**
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式外层多套了一个menu
* @param json
* @return
*/
public static WxMenu fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxMenu.class);
@ -55,11 +53,9 @@ public class WxMenu implements Serializable {
/**
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式外层多套了一个menu
* @param is
* @return
*/
public static WxMenu fromJson(InputStream is) {
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, Charsets.UTF_8), WxMenu.class);
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class);
}
@Override
@ -195,7 +191,7 @@ public class WxMenu implements Serializable {
this.language = language;
}
@Override
@Override
public String toString() {
return "matchrule:{" +
"tag_id='" + tagId + '\'' +

View File

@ -4,16 +4,11 @@ public interface WxSessionManager {
/**
* 获取某个sessionId对应的session,如果sessionId没有对应的session则新建一个并返回。
* @param sessionId
* @return
*/
public WxSession getSession(String sessionId);
/**
* 获取某个sessionId对应的session,如果sessionId没有对应的session若create为true则新建一个否则返回null。
* @param sessionId
* @param create
* @return
*/
public WxSession getSession(String sessionId, boolean create);

View File

@ -12,9 +12,6 @@ public class SHA1 {
/**
* 串接arr参数生成sha1 digest
*
* @param arr
* @return
*/
public static String gen(String... arr) throws NoSuchAlgorithmException {
Arrays.sort(arr);
@ -27,9 +24,6 @@ public class SHA1 {
/**
* 用&串接arr参数生成sha1 digest
*
* @param arr
* @return
*/
public static String genWithAmple(String... arr) throws NoSuchAlgorithmException {
Arrays.sort(arr);

View File

@ -35,16 +35,16 @@ public class WxCryptUtil {
private static final Base64 base64 = new Base64();
private static final Charset CHARSET = Charset.forName("utf-8");
private static final ThreadLocal<DocumentBuilder> builderLocal =
new ThreadLocal<DocumentBuilder>() {
@Override protected DocumentBuilder initialValue() {
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException exc) {
throw new IllegalArgumentException(exc);
}
}
};
private static final ThreadLocal<DocumentBuilder> builderLocal = new ThreadLocal<DocumentBuilder>() {
@Override
protected DocumentBuilder initialValue() {
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException exc) {
throw new IllegalArgumentException(exc);
}
}
};
protected byte[] aesKey;
protected String token;
@ -61,7 +61,8 @@ public class WxCryptUtil {
* @param encodingAesKey 公众平台上开发者设置的EncodingAESKey
* @param appidOrCorpid 公众平台appid/corpid
*/
public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) {
public WxCryptUtil(String token, String encodingAesKey,
String appidOrCorpid) {
this.token = token;
this.appidOrCorpid = appidOrCorpid;
this.aesKey = Base64.decodeBase64(encodingAesKey + "=");
@ -105,7 +106,8 @@ public class WxCryptUtil {
ByteGroup byteCollector = new ByteGroup();
byte[] randomStringBytes = randomStr.getBytes(CHARSET);
byte[] plainTextBytes = plainText.getBytes(CHARSET);
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder(plainTextBytes.length);
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder(
plainTextBytes.length);
byte[] appIdBytes = appidOrCorpid.getBytes(CHARSET);
// randomStr + networkBytesOrder + text + appid
@ -154,7 +156,8 @@ public class WxCryptUtil {
* @param encryptedXml 密文对应POST请求的数据
* @return 解密后的原文
*/
public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) {
public String decrypt(String msgSignature, String timeStamp, String nonce,
String encryptedXml) {
// 密钥公众账号的app corpSecret
// 提取密文
String cipherText = extractEncryptPart(encryptedXml);
@ -186,7 +189,8 @@ public class WxCryptUtil {
// 设置解密模式为AES的CBC模式
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
IvParameterSpec iv = new IvParameterSpec(
Arrays.copyOfRange(aesKey, 0, 16));
cipher.init(Cipher.DECRYPT_MODE, key_spec, iv);
// 使用BASE64对密文进行解码
@ -208,9 +212,10 @@ public class WxCryptUtil {
int xmlLength = bytesNetworkOrder2Number(networkOrder);
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET);
from_appid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length),
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength),
CHARSET);
from_appid = new String(
Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET);
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -224,34 +229,32 @@ public class WxCryptUtil {
}
/**
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3)
* @param packageParams 原始参数
* @param signKey 加密Key(即 商户Key)
* @param charset 编码
* @return 签名字符串
*/
public static String createSign(Map<String, String> packageParams, String signKey) {
SortedMap<String, String> sortedMap = new TreeMap<String, String>();
sortedMap.putAll(packageParams);
/**
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3)
* @param packageParams 原始参数
* @param signKey 加密Key(即 商户Key)
* @return 签名字符串
*/
public static String createSign(Map<String, String> packageParams,
String signKey) {
SortedMap<String, String> sortedMap = new TreeMap<String, String>();
sortedMap.putAll(packageParams);
List<String> keys = new ArrayList<String>(packageParams.keySet());
Collections.sort(keys);
List<String> keys = new ArrayList<String>(packageParams.keySet());
Collections.sort(keys);
StringBuffer toSign = new StringBuffer();
for (String key : keys) {
String value = packageParams.get(key);
if (null != value && !"".equals(value) && !"sign".equals(key)
&& !"key".equals(key)) {
toSign.append(key + "=" + value + "&");
}
}
toSign.append("key=" + signKey);
String sign = DigestUtils.md5Hex(toSign.toString())
.toUpperCase();
return sign;
StringBuffer toSign = new StringBuffer();
for (String key : keys) {
String value = packageParams.get(key);
if (null != value && !"".equals(value) && !"sign".equals(key)
&& !"key".equals(key)) {
toSign.append(key + "=" + value + "&");
}
}
toSign.append("key=" + signKey);
String sign = DigestUtils.md5Hex(toSign.toString()).toUpperCase();
return sign;
}
/**
* 将一个数字转换成生成4个字节的网络字节序bytes数组
@ -283,8 +286,6 @@ public class WxCryptUtil {
/**
* 随机生成16位字符串
*
* @return
*/
private String genRandomStr() {
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@ -306,14 +307,12 @@ public class WxCryptUtil {
* @param nonce 随机字符串
* @return 生成的xml字符串
*/
private String generateXml(String encrypt, String signature, String timestamp, String nonce) {
String format =
"<xml>\n"
+ "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
+ "<TimeStamp>%3$s</TimeStamp>\n"
+ "<Nonce><![CDATA[%4$s]]></Nonce>\n"
+ "</xml>";
private String generateXml(String encrypt, String signature, String timestamp,
String nonce) {
String format = "<xml>\n" + "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
+ "<TimeStamp>%3$s</TimeStamp>\n" + "<Nonce><![CDATA[%4$s]]></Nonce>\n"
+ "</xml>";
return String.format(format, encrypt, signature, timestamp, nonce);
}

View File

@ -14,8 +14,6 @@ public class FileUtils {
* @param name 文件名
* @param ext 扩展名
* @param tmpDirFile 临时文件夹目录
* @return
* @throws IOException
*/
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
FileOutputStream fos = null;
@ -56,8 +54,6 @@ public class FileUtils {
* @param inputStream
* @param name 文件名
* @param ext 扩展名
* @return
* @throws IOException
*/
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException {
return createTmpFile(inputStream, name, ext, null);

View File

@ -17,35 +17,30 @@ public interface ApacheHttpClientBuilder {
/**
* 代理服务器地址
* @param httpProxyHost
* @return
*/
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口
* @param httpProxyPort
* @return
*/
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名
* @param httpProxyUsername
* @return
*/
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码
* @param httpProxyPassword
* @return
*/
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword);
/**
* ssl连接socket工厂
* @param sslConnectionSocketFactory
* @return
*/
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
}

View File

@ -22,7 +22,6 @@ public interface RequestExecutor<T, E> {
* @param httpProxy http代理对象如果没有配置代理则为空
* @param uri uri
* @param data 数据
* @return
* @throws WxErrorException
* @throws ClientProtocolException
* @throws IOException