mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
release branch 0.0.14
This commit is contained in:
@@ -3,10 +3,11 @@ package com.github.houbb.sensitive.word.bs;
|
||||
import com.github.houbb.heaven.constant.CharConst;
|
||||
import com.github.houbb.heaven.util.common.ArgUtil;
|
||||
import com.github.houbb.heaven.util.util.CollectionUtil;
|
||||
import com.github.houbb.sensitive.word.api.*;
|
||||
import com.github.houbb.sensitive.word.exception.SensitiveWordException;
|
||||
import com.github.houbb.sensitive.word.api.IWordAllow;
|
||||
import com.github.houbb.sensitive.word.api.IWordContext;
|
||||
import com.github.houbb.sensitive.word.api.IWordDeny;
|
||||
import com.github.houbb.sensitive.word.api.IWordMap;
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.data.SensitiveWordData;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import com.github.houbb.sensitive.word.support.map.SensitiveWordMap;
|
||||
|
||||
@@ -156,6 +157,72 @@ public class SensitiveWordBs {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略大小写
|
||||
* @param ignoreCase 大小写
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreCase(boolean ignoreCase) {
|
||||
this.context.ignoreCase(ignoreCase);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略半角全角
|
||||
* @param ignoreWidth 半角全角
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreWidth(boolean ignoreWidth) {
|
||||
this.context.ignoreWidth(ignoreWidth);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略数字格式
|
||||
* @param ignoreNumStyle 数字格式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreNumStyle(boolean ignoreNumStyle) {
|
||||
this.context.ignoreNumStyle(ignoreNumStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略中文样式
|
||||
* @param ignoreChineseStyle 中文样式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreChineseStyle(boolean ignoreChineseStyle) {
|
||||
this.context.ignoreChineseStyle(ignoreChineseStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略英文样式
|
||||
* @param ignoreEnglishStyle 英文样式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreEnglishStyle(boolean ignoreEnglishStyle) {
|
||||
this.context.ignoreEnglishStyle(ignoreEnglishStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略重复
|
||||
* @param ignoreRepeat 忽略重复
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreRepeat(boolean ignoreRepeat) {
|
||||
this.context.ignoreRepeat(ignoreRepeat);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建默认的上下文
|
||||
*
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.github.houbb.sensitive.word.bs;
|
||||
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* <p> project: sensitive-word-SensitiveWordBsConfigTest </p>
|
||||
* <p> create on 2020/1/7 23:43 </p>
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public class SensitiveWordBsConfigTest {
|
||||
|
||||
@Test
|
||||
public void configTest() {
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.ignoreCase(true)
|
||||
.ignoreWidth(true)
|
||||
.ignoreNumStyle(true)
|
||||
.ignoreChineseStyle(true)
|
||||
.ignoreEnglishStyle(true)
|
||||
.ignoreRepeat(true)
|
||||
.init();
|
||||
|
||||
final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
|
||||
Assert.assertTrue(wordBs.contains(text));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user