Skip to content

Commit e8d0c4e

Browse files
committed
fix:
修复阿里规约的问题
1 parent 1134d9a commit e8d0c4e

File tree

12 files changed

+126
-111
lines changed

12 files changed

+126
-111
lines changed

common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
</dependencies>
9191

9292
<properties>
93-
<junrar.version>1.0.0</junrar.version>
93+
<junrar.version>1.0.1</junrar.version>
9494
<fst.version>2.56</fst.version>
9595
<cloning.version>1.9.6</cloning.version>
9696
<pinyin4j.version>2.5.1</pinyin4j.version>

common/src/main/java/pro/tools/constant/RegexConst.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
/**
88
* 正则的常量
99
*
10-
* @author SeanDragon Create By 2017-04-17 10:13
10+
* @author SeanDragon
11+
* @date 2017-04-17 10:13
1112
*/
1213
public final class RegexConst {
1314

common/src/main/java/pro/tools/data/decimal/Decimal.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ public Decimal sqrtN(int n) {
245245
this.bigDecimal = new BigDecimal(log, mathContext);
246246
return this;
247247
}
248+
248249
//endregion
249250

250251
//region 数据变现
252+
251253
@Override
252254
public String toString() {
253255
return fullStrValue();
@@ -287,13 +289,11 @@ public double moneyValue() {
287289
@Override
288290
public int intValue() {
289291
return (int) doubleValue();
290-
//return this.bigDecimal.intValueExact();
291292
}
292293

293294
@Override
294295
public long longValue() {
295296
return (long) doubleValue();
296-
//return this.bigDecimal.longValueExact();
297297
}
298298

299299
@Override
@@ -332,6 +332,7 @@ public double doubleValue(int scale, RoundingMode roundingMode) {
332332
String strValue = this.fullStrValue(scale, roundingMode);
333333
return Double.valueOf(strValue);
334334
}
335+
335336
//endregion
336337

337338

common/src/main/java/pro/tools/data/text/ToolPinYin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static String getPinYin(String src) throws BadHanyuPinyinOutputFormatComb
4141
t2 = PinyinHelper.toHanyuPinyinStringArray(aT1, t3);
4242
t4.append(t2[0]);
4343
} else {
44-
t4.append(Character.toString(aT1));
44+
t4.append(aT1);
4545
}
4646
}
4747
return t4.toString();
Lines changed: 37 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,79 @@
11
package pro.tools.data.text;
22

3+
import pro.tools.constant.StrConst;
4+
35
import java.io.ByteArrayInputStream;
46
import java.io.ByteArrayOutputStream;
57
import java.io.IOException;
68
import java.util.zip.GZIPInputStream;
79
import java.util.zip.GZIPOutputStream;
810

911
/**
10-
* Module: ZipUtil.java
11-
* Description: 对字符串的压缩及解压
12-
* Company:
13-
* Author: pantp
14-
* Date: May 6, 2012
12+
* 对字符串的压缩及解压
13+
*
14+
* @author SeanDragon
1515
*/
1616
public class ToolStrCompress {
1717

18-
public static void main(String[] args) throws IOException {
19-
// 字符串超过一定的长度
20-
String str = "ABCdef123中文~!@#$%^&*()_+{};/1111111111111111111111111AAAAAAAAAAAJDLFJDLFJDLFJLDFFFFJEIIIIIIIIIIFJJJJJJJJJJJJALLLLLLLLLLLLLLLLLLLLLL" +
21-
"LLppppppppppppppppppppppppppppppppppppppppp===========================------------------------------iiiiiiiiiiiiiiiiiiiiiii";
22-
str = "美国学者 Dime 和 Henman 为解决信息公开传送和密钥管理问题,提出一种新的密钥交换协议,允许在不安全的媒体上的通讯双方交换信息,安全地达成一致的密钥,这就是 “公开密钥系统”。与对称加密算法不同,非对称加密算法需要两个密钥:公开密钥(publickey)和私有密钥(privatekey)。公开密钥与私有密钥是一对,如果用公开密钥对数据进行加密,只有用对应的私有密钥才能解密;如果用私有密钥对数据进行加密,那么只有用对应的公开密钥才能解密。因为加密和解密使用的是两个不同的密钥,所以这种算法叫作非对称加密算法。工作过程如下图所示,甲乙之间使用非对称加密的方式完成了重要信息的安全传输。非对称加密工作过程简要示意图非对称加密工作过程简要示意图美国学者 Dime 和 Henman 为解决信息公开传送和密钥管理问题,提出一种新的密钥交换协议,允许在不安全的媒体上的通讯双方交换信息,安全地达成一致的密钥,这就是 “公开密钥系统”。与对称加密算法不同,非对称加密算法需要两个密钥:公开密钥(publickey)和私有密钥(privatekey)。公开密钥与私有密钥是一对,如果用公开密钥对数据进行加密,只有用对应的私有密钥才能解密;如果用私有密钥对数据进行加密,那么只有用对应的公开密钥才能解密。因为加密和解密使用的是两个不同的密钥,所以这种算法叫作非对称加密算法。工作过程如下图所示,甲乙之间使用非对称加密的方式完成了重要信息的安全传输。非对称加密工作过程简要示意图非对称加密工作过程简要示意图";
23-
// str = "1";
24-
25-
System.out.println("\n原始的字符串为------->" + str);
26-
float len0 = str.length();
27-
System.out.println("原始的字符串长度为------->" + len0);
28-
29-
String ys = compress(str);
30-
System.out.println("\n压缩后的字符串为----->" + ys);
31-
float len1 = ys.length();
32-
System.out.println("压缩后的字符串长度为----->" + len1);
33-
34-
String jy = unCompress(ys);
35-
System.out.println("\n解压缩后的字符串为--->" + jy);
36-
System.out.println("解压缩后的字符串长度为--->" + jy.length());
37-
38-
System.out.println("\n压缩比例为" + len1 / len0);
39-
40-
//判断
41-
if (str.equals(jy)) {
42-
System.out.println("先压缩再解压以后字符串和原来的是一模一样的");
43-
}
18+
private ToolStrCompress() {
19+
throw new UnsupportedOperationException("我是工具类,别初始化我。。。");
4420
}
4521

4622
/**
4723
* 字符串的压缩
4824
*
4925
* @param str 待压缩的字符串
26+
*
5027
* @return 返回压缩后的字符串
28+
*
5129
* @throws IOException
5230
*/
5331
public static String compress(String str) throws IOException {
5432
if (null == str || str.length() <= 0) {
5533
return str;
5634
}
57-
// 创建一个新的 byte 数组输出流
58-
ByteArrayOutputStream out = new ByteArrayOutputStream();
59-
// 使用默认缓冲区大小创建新的输出流
60-
GZIPOutputStream gzip = new GZIPOutputStream(out);
61-
// 将 b.length 个字节写入此输出流
62-
gzip.write(str.getBytes());
63-
gzip.close();
64-
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
65-
return out.toString("UTF-8");
35+
try (
36+
// 创建一个新的 byte 数组输出流
37+
ByteArrayOutputStream out = new ByteArrayOutputStream();
38+
// 使用默认缓冲区大小创建新的输出流
39+
GZIPOutputStream gzip = new GZIPOutputStream(out);) {
40+
// 将 b.length 个字节写入此输出流
41+
gzip.write(str.getBytes());
42+
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
43+
return out.toString(StrConst.DEFAULT_CHARSET_NAME);
44+
}
6645
}
6746

6847
/**
6948
* 字符串的解压
7049
*
7150
* @param str 对字符串解压
51+
*
7252
* @return 返回解压缩后的字符串
53+
*
7354
* @throws IOException
7455
*/
7556
public static String unCompress(String str) throws IOException {
7657
if (null == str || str.length() <= 0) {
7758
return str;
7859
}
79-
// 创建一个新的 byte 数组输出流
80-
ByteArrayOutputStream out = new ByteArrayOutputStream();
81-
// 创建一个 ByteArrayInputStream,使用 buf 作为其缓冲区数组
82-
ByteArrayInputStream in = new ByteArrayInputStream(str
83-
.getBytes("UTF-8"));
84-
// 使用默认缓冲区大小创建新的输入流
85-
GZIPInputStream gzip = new GZIPInputStream(in);
86-
byte[] buffer = new byte[256];
87-
int n = 0;
88-
while ((n = gzip.read(buffer)) >= 0) {// 将未压缩数据读入字节数组
89-
// 将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此 byte数组输出流
90-
out.write(buffer, 0, n);
60+
try (
61+
// 创建一个新的 byte 数组输出流
62+
ByteArrayOutputStream out = new ByteArrayOutputStream();
63+
// 创建一个 ByteArrayInputStream,使用 buf 作为其缓冲区数组
64+
ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes(StrConst.DEFAULT_CHARSET_NAME));
65+
// 使用默认缓冲区大小创建新的输入流
66+
GZIPInputStream gzip = new GZIPInputStream(in);) {
67+
byte[] buffer = new byte[256];
68+
int n = 0;
69+
// 将未压缩数据读入字节数组
70+
while ((n = gzip.read(buffer)) >= 0) {
71+
// 将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此 byte数组输出流
72+
out.write(buffer, 0, n);
73+
}
74+
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
75+
return out.toString(StrConst.DEFAULT_CHARSET_NAME);
9176
}
92-
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
93-
return out.toString("UTF-8");
9477
}
9578

9679
}

common/src/main/java/pro/tools/file/ToolFile.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,7 @@
55
import pro.tools.data.text.ToolConvert;
66
import pro.tools.data.text.ToolStr;
77

8-
import java.io.BufferedInputStream;
9-
import java.io.BufferedOutputStream;
10-
import java.io.BufferedReader;
11-
import java.io.BufferedWriter;
12-
import java.io.File;
13-
import java.io.FileInputStream;
14-
import java.io.FileOutputStream;
15-
import java.io.FileWriter;
16-
import java.io.FilenameFilter;
17-
import java.io.IOException;
18-
import java.io.InputStream;
19-
import java.io.InputStreamReader;
20-
import java.io.OutputStream;
8+
import java.io.*;
219
import java.nio.charset.Charset;
2210
import java.security.DigestInputStream;
2311
import java.security.MessageDigest;
@@ -1107,7 +1095,8 @@ public static String readFile2String(File file, String charsetName) throws IOExc
11071095

11081096
String line;
11091097
while ((line = reader.readLine()) != null) {
1110-
sb.append(line).append("\r\n");// windows系统换行为\r\n,Linux为\n
1098+
// windows系统换行为\r\n,Linux为\n
1099+
sb.append(line).append("\r\n");
11111100
}
11121101
// 要去除最后的换行符
11131102
return sb.delete(sb.length() - 2, sb.length()).toString();

common/src/main/java/pro/tools/system/ToolOS.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public final class ToolOS {
4343
public static final String USER_NAME = getOsSystemProperty("user.name"); // 用户的账户名称
4444
public static final String USER_HOME = getOsSystemProperty("user.home"); // 用户的主目录
4545
public static final String USER_DIR = getOsSystemProperty("user.dir"); // 用户的当前工作目录
46-
// 系统bean
46+
/**
47+
* 系统Bean
48+
*/
4749
private static final OperatingSystemMXBean SYSTEM_MX_BEAN;
4850
private static final List<GarbageCollectorMXBean> LIST;
49-
// K转换M
51+
/**
52+
* K转换M
53+
*/
5054
private static final long K2M = 1024L * 1024L;
5155

5256
static {

common/src/main/java/pro/tools/time/DatePlus.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package pro.tools.time;
22

33
import java.io.Serializable;
4-
import java.time.DayOfWeek;
5-
import java.time.LocalDate;
6-
import java.time.LocalDateTime;
7-
import java.time.LocalTime;
8-
import java.time.Month;
4+
import java.time.*;
95
import java.time.format.DateTimeFormatter;
106
import java.time.format.DateTimeParseException;
117
import java.time.temporal.ChronoUnit;
@@ -24,6 +20,7 @@ public class DatePlus implements Serializable, Cloneable {
2420
private LocalDateTime localDateTime;
2521

2622
//region 初始化区域
23+
2724
public DatePlus() {
2825
this.localDateTime = LocalDateTime.now();
2926
}
@@ -82,6 +79,7 @@ public DatePlus(String dateStr, DateTimeFormatter dateTimeFormatter) {
8279
}
8380

8481
//region 添加属性值
82+
8583
public DatePlus addYear(long year) {
8684
this.localDateTime = this.localDateTime.plusYears(year);
8785
return this;
@@ -291,6 +289,7 @@ public boolean isLeapYear() {
291289
}
292290

293291
//region 属性的比较
292+
294293
public boolean isBefore(DatePlus datePlus, DateType dateType) {
295294
boolean isBefore;
296295
switch (dateType) {
@@ -346,7 +345,6 @@ public boolean isSame(DatePlus datePlus, DateType dateType) {
346345
break;
347346
}
348347
return isSame;
349-
//return this.localDateTime.isEqual(datePlus.getLocalDateTime());
350348
}
351349

352350
public boolean isAfter(DatePlus datePlus, DateType dateType) {
@@ -375,7 +373,6 @@ public boolean isAfter(DatePlus datePlus, DateType dateType) {
375373
break;
376374
}
377375
return isAfter;
378-
//return this.localDateTime.isAfter(datePlus.getLocalDateTime());
379376
}
380377

381378
public long ofYear(DatePlus datePlus) {
@@ -409,6 +406,7 @@ public long ofNanos(DatePlus datePlus) {
409406
public long ofDateTime(ChronoUnit chronoUnit, DatePlus datePlus) {
410407
return -chronoUnit.between(this.localDateTime, datePlus.localDateTime);
411408
}
409+
412410
//endregion
413411

414412

@@ -543,9 +541,17 @@ public String toString() {
543541

544542

545543
//region 生肖和星座
544+
545+
/**
546+
* 生肖
547+
*/
546548
private static final String[] CHINESE_ZODIAC = {"猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊"};
549+
/**
550+
* 星座
551+
*/
547552
private static final String[] ZODIAC = {"水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "魔羯座"};
548553
private static final int[] ZODIAC_FLAGS = {20, 19, 21, 21, 21, 22, 23, 23, 23, 24, 23, 22};
554+
549555
//endregion
550556

551557
@Override

mail/src/main/java/pro/tools/mail/pojo/MailSend.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
*/
1010
public class MailSend implements java.io.Serializable {
1111

12-
//接受方邮箱地址列表
12+
/**
13+
* 接受方邮箱地址列表
14+
*/
1315
private List<String> toList;
14-
//标题
16+
/**
17+
* 标题
18+
*/
1519
private String subject;
16-
//内容
20+
/**
21+
* 内容
22+
*/
1723
private String content;
18-
//附件文件列表
24+
/**
25+
* 附件文件列表
26+
*/
1927
private List<String> attachFiles;
2028

2129

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<version>${junit.version}</version>
2828
<scope>test</scope>
2929
</dependency>
30+
<dependency>
31+
<groupId>org.projectlombok</groupId>
32+
<artifactId>lombok</artifactId>
33+
<version>1.18.6</version>
34+
</dependency>
3035
</dependencies>
3136

3237
<packaging>pom</packaging>

0 commit comments

Comments
 (0)