ur_rna.Utilities

## Class StringBuilderEx

- java.lang.Object
- - ur_rna.Utilities.StringBuilderEx

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Appendable, java.lang.CharSequence

      public class StringBuilderEx
      extends java.lang.Object
      implements java.io.Serializable, java.lang.Appendable, java.lang.CharSequence

  Delegates most functionality to the `StringBuilder` class, while adding a few additional methods.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.StringBuilder` | `_sb`
    `(package private) static long` | `serialVersionUID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringBuilderEx()`
    `StringBuilderEx(java.lang.CharSequence seq)`
    `StringBuilderEx(int capacity)`
    `StringBuilderEx(java.lang.String str)`
    `StringBuilderEx(java.lang.StringBuilder innerStringBuilder)` Use the given StringBuilder as the internal builder.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `StringBuilderEx` | `append(boolean b)`
    `StringBuilderEx` | `append(char c)`
    `StringBuilderEx` | `append(char[] str)`
    `StringBuilderEx` | `append(char[] str, int offset, int len)`
    `StringBuilderEx` | `append(java.lang.CharSequence s)`
    `StringBuilderEx` | `append(java.lang.CharSequence s, int start, int end)`
    `StringBuilderEx` | `append(double d)`
    `StringBuilderEx` | `append(float f)`
    `StringBuilderEx` | `append(int i)`
    `StringBuilderEx` | `append(long lng)`
    `StringBuilderEx` | `append(java.lang.Object obj)`
    `StringBuilderEx` | `append(java.lang.String str)`
    `StringBuilderEx` | `append(java.lang.StringBuffer sb)` Appends the specified `StringBuffer` to this sequence.
    `StringBuilderEx` | `appendCodePoint(int codePoint)`
    `StringBuilderEx` | `appendIfEmpty(java.lang.String str)`
    `StringBuilderEx` | `appendIfNotEmpty(java.lang.String str)`
    `StringBuilderEx` | `appendSeparator(java.lang.String separator)` Appends the given separator, but only if there is existing text and it does not already end with the separator.
    `int` | `capacity()` Returns the current capacity.
    `char` | `charAt(int index)` Returns the `char` value in this sequence at the specified index.
    `java.util.stream.IntStream` | `chars()` Returns a stream of `int` zero-extending the `char` values from this sequence.
    `int` | `codePointAt(int index)` Returns the character (Unicode code point) at the specified index.
    `int` | `codePointBefore(int index)` Returns the character (Unicode code point) before the specified index.
    `int` | `codePointCount(int beginIndex, int endIndex)` Returns the number of Unicode code points in the specified text range of this sequence.
    `java.util.stream.IntStream` | `codePoints()` Returns a stream of code point values from this sequence.
    `StringBuilderEx` | `delete(int start, int end)`
    `StringBuilderEx` | `deleteCharAt(int index)`
    `boolean` | `endsWith(java.lang.String test)`
    `boolean` | `endsWith(java.lang.String test, boolean ignoreCase)`
    `void` | `ensureCapacity(int minimumCapacity)` Ensures that the capacity is at least equal to the specified minimum.
    `void` | `getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)` Characters are copied from this sequence into the destination character array `dst`.
    `java.lang.StringBuilder` | `getStringBuilder()` Get the internal StringBuilder.
    `int` | `indexOf(java.lang.String str)`
    `int` | `indexOf(java.lang.String str, int fromIndex)`
    `StringBuilderEx` | `insert(int offset, boolean b)`
    `StringBuilderEx` | `insert(int offset, char c)`
    `StringBuilderEx` | `insert(int offset, char[] str)`
    `StringBuilderEx` | `insert(int index, char[] str, int offset, int len)`
    `StringBuilderEx` | `insert(int dstOffset, java.lang.CharSequence s)`
    `StringBuilderEx` | `insert(int dstOffset, java.lang.CharSequence s, int start, int end)`
    `StringBuilderEx` | `insert(int offset, double d)`
    `StringBuilderEx` | `insert(int offset, float f)`
    `StringBuilderEx` | `insert(int offset, int i)`
    `StringBuilderEx` | `insert(int offset, long l)`
    `StringBuilderEx` | `insert(int offset, java.lang.Object obj)`
    `StringBuilderEx` | `insert(int offset, java.lang.String str)`
    `int` | `lastIndexOf(java.lang.String str)`
    `int` | `lastIndexOf(java.lang.String str, int fromIndex)`
    `int` | `length()` Returns the length (character count).
    `int` | `offsetByCodePoints(int index, int codePointOffset)` Returns the index within this sequence that is offset from the given `index` by `codePointOffset` code points.
    `StringBuilderEx` | `replace(int start, int end, java.lang.String str)`
    `StringBuilderEx` | `reverse()`
    `void` | `setCharAt(int index, char ch)` The character at the specified index is set to `ch`.
    `void` | `setLength(int newLength)` Sets the length of the character sequence.
    `boolean` | `startsWith(java.lang.String test)`
    `boolean` | `startsWith(java.lang.String test, boolean ignoreCase)`
    `java.lang.CharSequence` | `subSequence(int start, int end)` Returns a new character sequence that is a subsequence of this sequence.
    `java.lang.String` | `substring(int start)` Returns a new `String` that contains a subsequence of characters currently contained in this character sequence.
    `java.lang.String` | `substring(int start, int end)` Returns a new `String` that contains a subsequence of characters currently contained in this sequence.
    `java.lang.String` | `toString()`
    `StringBuilderEx` | `trimEnd(char... remove)` Remove one or more instances of any of the specified characters from the end of the StringBuilder.
    `StringBuilderEx` | `trimEnd(char remove)` Remove one or more instances of the specified character from the end of the StringBuilder.
    `StringBuilderEx` | `trimEnd(char[] remove, int limit)` Remove one or more instances of any of the specified characters from the end of the StringBuilder.
    `StringBuilderEx` | `trimEnd(char remove, int limit)` Remove one or more instances of the specified character from the end of the StringBuilder.
    `void` | `trimToSize()` Attempts to reduce storage used for the character sequence.
    `StringBuilderEx` | `truncate(int numChars)` Remove the specified number of characters from the end of the string.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _sb

          private final java.lang.StringBuilder _sb

    - #### serialVersionUID

          static final long serialVersionUID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StringBuilderEx

          public StringBuilderEx()

    - #### StringBuilderEx

          public StringBuilderEx(java.lang.CharSequence seq)

    - #### StringBuilderEx

          public StringBuilderEx(int capacity)

    - #### StringBuilderEx

          public StringBuilderEx(java.lang.String str)

    - #### StringBuilderEx

          public StringBuilderEx(java.lang.StringBuilder innerStringBuilder)

      Use the given StringBuilder as the internal builder. This is useful if a StringBuilder has already been created.
      Parameters:
        `innerStringBuilder` -

  - ### Method Detail

    - #### append

          public StringBuilderEx append(boolean b)

    - #### append

          public StringBuilderEx append(char c)

      Specified by:
        `append` in interface `java.lang.Appendable`

    - #### append

          public StringBuilderEx append(char[] str)

    - #### append

          public StringBuilderEx append(char[] str,
                                        int offset,
                                        int len)

      Parameters:
        `str` -
        `offset` -
        `len` -
      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### append

          public StringBuilderEx append(java.lang.CharSequence s)

      Specified by:
        `append` in interface `java.lang.Appendable`

    - #### append

          public StringBuilderEx append(java.lang.CharSequence s,
                                        int start,
                                        int end)

      Specified by:
        `append` in interface `java.lang.Appendable`
      Parameters:
        `s` -
        `start` -
        `end` -
      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### append

          public StringBuilderEx append(double d)

    - #### append

          public StringBuilderEx append(float f)

    - #### append

          public StringBuilderEx append(int i)

    - #### append

          public StringBuilderEx append(long lng)

    - #### append

          public StringBuilderEx append(java.lang.Object obj)

    - #### append

          public StringBuilderEx append(java.lang.String str)

    - #### append

          public StringBuilderEx append(java.lang.StringBuffer sb)

      Appends the specified `StringBuffer` to this sequence.

      The characters of the `StringBuffer` argument are appended, in order, to this sequence, increasing the length of this sequence by the length of the argument. If `_sb` is `null`, then the four characters `"null"` are appended to this sequence.

      Let n be the length of this character sequence just prior to execution of the `append` method. Then the character at index k in the new character sequence is equal to the character at index k in the old character sequence, if k is less than n; otherwise, it is equal to the character at index k-n in the argument `_sb`.

      Parameters:
        `sb` - the `StringBuffer` to append.
      Returns:
        a reference to this object.

    - #### appendCodePoint

          public StringBuilderEx appendCodePoint(int codePoint)

      Parameters:
        `codePoint` -
      Since:
        1.5

    - #### appendIfEmpty

          public StringBuilderEx appendIfEmpty(java.lang.String str)

    - #### appendIfNotEmpty

          public StringBuilderEx appendIfNotEmpty(java.lang.String str)

    - #### appendSeparator

          public StringBuilderEx appendSeparator(java.lang.String separator)

      Appends the given separator, but only if there is existing text and it does not already end with the separator.
      Parameters:
        `separator` - The separator string to append.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).

    - #### capacity

          public int capacity()

      Returns the current capacity. The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur.
      Returns:
        the current capacity

    - #### charAt

          public char charAt(int index)

      Returns the `char` value in this sequence at the specified index. The first `char` value is at index `0`, the next at index `1`, and so on, as in array indexing.

      The index argument must be greater than or equal to `0`, and less than the length of this sequence.

      If the `char` value specified by the index is a surrogate, the surrogate value is returned.

      Specified by:
        `charAt` in interface `java.lang.CharSequence`
      Parameters:
        `index` - the index of the desired `char` value.
      Returns:
        the `char` value at the specified index.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if `index` is negative or greater than or equal to `length()`.

    - #### chars

          public java.util.stream.IntStream chars()

      Returns a stream of `int` zero-extending the `char` values from this sequence. Any char which maps to a surrogate code point is passed through uninterpreted.

      If the sequence is mutated while the stream is being read, the result is undefined.

      Specified by:
        `chars` in interface `java.lang.CharSequence`
      Returns:
        an IntStream of char values from this sequence
      Since:
        1.8

    - #### codePointAt

          public int codePointAt(int index)

      Returns the character (Unicode code point) at the specified index. The index refers to `char` values (Unicode code units) and ranges from `0` to `length()``- 1`.

      If the `char` value specified at the given index is in the high-surrogate range, the following index is less than the length of this sequence, and the `char` value at the following index is in the low-surrogate range, then the supplementary code point corresponding to this surrogate pair is returned. Otherwise, the `char` value at the given index is returned.

      Parameters:
        `index` - the index to the `char` values
      Returns:
        the code point value of the character at the `index`
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the `index` argument is negative or not less than the length of this sequence.

    - #### codePointBefore

          public int codePointBefore(int index)

      Returns the character (Unicode code point) before the specified index. The index refers to `char` values (Unicode code units) and ranges from `1` to `length()`.

      If the `char` value at `(index - 1)` is in the low-surrogate range, `(index - 2)` is not negative, and the `char` value at `(index - 2)` is in the high-surrogate range, then the supplementary code point value of the surrogate pair is returned. If the `char` value at `index - 1` is an unpaired low-surrogate or a high-surrogate, the surrogate value is returned.

      Parameters:
        `index` - the index following the code point that should be returned
      Returns:
        the Unicode code point value before the given index.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the `index` argument is less than 1 or greater than the length of this sequence.

    - #### codePointCount

          public int codePointCount(int beginIndex,
                                    int endIndex)

      Returns the number of Unicode code points in the specified text range of this sequence. The text range begins at the specified `beginIndex` and extends to the `char` at index `endIndex - 1`. Thus the length (in `char`s) of the text range is `endIndex-beginIndex`. Unpaired surrogates within this sequence count as one code point each.
      Parameters:
        `beginIndex` - the index to the first `char` of the text range.
        `endIndex` - the index after the last `char` of the text range.
      Returns:
        the number of Unicode code points in the specified text range
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the `beginIndex` is negative, or `endIndex` is larger than the length of this sequence, or `beginIndex` is larger than `endIndex`.

    - #### codePoints

          public java.util.stream.IntStream codePoints()

      Returns a stream of code point values from this sequence. Any surrogate pairs encountered in the sequence are combined as if by Character.toCodePoint and the result is passed to the stream. Any other code units, including ordinary BMP characters, unpaired surrogates, and undefined code units, are zero-extended to `int` values which are then passed to the stream.

      If the sequence is mutated while the stream is being read, the result is undefined.

      Specified by:
        `codePoints` in interface `java.lang.CharSequence`
      Returns:
        an IntStream of Unicode code points from this sequence
      Since:
        1.8

    - #### delete

          public StringBuilderEx delete(int start,
                                        int end)

      Parameters:
        `start` -
        `end` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### deleteCharAt

          public StringBuilderEx deleteCharAt(int index)

      Parameters:
        `index` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### endsWith

          public boolean endsWith(java.lang.String test)

    - #### endsWith

          public boolean endsWith(java.lang.String test,
                                  boolean ignoreCase)

    - #### ensureCapacity

          public void ensureCapacity(int minimumCapacity)

      Ensures that the capacity is at least equal to the specified minimum. If the current capacity is less than the argument, then a new internal array is allocated with greater capacity. The new capacity is the larger of:
      - The `minimumCapacity` argument.
      - Twice the old capacity, plus `2`.
      If the `minimumCapacity` argument is nonpositive, this method takes no action and simply returns. Note that subsequent operations on this object can reduce the actual capacity below that requested here.
      Parameters:
        `minimumCapacity` - the minimum desired capacity.

    - #### getChars

          public void getChars(int srcBegin,
                               int srcEnd,
                               char[] dst,
                               int dstBegin)

      Characters are copied from this sequence into the destination character array `dst`. The first character to be copied is at index `srcBegin`; the last character to be copied is at index `srcEnd-1`. The total number of characters to be copied is `srcEnd-srcBegin`. The characters are copied into the subarray of `dst` starting at index `dstBegin` and ending at index:

           dstbegin + (srcEnd-srcBegin) - 1

      Parameters:
        `srcBegin` - start copying at this offset.
        `srcEnd` - stop copying at this offset.
        `dst` - the array to copy the data into.
        `dstBegin` - offset into `dst`.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if any of the following is true:
        - `srcBegin` is negative
        - `dstBegin` is negative
        - the `srcBegin` argument is greater than the `srcEnd` argument.
        - `srcEnd` is greater than `this.length()`.
        - `dstBegin+srcEnd-srcBegin` is greater than `dst.length`

    - #### getStringBuilder

          public java.lang.StringBuilder getStringBuilder()

      Get the internal StringBuilder. It is safe to call any methods on this, because `StringBuilderEx` does not store any state data that would be altered by normal StringBuilder use.
      Returns:
        The internal StringBuilder.

    - #### indexOf

          public int indexOf(java.lang.String str)

    - #### indexOf

          public int indexOf(java.lang.String str,
                             int fromIndex)

    - #### insert

          public StringBuilderEx insert(int offset,
                                        boolean b)

      Parameters:
        `offset` -
        `b` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        char c)

      Parameters:
        `offset` -
        `c` -
      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        char[] str)

      Parameters:
        `offset` -
        `str` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int index,
                                        char[] str,
                                        int offset,
                                        int len)

      Parameters:
        `index` -
        `str` -
        `offset` -
        `len` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int dstOffset,
                                        java.lang.CharSequence s)

      Parameters:
        `dstOffset` -
        `s` -
      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int dstOffset,
                                        java.lang.CharSequence s,
                                        int start,
                                        int end)

      Parameters:
        `dstOffset` -
        `s` -
        `start` -
        `end` -
      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        double d)

      Parameters:
        `offset` -
        `d` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        float f)

      Parameters:
        `offset` -
        `f` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        int i)

      Parameters:
        `offset` -
        `i` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        long l)

      Parameters:
        `offset` -
        `l` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        java.lang.Object obj)

      Parameters:
        `offset` -
        `obj` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### insert

          public StringBuilderEx insert(int offset,
                                        java.lang.String str)

      Parameters:
        `offset` -
        `str` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### lastIndexOf

          public int lastIndexOf(java.lang.String str)

    - #### lastIndexOf

          public int lastIndexOf(java.lang.String str,
                                 int fromIndex)

    - #### length

          public int length()

      Returns the length (character count).
      Specified by:
        `length` in interface `java.lang.CharSequence`
      Returns:
        the length of the sequence of characters currently represented by this object

    - #### offsetByCodePoints

          public int offsetByCodePoints(int index,
                                        int codePointOffset)

      Returns the index within this sequence that is offset from the given `index` by `codePointOffset` code points. Unpaired surrogates within the text range given by `index` and `codePointOffset` count as one code point each.
      Parameters:
        `index` - the index to be offset
        `codePointOffset` - the offset in code points
      Returns:
        the index within this sequence
      Throws:
        `java.lang.IndexOutOfBoundsException` - if `index` is negative or larger then the length of this sequence, or if `codePointOffset` is positive and the subsequence starting with `index` has fewer than `codePointOffset` code points, or if `codePointOffset` is negative and the subsequence before `index` has fewer than the absolute value of `codePointOffset` code points.

    - #### replace

          public StringBuilderEx replace(int start,
                                         int end,
                                         java.lang.String str)

      Parameters:
        `start` -
        `end` -
        `str` -
      Throws:
        `java.lang.StringIndexOutOfBoundsException`

    - #### reverse

          public StringBuilderEx reverse()

    - #### setCharAt

          public void setCharAt(int index,
                                char ch)

      The character at the specified index is set to `ch`. This sequence is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character `ch` at position `index`.

      The index argument must be greater than or equal to `0`, and less than the length of this sequence.

      Parameters:
        `index` - the index of the character to modify.
        `ch` - the new character.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if `index` is negative or greater than or equal to `length()`.

    - #### setLength

          public void setLength(int newLength)

      Sets the length of the character sequence. The sequence is changed to a new character sequence whose length is specified by the argument. For every nonnegative index k less than `newLength`, the character at index k in the new character sequence is the same as the character at index k in the old sequence if k is less than the length of the old character sequence; otherwise, it is the null character `'\u0000'`. In other words, if the `newLength` argument is less than the current length, the length is changed to the specified length.

      If the `newLength` argument is greater than or equal to the current length, sufficient null characters (`'\u0000'`) are appended so that length becomes the `newLength` argument.

      The `newLength` argument must be greater than or equal to `0`.

      Parameters:
        `newLength` - the new length
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the `newLength` argument is negative.

    - #### startsWith

          public boolean startsWith(java.lang.String test)

    - #### startsWith

          public boolean startsWith(java.lang.String test,
                                    boolean ignoreCase)

    - #### subSequence

          public java.lang.CharSequence subSequence(int start,
                                                    int end)

      Returns a new character sequence that is a subsequence of this sequence.

      An invocation of this method of the form

           _sb.subSequence(begin,&nbsp;end)

      behaves in exactly the same way as the invocation

           _sb.substring(begin,&nbsp;end)

      This method is provided so that this class can implement the `CharSequence` interface.
      Specified by:
        `subSequence` in interface `java.lang.CharSequence`
      Parameters:
        `start` - the start index, inclusive.
        `end` - the end index, exclusive.
      Returns:
        the specified subsequence.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if `start` or `end` are negative, if `end` is greater than `length()`, or if `start` is greater than `end`

    - #### substring

          public java.lang.String substring(int start)

      Returns a new `String` that contains a subsequence of characters currently contained in this character sequence. The substring begins at the specified index and extends to the end of this sequence.
      Parameters:
        `start` - The beginning index, inclusive.
      Returns:
        The new string.
      Throws:
        `java.lang.StringIndexOutOfBoundsException` - if `start` is less than zero, or greater than the length of this object.

    - #### substring

          public java.lang.String substring(int start,
                                            int end)

      Returns a new `String` that contains a subsequence of characters currently contained in this sequence. The substring begins at the specified `start` and extends to the character at index `end - 1`.
      Parameters:
        `start` - The beginning index, inclusive.
        `end` - The ending index, exclusive.
      Returns:
        The new string.
      Throws:
        `java.lang.StringIndexOutOfBoundsException` - if `start` or `end` are negative or greater than `length()`, or `start` is greater than `end`.

    - #### toString

          public java.lang.String toString()

      Specified by:
        `toString` in interface `java.lang.CharSequence`
      Overrides:
        `toString` in class `java.lang.Object`

    - #### trimEnd

          public StringBuilderEx trimEnd(char... remove)

      Remove one or more instances of any of the specified characters from the end of the StringBuilder.
      Parameters:
        `remove` - A list of characters to remove, if it any are found at the end of the StringBuilder.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).

    - #### trimEnd

          public StringBuilderEx trimEnd(char remove)

      Remove one or more instances of the specified character from the end of the StringBuilder.
      Parameters:
        `remove` - The character to remove, if it is found at the end of the StringBuilder.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).

    - #### trimEnd

          public StringBuilderEx trimEnd(char[] remove,
                                         int limit)

      Remove one or more instances of any of the specified characters from the end of the StringBuilder.
      Parameters:
        `remove` - A list of characters to remove, if it any are found at the end of the StringBuilder.
        `limit` - The maximum number of characters to remove from the end. If this is 0, no trimming will be performed. A value of -1 indicates no limit.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).

    - #### trimEnd

          public StringBuilderEx trimEnd(char remove,
                                         int limit)

      Remove one or more instances of the specified character from the end of the StringBuilder.
      Parameters:
        `remove` - The character to remove, if it is found at the end of the StringBuilder.
        `limit` - The maximum number of characters to remove from the end. If this is 0, no trimming will be performed. A value of -1 indicates no limit.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).

    - #### trimToSize

          public void trimToSize()

      Attempts to reduce storage used for the character sequence. If the buffer is larger than necessary to hold its current sequence of characters, then it may be resized to become more space efficient. Calling this method may, but is not required to, affect the value returned by a subsequent call to the `capacity()` method.

    - #### truncate

          public StringBuilderEx truncate(int numChars)

      Remove the specified number of characters from the end of the string. This method is lenient in that no error is thrown when the StringBuilder's length is less than the number of characters specified.
      Parameters:
        `numChars` - The number of characters to remove from the end.
      Returns:
        This `StringBuilderEx` (to provide a fluent interface).