mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
release branch 0.16.0
This commit is contained in:
@@ -298,3 +298,9 @@
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:-----|---------------------|:-------------------|:-------------------------------------------------|
|
||||
| 1 | F | 调整默认文件名称,避免和其他框架重合。 | 2024-4-23 21:02:25 | https://github.com/houbb/sensitive-word/issues/54 |
|
||||
|
||||
# release_0.16.0
|
||||
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:-----|----------------------|:-------------------|:-------------------------------------------------|
|
||||
| 1 | F | 支持资源的释放,如 andriod 场景 | 2024-4-26 21:02:25 | https://github.com/houbb/sensitive-word/issues/53 |
|
||||
|
||||
19
README.md
19
README.md
@@ -52,9 +52,9 @@
|
||||
|
||||
[CHANGE_LOG.md](https://github.com/houbb/sensitive-word/blob/master/CHANGE_LOG.md)
|
||||
|
||||
V0.15.0:
|
||||
V0.16.0:
|
||||
|
||||
- [x] 修复 [#54](https://github.com/houbb/sensitive-word/issues/54)
|
||||
- [x] 支持内存释放 [#53](https://github.com/houbb/sensitive-word/issues/53)
|
||||
|
||||
## 更多资料
|
||||
|
||||
@@ -86,7 +86,7 @@ V0.15.0:
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.15.0</version>
|
||||
<version>0.16.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -450,6 +450,19 @@ Assert.assertTrue(wordBs.contains(text));
|
||||
| 13 | charIgnore | 忽略的字符 | none |
|
||||
| 14 | wordResultCondition | 针对匹配的敏感词额外加工,比如可以限制英文单词必须全匹配 | 恒为真 |
|
||||
|
||||
## 内存的释放
|
||||
|
||||
有时候我们需要释放内存,可以如下:
|
||||
|
||||
> [关于内存回收问题](https://github.com/houbb/sensitive-word/issues/53)
|
||||
|
||||
```java
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.init();
|
||||
// 后续因为一些原因移除了对应信息,希望释放内存。
|
||||
wordBs.destroy();
|
||||
```
|
||||
|
||||
# wordResultCondition-针对匹配词进一步判断
|
||||
|
||||
## 说明
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.15.0</version>
|
||||
<version>0.16.0</version>
|
||||
|
||||
<properties>
|
||||
<!--============================== All Plugins START ==============================-->
|
||||
|
||||
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
|
||||
|
||||
:: 版本号信息(需要手动指定)
|
||||
:::: 旧版本名称
|
||||
SET version=0.15.0
|
||||
SET version=0.16.0
|
||||
:::: 新版本名称
|
||||
SET newVersion=0.16.0
|
||||
SET newVersion=0.17.0
|
||||
:::: 组织名称
|
||||
SET groupName=com.github.houbb
|
||||
:::: 项目名称
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.github.houbb.sensitive.word.api;
|
||||
|
||||
public interface ISensitiveWordDestroy {
|
||||
|
||||
/**
|
||||
* 资源的销毁
|
||||
* @since 0.16.0
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public interface IWordData {
|
||||
public interface IWordData extends ISensitiveWordDestroy {
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Set;
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public class SensitiveWordBs {
|
||||
public class SensitiveWordBs implements ISensitiveWordDestroy {
|
||||
|
||||
/**
|
||||
* 私有化构造器
|
||||
@@ -573,6 +573,11 @@ public class SensitiveWordBs {
|
||||
return wordTag.getTag(word);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------ 公开方法 END
|
||||
|
||||
}
|
||||
|
||||
@@ -183,4 +183,11 @@ public class WordDataHashMap extends AbstractWordData {
|
||||
return currentMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void destroy() {
|
||||
if(innerWordMap != null) {
|
||||
innerWordMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,4 +117,10 @@ public class WordDataTree implements IWordData {
|
||||
return currentMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if(this.root != null) {
|
||||
this.root.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.github.houbb.sensitive.word.support.data;
|
||||
|
||||
import com.github.houbb.sensitive.word.api.ISensitiveWordDestroy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -8,7 +10,7 @@ import java.util.Map;
|
||||
*
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public class WordDataTreeNode {
|
||||
public class WordDataTreeNode implements ISensitiveWordDestroy {
|
||||
|
||||
/**
|
||||
* 关键词结束标识
|
||||
@@ -46,4 +48,11 @@ public class WordDataTreeNode {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if(subNodeMap != null) {
|
||||
subNodeMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.github.houbb.sensitive.word.bs;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 资源的销毁
|
||||
*
|
||||
* @since 0.16.0
|
||||
*/
|
||||
public class SensitiveWordBsDestroyTest {
|
||||
|
||||
@Test
|
||||
public void destroyTest() {
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.init();
|
||||
// 后续因为一些原因移除了对应信息,希望释放内存。
|
||||
wordBs.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user