MCPcopy Create free account
hub / github.com/davidgiven/luje / AbstractStringBuilder

Class AbstractStringBuilder

lib/java/lang/AbstractStringBuilder.java:32–884  ·  view source on GitHub ↗

A modifiable CharSequence sequence of characters for use in creating and modifying Strings. This class is intended as a base class for StringBuffer and StringBuilder. @see StringBuffer @see StringBuilder @since 1.5

Source from the content-addressed store, hash-verified

30 * @since 1.5
31 */
32abstract class AbstractStringBuilder {
33
34 static final int INITIAL_CAPACITY = 16;
35
36 private char[] value;
37
38 private int count;
39
40 private boolean shared;
41
42 /*
43 * Returns the character array.
44 */
45 final char[] getValue() {
46 return value;
47 }
48
49 /*
50 * Returns the underlying buffer and sets the shared flag.
51 */
52 final char[] shareValue() {
53 shared = true;
54 return value;
55 }
56
57 /*
58 * Restores internal state after deserialization.
59 */
60// final void set(char[] val, int len) throws InvalidObjectException {
61// if (val == null) {
62// val = new char[0];
63// }
64// if (val.length < len) {
65// throw new InvalidObjectException(Messages.getString("luni.4A")); //$NON-NLS-1$
66// }
67//
68// shared = false;
69// value = val;
70// count = len;
71// }
72
73 AbstractStringBuilder() {
74 value = new char[INITIAL_CAPACITY];
75 }
76
77 AbstractStringBuilder(int capacity) {
78 value = new char[capacity];
79 }
80
81 AbstractStringBuilder(String string) {
82 count = string.length();
83 shared = false;
84 value = new char[count + INITIAL_CAPACITY];
85 string.getChars(0, count, value, 0);
86 }
87
88 private void enlargeBuffer(int min) {
89 int newSize = ((value.length >> 1) + value.length) + 2;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected