类 TextStringBuilder

java.lang.Object
spring.turbo.util.TextStringBuilder
所有已实现的接口:
Serializable, Appendable, CharSequence

public final class TextStringBuilder extends Object implements Serializable, CharSequence, Appendable
增强型 String 创建器。功能比 StringBufferStringBuilder更强大。
从以下版本开始:
2.0.2
作者:
应卓
另请参阅:
  • 字段详细资料

    • CAPACITY

      public static final int CAPACITY
      另请参阅:
  • 构造器详细资料

    • TextStringBuilder

      public TextStringBuilder()
      默认构造方法
    • TextStringBuilder

      public TextStringBuilder(@Nullable CharSequence string)
      构造方法
      参数:
      string - 初始化字符串
    • TextStringBuilder

      public TextStringBuilder(int initialCapacity)
      构造方法
      参数:
      initialCapacity - 初始容量
  • 方法详细资料

    • append

      public TextStringBuilder append(boolean value)
      Appends a boolean value to the string builder.
      参数:
      value - the value to append
      返回:
      this, to enable chaining
    • append

      public TextStringBuilder append(char ch)
      Appends a char value to the string builder.
      指定者:
      append 在接口中 Appendable
      参数:
      ch - the value to append
      返回:
      this, to enable chaining
    • append

      public TextStringBuilder append(@Nullable char[] chars)
      Appends a char array to the string builder. Appending null will call appendNull().
      参数:
      chars - the char array to append
      返回:
      this, to enable chaining
    • append

      public TextStringBuilder append(@Nullable char[] chars, int startIndex, int length)
      Appends a char array to the string builder. Appending null will call appendNull().
      参数:
      chars - the char array to append
      startIndex - the start index, inclusive, must be valid
      length - the length to append, must be valid
      返回:
      this, to enable chaining
      抛出:
      StringIndexOutOfBoundsException - if startIndex is not in the range 0 <= startIndex <= chars.length
      StringIndexOutOfBoundsException - if length < 0
      StringIndexOutOfBoundsException - if startIndex + length > chars.length
    • append

      public TextStringBuilder append(@Nullable CharBuffer str)
      追加
      参数:
      str - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable CharBuffer buf, int startIndex, int length)
      追加
      参数:
      buf - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable CharSequence seq)
      追加
      指定者:
      append 在接口中 Appendable
      参数:
      seq - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable CharSequence seq, int startIndex, int endIndex)
      追加
      指定者:
      append 在接口中 Appendable
      参数:
      seq - 追加对象
      startIndex - 初始位置
      endIndex - 结束位置
      返回:
      this
    • append

      public TextStringBuilder append(double value)
      追加
      参数:
      value - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(float value)
      追加
      参数:
      value - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(int value)
      追加
      参数:
      value - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(long value)
      追加
      参数:
      value - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable Object obj)
      追加
      参数:
      obj - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable String str)
      追加
      参数:
      str - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable String str, int startIndex, int length)
      追加
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable StringBuffer str)
      追加
      参数:
      str - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable StringBuffer str, int startIndex, int length)
      追加
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable StringBuilder str)
      追加
      参数:
      str - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable StringBuilder str, int startIndex, int length)
      追加
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable TextStringBuilder str)
      追加
      参数:
      str - 追加对象
      返回:
      this
    • append

      public TextStringBuilder append(@Nullable TextStringBuilder str, int startIndex, int length)
      追加
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendAll

      public TextStringBuilder appendAll(@Nullable Iterable<?> iterable)
      追加
      参数:
      iterable - 追加对象(多个)
      返回:
      this
    • appendAll

      public TextStringBuilder appendAll(@Nullable Iterator<?> it)
      追加
      参数:
      it - 追加对象(多个)
      返回:
      this
    • appendAll

      public <T> TextStringBuilder appendAll(@Nullable T... array)
      追加
      参数:
      array - 追加对象(多个)
      返回:
      this
    • appendFixedWidthPadLeft

      public TextStringBuilder appendFixedWidthPadLeft(int value, int width, char padChar)
      带左填充的追加
      参数:
      value - 追加对象
      width - 固定宽度
      padChar - 填充字符
      返回:
      this
    • appendFixedWidthPadLeft

      public TextStringBuilder appendFixedWidthPadLeft(@Nullable Object obj, int width, char padChar)
      带左填充的追加
      参数:
      obj - 追加对象
      width - 固定宽度
      padChar - 填充字符
      返回:
      this
    • appendFixedWidthPadRight

      public TextStringBuilder appendFixedWidthPadRight(int value, int width, char padChar)
      带右填充的追加
      参数:
      value - 追加对象
      width - 固定宽度
      padChar - 填充字符
      返回:
      this
    • appendFixedWidthPadRight

      public TextStringBuilder appendFixedWidthPadRight(@Nullable Object obj, int width, char padChar)
      带右填充的追加
      参数:
      obj - 追加对象
      width - 固定宽度
      padChar - 填充字符
      返回:
      this
    • appendln

      public TextStringBuilder appendln(boolean value)
      追加并追加一个新行
      参数:
      value - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(char ch)
      追加并追加一个新行
      参数:
      ch - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable char[] chars)
      追加并追加一个新行
      参数:
      chars - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(char[] chars, int startIndex, int length)
      追加并追加一个新行
      参数:
      chars - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendln

      public TextStringBuilder appendln(double value)
      追加并追加一个新行
      参数:
      value - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(float value)
      追加并追加一个新行
      参数:
      value - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(int value)
      追加并追加一个新行
      参数:
      value - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(long value)
      追加并追加一个新行
      参数:
      value - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable Object obj)
      追加并追加一个新行
      参数:
      obj - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable String str)
      追加并追加一个新行
      参数:
      str - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable String str, int startIndex, int length)
      追加并追加一个新行
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable StringBuffer str)
      追加并追加一个新行
      参数:
      str - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable StringBuffer str, int startIndex, int length)
      追加并追加一个新行
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendln

      public TextStringBuilder appendln(@Nullable StringBuilder str)
      追加并追加一个新行
      参数:
      str - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(StringBuilder str, int startIndex, int length)
      追加并追加一个新行
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendln

      public TextStringBuilder appendln(TextStringBuilder str)
      追加并追加一个新行
      参数:
      str - 追加对象
      返回:
      this
    • appendln

      public TextStringBuilder appendln(TextStringBuilder str, int startIndex, int length)
      追加并追加一个新行
      参数:
      str - 追加对象
      startIndex - 初始位置
      length - 长度
      返回:
      this
    • appendNewLine

      public TextStringBuilder appendNewLine()
      追加并追加一个新行
      返回:
      this
      另请参阅:
    • appendNull

      public TextStringBuilder appendNull()
      追加并追加一个控制
      返回:
      this
      另请参阅:
    • appendPadding

      public TextStringBuilder appendPadding(int length, char padChar)
      追加一个填充
      参数:
      length - 填充的长度
      padChar - 填充的字符
      返回:
      this
    • appendSeparator

      public TextStringBuilder appendSeparator(char separator)
      追加一个分隔符。当 TextStringBuilder是空的时候,本方法不会起作用。
      参数:
      separator - 分隔符
      返回:
      this
    • appendSeparator

      public TextStringBuilder appendSeparator(char standard, char defaultIfEmpty)
      追加一个分隔符。 当 TextStringBuilder是空的时候,追加 defaultIfEmpty,否则追加 standard。
      参数:
      standard - 标准分隔符
      defaultIfEmpty - TextStringBuilder 为空时使用的分隔符。
      返回:
      this
    • appendSeparator

      public TextStringBuilder appendSeparator(String separator)
      追加一个分隔符。当 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

      public TextStringBuilder appendWithSeparators(@Nullable Iterator<?> it, @Nullable String separator)
      追加多个元素并在其之中添加分隔符
      参数:
      it - 多个元素
      separator - 分隔符,null 时意味着没有分隔符。
      返回:
      this
    • appendWithSeparators

      public TextStringBuilder appendWithSeparators(@Nullable Object[] array, @Nullable String separator)
      追加多个元素并在其之中添加分隔符
      参数:
      array - 多个元素
      separator - 分隔符,null 时意味着没有分隔符。
      返回:
      this
    • asTokenizer

      public StringTokenizer asTokenizer()
      转换成 StringTokenizer 对象
      返回:
      结果
    • build

      public String build()
      构建字符串
      返回:
      字符串
      另请参阅:
    • capacity

      public int capacity()
      获取容量
      返回:
      容量
    • charAt

      public char charAt(int index)
      指定者:
      charAt 在接口中 CharSequence
    • clear

      public TextStringBuilder clear()
      清空所有内容
      返回:
      this
    • contains

      public boolean contains(char ch)
      判断是否包含指定的字符
      参数:
      ch - 待查找的字符
      返回:
      结果
    • contains

      public boolean contains(String str)
      判断是否包含指定的子串
      参数:
      str - 待查找的子串
      返回:
      结果
    • contains

      public boolean contains(StringMatcher matcher)
      判断是否包含指定的子串
      参数:
      matcher - 匹配器
      返回:
      结果
    • delete

      public TextStringBuilder delete(int startIndex, int endIndex)
      删除一部分
      参数:
      startIndex - 开始位置 (包含)
      endIndex - 结束位置 (不包含)
      返回:
      this
    • deleteAll

      public TextStringBuilder deleteAll(char ch)
      删除单个所有的固定字符
      参数:
      ch - 待删除的字符
      返回:
      this
    • deleteAll

      public TextStringBuilder deleteAll(@Nullable String str)
      删除单个所有的固定字符串
      参数:
      str - 待删除的字符串
      返回:
      this
    • deleteAll

      public TextStringBuilder deleteAll(StringMatcher matcher)
      删除单个所有的固定字符串
      参数:
      matcher - 字符串匹配器
      返回:
      this
    • deleteCharAt

      public TextStringBuilder deleteCharAt(int index)
      删除指定位置的字符
      参数:
      index - 位置
      返回:
      this
      另请参阅:
    • deleteFirst

      public TextStringBuilder deleteFirst(char ch)
      删除首个出现的字符
      参数:
      ch - 待删除的字符
      返回:
      this
    • deleteFirst

      public TextStringBuilder deleteFirst(@Nullable String str)
      删除首个出现的字符串
      参数:
      str - 待删除的字符串
      返回:
      this
    • deleteFirst

      public TextStringBuilder deleteFirst(StringMatcher matcher)
      删除首个出现的字符串
      参数:
      matcher - 待删除的字符串匹配器
      返回:
      this
    • endsWith

      public boolean endsWith(String str)
      判断是否为指定的后缀
      参数:
      str - 待测试的后缀
      返回:
      结果
    • ensureCapacity

      public TextStringBuilder ensureCapacity(int capacity)
      确保容量不小于指定值
      参数:
      capacity - 容量指定值
      返回:
      this
    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • equals

      public boolean equals(@Nullable TextStringBuilder other)
      相等性测试
      参数:
      other - 右值
      返回:
      结果
    • equalsIgnoreCase

      public boolean equalsIgnoreCase(@Nullable TextStringBuilder other)
      相等性测试 (大小写不敏感)
      参数:
      other - 右值
      返回:
      结果
    • getNewLineText

      @Nullable public String getNewLineText()
      获取空行文本
      返回:
      结果
    • setNewLineText

      public TextStringBuilder setNewLineText(@Nullable String newLine)
      设置新行字符串
      参数:
      newLine - 新行字符串
      返回:
      this
    • getNullText

      @Nullable public String getNullText()
      获取空值文本
      返回:
      结果
    • setNullText

      public TextStringBuilder setNullText(@Nullable String nullText)
      设置空值字符串
      参数:
      nullText - 空值字符串
      返回:
      this
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • indexOf

      public int indexOf(char ch)
      查找指定字符
      参数:
      ch - 待查找的字符
      返回:
      第一次出现的位置,找不到时返回 -1
    • indexOf

      public int indexOf(char ch, int startIndex)
      查找指定字符
      参数:
      ch - 待查找的字符
      startIndex - 查找起点
      返回:
      第一次出现的位置,找不到时返回 -1
    • indexOf

      public int indexOf(@Nullable String str)
      查找指定字符串
      参数:
      str - 待查找的字符
      返回:
      第一次出现的位置,找不到时返回 -1
    • indexOf

      public int indexOf(@Nullable String str, int startIndex)
      查找指定字符
      参数:
      str - 待查找的字符
      startIndex - 查找起点
      返回:
      第一次出现的位置,找不到时返回 -1
    • indexOf

      public int indexOf(@Nullable StringMatcher matcher)
      查找指定字符串
      参数:
      matcher - 待查找的字符匹配器
      返回:
      第一次出现的位置,找不到时返回 -1
    • indexOf

      public int indexOf(@Nullable StringMatcher matcher, int startIndex)
      查找指定字符串
      参数:
      matcher - 待查找的字符匹配器
      startIndex - 查找起点
      返回:
      第一次出现的位置,找不到时返回 -1
    • insert

      public TextStringBuilder insert(int index, boolean value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, char value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, @Nullable char[] chars)
      插入值
      参数:
      index - 插入位置
      chars - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, @Nullable char[] chars, int offset, int length)
      插入值
      参数:
      index - 插入位置
      chars - 值
      offset - 偏移量
      length - 长度
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, double value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, float value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, int value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, long value)
      插入值
      参数:
      index - 插入位置
      value - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, @Nullable Object obj)
      插入值
      参数:
      index - 插入位置
      obj - 值
      返回:
      this
    • insert

      public TextStringBuilder insert(int index, @Nullable String str)
      插入值
      参数:
      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

      public int lastIndexOf(@Nullable String str)
      反向查找
      参数:
      str - 待查找的东西
      返回:
      索引或-1
    • lastIndexOf

      public int lastIndexOf(@Nullable String str, int startIndex)
      反向查找
      参数:
      str - 待查找的东西
      startIndex - 查找起点
      返回:
      索引或-1
    • lastIndexOf

      public int lastIndexOf(StringMatcher matcher)
      反向查找
      参数:
      matcher - 待查找的东西
      返回:
      索引或-1
    • lastIndexOf

      public int lastIndexOf(StringMatcher matcher, int startIndex)
      反向查找
      参数:
      matcher - 待查找的东西
      startIndex - 查找起点
      返回:
      索引或-1
    • length

      public int length()
      获取字符串长度
      指定者:
      length 在接口中 CharSequence
      返回:
      长度
    • minimizeCapacity

      public TextStringBuilder minimizeCapacity()
      最小化容量
      返回:
      this
    • replace

      public TextStringBuilder replace(int startIndex, int endIndex, String replaceStr)
      替换字符串
      参数:
      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

      public TextStringBuilder replaceAll(char search, char replace)
      替换所有的指定字符
      参数:
      search - 查找字符
      replace - 替换字符
      返回:
      this
    • replaceAll

      public TextStringBuilder replaceAll(@Nullable String searchStr, String replaceStr)
      替换所有的指定字符串
      参数:
      searchStr - 查找字符串
      replaceStr - 替换字符串
      返回:
      this
    • replaceAll

      public TextStringBuilder replaceAll(StringMatcher matcher, String replaceStr)
      替换所有的指定字符串
      参数:
      matcher - 查找字符串匹配器
      replaceStr - 替换字符串
      返回:
      this
    • replaceFirst

      public TextStringBuilder replaceFirst(char search, char replace)
      替换首个指定字符
      参数:
      search - 查找字符
      replace - 替换字符
      返回:
      this
    • replaceFirst

      public TextStringBuilder replaceFirst(String searchStr, String replaceStr)
      替换首个指定字符串
      参数:
      searchStr - 查找字符
      replaceStr - 替换字符
      返回:
      this
    • replaceFirst

      public TextStringBuilder replaceFirst(StringMatcher matcher, String replaceStr)
      替换首个指定字符串
      参数:
      matcher - 查找字符匹配器
      replaceStr - 替换字符
      返回:
      this
    • reverse

      public TextStringBuilder reverse()
      反向
      返回:
      this
    • set

      public TextStringBuilder set(CharSequence str)
      重置字符串
      参数:
      str - 要重置的字符串
      返回:
      this
    • setCharAt

      public TextStringBuilder setCharAt(int index, char ch)
      设置指定位置上的字符
      参数:
      index - 位置
      ch - 要设置的字符
      返回:
      this
    • size

      public int size()
      获取长度
      返回:
      长度
    • startsWith

      public boolean startsWith(String str)
      判断是否为指定的字符串开始
      参数:
      str - 待测试的前缀
      返回:
      结果
    • substring

      public String substring(int start)
      取子串
      参数:
      start - 开始位置
      返回:
      结果
    • substring

      public String substring(int startIndex, int endIndex)
      取子串
      参数:
      startIndex - 开始位置 (包含)
      endIndex - 结束位置 (不包含)
      返回:
      结果
    • subSequence

      public CharSequence subSequence(int startIndex, int endIndex)
      指定者:
      subSequence 在接口中 CharSequence
    • toCharArray

      public char[] toCharArray()
      转换成 char[]
      返回:
      结果
    • toCharArray

      public char[] toCharArray(int startIndex, int endIndex)
      转换成 char[]
      参数:
      startIndex - 开始位置 (包含)
      endIndex - 结束位置 (不包含)
      返回:
      结果
    • toString

      public String toString()
      指定者:
      toString 在接口中 CharSequence
      覆盖:
      toString 在类中 Object
    • toStringBuffer

      public StringBuffer toStringBuffer()
      转换为 StringBuffer
      返回:
      结果
    • toStringBuilder

      public StringBuilder toStringBuilder()
      转换为 StringBuilder
      返回:
      结果
    • trim

      public TextStringBuilder trim()
      消除两端的空白字符
      返回:
      this