mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
98e3b9cfc5
commit
5819892842
0
hutool-core/src/main/java/cn/hutool/core/lang/func/Replacer.java
Executable file → Normal file
0
hutool-core/src/main/java/cn/hutool/core/lang/func/Replacer.java
Executable file → Normal file
@ -1,6 +1,8 @@
|
||||
package cn.hutool.core.text;
|
||||
|
||||
|
||||
import cn.hutool.core.text.split.SplitUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -422,7 +424,7 @@ public class AntPathMatcher {
|
||||
* @return the tokenized path parts
|
||||
*/
|
||||
protected String[] tokenizePath(String path) {
|
||||
return StrSplitter.splitToArray(path, this.pathSeparator, 0, this.trimTokens, true);
|
||||
return SplitUtil.splitToArray(path, this.pathSeparator, 0, this.trimTokens, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.text.finder.CharFinder;
|
||||
import cn.hutool.core.text.finder.Finder;
|
||||
import cn.hutool.core.text.finder.StrFinder;
|
||||
import cn.hutool.core.text.split.SplitUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
@ -1691,7 +1692,7 @@ public class CharSequenceUtil {
|
||||
return new String[]{};
|
||||
}
|
||||
|
||||
return StrSplitter.splitToArray(str.toString(), str(separator), 0, false, false);
|
||||
return SplitUtil.splitToArray(str.toString(), str(separator), 0, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1715,7 +1716,7 @@ public class CharSequenceUtil {
|
||||
*/
|
||||
public static String[] splitToArray(CharSequence text, char separator, int limit) {
|
||||
Assert.notNull(text, "Text must be not null!");
|
||||
return StrSplitter.splitToArray(text.toString(), separator, limit, false, false);
|
||||
return SplitUtil.splitToArray(text.toString(), separator, limit, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1806,7 +1807,7 @@ public class CharSequenceUtil {
|
||||
* @since 3.0.8
|
||||
*/
|
||||
public static List<String> split(CharSequence str, char separator, int limit, boolean isTrim, boolean ignoreEmpty) {
|
||||
return StrSplitter.split(str, separator, limit, isTrim, ignoreEmpty);
|
||||
return SplitUtil.split(str, separator, limit, isTrim, ignoreEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1822,7 +1823,7 @@ public class CharSequenceUtil {
|
||||
* @since 5.7.14
|
||||
*/
|
||||
public static <R> List<R> split(CharSequence str, char separator, int limit, boolean ignoreEmpty, Function<String, R> mapping) {
|
||||
return StrSplitter.split(str, separator, limit, ignoreEmpty, mapping);
|
||||
return SplitUtil.split(str, separator, limit, ignoreEmpty, mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1864,7 +1865,7 @@ public class CharSequenceUtil {
|
||||
*/
|
||||
public static List<String> split(CharSequence str, CharSequence separator, int limit, boolean isTrim, boolean ignoreEmpty) {
|
||||
final String separatorStr = (null == separator) ? null : separator.toString();
|
||||
return StrSplitter.split(str, separatorStr, limit, isTrim, ignoreEmpty);
|
||||
return SplitUtil.split(str, separatorStr, limit, isTrim, ignoreEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1873,10 +1874,10 @@ public class CharSequenceUtil {
|
||||
* @param str 字符串
|
||||
* @param len 每一个小节的长度
|
||||
* @return 截取后的字符串数组
|
||||
* @see StrSplitter#splitByLength(CharSequence, int)
|
||||
* @see SplitUtil#splitByLength(CharSequence, int)
|
||||
*/
|
||||
public static String[] splitToArray(CharSequence str, int len) {
|
||||
return StrSplitter.splitByLength(str, len);
|
||||
return SplitUtil.splitByLength(str, len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@ package cn.hutool.core.text;
|
||||
|
||||
/**
|
||||
* 检测密码强度<br>
|
||||
* 来自:https://github.com/venshine/CheckPasswordStrength
|
||||
* 来自:<a href="https://github.com/venshine/CheckPasswordStrength">https://github.com/venshine/CheckPasswordStrength</a>
|
||||
*
|
||||
* @author venshine
|
||||
* @since 5.7.3
|
||||
|
@ -13,7 +13,7 @@ import java.util.concurrent.locks.StampedLock;
|
||||
/**
|
||||
* <p>
|
||||
* Simhash是一种局部敏感hash,用于海量文本去重。<br>
|
||||
* 算法实现来自:https://github.com/xlturing/Simhash4J
|
||||
* 算法实现来自:<a href="https://github.com/xlturing/Simhash4J">https://github.com/xlturing/Simhash4J</a>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
|
@ -1,12 +1,12 @@
|
||||
package cn.hutool.core.text;
|
||||
package cn.hutool.core.text.split;
|
||||
|
||||
import cn.hutool.core.regex.PatternPool;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.text.finder.CharFinder;
|
||||
import cn.hutool.core.text.finder.CharMatcherFinder;
|
||||
import cn.hutool.core.text.finder.LengthFinder;
|
||||
import cn.hutool.core.text.finder.PatternFinder;
|
||||
import cn.hutool.core.text.finder.StrFinder;
|
||||
import cn.hutool.core.text.split.SplitIter;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -19,7 +19,7 @@ import java.util.regex.Pattern;
|
||||
* @author Looly
|
||||
* @since 5.7.0
|
||||
*/
|
||||
public class StrSplitter {
|
||||
public class SplitUtil {
|
||||
|
||||
//---------------------------------------------------------------------------------------------- Split by char
|
||||
|
@ -1,13 +1,12 @@
|
||||
package cn.hutool.core.text.split;
|
||||
|
||||
import cn.hutool.core.text.StrSplitter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link StrSplitter} 单元测试
|
||||
* {@link SplitUtil} 单元测试
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
@ -16,7 +15,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitByCharTest(){
|
||||
String str1 = "a, ,efedsfs, ddf";
|
||||
List<String> split = StrSplitter.split(str1, ',', 0, true, true);
|
||||
List<String> split = SplitUtil.split(str1, ',', 0, true, true);
|
||||
|
||||
Assert.assertEquals("ddf", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
@ -25,7 +24,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitByStrTest(){
|
||||
String str1 = "aabbccaaddaaee";
|
||||
List<String> split = StrSplitter.split(str1, "aa", 0, true, true);
|
||||
List<String> split = SplitUtil.split(str1, "aa", 0, true, true);
|
||||
Assert.assertEquals("ee", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
@ -33,7 +32,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitByBlankTest(){
|
||||
String str1 = "aa bbccaa ddaaee";
|
||||
List<String> split = StrSplitter.split(str1, 0);
|
||||
List<String> split = SplitUtil.split(str1, 0);
|
||||
Assert.assertEquals("ddaaee", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
@ -41,7 +40,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitPathTest(){
|
||||
String str1 = "/use/local/bin";
|
||||
List<String> split = StrSplitter.splitPath(str1, 0);
|
||||
List<String> split = SplitUtil.splitPath(str1, 0);
|
||||
Assert.assertEquals("bin", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
@ -49,7 +48,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitMappingTest() {
|
||||
String str = "1.2.";
|
||||
List<Long> split = StrSplitter.split(str, '.', 0, true, true, Long::parseLong);
|
||||
List<Long> split = SplitUtil.split(str, '.', 0, true, true, Long::parseLong);
|
||||
Assert.assertEquals(2, split.size());
|
||||
Assert.assertEquals(Long.valueOf(1L), split.get(0));
|
||||
Assert.assertEquals(Long.valueOf(2L), split.get(1));
|
||||
@ -59,7 +58,7 @@ public class StrSplitterTest {
|
||||
public void splitEmptyTest(){
|
||||
String str = "";
|
||||
final String[] split = str.split(",");
|
||||
final String[] strings = StrSplitter.splitToArray(str, ",", -1, false, false);
|
||||
final String[] strings = SplitUtil.splitToArray(str, ",", -1, false, false);
|
||||
Assert.assertNotNull(strings);
|
||||
Assert.assertArrayEquals(split, strings);
|
||||
}
|
||||
@ -67,7 +66,7 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitNullTest(){
|
||||
String str = null;
|
||||
final String[] strings = StrSplitter.splitToArray(str, ",", -1, false, false);
|
||||
final String[] strings = SplitUtil.splitToArray(str, ",", -1, false, false);
|
||||
Assert.assertNotNull(strings);
|
||||
Assert.assertEquals(0, strings.length);
|
||||
}
|
||||
@ -78,12 +77,12 @@ public class StrSplitterTest {
|
||||
@Test
|
||||
public void splitByRegexTest(){
|
||||
String text = "01 821 34567890182345617821";
|
||||
List<String> strings = StrSplitter.splitByRegex(text, "21", 0, false, true);
|
||||
List<String> strings = SplitUtil.splitByRegex(text, "21", 0, false, true);
|
||||
Assert.assertEquals(2, strings.size());
|
||||
Assert.assertEquals("01 8", strings.get(0));
|
||||
Assert.assertEquals(" 345678901823456178", strings.get(1));
|
||||
|
||||
strings = StrSplitter.splitByRegex(text, "21", 0, false, false);
|
||||
strings = SplitUtil.splitByRegex(text, "21", 0, false, false);
|
||||
Assert.assertEquals(3, strings.size());
|
||||
Assert.assertEquals("01 8", strings.get(0));
|
||||
Assert.assertEquals(" 345678901823456178", strings.get(1));
|
||||
|
@ -101,7 +101,7 @@ public class ClassUtilTest {
|
||||
public void getShortClassNameTest() {
|
||||
String className = "cn.hutool.core.text.StrUtil";
|
||||
String result = ClassUtil.getShortClassName(className);
|
||||
Assert.assertEquals("c.h.c.u.StrUtil", result);
|
||||
Assert.assertEquals("c.h.c.t.StrUtil", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2,7 +2,7 @@ package cn.hutool.db.sql;
|
||||
|
||||
import cn.hutool.core.clone.CloneSupport;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.StrSplitter;
|
||||
import cn.hutool.core.text.split.SplitUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
@ -503,7 +503,7 @@ public class Condition extends CloneSupport<Condition> {
|
||||
|
||||
// 处理BETWEEN x AND y
|
||||
if (OPERATOR_BETWEEN.equals(firstPart)) {
|
||||
final List<String> betweenValueStrs = StrSplitter.splitTrimIgnoreCase(strs.get(1), LogicalOperator.AND.toString(), 2, true);
|
||||
final List<String> betweenValueStrs = SplitUtil.splitTrimIgnoreCase(strs.get(1), LogicalOperator.AND.toString(), 2, true);
|
||||
if (betweenValueStrs.size() < 2) {
|
||||
// 必须满足a AND b格式,不满足被当作普通值
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user