diff options
| author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-05-05 18:42:03 +0000 |
|---|---|---|
| committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-05-05 18:42:03 +0000 |
| commit | 40d5f2296d816b5e5a9b18005214f7b6a1cebe4e (patch) | |
| tree | 0010461e13da955bc29b7427f966c6f5ed8440c7 /gnu/java/lang/CPStringBuilder.java | |
| parent | 8a9a69fd0582756c8f576de969cf53362f2356d5 (diff) | |
| download | classpath-40d5f2296d816b5e5a9b18005214f7b6a1cebe4e.tar.gz | |
2008-05-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/21869
* gnu/java/lang/CPStringBuilder.java:
(CPStringBuilder(StringBuffer)): Added.
(CPStringBuulder(StringBuilder)): Likewise.
* gnu/java/text/AttributedFormatBuffer.java:
Swap use of StringBuffer for CPStringBuilder,
and make fields final.
* gnu/java/text/StringFormatBuffer.java:
Make fields final.
* java/text/SimpleDateFormat.java:
Add thread safety warning.
Diffstat (limited to 'gnu/java/lang/CPStringBuilder.java')
| -rw-r--r-- | gnu/java/lang/CPStringBuilder.java | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/gnu/java/lang/CPStringBuilder.java b/gnu/java/lang/CPStringBuilder.java index 978a2043f..d6ddca2c5 100644 --- a/gnu/java/lang/CPStringBuilder.java +++ b/gnu/java/lang/CPStringBuilder.java @@ -82,7 +82,7 @@ public final class CPStringBuilder } /** - * Create an empty <code>StringBuffer</code> with the specified initial + * Create an empty <code>CPStringBuilder</code> with the specified initial * capacity. * * @param capacity the initial capacity @@ -94,7 +94,7 @@ public final class CPStringBuilder } /** - * Create a new <code>StringBuffer</code> with the characters in the + * Create a new <code>CPStringBuilder</code> with the characters in the * specified <code>String</code>. Initial capacity will be the size of the * String plus 16. * @@ -109,7 +109,37 @@ public final class CPStringBuilder } /** - * Create a new <code>StringBuffer</code> with the characters in the + * Create a new <code>CPStringBuilder</code> with the characters in the + * specified <code>StringBuffer</code>. Initial capacity will be the size of the + * String plus 16. + * + * @param str the <code>String</code> to convert + * @throws NullPointerException if str is null + */ + public CPStringBuilder(StringBuffer str) + { + count = str.length(); + value = new char[count + DEFAULT_CAPACITY]; + str.getChars(0, count, value, 0); + } + + /** + * Create a new <code>CPStringBuilder</code> with the characters in the + * specified <code>StringBuilder</code>. Initial capacity will be the size of the + * String plus 16. + * + * @param str the <code>String</code> to convert + * @throws NullPointerException if str is null + */ + public CPStringBuilder(StringBuilder str) + { + count = str.length(); + value = new char[count + DEFAULT_CAPACITY]; + str.getChars(0, count, value, 0); + } + + /** + * Create a new <code>CPStringBuilder</code> with the characters in the * specified <code>CharSequence</code>. Initial capacity will be the * length of the sequence plus 16; if the sequence reports a length * less than or equal to 0, then the initial capacity will be 16. @@ -128,7 +158,7 @@ public final class CPStringBuilder } /** - * Increase the capacity of this <code>StringBuffer</code>. This will + * Increase the capacity of this <code>CPStringBuilder</code>. This will * ensure that an expensive growing operation will not occur until * <code>minimumCapacity</code> is reached. The buffer is grown to the * larger of <code>minimumCapacity</code> and |
