Builds a string from constituent parts providing a more flexible and powerful API than StringBuffer. The main differences from StringBuffer/StringBuilder are: Not synchronized Not final Subclasses have direct access to character array Additional methods
| 78 | * TextStringBuilder</a> instead |
| 79 | */ |
| 80 | @Deprecated |
| 81 | public class StrBuilder implements CharSequence, Appendable, Serializable, Builder<String> { |
| 82 | |
| 83 | /** |
| 84 | * The extra capacity for new builders. |
| 85 | */ |
| 86 | static final int CAPACITY = 32; |
| 87 | |
| 88 | /** |
| 89 | * Required for serialization support. |
| 90 | * |
| 91 | * @see java.io.Serializable |
| 92 | */ |
| 93 | private static final long serialVersionUID = 7628716375283629643L; |
| 94 | |
| 95 | /** Internal data storage. */ |
| 96 | protected char[] buffer; // TODO make private? |
| 97 | /** Current size of the buffer. */ |
| 98 | protected int size; // TODO make private? |
| 99 | /** The new line. */ |
| 100 | private String newLine; |
| 101 | /** The null text. */ |
| 102 | private String nullText; |
| 103 | |
| 104 | //----------------------------------------------------------------------- |
| 105 | /** |
| 106 | * Constructor that creates an empty builder initial capacity 32 characters. |
| 107 | */ |
| 108 | public StrBuilder() { |
| 109 | this(CAPACITY); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Constructor that creates an empty builder the specified initial capacity. |
| 114 | * |
| 115 | * @param initialCapacity the initial capacity, zero or less will be converted to 32 |
| 116 | */ |
| 117 | public StrBuilder(int initialCapacity) { |
| 118 | super(); |
| 119 | if (initialCapacity <= 0) { |
| 120 | initialCapacity = CAPACITY; |
| 121 | } |
| 122 | buffer = new char[initialCapacity]; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Constructor that creates a builder from the string, allocating |
| 127 | * 32 extra characters for growth. |
| 128 | * |
| 129 | * @param str the string to copy, null treated as blank string |
| 130 | */ |
| 131 | public StrBuilder(final String str) { |
| 132 | super(); |
| 133 | if (str == null) { |
| 134 | buffer = new char[CAPACITY]; |
| 135 | } else { |
| 136 | buffer = new char[str.length() + CAPACITY]; |
| 137 | append(str); |
nothing calls this directly
no outgoing calls
no test coverage detected