add method and fix GlobalMailAccount

This commit is contained in:
Looly 2020-09-25 11:37:46 +08:00
parent 3846985acd
commit 74cb1abeeb
8 changed files with 38 additions and 8 deletions

View File

@ -16,6 +16,9 @@
* 【core 】 CharUtil and StrUtil增加@pr#1106@Github
* 【extra 】 优化EMOJ查询逻辑pr#1112@Github
* 【extra 】 优化CollUtil交并集结果集合设置初始化大小避免扩容成本pr#1110@Github
* 【core 】 优化PageUtil彩虹算法issue#1110@Github
* 【core 】 IoUtil增加readUtf8方法
* 【core 】 优化全局邮箱账户初始化逻辑pr#1114@Github
### Bug修复
* 【crypto 】 修复SM2验签后无法解密问题issue#I1W0VP@Gitee

View File

@ -214,9 +214,14 @@ public class DateUtil extends CalendarUtil {
/**
* 获得指定日期是所在年份的第几周<br>
* 此方法返回值与一周的第一天有关比如<br>
* 2016年1月3日为周日如果一周的第一天为周日那这天是第二周返回2<br>
* 如果一周的第一天为周一那这天是第一周返回1<br>
* 跨年的那个星期得到的结果总是1
*
* @param date 日期
* @return
* @see DateTime#setFirstDayOfWeek(Week)
*/
public static int weekOfYear(Date date) {
return DateTime.of(date).weekOfYear();

View File

@ -421,6 +421,18 @@ public class IoUtil {
// -------------------------------------------------------------------------------------- read start
/**
* 从流中读取UTF8编码的内容
*
* @param in 输入流
* @return 内容
* @throws IORuntimeException IO异常
* @since 5.4.4
*/
public static String readUtf8(InputStream in) throws IORuntimeException {
return read(in, CharsetUtil.CHARSET_UTF_8);
}
/**
* 从流中读取内容
*
@ -1251,7 +1263,7 @@ public class IoUtil {
* @throws IORuntimeException IO异常
* @since 5.4.0
*/
public static long checksumValue(InputStream in, Checksum checksum){
public static long checksumValue(InputStream in, Checksum checksum) {
return checksum(in, checksum).getValue();
}
}

View File

@ -5,6 +5,8 @@ import cn.hutool.core.text.replacer.ReplacerChain;
/**
* HTML4的ESCAPE
* 参考Commons Lang3
*
* @author looly
*
*/

View File

@ -160,9 +160,10 @@ public class PageUtil {
* @return 分页条
*/
public static int[] rainbow(int pageNo, int totalPage, int displayCount) {
boolean isEven = displayCount % 2 == 0;
int left = displayCount / 2;
int right = displayCount / 2;
// displayCount % 2
boolean isEven = (displayCount & 1) == 0;
int left = displayCount >> 1;
int right = displayCount >> 1;
int length = displayCount;
if (isEven) {

View File

@ -37,4 +37,11 @@ public class EscapeUtilTest {
String unescape = EscapeUtil.unescape(escape);
Assert.assertEquals(str, unescape);
}
@Test
public void escapeSinleQuotesTest(){
String str = "'some text with single quotes'";
final String s = EscapeUtil.escapeHtml4(str);
Assert.assertEquals(str, s);
}
}

View File

@ -38,7 +38,7 @@ public enum GlobalMailAccount {
for (String mailSettingPath : MailAccount.MAIL_SETTING_PATHS) {
try {
return new MailAccount(mailSettingPath);
} catch (IORuntimeException e) {
} catch (IORuntimeException ignore) {
//ignore
}
}

View File

@ -93,7 +93,7 @@ public class SoapClient extends HttpBase<SoapClient> {
* 创建SOAP客户端默认使用soap1.1版本协议
*
* @param url WS的URL地址
* @return {@link SoapClient}
* @return this
*/
public static SoapClient create(String url) {
return new SoapClient(url);
@ -104,7 +104,7 @@ public class SoapClient extends HttpBase<SoapClient> {
*
* @param url WS的URL地址
* @param protocol 协议{@link SoapProtocol}
* @return {@link SoapClient}
* @return this
*/
public static SoapClient create(String url, SoapProtocol protocol) {
return new SoapClient(url, protocol);
@ -116,7 +116,7 @@ public class SoapClient extends HttpBase<SoapClient> {
* @param url WS的URL地址
* @param protocol 协议{@link SoapProtocol}
* @param namespaceURI 方法上的命名空间URI
* @return {@link SoapClient}
* @return this
* @since 4.5.6
*/
public static SoapClient create(String url, SoapProtocol protocol, String namespaceURI) {