Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Apr 10, 2019
2 parents aa1a511 + a27e06b commit a3603a4
Show file tree
Hide file tree
Showing 33 changed files with 162 additions and 82 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

## 4.5.4

### 新特性

### Bug修复
* 【core】 Assert中NullPointerException改为IllegalArgumentException(issue#IV41L@Gitee)
* 【core】 修复创建新sheet时比较器未清空导致的顺序问题(issue#318@Github)

-------------------------------------------------------------------------------------------------------------

## 4.5.4

### 新特性
* 【core】 NetUtil增加getUsableLocalPort方法,并迁移至cn.hutool.core.net包
* 【core】 FileUtil增加isSub方法(pr#39@Gitee)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ Hutool是Hu + tool的自造词,谐音“糊涂”,寓意追求“万事都
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</dependency>
```

### Gradle
```
compile 'cn.hutool:hutool-all:4.5.4'
compile 'cn.hutool:hutool-all:4.5.5'
```

### 非Maven项目

点击以下任一链接,下载`hutool-all-X.X.X.jar`即可:

- [Maven中央库1](https://repo1.maven.org/maven2/cn/hutool/hutool-all/4.5.4/)
- [Maven中央库2](http://repo2.maven.org/maven2/cn/hutool/hutool-all/4.5.4/)
- [Maven中央库1](https://repo1.maven.org/maven2/cn/hutool/hutool-all/4.5.5/)
- [Maven中央库2](http://repo2.maven.org/maven2/cn/hutool/hutool-all/4.5.5/)

> 注意
> Hutool只支持JDK7+,对应Android平台没有测试,部分方法并不支持。
Expand Down
2 changes: 1 addition & 1 deletion bin/replaceVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
# 替换README.md中的版本
sed -i "s/${old_version}/${new_version}/g" $pwd/README.md
# 替换docs/index.html中的版本
sed -i "s/${old_version}/${new_version}/g" $pwd/docs/index.html
#sed -i "s/${old_version}/${new_version}/g" $pwd/docs/index.html

# 保留新版本号
echo "$new_version" > $pwd/bin/version.txt
2 changes: 1 addition & 1 deletion bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5.4
4.5.5
2 changes: 1 addition & 1 deletion hutool-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-all</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-aop</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-bloomFilter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-bloomFilter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-cache</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-captcha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-captcha</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-core</artifactId>
Expand Down
14 changes: 7 additions & 7 deletions hutool-core/src/main/java/cn/hutool/core/lang/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public static void isNull(Object object, String errorMsgTemplate, Object... para
* </pre>
*
* @param object 被检查对象
* @throws NullPointerException if the object is not {@code null}
* @throws IllegalArgumentException if the object is not {@code null}
*/
public static void isNull(Object object) throws NullPointerException {
public static void isNull(Object object) throws IllegalArgumentException {
isNull(object, "[Assertion failed] - the object argument must be null");
}

Expand All @@ -125,11 +125,11 @@ public static void isNull(Object object) throws NullPointerException {
* @param errorMsgTemplate 错误消息模板,变量使用{}表示
* @param params 参数
* @return 被检查后的对象
* @throws NullPointerException if the object is {@code null}
* @throws IllegalArgumentException if the object is {@code null}
*/
public static <T> T notNull(T object, String errorMsgTemplate, Object... params) throws NullPointerException {
public static <T> T notNull(T object, String errorMsgTemplate, Object... params) throws IllegalArgumentException {
if (object == null) {
throw new NullPointerException(StrUtil.format(errorMsgTemplate, params));
throw new IllegalArgumentException(StrUtil.format(errorMsgTemplate, params));
}
return object;
}
Expand All @@ -144,9 +144,9 @@ public static <T> T notNull(T object, String errorMsgTemplate, Object... params)
* @param <T> 被检查对象类型
* @param object 被检查对象
* @return 非空对象
* @throws NullPointerException if the object is {@code null}
* @throws IllegalArgumentException if the object is {@code null}
*/
public static <T> T notNull(T object) throws NullPointerException {
public static <T> T notNull(T object) throws IllegalArgumentException {
return notNull(object, "[Assertion failed] - this argument is required; it must not be null");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PatternPool {
public final static Pattern GROUP_VAR = Pattern.compile("\\$(\\d+)");
/** IP v4 */
public final static Pattern IPV4 = Pattern.compile("\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
/** IP v4 */
/** IP v6 */
public final static Pattern IPV6 = Pattern.compile("(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))");
/** 货币 */
public final static Pattern MONEY = Pattern.compile("^(\\d+(?:\\.\\d+)?)$");
Expand Down
9 changes: 9 additions & 0 deletions hutool-core/src/main/java/cn/hutool/core/lang/Snowflake.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public synchronized long nextId() {

return ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence;
}

/**
* 下一个ID(字符串形式)
*
* @return ID 字符串形式
*/
public String nextIdStr() {
return Long.toString(nextId());
}

// ------------------------------------------------------------------------------------------------------------------------------------ Private method start
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author looly,
*
*/
public final class URLEncoder {
public class URLEncoder {

// --------------------------------------------------------------------------------------------- Static method start
/**
Expand Down
67 changes: 49 additions & 18 deletions hutool-core/src/main/java/cn/hutool/core/util/URLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static URL url(String url, URLStreamHandler handler) {
}
}
}

/**
* 将URL字符串转换为URL对象,并做必要验证
*
Expand All @@ -107,7 +107,7 @@ public static URL url(String url, URLStreamHandler handler) {
public static URL toUrlForHttp(String urlStr) {
return toUrlForHttp(urlStr, null);
}

/**
* 将URL字符串转换为URL对象,并做必要验证
*
Expand Down Expand Up @@ -205,6 +205,35 @@ public static String complateUrl(String baseUrl, String relativePath) {
}
}

/**
* 编码URL,默认使用UTF-8编码<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。
*
* @param url URL
* @return 编码后的URL
* @exception UtilException UnsupportedEncodingException
*/
public static String encodeAll(String url) {
return encodeAll(url, CharsetUtil.CHARSET_UTF_8);
}

/**
* 编码URL<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。
*
* @param url URL
* @param charset 编码
* @return 编码后的URL
* @exception UtilException UnsupportedEncodingException
*/
public static String encodeAll(String url, Charset charset) throws UtilException {
try {
return java.net.URLEncoder.encode(url, charset.toString());
} catch (UnsupportedEncodingException e) {
throw new UtilException(e);
}
}

/**
* 编码URL,默认使用UTF-8编码<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
Expand All @@ -218,7 +247,7 @@ public static String complateUrl(String baseUrl, String relativePath) {
public static String encode(String url) throws UtilException {
return encode(url, CharsetUtil.CHARSET_UTF_8);
}

/**
* 编码URL,默认使用UTF-8编码<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
Expand All @@ -232,7 +261,7 @@ public static String encode(String url) throws UtilException {
public static String encodeQuery(String url) throws UtilException {
return encodeQuery(url, CharsetUtil.CHARSET_UTF_8);
}

/**
* 编码字符为 application/x-www-form-urlencoded<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
Expand All @@ -252,7 +281,7 @@ public static String encode(String url, Charset charset) {
}
return URLEncoder.DEFAULT.encode(url, charset);
}

/**
* 编码字符为URL中查询语句<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
Expand Down Expand Up @@ -289,7 +318,7 @@ public static String encode(String url, String charset) throws UtilException {
}
return encode(url, StrUtil.isBlank(charset) ? CharsetUtil.defaultCharset() : CharsetUtil.charset(charset));
}

/**
* 编码URL<br>
* 将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。<br>
Expand All @@ -316,7 +345,7 @@ public static String encodeQuery(String url, String charset) throws UtilExceptio
public static String decode(String url) throws UtilException {
return decode(url, CharsetUtil.UTF_8);
}

/**
* 解码application/x-www-form-urlencoded字符
*
Expand Down Expand Up @@ -510,9 +539,10 @@ public static JarFile getJarFile(URL url) {
throw new IORuntimeException(e);
}
}

/**
* 标准化URL字符串,包括:
*
* <pre>
* 1. 多个/替换为一个
* </pre>
Expand All @@ -523,9 +553,10 @@ public static JarFile getJarFile(URL url) {
public static String normalize(String url) {
return normalize(url, false);
}

/**
* 标准化URL字符串,包括:
*
* <pre>
* 1. 多个/替换为一个
* </pre>
Expand All @@ -536,32 +567,32 @@ public static String normalize(String url) {
* @since 4.4.1
*/
public static String normalize(String url, boolean isEncodeBody) {
if(StrUtil.isBlank(url)) {
if (StrUtil.isBlank(url)) {
return url;
}
final int sepIndex = url.indexOf("://");
String pre;
String body;
if(sepIndex > 0) {
if (sepIndex > 0) {
pre = StrUtil.subPre(url, sepIndex + 3);
body = StrUtil.subSuf(url, sepIndex + 3);
}else {
} else {
pre = "http://";
body = url;
}

final int paramsSepIndex = StrUtil.indexOf(body, '?');
String params = null;
if(paramsSepIndex > 0) {
if (paramsSepIndex > 0) {
params = StrUtil.subSuf(body, paramsSepIndex);
body = StrUtil.subPre(body, paramsSepIndex);
}
//去除开头的\或者/

// 去除开头的\或者/
body = body.replaceAll("^[\\/]+", StrUtil.EMPTY);
//替换多个\或/为单个/
// 替换多个\或/为单个/
body = body.replace("\\", "/").replaceAll("//+", "/");
if(isEncodeBody) {
if (isEncodeBody) {
body = encode(body);
}
return pre + body + StrUtil.nullToEmpty(params);
Expand Down
2 changes: 1 addition & 1 deletion hutool-core/src/test/java/cn/hutool/core/img/ImgTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void compressTest() {
}

@Test
// @Ignore
@Ignore
public void roundTest() {
Img.from(FileUtil.file("e:/pic/face.jpg")).round(0.5).write(FileUtil.file("e:/pic/face_round.png"));
}
Expand Down
2 changes: 1 addition & 1 deletion hutool-cron/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-cron</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ public class CronPatternTest {
public void matchAllTest() {
CronPattern pattern;
// 任何时间匹配
pattern = new CronPattern("* * * * *");
pattern = new CronPattern("* * * * * *");
Assert.assertTrue(pattern.match(DateUtil.current(false), true));
Assert.assertTrue(pattern.match(DateUtil.current(false), false));
}

@Test
public void matchAllTest2() {
// 在5位表达式中,秒部分并不是任意匹配,而是一个固定值
// 因此此处匹配就不能匹配秒
CronPattern pattern;
// 任何时间匹配
pattern = new CronPattern("* * * * *");
for(int i = 0; i < 1; i++) {
Assert.assertTrue(pattern.match(DateUtil.current(false), false));
}
}

@Test
public void cronPatternTest() {
Expand Down
2 changes: 1 addition & 1 deletion hutool-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.5.4</version>
<version>4.5.5</version>
</parent>

<artifactId>hutool-crypto</artifactId>
Expand Down
Loading

0 comments on commit a3603a4

Please sign in to comment.