diff options
| author | Tom Tromey <tromey@redhat.com> | 2005-10-24 23:58:21 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2005-10-24 23:58:21 +0000 |
| commit | a2d1f55ea70ba689b864cd01d1abdf8e579f1cb7 (patch) | |
| tree | e3301b9c670b94b7ab001320cd39228c61277628 /java/lang | |
| parent | 4e95295a1686316c251eab12c85e6fb267080010 (diff) | |
| download | classpath-a2d1f55ea70ba689b864cd01d1abdf8e579f1cb7.tar.gz | |
* java/lang/StringBuffer.java (appendCodePoint): Added @since.
* java/lang/StringBuilder.java (insert): New overloads.
(appendCodePoint): New method.
Diffstat (limited to 'java/lang')
| -rw-r--r-- | java/lang/StringBuffer.java | 1 | ||||
| -rw-r--r-- | java/lang/StringBuilder.java | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/java/lang/StringBuffer.java b/java/lang/StringBuffer.java index 645ae132a..caffd6e70 100644 --- a/java/lang/StringBuffer.java +++ b/java/lang/StringBuffer.java @@ -504,6 +504,7 @@ public final class StringBuffer implements Serializable, CharSequence * @param code the code point to append * @return this <code>StringBuffer</code> * @see Character#toChars(int, char[], int) + * @since 1.5 */ public synchronized StringBuffer appendCodePoint(int code) { diff --git a/java/lang/StringBuilder.java b/java/lang/StringBuilder.java index b54c8ef7e..470f1ba9a 100644 --- a/java/lang/StringBuilder.java +++ b/java/lang/StringBuilder.java @@ -464,6 +464,25 @@ public final class StringBuilder } /** + * Append the code point to this <code>StringBuilder</code>. + * This is like #append(char), but will append two characters + * if a supplementary code point is given. + * + * @param code the code point to append + * @return this <code>StringBuilder</code> + * @see Character#toChars(int, char[], int) + * @since 1.5 + */ + public synchronized StringBuilder appendCodePoint(int code) + { + int len = Character.charCount(code); + ensureCapacity(count + len); + Character.toChars(code, value, count); + count += len; + return this; + } + + /** * Append the <code>String</code> value of the argument to this * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert * to <code>String</code>. @@ -705,6 +724,52 @@ public final class StringBuilder } /** + * Insert the <code>CharSequence</code> argument into this + * <code>StringBuilder</code>. If the sequence is null, the String + * "null" is used instead. + * + * @param offset the place to insert in this buffer + * @param sequence the <code>CharSequence</code> to insert + * @return this <code>StringBuilder</code> + * @throws IndexOutOfBoundsException if offset is out of bounds + */ + public synchronized StringBuilder insert(int offset, CharSequence sequence) + { + if (sequence == null) + sequence = "null"; + return insert(offset, sequence, 0, sequence.length()); + } + + /** + * Insert a subsequence of the <code>CharSequence</code> argument into this + * <code>StringBuilder</code>. If the sequence is null, the String + * "null" is used instead. + * + * @param offset the place to insert in this buffer + * @param sequence the <code>CharSequence</code> to insert + * @param start the starting index of the subsequence + * @param end one past the ending index of the subsequence + * @return this <code>StringBuilder</code> + * @throws IndexOutOfBoundsException if offset, start, + * or end are out of bounds + */ + public synchronized StringBuilder insert(int offset, CharSequence sequence, + int start, int end) + { + if (sequence == null) + sequence = "null"; + if (start < 0 || end < 0 || start > end || end > sequence.length()) + throw new IndexOutOfBoundsException(); + int len = end - start; + ensureCapacity(count + len); + VMSystem.arraycopy(value, offset, value, offset + len, count - offset); + for (int i = start; i < end; ++i) + value[offset++] = sequence.charAt(i); + count += len; + return this; + } + + /** * Insert the <code>char[]</code> argument into this * <code>StringBuilder</code>. * |
