public void setText (CharSequence newText) {\r
if (newText instanceof StringBuilder) {\r
if (text.equals(newText)) return;\r
+ text.setLength(0);\r
+ text.append((StringBuilder)newText);\r
} else {\r
if (newText == null) newText = "";\r
if (isEqual(text.chars, newText)) return;\r
+ text.setLength(0);\r
+ text.append(newText);\r
}\r
- text.setLength(0);\r
- text.append(newText);\r
computeBounds();\r
invalidateHierarchy();\r
}\r
this(seq.toString());\r
}\r
\r
+ public StringBuilder (StringBuilder builder) {\r
+ length = builder.length;\r
+ chars = new char[length + INITIAL_CAPACITY];\r
+ System.arraycopy(builder.chars, 0, chars, 0, length);\r
+ }\r
+\r
/** Constructs an instance that's initialized with the contents of the specified {@code String}. The capacity of the new builder\r
* will be the length of the {@code String} plus 16.\r
* \r
return this;\r
}\r
\r
+ public StringBuilder append (StringBuilder builder) {\r
+ if (builder == null)\r
+ appendNull();\r
+ else\r
+ append0(builder.chars, 0, builder.length);\r
+ return this;\r
+ }\r
+\r
/** Appends the string representation of the specified subsequence of the {@code CharSequence}. If the {@code CharSequence} is\r
* {@code null}, then the string {@code "null"} is used to extract the subsequence from.\r
* \r
return this;\r
}\r
\r
+ public StringBuilder append (StringBuilder builder, int start, int end) {\r
+ if (builder == null)\r
+ appendNull();\r
+ else\r
+ append0(builder.chars, start, end);\r
+ return this;\r
+ }\r
+\r
/** Appends the encoded Unicode code point. The code point is converted to a {@code char[]} as defined by\r
* {@link Character#toChars(int)}.\r
* \r