1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
672 int spaceNeeded = count + appendedLength;
673 ensureCapacityInternal(spaceNeeded);
674 Long.getChars(l, spaceNeeded, value);
675 count = spaceNeeded;
676 return this;
677 }
678
679 /**
680 * Appends the string representation of the {@code float}
681 * argument to this sequence.
682 * <p>
683 * The overall effect is exactly as if the argument were converted
684 * to a string by the method {@link String#valueOf(float)},
685 * and the characters of that string were then
686 * {@link #append(String) appended} to this character sequence.
687 *
688 * @param f a {@code float}.
689 * @return a reference to this object.
690 */
691 public AbstractStringBuilder append(float f) {
692 new FloatingDecimal(f).appendTo(this);
693 return this;
694 }
695
696 /**
697 * Appends the string representation of the {@code double}
698 * argument to this sequence.
699 * <p>
700 * The overall effect is exactly as if the argument were converted
701 * to a string by the method {@link String#valueOf(double)},
702 * and the characters of that string were then
703 * {@link #append(String) appended} to this character sequence.
704 *
705 * @param d a {@code double}.
706 * @return a reference to this object.
707 */
708 public AbstractStringBuilder append(double d) {
709 new FloatingDecimal(d).appendTo(this);
710 return this;
711 }
712
713 /**
714 * Removes the characters in a substring of this sequence.
715 * The substring begins at the specified {@code start} and extends to
716 * the character at index {@code end - 1} or to the end of the
717 * sequence if no such character exists. If
718 * {@code start} is equal to {@code end}, no changes are made.
719 *
720 * @param start The beginning index, inclusive.
721 * @param end The ending index, exclusive.
722 * @return This object.
723 * @throws StringIndexOutOfBoundsException if {@code start}
724 * is negative, greater than {@code length()}, or
725 * greater than {@code end}.
726 */
727 public AbstractStringBuilder delete(int start, int end) {
728 if (start < 0)
729 throw new StringIndexOutOfBoundsException(start);
|
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
672 int spaceNeeded = count + appendedLength;
673 ensureCapacityInternal(spaceNeeded);
674 Long.getChars(l, spaceNeeded, value);
675 count = spaceNeeded;
676 return this;
677 }
678
679 /**
680 * Appends the string representation of the {@code float}
681 * argument to this sequence.
682 * <p>
683 * The overall effect is exactly as if the argument were converted
684 * to a string by the method {@link String#valueOf(float)},
685 * and the characters of that string were then
686 * {@link #append(String) appended} to this character sequence.
687 *
688 * @param f a {@code float}.
689 * @return a reference to this object.
690 */
691 public AbstractStringBuilder append(float f) {
692 FloatingDecimal.appendTo(f,this);
693 return this;
694 }
695
696 /**
697 * Appends the string representation of the {@code double}
698 * argument to this sequence.
699 * <p>
700 * The overall effect is exactly as if the argument were converted
701 * to a string by the method {@link String#valueOf(double)},
702 * and the characters of that string were then
703 * {@link #append(String) appended} to this character sequence.
704 *
705 * @param d a {@code double}.
706 * @return a reference to this object.
707 */
708 public AbstractStringBuilder append(double d) {
709 FloatingDecimal.appendTo(d,this);
710 return this;
711 }
712
713 /**
714 * Removes the characters in a substring of this sequence.
715 * The substring begins at the specified {@code start} and extends to
716 * the character at index {@code end - 1} or to the end of the
717 * sequence if no such character exists. If
718 * {@code start} is equal to {@code end}, no changes are made.
719 *
720 * @param start The beginning index, inclusive.
721 * @param end The ending index, exclusive.
722 * @return This object.
723 * @throws StringIndexOutOfBoundsException if {@code start}
724 * is negative, greater than {@code length()}, or
725 * greater than {@code end}.
726 */
727 public AbstractStringBuilder delete(int start, int end) {
728 if (start < 0)
729 throw new StringIndexOutOfBoundsException(start);
|