From 8f523f3a1047919d3563daf1ef47ba87336ebe89 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 15 Nov 2005 23:20:01 +0000 Subject: Imported GNU Classpath 0.19 + gcj-import-20051115. * sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. From-SVN: r107049 --- libjava/classpath/java/lang/StringBuilder.java | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'libjava/classpath/java/lang/StringBuilder.java') diff --git a/libjava/classpath/java/lang/StringBuilder.java b/libjava/classpath/java/lang/StringBuilder.java index b54c8ef7eb4..470f1ba9ad5 100644 --- a/libjava/classpath/java/lang/StringBuilder.java +++ b/libjava/classpath/java/lang/StringBuilder.java @@ -463,6 +463,25 @@ public final class StringBuilder return this; } + /** + * Append the code point to this StringBuilder. + * 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 StringBuilder + * @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 String value of the argument to this * StringBuilder. Uses String.valueOf() to convert @@ -704,6 +723,52 @@ public final class StringBuilder return this; } + /** + * Insert the CharSequence argument into this + * StringBuilder. If the sequence is null, the String + * "null" is used instead. + * + * @param offset the place to insert in this buffer + * @param sequence the CharSequence to insert + * @return this StringBuilder + * @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 CharSequence argument into this + * StringBuilder. If the sequence is null, the String + * "null" is used instead. + * + * @param offset the place to insert in this buffer + * @param sequence the CharSequence to insert + * @param start the starting index of the subsequence + * @param end one past the ending index of the subsequence + * @return this StringBuilder + * @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 char[] argument into this * StringBuilder. -- cgit v1.2.3