类 TextStringBuilder
java.lang.Object
spring.turbo.util.TextStringBuilder
- 所有已实现的接口:
Serializable,Appendable,CharSequence
public final class TextStringBuilder
extends Object
implements Serializable, CharSequence, Appendable
- 从以下版本开始:
- 2.0.2
- 作者:
- 应卓
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器构造器说明默认构造方法TextStringBuilder(int initialCapacity) 构造方法TextStringBuilder(CharSequence string) 构造方法 -
方法概要
修饰符和类型方法说明append(boolean value) Appends a boolean value to the string builder.append(char ch) Appends a char value to the string builder.append(char[] chars) Appends a char array to the string builder.append(char[] chars, int startIndex, int length) Appends a char array to the string builder.append(double value) 追加append(float value) 追加append(int value) 追加append(long value) 追加append(CharSequence seq) 追加append(CharSequence seq, int startIndex, int endIndex) 追加追加追加append(StringBuffer str) 追加append(StringBuffer str, int startIndex, int length) 追加append(StringBuilder str) 追加append(StringBuilder str, int startIndex, int length) 追加追加append(CharBuffer str) 追加append(CharBuffer buf, int startIndex, int length) 追加append(TextStringBuilder str) 追加append(TextStringBuilder str, int startIndex, int length) 追加追加追加appendAll(T... array) 追加appendFixedWidthPadLeft(int value, int width, char padChar) 带左填充的追加appendFixedWidthPadLeft(Object obj, int width, char padChar) 带左填充的追加appendFixedWidthPadRight(int value, int width, char padChar) 带右填充的追加appendFixedWidthPadRight(Object obj, int width, char padChar) 带右填充的追加appendln(boolean value) 追加并追加一个新行appendln(char ch) 追加并追加一个新行appendln(char[] chars) 追加并追加一个新行appendln(char[] chars, int startIndex, int length) 追加并追加一个新行appendln(double value) 追加并追加一个新行appendln(float value) 追加并追加一个新行appendln(int value) 追加并追加一个新行appendln(long value) 追加并追加一个新行追加并追加一个新行追加并追加一个新行appendln(StringBuffer str) 追加并追加一个新行appendln(StringBuffer str, int startIndex, int length) 追加并追加一个新行appendln(StringBuilder str) 追加并追加一个新行appendln(StringBuilder str, int startIndex, int length) 追加并追加一个新行追加并追加一个新行追加并追加一个新行appendln(TextStringBuilder str, int startIndex, int length) 追加并追加一个新行追加并追加一个新行追加并追加一个控制appendPadding(int length, char padChar) 追加一个填充appendSeparator(char separator) 追加一个分隔符。appendSeparator(char standard, char defaultIfEmpty) 追加一个分隔符。appendSeparator(String separator) 追加一个分隔符。appendSeparator(String standard, String defaultIfEmpty) 追加一个分隔符。appendWithSeparators(Iterable<?> iterable, String separator) 追加多个元素并在其之中添加分隔符appendWithSeparators(Object[] array, String separator) 追加多个元素并在其之中添加分隔符appendWithSeparators(Iterator<?> it, String separator) 追加多个元素并在其之中添加分隔符转换成StringTokenizer对象build()构建字符串intcapacity()获取容量charcharAt(int index) clear()清空所有内容booleancontains(char ch) 判断是否包含指定的字符boolean判断是否包含指定的子串booleancontains(StringMatcher matcher) 判断是否包含指定的子串delete(int startIndex, int endIndex) 删除一部分deleteAll(char ch) 删除单个所有的固定字符删除单个所有的固定字符串deleteAll(StringMatcher matcher) 删除单个所有的固定字符串deleteCharAt(int index) 删除指定位置的字符deleteFirst(char ch) 删除首个出现的字符deleteFirst(String str) 删除首个出现的字符串deleteFirst(StringMatcher matcher) 删除首个出现的字符串boolean判断是否为指定的后缀ensureCapacity(int capacity) 确保容量不小于指定值booleanbooleanequals(TextStringBuilder other) 相等性测试boolean相等性测试 (大小写不敏感)获取空行文本获取空值文本inthashCode()intindexOf(char ch) 查找指定字符intindexOf(char ch, int startIndex) 查找指定字符int查找指定字符串int查找指定字符intindexOf(StringMatcher matcher) 查找指定字符串intindexOf(StringMatcher matcher, int startIndex) 查找指定字符串insert(int index, boolean value) 插入值insert(int index, char value) 插入值insert(int index, char[] chars) 插入值insert(int index, char[] chars, int offset, int length) 插入值insert(int index, double value) 插入值insert(int index, float value) 插入值insert(int index, int value) 插入值insert(int index, long value) 插入值插入值插入值booleanisEmpty()判断本创建器是否为空boolean判断本创建器是否不为空intlastIndexOf(char ch) 反向查找intlastIndexOf(char ch, int startIndex) 反向查找intlastIndexOf(String str) 反向查找intlastIndexOf(String str, int startIndex) 反向查找intlastIndexOf(StringMatcher matcher) 反向查找intlastIndexOf(StringMatcher matcher, int startIndex) 反向查找intlength()获取字符串长度最小化容量替换字符串replace(StringMatcher matcher, String replaceStr, int startIndex, int endIndex, int replaceCount) 替换字符串 (高级)replaceAll(char search, char replace) 替换所有的指定字符replaceAll(String searchStr, String replaceStr) 替换所有的指定字符串replaceAll(StringMatcher matcher, String replaceStr) 替换所有的指定字符串replaceFirst(char search, char replace) 替换首个指定字符replaceFirst(String searchStr, String replaceStr) 替换首个指定字符串replaceFirst(StringMatcher matcher, String replaceStr) 替换首个指定字符串reverse()反向set(CharSequence str) 重置字符串setCharAt(int index, char ch) 设置指定位置上的字符setNewLineText(String newLine) 设置新行字符串setNullText(String nullText) 设置空值字符串intsize()获取长度booleanstartsWith(String str) 判断是否为指定的字符串开始subSequence(int startIndex, int endIndex) substring(int start) 取子串substring(int startIndex, int endIndex) 取子串char[]转换成 char[]char[]toCharArray(int startIndex, int endIndex) 转换成 char[]toString()转换为StringBuffer转换为StringBuildertrim()消除两端的空白字符从接口继承的方法 java.lang.CharSequence
chars, codePoints
-
字段详细资料
-
CAPACITY
public static final int CAPACITY- 另请参阅:
-
-
构造器详细资料
-
TextStringBuilder
public TextStringBuilder()默认构造方法 -
TextStringBuilder
构造方法- 参数:
string- 初始化字符串
-
TextStringBuilder
public TextStringBuilder(int initialCapacity) 构造方法- 参数:
initialCapacity- 初始容量
-
-
方法详细资料
-
append
Appends a boolean value to the string builder.- 参数:
value- the value to append- 返回:
- this, to enable chaining
-
append
Appends a char value to the string builder.- 指定者:
append在接口中Appendable- 参数:
ch- the value to append- 返回:
- this, to enable chaining
-
append
Appends a char array to the string builder. Appending null will callappendNull().- 参数:
chars- the char array to append- 返回:
- this, to enable chaining
-
append
Appends a char array to the string builder. Appending null will callappendNull().- 参数:
chars- the char array to appendstartIndex- the start index, inclusive, must be validlength- the length to append, must be valid- 返回:
- this, to enable chaining
- 抛出:
StringIndexOutOfBoundsException- ifstartIndexis not in the range0 <= startIndex <= chars.lengthStringIndexOutOfBoundsException- iflength < 0StringIndexOutOfBoundsException- ifstartIndex + length > chars.length
-
append
追加- 参数:
str- 追加对象- 返回:
- this
-
append
追加- 参数:
buf- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
append
追加- 指定者:
append在接口中Appendable- 参数:
seq- 追加对象- 返回:
- this
-
append
追加- 指定者:
append在接口中Appendable- 参数:
seq- 追加对象startIndex- 初始位置endIndex- 结束位置- 返回:
- this
-
append
追加- 参数:
value- 追加对象- 返回:
- this
-
append
追加- 参数:
value- 追加对象- 返回:
- this
-
append
追加- 参数:
value- 追加对象- 返回:
- this
-
append
追加- 参数:
value- 追加对象- 返回:
- this
-
append
追加- 参数:
obj- 追加对象- 返回:
- this
-
append
追加- 参数:
str- 追加对象- 返回:
- this
-
append
追加- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
append
追加- 参数:
str- 追加对象- 返回:
- this
-
append
追加- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
append
追加- 参数:
str- 追加对象- 返回:
- this
-
append
追加- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
append
追加- 参数:
str- 追加对象- 返回:
- this
-
append
追加- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendAll
追加- 参数:
iterable- 追加对象(多个)- 返回:
- this
-
appendAll
追加- 参数:
it- 追加对象(多个)- 返回:
- this
-
appendAll
追加- 参数:
array- 追加对象(多个)- 返回:
- this
-
appendFixedWidthPadLeft
带左填充的追加- 参数:
value- 追加对象width- 固定宽度padChar- 填充字符- 返回:
- this
-
appendFixedWidthPadLeft
带左填充的追加- 参数:
obj- 追加对象width- 固定宽度padChar- 填充字符- 返回:
- this
-
appendFixedWidthPadRight
带右填充的追加- 参数:
value- 追加对象width- 固定宽度padChar- 填充字符- 返回:
- this
-
appendFixedWidthPadRight
带右填充的追加- 参数:
obj- 追加对象width- 固定宽度padChar- 填充字符- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
value- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
ch- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
chars- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
chars- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
value- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
value- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
value- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
value- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
obj- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象- 返回:
- this
-
appendln
追加并追加一个新行- 参数:
str- 追加对象startIndex- 初始位置length- 长度- 返回:
- this
-
appendNewLine
追加并追加一个新行- 返回:
- this
- 另请参阅:
-
appendNull
追加并追加一个控制- 返回:
- this
- 另请参阅:
-
appendPadding
追加一个填充- 参数:
length- 填充的长度padChar- 填充的字符- 返回:
- this
-
appendSeparator
追加一个分隔符。当TextStringBuilder是空的时候,本方法不会起作用。- 参数:
separator- 分隔符- 返回:
- this
-
appendSeparator
追加一个分隔符。 当TextStringBuilder是空的时候,追加 defaultIfEmpty,否则追加 standard。- 参数:
standard- 标准分隔符defaultIfEmpty-TextStringBuilder为空时使用的分隔符。- 返回:
- this
-
appendSeparator
追加一个分隔符。当TextStringBuilder是空的时候,本方法不会起作用。- 参数:
separator- 分隔符- 返回:
- this
-
appendSeparator
public TextStringBuilder appendSeparator(@Nullable String standard, @Nullable String defaultIfEmpty) 追加一个分隔符。 当TextStringBuilder是空的时候,追加 defaultIfEmpty,否则追加 standard。- 参数:
standard- 标准分隔符defaultIfEmpty-TextStringBuilder为空时使用的分隔符。- 返回:
- this
-
appendWithSeparators
public TextStringBuilder appendWithSeparators(@Nullable Iterable<?> iterable, @Nullable String separator) 追加多个元素并在其之中添加分隔符- 参数:
iterable- 多个元素separator- 分隔符,null时意味着没有分隔符。- 返回:
- this
-
appendWithSeparators
追加多个元素并在其之中添加分隔符- 参数:
it- 多个元素separator- 分隔符,null时意味着没有分隔符。- 返回:
- this
-
appendWithSeparators
追加多个元素并在其之中添加分隔符- 参数:
array- 多个元素separator- 分隔符,null时意味着没有分隔符。- 返回:
- this
-
asTokenizer
转换成StringTokenizer对象- 返回:
- 结果
-
build
构建字符串- 返回:
- 字符串
- 另请参阅:
-
capacity
public int capacity()获取容量- 返回:
- 容量
-
charAt
public char charAt(int index) - 指定者:
charAt在接口中CharSequence
-
clear
清空所有内容- 返回:
- this
-
contains
public boolean contains(char ch) 判断是否包含指定的字符- 参数:
ch- 待查找的字符- 返回:
- 结果
-
contains
判断是否包含指定的子串- 参数:
str- 待查找的子串- 返回:
- 结果
-
contains
判断是否包含指定的子串- 参数:
matcher- 匹配器- 返回:
- 结果
-
delete
删除一部分- 参数:
startIndex- 开始位置 (包含)endIndex- 结束位置 (不包含)- 返回:
- this
-
deleteAll
删除单个所有的固定字符- 参数:
ch- 待删除的字符- 返回:
- this
-
deleteAll
删除单个所有的固定字符串- 参数:
str- 待删除的字符串- 返回:
- this
-
deleteAll
删除单个所有的固定字符串- 参数:
matcher- 字符串匹配器- 返回:
- this
-
deleteCharAt
删除指定位置的字符- 参数:
index- 位置- 返回:
- this
- 另请参阅:
-
deleteFirst
删除首个出现的字符- 参数:
ch- 待删除的字符- 返回:
- this
-
deleteFirst
删除首个出现的字符串- 参数:
str- 待删除的字符串- 返回:
- this
-
deleteFirst
删除首个出现的字符串- 参数:
matcher- 待删除的字符串匹配器- 返回:
- this
-
endsWith
判断是否为指定的后缀- 参数:
str- 待测试的后缀- 返回:
- 结果
-
ensureCapacity
确保容量不小于指定值- 参数:
capacity- 容量指定值- 返回:
- this
-
equals
-
equals
相等性测试- 参数:
other- 右值- 返回:
- 结果
-
equalsIgnoreCase
相等性测试 (大小写不敏感)- 参数:
other- 右值- 返回:
- 结果
-
getNewLineText
获取空行文本- 返回:
- 结果
-
setNewLineText
设置新行字符串- 参数:
newLine- 新行字符串- 返回:
- this
-
getNullText
获取空值文本- 返回:
- 结果
-
setNullText
设置空值字符串- 参数:
nullText- 空值字符串- 返回:
- this
-
hashCode
public int hashCode() -
indexOf
public int indexOf(char ch) 查找指定字符- 参数:
ch- 待查找的字符- 返回:
- 第一次出现的位置,找不到时返回 -1
-
indexOf
public int indexOf(char ch, int startIndex) 查找指定字符- 参数:
ch- 待查找的字符startIndex- 查找起点- 返回:
- 第一次出现的位置,找不到时返回 -1
-
indexOf
查找指定字符串- 参数:
str- 待查找的字符- 返回:
- 第一次出现的位置,找不到时返回 -1
-
indexOf
查找指定字符- 参数:
str- 待查找的字符startIndex- 查找起点- 返回:
- 第一次出现的位置,找不到时返回 -1
-
indexOf
查找指定字符串- 参数:
matcher- 待查找的字符匹配器- 返回:
- 第一次出现的位置,找不到时返回 -1
-
indexOf
查找指定字符串- 参数:
matcher- 待查找的字符匹配器startIndex- 查找起点- 返回:
- 第一次出现的位置,找不到时返回 -1
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置chars- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置chars- 值offset- 偏移量length- 长度- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置value- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置obj- 值- 返回:
- this
-
insert
插入值- 参数:
index- 插入位置str- 值- 返回:
- this
-
isEmpty
public boolean isEmpty()判断本创建器是否为空- 指定者:
isEmpty在接口中CharSequence- 返回:
- 结果
-
isNotEmpty
public boolean isNotEmpty()判断本创建器是否不为空- 返回:
- 结果
-
lastIndexOf
public int lastIndexOf(char ch) 反向查找- 参数:
ch- 待查找的东西- 返回:
- 索引或-1
-
lastIndexOf
public int lastIndexOf(char ch, int startIndex) 反向查找- 参数:
ch- 待查找的东西startIndex- 查找起点- 返回:
- 索引或-1
-
lastIndexOf
反向查找- 参数:
str- 待查找的东西- 返回:
- 索引或-1
-
lastIndexOf
反向查找- 参数:
str- 待查找的东西startIndex- 查找起点- 返回:
- 索引或-1
-
lastIndexOf
反向查找- 参数:
matcher- 待查找的东西- 返回:
- 索引或-1
-
lastIndexOf
反向查找- 参数:
matcher- 待查找的东西startIndex- 查找起点- 返回:
- 索引或-1
-
length
public int length()获取字符串长度- 指定者:
length在接口中CharSequence- 返回:
- 长度
-
minimizeCapacity
最小化容量- 返回:
- this
-
replace
替换字符串- 参数:
startIndex- 替换开始位置 (包含)endIndex- 替换结束位置 (不包含)replaceStr- 替换字符串- 返回:
- this
-
replace
public TextStringBuilder replace(StringMatcher matcher, String replaceStr, int startIndex, int endIndex, int replaceCount) 替换字符串 (高级)- 参数:
matcher- 需要替换的部分字符串匹配器replaceStr- 要替换的字符串startIndex- 要替换的字符串开始位置 (包含)endIndex- 要替换的字符串结束位置 (不包含)replaceCount- 查找并替换的次数, -1 为不限次数- 返回:
- this
-
replaceAll
替换所有的指定字符- 参数:
search- 查找字符replace- 替换字符- 返回:
- this
-
replaceAll
替换所有的指定字符串- 参数:
searchStr- 查找字符串replaceStr- 替换字符串- 返回:
- this
-
replaceAll
替换所有的指定字符串- 参数:
matcher- 查找字符串匹配器replaceStr- 替换字符串- 返回:
- this
-
replaceFirst
替换首个指定字符- 参数:
search- 查找字符replace- 替换字符- 返回:
- this
-
replaceFirst
替换首个指定字符串- 参数:
searchStr- 查找字符replaceStr- 替换字符- 返回:
- this
-
replaceFirst
替换首个指定字符串- 参数:
matcher- 查找字符匹配器replaceStr- 替换字符- 返回:
- this
-
reverse
反向- 返回:
- this
-
set
重置字符串- 参数:
str- 要重置的字符串- 返回:
- this
-
setCharAt
设置指定位置上的字符- 参数:
index- 位置ch- 要设置的字符- 返回:
- this
-
size
public int size()获取长度- 返回:
- 长度
-
startsWith
判断是否为指定的字符串开始- 参数:
str- 待测试的前缀- 返回:
- 结果
-
substring
取子串- 参数:
start- 开始位置- 返回:
- 结果
-
substring
取子串- 参数:
startIndex- 开始位置 (包含)endIndex- 结束位置 (不包含)- 返回:
- 结果
-
subSequence
- 指定者:
subSequence在接口中CharSequence
-
toCharArray
public char[] toCharArray()转换成 char[]- 返回:
- 结果
-
toCharArray
public char[] toCharArray(int startIndex, int endIndex) 转换成 char[]- 参数:
startIndex- 开始位置 (包含)endIndex- 结束位置 (不包含)- 返回:
- 结果
-
toString
- 指定者:
toString在接口中CharSequence- 覆盖:
toString在类中Object
-
toStringBuffer
转换为StringBuffer- 返回:
- 结果
-
toStringBuilder
转换为StringBuilder- 返回:
- 结果
-
trim
消除两端的空白字符- 返回:
- this
-