463 |
} |
} |
464 |
|
|
465 |
/** |
/** |
466 |
|
* Append the code point to this <code>StringBuilder</code>. |
467 |
|
* This is like #append(char), but will append two characters |
468 |
|
* if a supplementary code point is given. |
469 |
|
* |
470 |
|
* @param code the code point to append |
471 |
|
* @return this <code>StringBuilder</code> |
472 |
|
* @see Character#toChars(int, char[], int) |
473 |
|
* @since 1.5 |
474 |
|
*/ |
475 |
|
public synchronized StringBuilder appendCodePoint(int code) |
476 |
|
{ |
477 |
|
int len = Character.charCount(code); |
478 |
|
ensureCapacity(count + len); |
479 |
|
Character.toChars(code, value, count); |
480 |
|
count += len; |
481 |
|
return this; |
482 |
|
} |
483 |
|
|
484 |
|
/** |
485 |
* Append the <code>String</code> value of the argument to this |
* Append the <code>String</code> value of the argument to this |
486 |
* <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert |
* <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert |
487 |
* to <code>String</code>. |
* to <code>String</code>. |
721 |
count += len; |
count += len; |
722 |
return this; |
return this; |
723 |
} |
} |
724 |
|
|
725 |
|
/** |
726 |
|
* Insert the <code>CharSequence</code> argument into this |
727 |
|
* <code>StringBuilder</code>. If the sequence is null, the String |
728 |
|
* "null" is used instead. |
729 |
|
* |
730 |
|
* @param offset the place to insert in this buffer |
731 |
|
* @param sequence the <code>CharSequence</code> to insert |
732 |
|
* @return this <code>StringBuilder</code> |
733 |
|
* @throws IndexOutOfBoundsException if offset is out of bounds |
734 |
|
*/ |
735 |
|
public synchronized StringBuilder insert(int offset, CharSequence sequence) |
736 |
|
{ |
737 |
|
if (sequence == null) |
738 |
|
sequence = "null"; |
739 |
|
return insert(offset, sequence, 0, sequence.length()); |
740 |
|
} |
741 |
|
|
742 |
|
/** |
743 |
|
* Insert a subsequence of the <code>CharSequence</code> argument into this |
744 |
|
* <code>StringBuilder</code>. If the sequence is null, the String |
745 |
|
* "null" is used instead. |
746 |
|
* |
747 |
|
* @param offset the place to insert in this buffer |
748 |
|
* @param sequence the <code>CharSequence</code> to insert |
749 |
|
* @param start the starting index of the subsequence |
750 |
|
* @param end one past the ending index of the subsequence |
751 |
|
* @return this <code>StringBuilder</code> |
752 |
|
* @throws IndexOutOfBoundsException if offset, start, |
753 |
|
* or end are out of bounds |
754 |
|
*/ |
755 |
|
public synchronized StringBuilder insert(int offset, CharSequence sequence, |
756 |
|
int start, int end) |
757 |
|
{ |
758 |
|
if (sequence == null) |
759 |
|
sequence = "null"; |
760 |
|
if (start < 0 || end < 0 || start > end || end > sequence.length()) |
761 |
|
throw new IndexOutOfBoundsException(); |
762 |
|
int len = end - start; |
763 |
|
ensureCapacity(count + len); |
764 |
|
VMSystem.arraycopy(value, offset, value, offset + len, count - offset); |
765 |
|
for (int i = start; i < end; ++i) |
766 |
|
value[offset++] = sequence.charAt(i); |
767 |
|
count += len; |
768 |
|
return this; |
769 |
|
} |
770 |
|
|
771 |
/** |
/** |
772 |
* Insert the <code>char[]</code> argument into this |
* Insert the <code>char[]</code> argument into this |