author | jgish |
Fri, 28 Dec 2012 16:56:54 -0500 | |
changeset 14997 | 97d6098fd419 |
parent 14332 | 451c5dd717dc |
child 15312 | 4b57f9da8192 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1994, 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 thread-safe, mutable sequence of characters. |
|
31 |
* A string buffer is like a {@link String}, but can be modified. At any |
|
32 |
* point in time it contains some particular sequence of characters, but |
|
33 |
* the length and content of the sequence can be changed through certain |
|
34 |
* method calls. |
|
35 |
* <p> |
|
36 |
* String buffers are safe for use by multiple threads. The methods |
|
37 |
* are synchronized where necessary so that all the operations on any |
|
38 |
* particular instance behave as if they occur in some serial order |
|
39 |
* that is consistent with the order of the method calls made by each of |
|
40 |
* the individual threads involved. |
|
41 |
* <p> |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
42 |
* The principal operations on a {@code StringBuffer} are the |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
43 |
* {@code append} and {@code insert} methods, which are |
2 | 44 |
* overloaded so as to accept data of any type. Each effectively |
45 |
* converts a given datum to a string and then appends or inserts the |
|
46 |
* characters of that string to the string buffer. The |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
47 |
* {@code append} method always adds these characters at the end |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
48 |
* of the buffer; the {@code insert} method adds the characters at |
2 | 49 |
* a specified point. |
50 |
* <p> |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
51 |
* For example, if {@code z} refers to a string buffer object |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
52 |
* whose current contents are {@code "start"}, then |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
53 |
* the method call {@code z.append("le")} would cause the string |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
54 |
* buffer to contain {@code "startle"}, whereas |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
55 |
* {@code z.insert(4, "le")} would alter the string buffer to |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
56 |
* contain {@code "starlet"}. |
2 | 57 |
* <p> |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
58 |
* In general, if sb refers to an instance of a {@code StringBuffer}, |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
59 |
* then {@code sb.append(x)} has the same effect as |
14997 | 60 |
* {@code sb.insert(sb.length(), x)}. |
2 | 61 |
* <p> |
62 |
* Whenever an operation occurs involving a source sequence (such as |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
63 |
* appending or inserting from a source sequence), this class synchronizes |
2 | 64 |
* only on the string buffer performing the operation, not on the source. |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
65 |
* Note that while {@code StringBuffer} is designed to be safe to use |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
66 |
* concurrently from multiple threads, if the constructor or the |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
67 |
* {@code append} or {@code insert} operation is passed a source sequence |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
68 |
* that is shared across threads, the calling code must ensure |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
69 |
* that the operation has a consistent and unchanging view of the source |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
70 |
* sequence for the duration of the operation. |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
71 |
* This could be satisfied by the caller holding a lock during the |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
72 |
* operation's call, by using an immutable source sequence, or by not |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
73 |
* sharing the source sequence across threads. |
2 | 74 |
* <p> |
75 |
* Every string buffer has a capacity. As long as the length of the |
|
76 |
* character sequence contained in the string buffer does not exceed |
|
77 |
* the capacity, it is not necessary to allocate a new internal |
|
78 |
* buffer array. If the internal buffer overflows, it is |
|
79 |
* automatically made larger. |
|
80 |
* |
|
81 |
* As of release JDK 5, this class has been supplemented with an equivalent |
|
82 |
* class designed for use by a single thread, {@link StringBuilder}. The |
|
14997 | 83 |
* {@code StringBuilder} class should generally be used in preference to |
2 | 84 |
* this one, as it supports all of the same operations but it is faster, as |
85 |
* it performs no synchronization. |
|
86 |
* |
|
87 |
* @author Arthur van Hoff |
|
88 |
* @see java.lang.StringBuilder |
|
89 |
* @see java.lang.String |
|
90 |
* @since JDK1.0 |
|
91 |
*/ |
|
92 |
public final class StringBuffer |
|
93 |
extends AbstractStringBuilder |
|
94 |
implements java.io.Serializable, CharSequence |
|
95 |
{ |
|
96 |
||
97 |
/** use serialVersionUID from JDK 1.0.2 for interoperability */ |
|
98 |
static final long serialVersionUID = 3388685877147921107L; |
|
99 |
||
100 |
/** |
|
101 |
* Constructs a string buffer with no characters in it and an |
|
102 |
* initial capacity of 16 characters. |
|
103 |
*/ |
|
104 |
public StringBuffer() { |
|
105 |
super(16); |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* Constructs a string buffer with no characters in it and |
|
110 |
* the specified initial capacity. |
|
111 |
* |
|
112 |
* @param capacity the initial capacity. |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
113 |
* @exception NegativeArraySizeException if the {@code capacity} |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
114 |
* argument is less than {@code 0}. |
2 | 115 |
*/ |
116 |
public StringBuffer(int capacity) { |
|
117 |
super(capacity); |
|
118 |
} |
|
119 |
||
120 |
/** |
|
121 |
* Constructs a string buffer initialized to the contents of the |
|
122 |
* specified string. The initial capacity of the string buffer is |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
123 |
* {@code 16} plus the length of the string argument. |
2 | 124 |
* |
125 |
* @param str the initial contents of the buffer. |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
126 |
* @exception NullPointerException if {@code str} is {@code null} |
2 | 127 |
*/ |
128 |
public StringBuffer(String str) { |
|
129 |
super(str.length() + 16); |
|
130 |
append(str); |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
* Constructs a string buffer that contains the same characters |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
135 |
* as the specified {@code CharSequence}. The initial capacity of |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
136 |
* the string buffer is {@code 16} plus the length of the |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
137 |
* {@code CharSequence} argument. |
2 | 138 |
* <p> |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
139 |
* If the length of the specified {@code CharSequence} is |
2 | 140 |
* less than or equal to zero, then an empty buffer of capacity |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
141 |
* {@code 16} is returned. |
2 | 142 |
* |
143 |
* @param seq the sequence to copy. |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
144 |
* @exception NullPointerException if {@code seq} is {@code null} |
2 | 145 |
* @since 1.5 |
146 |
*/ |
|
147 |
public StringBuffer(CharSequence seq) { |
|
148 |
this(seq.length() + 16); |
|
149 |
append(seq); |
|
150 |
} |
|
151 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
152 |
@Override |
2 | 153 |
public synchronized int length() { |
154 |
return count; |
|
155 |
} |
|
156 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
157 |
@Override |
2 | 158 |
public synchronized int capacity() { |
159 |
return value.length; |
|
160 |
} |
|
161 |
||
162 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
163 |
@Override |
2 | 164 |
public synchronized void ensureCapacity(int minimumCapacity) { |
165 |
if (minimumCapacity > value.length) { |
|
166 |
expandCapacity(minimumCapacity); |
|
167 |
} |
|
168 |
} |
|
169 |
||
170 |
/** |
|
171 |
* @since 1.5 |
|
172 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
173 |
@Override |
2 | 174 |
public synchronized void trimToSize() { |
175 |
super.trimToSize(); |
|
176 |
} |
|
177 |
||
178 |
/** |
|
179 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
180 |
* @see #length() |
|
181 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
182 |
@Override |
2 | 183 |
public synchronized void setLength(int newLength) { |
184 |
super.setLength(newLength); |
|
185 |
} |
|
186 |
||
187 |
/** |
|
188 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
189 |
* @see #length() |
|
190 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
191 |
@Override |
2 | 192 |
public synchronized char charAt(int index) { |
193 |
if ((index < 0) || (index >= count)) |
|
194 |
throw new StringIndexOutOfBoundsException(index); |
|
195 |
return value[index]; |
|
196 |
} |
|
197 |
||
198 |
/** |
|
199 |
* @since 1.5 |
|
200 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
201 |
@Override |
2 | 202 |
public synchronized int codePointAt(int index) { |
203 |
return super.codePointAt(index); |
|
204 |
} |
|
205 |
||
206 |
/** |
|
207 |
* @since 1.5 |
|
208 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
209 |
@Override |
2 | 210 |
public synchronized int codePointBefore(int index) { |
211 |
return super.codePointBefore(index); |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* @since 1.5 |
|
216 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
217 |
@Override |
2 | 218 |
public synchronized int codePointCount(int beginIndex, int endIndex) { |
219 |
return super.codePointCount(beginIndex, endIndex); |
|
220 |
} |
|
221 |
||
222 |
/** |
|
223 |
* @since 1.5 |
|
224 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
225 |
@Override |
2 | 226 |
public synchronized int offsetByCodePoints(int index, int codePointOffset) { |
227 |
return super.offsetByCodePoints(index, codePointOffset); |
|
228 |
} |
|
229 |
||
230 |
/** |
|
231 |
* @throws NullPointerException {@inheritDoc} |
|
232 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
233 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
234 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
235 |
public synchronized void getChars(int srcBegin, int srcEnd, char[] dst, |
2 | 236 |
int dstBegin) |
237 |
{ |
|
238 |
super.getChars(srcBegin, srcEnd, dst, dstBegin); |
|
239 |
} |
|
240 |
||
241 |
/** |
|
242 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
243 |
* @see #length() |
|
244 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
245 |
@Override |
2 | 246 |
public synchronized void setCharAt(int index, char ch) { |
247 |
if ((index < 0) || (index >= count)) |
|
248 |
throw new StringIndexOutOfBoundsException(index); |
|
249 |
value[index] = ch; |
|
250 |
} |
|
251 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
252 |
@Override |
2 | 253 |
public synchronized StringBuffer append(Object obj) { |
254 |
super.append(String.valueOf(obj)); |
|
255 |
return this; |
|
256 |
} |
|
257 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
258 |
@Override |
2 | 259 |
public synchronized StringBuffer append(String str) { |
260 |
super.append(str); |
|
261 |
return this; |
|
262 |
} |
|
263 |
||
264 |
/** |
|
14997 | 265 |
* Appends the specified {@code StringBuffer} to this sequence. |
2 | 266 |
* <p> |
14997 | 267 |
* The characters of the {@code StringBuffer} argument are appended, |
268 |
* in order, to the contents of this {@code StringBuffer}, increasing the |
|
269 |
* length of this {@code StringBuffer} by the length of the argument. |
|
270 |
* If {@code sb} is {@code null}, then the four characters |
|
271 |
* {@code "null"} are appended to this {@code StringBuffer}. |
|
2 | 272 |
* <p> |
273 |
* Let <i>n</i> be the length of the old character sequence, the one |
|
14997 | 274 |
* contained in the {@code StringBuffer} just prior to execution of the |
275 |
* {@code append} method. Then the character at index <i>k</i> in |
|
2 | 276 |
* the new character sequence is equal to the character at index <i>k</i> |
277 |
* in the old character sequence, if <i>k</i> is less than <i>n</i>; |
|
278 |
* otherwise, it is equal to the character at index <i>k-n</i> in the |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
279 |
* argument {@code sb}. |
2 | 280 |
* <p> |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
281 |
* This method synchronizes on {@code this}, the destination |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
282 |
* object, but does not synchronize on the source ({@code sb}). |
2 | 283 |
* |
14997 | 284 |
* @param sb the {@code StringBuffer} to append. |
2 | 285 |
* @return a reference to this object. |
286 |
* @since 1.4 |
|
287 |
*/ |
|
288 |
public synchronized StringBuffer append(StringBuffer sb) { |
|
289 |
super.append(sb); |
|
290 |
return this; |
|
291 |
} |
|
292 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
293 |
/** |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
294 |
* @since 1.8 |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
295 |
*/ |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
296 |
@Override |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
297 |
synchronized StringBuffer append(AbstractStringBuilder asb) { |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
298 |
super.append(asb); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
299 |
return this; |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
300 |
} |
2 | 301 |
|
302 |
/** |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
303 |
* Appends the specified {@code CharSequence} to this |
2 | 304 |
* sequence. |
305 |
* <p> |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
306 |
* The characters of the {@code CharSequence} argument are appended, |
2 | 307 |
* in order, increasing the length of this sequence by the length of the |
308 |
* argument. |
|
309 |
* |
|
310 |
* <p>The result of this method is exactly the same as if it were an |
|
311 |
* invocation of this.append(s, 0, s.length()); |
|
312 |
* |
|
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
313 |
* <p>This method synchronizes on {@code this}, the destination |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
314 |
* object, but does not synchronize on the source ({@code s}). |
2 | 315 |
* |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
316 |
* <p>If {@code s} is {@code null}, then the four characters |
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
317 |
* {@code "null"} are appended. |
2 | 318 |
* |
13155
8140afb39557
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents:
5506
diff
changeset
|
319 |
* @param s the {@code CharSequence} to append. |
2 | 320 |
* @return a reference to this object. |
321 |
* @since 1.5 |
|
322 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
323 |
@Override |
2 | 324 |
public StringBuffer append(CharSequence s) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
325 |
// Note, synchronization achieved via invocations of other StringBuffer methods after |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
326 |
// narrowing of s to specific type |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
327 |
super.append(s); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
328 |
return this; |
2 | 329 |
} |
330 |
||
331 |
/** |
|
332 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
333 |
* @since 1.5 |
|
334 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
335 |
@Override |
2 | 336 |
public synchronized StringBuffer append(CharSequence s, int start, int end) |
337 |
{ |
|
338 |
super.append(s, start, end); |
|
339 |
return this; |
|
340 |
} |
|
341 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
342 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
343 |
public synchronized StringBuffer append(char[] str) { |
2 | 344 |
super.append(str); |
345 |
return this; |
|
346 |
} |
|
347 |
||
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
348 |
/** |
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
349 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
350 |
*/ |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
351 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
352 |
public synchronized StringBuffer append(char[] str, int offset, int len) { |
2 | 353 |
super.append(str, offset, len); |
354 |
return this; |
|
355 |
} |
|
356 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
357 |
@Override |
2 | 358 |
public synchronized StringBuffer append(boolean b) { |
359 |
super.append(b); |
|
360 |
return this; |
|
361 |
} |
|
362 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
363 |
@Override |
2 | 364 |
public synchronized StringBuffer append(char c) { |
365 |
super.append(c); |
|
366 |
return this; |
|
367 |
} |
|
368 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
369 |
@Override |
2 | 370 |
public synchronized StringBuffer append(int i) { |
371 |
super.append(i); |
|
372 |
return this; |
|
373 |
} |
|
374 |
||
375 |
/** |
|
376 |
* @since 1.5 |
|
377 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
378 |
@Override |
2 | 379 |
public synchronized StringBuffer appendCodePoint(int codePoint) { |
380 |
super.appendCodePoint(codePoint); |
|
381 |
return this; |
|
382 |
} |
|
383 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
384 |
@Override |
2 | 385 |
public synchronized StringBuffer append(long lng) { |
386 |
super.append(lng); |
|
387 |
return this; |
|
388 |
} |
|
389 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
390 |
@Override |
2 | 391 |
public synchronized StringBuffer append(float f) { |
392 |
super.append(f); |
|
393 |
return this; |
|
394 |
} |
|
395 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
396 |
@Override |
2 | 397 |
public synchronized StringBuffer append(double d) { |
398 |
super.append(d); |
|
399 |
return this; |
|
400 |
} |
|
401 |
||
402 |
/** |
|
403 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
404 |
* @since 1.2 |
|
405 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
406 |
@Override |
2 | 407 |
public synchronized StringBuffer delete(int start, int end) { |
408 |
super.delete(start, end); |
|
409 |
return this; |
|
410 |
} |
|
411 |
||
412 |
/** |
|
413 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
414 |
* @since 1.2 |
|
415 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
416 |
@Override |
2 | 417 |
public synchronized StringBuffer deleteCharAt(int index) { |
418 |
super.deleteCharAt(index); |
|
419 |
return this; |
|
420 |
} |
|
421 |
||
422 |
/** |
|
423 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
424 |
* @since 1.2 |
|
425 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
426 |
@Override |
2 | 427 |
public synchronized StringBuffer replace(int start, int end, String str) { |
428 |
super.replace(start, end, str); |
|
429 |
return this; |
|
430 |
} |
|
431 |
||
432 |
/** |
|
433 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
434 |
* @since 1.2 |
|
435 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
436 |
@Override |
2 | 437 |
public synchronized String substring(int start) { |
438 |
return substring(start, count); |
|
439 |
} |
|
440 |
||
441 |
/** |
|
442 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
443 |
* @since 1.4 |
|
444 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
445 |
@Override |
2 | 446 |
public synchronized CharSequence subSequence(int start, int end) { |
447 |
return super.substring(start, end); |
|
448 |
} |
|
449 |
||
450 |
/** |
|
451 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
452 |
* @since 1.2 |
|
453 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
454 |
@Override |
2 | 455 |
public synchronized String substring(int start, int end) { |
456 |
return super.substring(start, end); |
|
457 |
} |
|
458 |
||
459 |
/** |
|
460 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
461 |
* @since 1.2 |
|
462 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
463 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
464 |
public synchronized StringBuffer insert(int index, char[] str, int offset, |
2 | 465 |
int len) |
466 |
{ |
|
467 |
super.insert(index, str, offset, len); |
|
468 |
return this; |
|
469 |
} |
|
470 |
||
471 |
/** |
|
472 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
473 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
474 |
@Override |
2 | 475 |
public synchronized StringBuffer insert(int offset, Object obj) { |
476 |
super.insert(offset, String.valueOf(obj)); |
|
477 |
return this; |
|
478 |
} |
|
479 |
||
480 |
/** |
|
481 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
482 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
483 |
@Override |
2 | 484 |
public synchronized StringBuffer insert(int offset, String str) { |
485 |
super.insert(offset, str); |
|
486 |
return this; |
|
487 |
} |
|
488 |
||
489 |
/** |
|
490 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
491 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
492 |
@Override |
1223
5c1037124466
6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents:
2
diff
changeset
|
493 |
public synchronized StringBuffer insert(int offset, char[] str) { |
2 | 494 |
super.insert(offset, str); |
495 |
return this; |
|
496 |
} |
|
497 |
||
498 |
/** |
|
499 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
500 |
* @since 1.5 |
|
501 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
502 |
@Override |
2 | 503 |
public StringBuffer insert(int dstOffset, CharSequence s) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
504 |
// Note, synchronization achieved via invocations of other StringBuffer methods |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
505 |
// after narrowing of s to specific type |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
506 |
super.insert(dstOffset, s); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
507 |
return this; |
2 | 508 |
} |
509 |
||
510 |
/** |
|
511 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
512 |
* @since 1.5 |
|
513 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
514 |
@Override |
2 | 515 |
public synchronized StringBuffer insert(int dstOffset, CharSequence s, |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
516 |
int start, int end) |
2 | 517 |
{ |
518 |
super.insert(dstOffset, s, start, end); |
|
519 |
return this; |
|
520 |
} |
|
521 |
||
522 |
/** |
|
523 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
524 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
525 |
@Override |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
526 |
public StringBuffer insert(int offset, boolean b) { |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
527 |
// Note, synchronization achieved via invocation of StringBuffer insert(int, String) |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
528 |
// after conversion of b to String by super class method |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
529 |
super.insert(offset, b); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
530 |
return this; |
2 | 531 |
} |
532 |
||
533 |
/** |
|
534 |
* @throws IndexOutOfBoundsException {@inheritDoc} |
|
535 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
536 |
@Override |
2 | 537 |
public synchronized StringBuffer insert(int offset, char c) { |
538 |
super.insert(offset, c); |
|
539 |
return this; |
|
540 |
} |
|
541 |
||
542 |
/** |
|
543 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
544 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
545 |
@Override |
2 | 546 |
public StringBuffer insert(int offset, int i) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
547 |
// Note, synchronization achieved via invocation of StringBuffer insert(int, String) |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
548 |
// after conversion of i to String by super class method |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
549 |
super.insert(offset, i); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
550 |
return this; |
2 | 551 |
} |
552 |
||
553 |
/** |
|
554 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
555 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
556 |
@Override |
2 | 557 |
public StringBuffer insert(int offset, long l) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
558 |
// Note, synchronization achieved via invocation of StringBuffer insert(int, String) |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
559 |
// after conversion of l to String by super class method |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
560 |
super.insert(offset, l); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
561 |
return this; |
2 | 562 |
} |
563 |
||
564 |
/** |
|
565 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
566 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
567 |
@Override |
2 | 568 |
public StringBuffer insert(int offset, float f) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
569 |
// Note, synchronization achieved via invocation of StringBuffer insert(int, String) |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
570 |
// after conversion of f to String by super class method |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
571 |
super.insert(offset, f); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
572 |
return this; |
2 | 573 |
} |
574 |
||
575 |
/** |
|
576 |
* @throws StringIndexOutOfBoundsException {@inheritDoc} |
|
577 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
578 |
@Override |
2 | 579 |
public StringBuffer insert(int offset, double d) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
580 |
// Note, synchronization achieved via invocation of StringBuffer insert(int, String) |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
581 |
// after conversion of d to String by super class method |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
582 |
super.insert(offset, d); |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
583 |
return this; |
2 | 584 |
} |
585 |
||
586 |
/** |
|
587 |
* @throws NullPointerException {@inheritDoc} |
|
588 |
* @since 1.4 |
|
589 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
590 |
@Override |
2 | 591 |
public int indexOf(String str) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
592 |
// Note, synchronization achieved via invocations of other StringBuffer methods |
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
593 |
return super.indexOf(str); |
2 | 594 |
} |
595 |
||
596 |
/** |
|
597 |
* @throws NullPointerException {@inheritDoc} |
|
598 |
* @since 1.4 |
|
599 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
600 |
@Override |
2 | 601 |
public synchronized int indexOf(String str, int fromIndex) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
602 |
return super.indexOf(str, fromIndex); |
2 | 603 |
} |
604 |
||
605 |
/** |
|
606 |
* @throws NullPointerException {@inheritDoc} |
|
607 |
* @since 1.4 |
|
608 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
609 |
@Override |
2 | 610 |
public int lastIndexOf(String str) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
611 |
// Note, synchronization achieved via invocations of other StringBuffer methods |
2 | 612 |
return lastIndexOf(str, count); |
613 |
} |
|
614 |
||
615 |
/** |
|
616 |
* @throws NullPointerException {@inheritDoc} |
|
617 |
* @since 1.4 |
|
618 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
619 |
@Override |
2 | 620 |
public synchronized int lastIndexOf(String str, int fromIndex) { |
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
621 |
return super.lastIndexOf(str, fromIndex); |
2 | 622 |
} |
623 |
||
624 |
/** |
|
625 |
* @since JDK1.0.2 |
|
626 |
*/ |
|
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
627 |
@Override |
2 | 628 |
public synchronized StringBuffer reverse() { |
629 |
super.reverse(); |
|
630 |
return this; |
|
631 |
} |
|
632 |
||
14332
451c5dd717dc
6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents:
13155
diff
changeset
|
633 |
@Override |
2 | 634 |
public synchronized String toString() { |
635 |
return new String(value, 0, count); |
|
636 |
} |
|
637 |
||
638 |
/** |
|
639 |
* Serializable fields for StringBuffer. |
|
640 |
* |
|
641 |
* @serialField value char[] |
|
642 |
* The backing character array of this StringBuffer. |
|
643 |
* @serialField count int |
|
644 |
* The number of characters in this StringBuffer. |
|
645 |
* @serialField shared boolean |
|
646 |
* A flag indicating whether the backing array is shared. |
|
647 |
* The value is ignored upon deserialization. |
|
648 |
*/ |
|
649 |
private static final java.io.ObjectStreamField[] serialPersistentFields = |
|
650 |
{ |
|
651 |
new java.io.ObjectStreamField("value", char[].class), |
|
652 |
new java.io.ObjectStreamField("count", Integer.TYPE), |
|
653 |
new java.io.ObjectStreamField("shared", Boolean.TYPE), |
|
654 |
}; |
|
655 |
||
656 |
/** |
|
657 |
* readObject is called to restore the state of the StringBuffer from |
|
658 |
* a stream. |
|
659 |
*/ |
|
660 |
private synchronized void writeObject(java.io.ObjectOutputStream s) |
|
661 |
throws java.io.IOException { |
|
662 |
java.io.ObjectOutputStream.PutField fields = s.putFields(); |
|
663 |
fields.put("value", value); |
|
664 |
fields.put("count", count); |
|
665 |
fields.put("shared", false); |
|
666 |
s.writeFields(); |
|
667 |
} |
|
668 |
||
669 |
/** |
|
670 |
* readObject is called to restore the state of the StringBuffer from |
|
671 |
* a stream. |
|
672 |
*/ |
|
673 |
private void readObject(java.io.ObjectInputStream s) |
|
674 |
throws java.io.IOException, ClassNotFoundException { |
|
675 |
java.io.ObjectInputStream.GetField fields = s.readFields(); |
|
676 |
value = (char[])fields.get("value", null); |
|
677 |
count = fields.get("count", 0); |
|
678 |
} |
|
679 |
} |