author | alanb |
Fri, 02 Nov 2012 15:50:11 +0000 | |
changeset 14342 | 8435a30053c1 |
parent 14332 | 451c5dd717dc |
child 14997 | 97d6098fd419 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
14332
diff
changeset
|
2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.lang; |
|
27 |
||
28 |
||
29 |
/** |
|
30 |
* A mutable sequence of characters. This class provides an API compatible |
|
31 |
* with <code>StringBuffer</code>, but with no guarantee of synchronization. |
|
32 |
* This class is designed for use as a drop-in replacement for |
|
33 |
* <code>StringBuffer</code> in places where the string buffer was being |
|
34 |
* used by a single thread (as is generally the case). Where possible, |
|
35 |
* it is recommended that this class be used in preference to |
|
36 |
* <code>StringBuffer</code> as it will be faster under most implementations. |
|
37 |
* |
|
38 |
* <p>The principal operations on a <code>StringBuilder</code> are the |
|
39 |
* <code>append</code> and <code>insert</code> methods, which are |
|
40 |
* overloaded so as to accept data of any type. Each effectively |
|
41 |
* converts a given datum to a string and then appends or inserts the |
|
42 |
* characters of that string to the string builder. The |
|
43 |
* <code>append</code> method always adds these characters at the end |
|
44 |
* of the builder; the <code>insert</code> method adds the characters at |
|
45 |
* a specified point. |
|
46 |
* <p> |
|
47 |
* For example, if <code>z</code> refers to a string builder object |
|
48 |
* whose current contents are "<code>start</code>", then |
|
49 |
* the method call <code>z.append("le")</code> would cause the string |
|
50 |
* builder to contain "<code>startle</code>", whereas |
|
51 |
* <code>z.insert(4, "le")</code> would alter the string builder to |
|
52 |
* contain "<code>starlet</code>". |
|
53 |
* <p> |
|
54 |
* In general, if sb refers to an instance of a <code>StringBuilder</code>, |
|
55 |
* then <code>sb.append(x)</code> has the same effect as |
|
56 |
* <code>sb.insert(sb.length(), x)</code>. |
|
57 |
* |
|
58 |
* Every string builder has a capacity. As long as the length of the |
|
59 |
* character sequence contained in the string builder does not exceed |
|
60 |
* the capacity, it is not necessary to allocate a new internal |
|
61 |
* buffer. If the internal buffer overflows, it is automatically made larger. |
|
62 |
* |
|
63 |
* <p>Instances of <code>StringBuilder</code> are not safe for |
|
64 |
* use by multiple threads. If such synchronization is required then it is |
|
65 |
* recommended that {@link java.lang.StringBuffer} be used. |
|
66 |
* |
|
67 |
* @author Michael McCloskey |
|
68 |
* @see java.lang.StringBuffer |
|
69 |
* @see java.lang.String |
|
70 |
* @since 1.5 |
|
71 |
*/ |
|
72 |
public final class StringBuilder |
|
73 |
extends AbstractStringBuilder |
|
74 |
implements java.io.Serializable, CharSequence |
|
75 |
{ |
|
76 |
||
77 |
/** use serialVersionUID for interoperability */ |
|
78 |
static final long serialVersionUID = 4383685877147921099L; |
|
79 |
||
80 |
/** |
|
81 |
* Constructs a string builder with no characters in it and an |
|
82 |
* initial capacity of 16 characters. |
|
83 |
*/ |
|
84 |
public StringBuilder() { |
|
85 |
super(16); |
|
86 |
} |
|
87 |
||
88 |
/** |
|
89 |
* Constructs a string builder with no characters in it and an |
|
90 |
* initial capacity specified by the <code>capacity</code> argument. |
|
91 |
* |
|
92 |
* @param capacity the initial capacity. |
|
93 |
* @throws NegativeArraySizeException if the <code>capacity</code> |
|
94 |
* argument is less than <code>0</code>. |
|
95 |
*/ |
|
96 |
public StringBuilder(int capacity) { |
|
97 |
super(capacity); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
101 |
* Constructs a string builder initialized to the contents of the |
|
102 |
* specified string. The initial capacity of the string builder is |
|
103 |
* <code>16</code> plus the length of the string argument. |
|
104 |
* |
|
105 |
* @param str the initial contents of the buffer. |
|
106 |
* @throws NullPointerException if <code>str</code> is <code>null</code> |
|
107 |
*/ |
|
108 |
public StringBuilder(String str) { |
|
109 |
super(str.length() + 16); |
|
110 |
append(str); |
|
111 |
} |
|
112 |
||
113 |
/** |
|
114 |
* Constructs a string builder that contains the same characters |
|
115 |
* as the specified <code>CharSequence</code>. The initial capacity of |
|
116 |
* the string builder is <code>16</code> plus the length of the |
|
117 |
* <code>CharSequence</code> argument. |
|
118 |
* |
|
119 |
* @param seq the sequence to copy. |
|
120 |
* @throws NullPointerException if <code>seq</code> is <code>null</code> |
|
121 |
*/ |
|
122 |
public StringBuilder(CharSequence seq) { |
|
123 |
this(seq.length() + 16); |
|
124 |
append(seq); |
|
125 |
} |
|
126 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
127 |
@Override |
2 | 128 |
public StringBuilder append(Object obj) { |
129 |
return append(String.valueOf(obj)); |
|
130 |
} |
|
131 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
132 |
@Override |
2 | 133 |
public StringBuilder append(String str) { |
134 |
super.append(str); |
|
135 |
return this; |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Appends the specified <tt>StringBuffer</tt> to this sequence. |
|
140 |
* <p> |
|
141 |
* The characters of the <tt>StringBuffer</tt> argument are appended, |
|
142 |
* in order, to this sequence, increasing the |
|
143 |
* length of this sequence by the length of the argument. |
|
144 |
* If <tt>sb</tt> is <tt>null</tt>, then the four characters |
|
145 |
* <tt>"null"</tt> are appended to this sequence. |
|
146 |
* <p> |
|
147 |
* Let <i>n</i> be the length of this character sequence just prior to |
|
148 |
* execution of the <tt>append</tt> method. Then the character at index |
|
149 |
* <i>k</i> in the new character sequence is equal to the character at |
|
150 |
* index <i>k</i> in the old character sequence, if <i>k</i> is less than |
|
151 |
* <i>n</i>; otherwise, it is equal to the character at index <i>k-n</i> |
|
152 |
* in the argument <code>sb</code>. |
|
153 |
* |
|
154 |
* @param sb the <tt>StringBuffer</tt> to append. |
|
155 |
* @return a reference to this object. |
|
156 |
*/ |
|
157 |
public StringBuilder append(StringBuffer sb) { |
|
158 |
super.append(sb); |
|
159 |
return this; |
|
160 |
} |
|
161 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
162 |
@Override |
2 | 163 |
public StringBuilder append(CharSequence s) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
164 |
super.append(s); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
165 |
return this; |
2 | 166 |
} |
167 |
||
168 |
/** |
|
169 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
170 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
171 |
@Override |
2 | 172 |
public StringBuilder append(CharSequence s, int start, int end) { |
173 |
super.append(s, start, end); |
|
174 |
return this; |
|
175 |
} |
|
176 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
177 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
178 |
public StringBuilder append(char[] str) { |
2 | 179 |
super.append(str); |
180 |
return this; |
|
181 |
} |
|
182 |
||
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
183 |
/** |
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
184 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
185 |
*/ |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
186 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
187 |
public StringBuilder append(char[] str, int offset, int len) { |
2 | 188 |
super.append(str, offset, len); |
189 |
return this; |
|
190 |
} |
|
191 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
192 |
@Override |
2 | 193 |
public StringBuilder append(boolean b) { |
194 |
super.append(b); |
|
195 |
return this; |
|
196 |
} |
|
197 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
198 |
@Override |
2 | 199 |
public StringBuilder append(char c) { |
200 |
super.append(c); |
|
201 |
return this; |
|
202 |
} |
|
203 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
204 |
@Override |
2 | 205 |
public StringBuilder append(int i) { |
206 |
super.append(i); |
|
207 |
return this; |
|
208 |
} |
|
209 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
210 |
@Override |
2 | 211 |
public StringBuilder append(long lng) { |
212 |
super.append(lng); |
|
213 |
return this; |
|
214 |
} |
|
215 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
216 |
@Override |
2 | 217 |
public StringBuilder append(float f) { |
218 |
super.append(f); |
|
219 |
return this; |
|
220 |
} |
|
221 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
222 |
@Override |
2 | 223 |
public StringBuilder append(double d) { |
224 |
super.append(d); |
|
225 |
return this; |
|
226 |
} |
|
227 |
||
228 |
/** |
|
229 |
* @since 1.5 |
|
230 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
231 |
@Override |
2 | 232 |
public StringBuilder appendCodePoint(int codePoint) { |
233 |
super.appendCodePoint(codePoint); |
|
234 |
return this; |
|
235 |
} |
|
236 |
||
237 |
/** |
|
238 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
239 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
240 |
@Override |
2 | 241 |
public StringBuilder delete(int start, int end) { |
242 |
super.delete(start, end); |
|
243 |
return this; |
|
244 |
} |
|
245 |
||
246 |
/** |
|
247 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
248 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
249 |
@Override |
2 | 250 |
public StringBuilder deleteCharAt(int index) { |
251 |
super.deleteCharAt(index); |
|
252 |
return this; |
|
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
257 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
258 |
@Override |
2 | 259 |
public StringBuilder replace(int start, int end, String str) { |
260 |
super.replace(start, end, str); |
|
261 |
return this; |
|
262 |
} |
|
263 |
||
264 |
/** |
|
265 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
266 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
267 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
268 |
public StringBuilder insert(int index, char[] str, int offset, |
2 | 269 |
int len) |
270 |
{ |
|
271 |
super.insert(index, str, offset, len); |
|
272 |
return this; |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
277 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
278 |
@Override |
2 | 279 |
public StringBuilder insert(int offset, Object obj) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
280 |
super.insert(offset, obj); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
281 |
return this; |
2 | 282 |
} |
283 |
||
284 |
/** |
|
285 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
286 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
287 |
@Override |
2 | 288 |
public StringBuilder insert(int offset, String str) { |
289 |
super.insert(offset, str); |
|
290 |
return this; |
|
291 |
} |
|
292 |
||
293 |
/** |
|
294 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
295 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
296 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
297 |
public StringBuilder insert(int offset, char[] str) { |
2 | 298 |
super.insert(offset, str); |
299 |
return this; |
|
300 |
} |
|
301 |
||
302 |
/** |
|
303 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
304 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
305 |
@Override |
2 | 306 |
public StringBuilder insert(int dstOffset, CharSequence s) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
307 |
super.insert(dstOffset, s); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
308 |
return this; |
2 | 309 |
} |
310 |
||
311 |
/** |
|
312 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
313 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
314 |
@Override |
2 | 315 |
public StringBuilder insert(int dstOffset, CharSequence s, |
316 |
int start, int end) |
|
317 |
{ |
|
318 |
super.insert(dstOffset, s, start, end); |
|
319 |
return this; |
|
320 |
} |
|
321 |
||
322 |
/** |
|
323 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
324 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
325 |
@Override |
2 | 326 |
public StringBuilder insert(int offset, boolean b) { |
327 |
super.insert(offset, b); |
|
328 |
return this; |
|
329 |
} |
|
330 |
||
331 |
/** |
|
332 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
333 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
334 |
@Override |
2 | 335 |
public StringBuilder insert(int offset, char c) { |
336 |
super.insert(offset, c); |
|
337 |
return this; |
|
338 |
} |
|
339 |
||
340 |
/** |
|
341 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
342 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
343 |
@Override |
2 | 344 |
public StringBuilder insert(int offset, int i) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
345 |
super.insert(offset, i); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
346 |
return this; |
2 | 347 |
} |
348 |
||
349 |
/** |
|
350 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
351 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
352 |
@Override |
2 | 353 |
public StringBuilder insert(int offset, long l) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
354 |
super.insert(offset, l); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
355 |
return this; |
2 | 356 |
} |
357 |
||
358 |
/** |
|
359 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
360 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
361 |
@Override |
2 | 362 |
public StringBuilder insert(int offset, float f) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
363 |
super.insert(offset, f); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
364 |
return this; |
2 | 365 |
} |
366 |
||
367 |
/** |
|
368 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
369 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
370 |
@Override |
2 | 371 |
public StringBuilder insert(int offset, double d) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
372 |
super.insert(offset, d); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
373 |
return this; |
2 | 374 |
} |
375 |
||
376 |
/** |
|
377 |
* @throws NullPointerException {@inheritDoc} |
|
378 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
379 |
@Override |
2 | 380 |
public int indexOf(String str) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
381 |
return super.indexOf(str); |
2 | 382 |
} |
383 |
||
384 |
/** |
|
385 |
* @throws NullPointerException {@inheritDoc} |
|
386 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
387 |
@Override |
2 | 388 |
public int indexOf(String str, int fromIndex) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
389 |
return super.indexOf(str, fromIndex); |
2 | 390 |
} |
391 |
||
392 |
/** |
|
393 |
* @throws NullPointerException {@inheritDoc} |
|
394 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
395 |
@Override |
2 | 396 |
public int lastIndexOf(String str) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
397 |
return super.lastIndexOf(str); |
2 | 398 |
} |
399 |
||
400 |
/** |
|
401 |
* @throws NullPointerException {@inheritDoc} |
|
402 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
403 |
@Override |
2 | 404 |
public int lastIndexOf(String str, int fromIndex) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
405 |
return super.lastIndexOf(str, fromIndex); |
2 | 406 |
} |
407 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
408 |
@Override |
2 | 409 |
public StringBuilder reverse() { |
410 |
super.reverse(); |
|
411 |
return this; |
|
412 |
} |
|
413 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
5506
diff
changeset
|
414 |
@Override |
2 | 415 |
public String toString() { |
416 |
// Create a copy, don't share the array |
|
417 |
return new String(value, 0, count); |
|
418 |
} |
|
419 |
||
420 |
/** |
|
421 |
* Save the state of the <tt>StringBuilder</tt> instance to a stream |
|
422 |
* (that is, serialize it). |
|
423 |
* |
|
424 |
* @serialData the number of characters currently stored in the string |
|
425 |
* builder (<tt>int</tt>), followed by the characters in the |
|
426 |
* string builder (<tt>char[]</tt>). The length of the |
|
427 |
* <tt>char</tt> array may be greater than the number of |
|
428 |
* characters currently stored in the string builder, in which |
|
429 |
* case extra characters are ignored. |
|
430 |
*/ |
|
431 |
private void writeObject(java.io.ObjectOutputStream s) |
|
432 |
throws java.io.IOException { |
|
433 |
s.defaultWriteObject(); |
|
434 |
s.writeInt(count); |
|
435 |
s.writeObject(value); |
|
436 |
} |
|
437 |
||
438 |
/** |
|
439 |
* readObject is called to restore the state of the StringBuffer from |
|
440 |
* a stream. |
|
441 |
*/ |
|
442 |
private void readObject(java.io.ObjectInputStream s) |
|
443 |
throws java.io.IOException, ClassNotFoundException { |
|
444 |
s.defaultReadObject(); |
|
445 |
count = s.readInt(); |
|
446 |
value = (char[]) s.readObject(); |
|
447 |
} |
|
448 |
||
449 |
} |