jaroslav@52: /* jaroslav@52: * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. jaroslav@52: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@52: * jaroslav@52: * This code is free software; you can redistribute it and/or modify it jaroslav@52: * under the terms of the GNU General Public License version 2 only, as jaroslav@52: * published by the Free Software Foundation. Oracle designates this jaroslav@52: * particular file as subject to the "Classpath" exception as provided jaroslav@52: * by Oracle in the LICENSE file that accompanied this code. jaroslav@52: * jaroslav@52: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@52: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@52: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@52: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@52: * accompanied this code). jaroslav@52: * jaroslav@52: * You should have received a copy of the GNU General Public License version jaroslav@52: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@52: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@52: * jaroslav@52: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@52: * or visit www.oracle.com if you need additional information or have any jaroslav@52: * questions. jaroslav@52: */ jaroslav@52: jaroslav@52: package java.lang; jaroslav@52: jaroslav@52: jaroslav@52: /** jaroslav@52: * A thread-safe, mutable sequence of characters. jaroslav@52: * A string buffer is like a {@link String}, but can be modified. At any jaroslav@52: * point in time it contains some particular sequence of characters, but jaroslav@52: * the length and content of the sequence can be changed through certain jaroslav@52: * method calls. jaroslav@52: *
jaroslav@52: * String buffers are safe for use by multiple threads. The methods jaroslav@52: * are synchronized where necessary so that all the operations on any jaroslav@52: * particular instance behave as if they occur in some serial order jaroslav@52: * that is consistent with the order of the method calls made by each of jaroslav@52: * the individual threads involved. jaroslav@52: *
jaroslav@52: * The principal operations on a StringBuffer
are the
jaroslav@52: * append
and insert
methods, which are
jaroslav@52: * overloaded so as to accept data of any type. Each effectively
jaroslav@52: * converts a given datum to a string and then appends or inserts the
jaroslav@52: * characters of that string to the string buffer. The
jaroslav@52: * append
method always adds these characters at the end
jaroslav@52: * of the buffer; the insert
method adds the characters at
jaroslav@52: * a specified point.
jaroslav@52: *
jaroslav@52: * For example, if z
refers to a string buffer object
jaroslav@52: * whose current contents are "start
", then
jaroslav@52: * the method call z.append("le")
would cause the string
jaroslav@52: * buffer to contain "startle
", whereas
jaroslav@52: * z.insert(4, "le")
would alter the string buffer to
jaroslav@52: * contain "starlet
".
jaroslav@52: *
jaroslav@52: * In general, if sb refers to an instance of a StringBuffer
,
jaroslav@52: * then sb.append(x)
has the same effect as
jaroslav@52: * sb.insert(sb.length(), x)
.
jaroslav@52: *
jaroslav@52: * Whenever an operation occurs involving a source sequence (such as jaroslav@52: * appending or inserting from a source sequence) this class synchronizes jaroslav@52: * only on the string buffer performing the operation, not on the source. jaroslav@52: *
jaroslav@52: * Every string buffer has a capacity. As long as the length of the
jaroslav@52: * character sequence contained in the string buffer does not exceed
jaroslav@52: * the capacity, it is not necessary to allocate a new internal
jaroslav@52: * buffer array. If the internal buffer overflows, it is
jaroslav@52: * automatically made larger.
jaroslav@52: *
jaroslav@52: * As of release JDK 5, this class has been supplemented with an equivalent
jaroslav@52: * class designed for use by a single thread, {@link StringBuilder}. The
jaroslav@52: * StringBuilder class should generally be used in preference to
jaroslav@52: * this one, as it supports all of the same operations but it is faster, as
jaroslav@52: * it performs no synchronization.
jaroslav@52: *
jaroslav@52: * @author Arthur van Hoff
jaroslav@52: * @see java.lang.StringBuilder
jaroslav@52: * @see java.lang.String
jaroslav@52: * @since JDK1.0
jaroslav@52: */
jaroslav@52: public final class StringBuffer
jaroslav@52: extends AbstractStringBuilder
jaroslav@52: implements java.io.Serializable, CharSequence
jaroslav@52: {
jaroslav@52:
jaroslav@52: /** use serialVersionUID from JDK 1.0.2 for interoperability */
jaroslav@52: static final long serialVersionUID = 3388685877147921107L;
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Constructs a string buffer with no characters in it and an
jaroslav@52: * initial capacity of 16 characters.
jaroslav@52: */
jaroslav@52: public StringBuffer() {
jaroslav@52: super(16);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Constructs a string buffer with no characters in it and
jaroslav@52: * the specified initial capacity.
jaroslav@52: *
jaroslav@52: * @param capacity the initial capacity.
jaroslav@52: * @exception NegativeArraySizeException if the capacity
jaroslav@52: * argument is less than 0
.
jaroslav@52: */
jaroslav@52: public StringBuffer(int capacity) {
jaroslav@52: super(capacity);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Constructs a string buffer initialized to the contents of the
jaroslav@52: * specified string. The initial capacity of the string buffer is
jaroslav@52: * 16
plus the length of the string argument.
jaroslav@52: *
jaroslav@52: * @param str the initial contents of the buffer.
jaroslav@52: * @exception NullPointerException if str
is null
jaroslav@52: */
jaroslav@52: public StringBuffer(String str) {
jaroslav@52: super(str.length() + 16);
jaroslav@52: append(str);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Constructs a string buffer that contains the same characters
jaroslav@52: * as the specified CharSequence
. The initial capacity of
jaroslav@52: * the string buffer is 16
plus the length of the
jaroslav@52: * CharSequence
argument.
jaroslav@52: *
jaroslav@52: * If the length of the specified CharSequence
is
jaroslav@52: * less than or equal to zero, then an empty buffer of capacity
jaroslav@52: * 16
is returned.
jaroslav@52: *
jaroslav@52: * @param seq the sequence to copy.
jaroslav@52: * @exception NullPointerException if seq
is null
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public StringBuffer(CharSequence seq) {
jaroslav@52: this(seq.length() + 16);
jaroslav@52: append(seq);
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized int length() {
jaroslav@52: return count;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized int capacity() {
jaroslav@52: return value.length;
jaroslav@52: }
jaroslav@52:
jaroslav@52:
jaroslav@52: public synchronized void ensureCapacity(int minimumCapacity) {
jaroslav@52: if (minimumCapacity > value.length) {
jaroslav@52: expandCapacity(minimumCapacity);
jaroslav@52: }
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized void trimToSize() {
jaroslav@52: super.trimToSize();
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @see #length()
jaroslav@52: */
jaroslav@52: public synchronized void setLength(int newLength) {
jaroslav@52: super.setLength(newLength);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @see #length()
jaroslav@52: */
jaroslav@52: public synchronized char charAt(int index) {
jaroslav@52: if ((index < 0) || (index >= count))
jaroslav@52: throw new StringIndexOutOfBoundsException(index);
jaroslav@52: return value[index];
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized int codePointAt(int index) {
jaroslav@52: return super.codePointAt(index);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized int codePointBefore(int index) {
jaroslav@52: return super.codePointBefore(index);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized int codePointCount(int beginIndex, int endIndex) {
jaroslav@52: return super.codePointCount(beginIndex, endIndex);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized int offsetByCodePoints(int index, int codePointOffset) {
jaroslav@52: return super.offsetByCodePoints(index, codePointOffset);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws NullPointerException {@inheritDoc}
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
jaroslav@52: int dstBegin)
jaroslav@52: {
jaroslav@52: super.getChars(srcBegin, srcEnd, dst, dstBegin);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @see #length()
jaroslav@52: */
jaroslav@52: public synchronized void setCharAt(int index, char ch) {
jaroslav@52: if ((index < 0) || (index >= count))
jaroslav@52: throw new StringIndexOutOfBoundsException(index);
jaroslav@52: value[index] = ch;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(Object obj) {
jaroslav@52: super.append(String.valueOf(obj));
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(String str) {
jaroslav@52: super.append(str);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Appends the specified StringBuffer to this sequence.
jaroslav@52: *
jaroslav@52: * The characters of the StringBuffer argument are appended, jaroslav@52: * in order, to the contents of this StringBuffer, increasing the jaroslav@52: * length of this StringBuffer by the length of the argument. jaroslav@52: * If sb is null, then the four characters jaroslav@52: * "null" are appended to this StringBuffer. jaroslav@52: *
jaroslav@52: * Let n be the length of the old character sequence, the one
jaroslav@52: * contained in the StringBuffer just prior to execution of the
jaroslav@52: * append method. Then the character at index k in
jaroslav@52: * the new character sequence is equal to the character at index k
jaroslav@52: * in the old character sequence, if k is less than n;
jaroslav@52: * otherwise, it is equal to the character at index k-n in the
jaroslav@52: * argument sb
.
jaroslav@52: *
jaroslav@52: * This method synchronizes on this
(the destination)
jaroslav@52: * object but does not synchronize on the source (sb
).
jaroslav@52: *
jaroslav@52: * @param sb the StringBuffer to append.
jaroslav@52: * @return a reference to this object.
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer append(StringBuffer sb) {
jaroslav@52: super.append(sb);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Appends the specified CharSequence
to this
jaroslav@52: * sequence.
jaroslav@52: *
jaroslav@52: * The characters of the CharSequence
argument are appended,
jaroslav@52: * in order, increasing the length of this sequence by the length of the
jaroslav@52: * argument.
jaroslav@52: *
jaroslav@52: *
The result of this method is exactly the same as if it were an jaroslav@52: * invocation of this.append(s, 0, s.length()); jaroslav@52: * jaroslav@52: *
This method synchronizes on this (the destination)
jaroslav@52: * object but does not synchronize on the source (s
).
jaroslav@52: *
jaroslav@52: *
If s
is null
, then the four characters
jaroslav@52: * "null"
are appended.
jaroslav@52: *
jaroslav@52: * @param s the CharSequence
to append.
jaroslav@52: * @return a reference to this object.
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public StringBuffer append(CharSequence s) {
jaroslav@52: // Note, synchronization achieved via other invocations
jaroslav@52: if (s == null)
jaroslav@52: s = "null";
jaroslav@52: if (s instanceof String)
jaroslav@52: return this.append((String)s);
jaroslav@52: if (s instanceof StringBuffer)
jaroslav@52: return this.append((StringBuffer)s);
jaroslav@52: return this.append(s, 0, s.length());
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer append(CharSequence s, int start, int end)
jaroslav@52: {
jaroslav@52: super.append(s, start, end);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(char[] str) {
jaroslav@52: super.append(str);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer append(char[] str, int offset, int len) {
jaroslav@52: super.append(str, offset, len);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(boolean b) {
jaroslav@52: super.append(b);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(char c) {
jaroslav@52: super.append(c);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(int i) {
jaroslav@52: super.append(i);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer appendCodePoint(int codePoint) {
jaroslav@52: super.appendCodePoint(codePoint);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(long lng) {
jaroslav@52: super.append(lng);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(float f) {
jaroslav@52: super.append(f);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized StringBuffer append(double d) {
jaroslav@52: super.append(d);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer delete(int start, int end) {
jaroslav@52: super.delete(start, end);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer deleteCharAt(int index) {
jaroslav@52: super.deleteCharAt(index);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer replace(int start, int end, String str) {
jaroslav@52: super.replace(start, end, str);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized String substring(int start) {
jaroslav@52: return substring(start, count);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public synchronized CharSequence subSequence(int start, int end) {
jaroslav@52: return super.substring(start, end);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized String substring(int start, int end) {
jaroslav@52: return super.substring(start, end);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.2
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int index, char[] str, int offset,
jaroslav@52: int len)
jaroslav@52: {
jaroslav@52: super.insert(index, str, offset, len);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int offset, Object obj) {
jaroslav@52: super.insert(offset, String.valueOf(obj));
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int offset, String str) {
jaroslav@52: super.insert(offset, str);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int offset, char[] str) {
jaroslav@52: super.insert(offset, str);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int dstOffset, CharSequence s) {
jaroslav@52: // Note, synchronization achieved via other invocations
jaroslav@52: if (s == null)
jaroslav@52: s = "null";
jaroslav@52: if (s instanceof String)
jaroslav@52: return this.insert(dstOffset, (String)s);
jaroslav@52: return this.insert(dstOffset, s, 0, s.length());
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: * @since 1.5
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int dstOffset, CharSequence s,
jaroslav@52: int start, int end)
jaroslav@52: {
jaroslav@52: super.insert(dstOffset, s, start, end);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int offset, boolean b) {
jaroslav@52: return insert(offset, String.valueOf(b));
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws IndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer insert(int offset, char c) {
jaroslav@52: super.insert(offset, c);
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int offset, int i) {
jaroslav@52: return insert(offset, String.valueOf(i));
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int offset, long l) {
jaroslav@52: return insert(offset, String.valueOf(l));
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int offset, float f) {
jaroslav@52: return insert(offset, String.valueOf(f));
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws StringIndexOutOfBoundsException {@inheritDoc}
jaroslav@52: */
jaroslav@52: public StringBuffer insert(int offset, double d) {
jaroslav@52: return insert(offset, String.valueOf(d));
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws NullPointerException {@inheritDoc}
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public int indexOf(String str) {
jaroslav@52: return indexOf(str, 0);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws NullPointerException {@inheritDoc}
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public synchronized int indexOf(String str, int fromIndex) {
jaroslav@403: return super.indexOf(str, fromIndex);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws NullPointerException {@inheritDoc}
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public int lastIndexOf(String str) {
jaroslav@52: // Note, synchronization achieved via other invocations
jaroslav@52: return lastIndexOf(str, count);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @throws NullPointerException {@inheritDoc}
jaroslav@52: * @since 1.4
jaroslav@52: */
jaroslav@52: public synchronized int lastIndexOf(String str, int fromIndex) {
jaroslav@52: return String.lastIndexOf(value, 0, count,
jaroslav@52: str.toCharArray(), 0, str.length(), fromIndex);
jaroslav@52: }
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * @since JDK1.0.2
jaroslav@52: */
jaroslav@52: public synchronized StringBuffer reverse() {
jaroslav@52: super.reverse();
jaroslav@52: return this;
jaroslav@52: }
jaroslav@52:
jaroslav@52: public synchronized String toString() {
jaroslav@52: return new String(value, 0, count);
jaroslav@52: }
jaroslav@52:
jaroslav@65: // /**
jaroslav@65: // * Serializable fields for StringBuffer.
jaroslav@65: // *
jaroslav@65: // * @serialField value char[]
jaroslav@65: // * The backing character array of this StringBuffer.
jaroslav@65: // * @serialField count int
jaroslav@65: // * The number of characters in this StringBuffer.
jaroslav@65: // * @serialField shared boolean
jaroslav@65: // * A flag indicating whether the backing array is shared.
jaroslav@65: // * The value is ignored upon deserialization.
jaroslav@65: // */
jaroslav@65: // private static final java.io.ObjectStreamField[] serialPersistentFields =
jaroslav@65: // {
jaroslav@65: // new java.io.ObjectStreamField("value", char[].class),
jaroslav@65: // new java.io.ObjectStreamField("count", Integer.TYPE),
jaroslav@65: // new java.io.ObjectStreamField("shared", Boolean.TYPE),
jaroslav@65: // };
jaroslav@65: //
jaroslav@65: // /**
jaroslav@65: // * readObject is called to restore the state of the StringBuffer from
jaroslav@65: // * a stream.
jaroslav@65: // */
jaroslav@65: // private synchronized void writeObject(java.io.ObjectOutputStream s)
jaroslav@65: // throws java.io.IOException {
jaroslav@65: // java.io.ObjectOutputStream.PutField fields = s.putFields();
jaroslav@65: // fields.put("value", value);
jaroslav@65: // fields.put("count", count);
jaroslav@65: // fields.put("shared", false);
jaroslav@65: // s.writeFields();
jaroslav@65: // }
jaroslav@65: //
jaroslav@65: // /**
jaroslav@65: // * readObject is called to restore the state of the StringBuffer from
jaroslav@65: // * a stream.
jaroslav@65: // */
jaroslav@65: // private void readObject(java.io.ObjectInputStream s)
jaroslav@65: // throws java.io.IOException, ClassNotFoundException {
jaroslav@65: // java.io.ObjectInputStream.GetField fields = s.readFields();
jaroslav@65: // value = (char[])fields.get("value", null);
jaroslav@65: // count = fields.get("count", 0);
jaroslav@65: // }
jaroslav@52: }