Package org.aoju.bus.core.toolkit
Class TextKit
java.lang.Object
org.aoju.bus.core.toolkit.TextKit
- All Implemented Interfaces:
Serializable,Appendable,CharSequence
可复用的字符串生成器,非线程安全
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTextKit()构造TextKit(int initialCapacity) 构造TextKit(CharSequence... texts) 构造 -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) 追加一个字符append(char[] src) 追加一个字符数组append(char[] src, int srcPos, int length) 追加一个字符数组append(CharSequence csq) append(CharSequence csq, int start, int end) 追加对象,对象会被转换为字符串charcharAt(int index) clear()删除全部字符,位置归零static TextKitcreate(int initialCapacity) 创建字符串构建器static TextKitcreate(CharSequence... texts) 创建字符串构建器del(int start, int end) 删除指定长度的字符delTo(int newPosition) 删除到指定位置 如果新位置小于等于0,则删除全部getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 将指定段的字符列表写出到目标字符数组中boolean是否有内容insert(int index, char c) 插入指定字符insert(int index, char[] src) 指定位置插入数据 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格insert(int index, char[] src, int srcPos, int length) 指定位置插入数据 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格insert(int index, CharSequence csq) 指定位置插入字符串的某个部分 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格insert(int index, CharSequence csq, int start, int end) 指定位置插入字符串的某个部分 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格追加对象,对象会被转换为字符串booleanisEmpty()是否为空intlength()static TextKitof()创建字符串构建器reset()删除全部字符,位置归零static double计算相似度static String计算相似度百分比subSequence(int start, int end) subString(int start) 返回自定段的字符串subString(int start, int end) 返回自定段的字符串toString()生成字符串toString(boolean isReset) 生成字符串重置并返回生成的字符串Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints
-
Constructor Details
-
TextKit
public TextKit()构造 -
TextKit
public TextKit(int initialCapacity) 构造- Parameters:
initialCapacity- 初始容量
-
TextKit
-
-
Method Details
-
of
-
create
-
create
创建字符串构建器- Parameters:
texts- 初始字符串- Returns:
TextKit
-
similar
-
similar
-
append
-
append
追加一个字符- Specified by:
appendin interfaceAppendable- Parameters:
c- 字符- Returns:
- this
-
append
-
append
追加一个字符数组- Parameters:
src- 字符数组srcPos- 开始位置(包括)length- 长度- Returns:
- this
-
append
- Specified by:
appendin interfaceAppendable
-
append
- Specified by:
appendin interfaceAppendable
-
insert
-
insert
-
insert
指定位置插入数据 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格- Parameters:
index- 插入位置src- 源数组- Returns:
- this
-
insert
指定位置插入数据 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格- Parameters:
index- 插入位置src- 源数组srcPos- 位置length- 长度- Returns:
- this
-
insert
指定位置插入字符串的某个部分 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格- Parameters:
index- 位置csq- 字符串- Returns:
- this
-
insert
指定位置插入字符串的某个部分 如果插入位置为当前位置,则定义为追加 如果插入位置大于当前位置,则中间部分补充空格- Parameters:
index- 位置csq- 字符串start- 字符串开始位置(包括)end- 字符串结束位置(不包括)- Returns:
- this
-
getChars
将指定段的字符列表写出到目标字符数组中- Parameters:
srcBegin- 起始位置(包括)srcEnd- 结束位置(不包括)dst- 目标数组dstBegin- 目标起始位置(包括)- Returns:
- this
-
hasContent
public boolean hasContent()是否有内容- Returns:
- 是否有内容
-
isEmpty
-
clear
-
reset
-
delTo
删除到指定位置 如果新位置小于等于0,则删除全部- Parameters:
newPosition- 新的位置,不包括这个位置- Returns:
- this
-
del
删除指定长度的字符- Parameters:
start- 开始位置(包括)end- 结束位置(不包括)- Returns:
- this
-
toString
生成字符串- Parameters:
isReset- 是否重置,重置后相当于空的构建器- Returns:
- 生成的字符串
-
toStringAndReset
-
toString
生成字符串- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
subString
-
subString
返回自定段的字符串- Parameters:
start- 开始位置(包括)end- 结束位置(不包括)- Returns:
- this
-