Skip to content

Commit

Permalink
prepare 4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Nov 24, 2018
1 parent 6474c77 commit 76938e8
Show file tree
Hide file tree
Showing 24 changed files with 240 additions and 21 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

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

## 4.2.1

### 新特性
* 【extra】 增加基于emoji-java的EmojiUtil
* 【http】 增加User-agent解析

### Bug修复

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

## 4.1.22

### 新特性
Expand Down
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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-core</artifactId>
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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-cron</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-crypto/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-crypto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-db/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-db</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-dfa/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-dfa</artifactId>
Expand Down
14 changes: 11 additions & 3 deletions hutool-extra/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-extra</artifactId>
Expand All @@ -28,6 +28,7 @@
<jsch.version>0.1.54</jsch.version>
<zxing.version>3.3.3</zxing.version>
<net.version>3.6</net.version>
<emoji-java.version>4.0.0</emoji-java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -109,7 +110,6 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>

<!-- 二维码 -->
<dependency>
<groupId>com.google.zxing</groupId>
Expand All @@ -118,13 +118,21 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>

<!-- FTP工具 -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>${net.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Emoji工具依赖 -->
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>${emoji-java.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
152 changes: 152 additions & 0 deletions hutool-extra/src/main/java/cn/hutool/extra/emoji/EmojiUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package cn.hutool.extra.emoji;

import java.util.List;
import java.util.Set;

import com.vdurmont.emoji.Emoji;
import com.vdurmont.emoji.EmojiManager;
import com.vdurmont.emoji.EmojiParser;
import com.vdurmont.emoji.EmojiParser.FitzpatrickAction;

/**
* 基于<a href=“https://github.com/vdurmont/emoji-java”>emoji-java</a>的Emoji表情工具类
* <p>
* emoji-java文档以及别名列表见:<a href="https://github.com/vdurmont/emoji-java">https://github.com/vdurmont/emoji-java</a>
*
* @author looly
*@since 4.2.1
*/
public class EmojiUtil {

/**
* 是否为Emoji表情的Unicode符
*
* @param str 被测试的字符串
* @return 是否为Emoji表情的Unicode符
*/
public static boolean isEmoji(String str) {
return EmojiManager.isEmoji(str);
}

/**
* 通过tag方式获取对应的所有Emoji表情
*
* @param tag tag标签,例如“happy”
* @return Emoji表情集合,如果找不到返回null
*/
public static Set<Emoji> getByTag(String tag) {
return EmojiManager.getForTag(tag);
}

/**
* 通过别名获取Emoji
*
* @param alias 别名,例如“smile”
* @return Emoji对象,如果找不到返回null
*/
public static Emoji get(String alias) {
return EmojiManager.getForAlias(alias);
}

/**
* 将子串中的Emoji别名(两个":"包围的格式)和其HTML表示形式替换为为Unicode Emoji符号
* <p>
* 例如:
*
* <pre>
* <code>:smile:</code> 替换为 <code>😄</code>
* <code>&amp;#128516;</code> 替换为 <code>😄</code>
* <code>:boy|type_6:</code> 替换为 <code>👦🏿</code>
* </pre>
*
* @param str 包含Emoji别名或者HTML表现形式的字符串
* @return 替换后的字符串
*/
public static String toUnicode(String str) {
return EmojiParser.parseToUnicode(str);
}

/**
* 将字符串中的Unicode Emoji字符转换为别名表现形式(两个":"包围的格式)
* <p>
* 例如: <code>😄</code> 转换为 <code>:smile:</code>
*
* <p>
* {@link FitzpatrickAction}参数被设置为{@link FitzpatrickAction#PARSE},则别名后会增加"|"并追加fitzpatrick类型
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>:boy|type_6:</code>
*
* <p>
* {@link FitzpatrickAction}参数被设置为{@link FitzpatrickAction#REMOVE},则别名后的"|"和类型将被去除
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>:boy:</code>
*
* <p>
* {@link FitzpatrickAction}参数被设置为{@link FitzpatrickAction#IGNORE},则别名后的类型将被忽略
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>:boy:🏿</code>
*
* @param str 包含Emoji Unicode字符的字符串
* @param fitzpatrickAction {@link FitzpatrickAction} Fitzpatrick类型
* @return 替换后的字符串
*/
public static String toAlias(String str) {
return toAlias(str, FitzpatrickAction.PARSE);
}

/**
* 将字符串中的Unicode Emoji字符转换为别名表现形式(两个":"包围的格式),别名后会增加"|"并追加fitzpatrick类型
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>:boy|type_6:</code>
*
* @param str 包含Emoji Unicode字符的字符串
* @return 替换后的字符串
*/
public static String toAlias(String str, FitzpatrickAction fitzpatrickAction) {
return EmojiParser.parseToAliases(str, fitzpatrickAction);
}

/**
* 将字符串中的Unicode Emoji字符转换为HTML 16进制表现形式
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>&amp;#x1f466;</code>
*
* @param str 包含Emoji Unicode字符的字符串
* @return 替换后的字符串
*/
public static String toHtmlHex(String str) {
return EmojiParser.parseToHtmlHexadecimal(str);
}

/**
* 将字符串中的Unicode Emoji字符转换为HTML表现形式
* <p>
* 例如:<code>👦🏿</code> 转换为 <code>&amp;#128102;</code>
*
* @param str 包含Emoji Unicode字符的字符串
* @return 替换后的字符串
*/
public static String toHtml(String str) {
return EmojiParser.parseToHtmlHexadecimal(str);
}

/**
* 去除字符串中所有的Emoji Unicode字符
*
* @param str 包含Emoji字符的字符串
* @return 替换后的字符串
*/
public static String removeAllEmojis(String str) {
return EmojiParser.removeAllEmojis(str);
}

/**
* 提取字符串中所有的Emoji Unicode
*
* @param str 包含Emoji字符的字符串
* @return Emoji字符列表
*/
public static List<String> extractEmojis(String str) {
return EmojiParser.extractEmojis(str);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* 基于<a href=“https://github.com/vdurmont/emoji-java”>emoji-java</a>的Emoji表情工具类
*
* @author looly
*
*/
package cn.hutool.extra.emoji;
2 changes: 1 addition & 1 deletion hutool-http/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-http</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cn.hutool.http.useragent;

import java.util.regex.Pattern;

/**
* User-agent信息
*
* @author looly
* @since 4.2.1
*/
public class UserAgentInfo {
private String name;
private Pattern pattern;

public UserAgentInfo(String name, Pattern pattern) {
this.name = name;
this.pattern = pattern;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Pattern getPattern() {
return pattern;
}

public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* User-Agent解析
*
* @author looly
*
*/
package cn.hutool.http.useragent;
2 changes: 1 addition & 1 deletion hutool-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-json</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-log/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.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

<artifactId>hutool-log</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-poi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>4.1.22-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
</parent>

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

0 comments on commit 76938e8

Please sign in to comment.