public AbstractStringBuilder append(int i) { if (i == Integer.MIN_VALUE) { append("-2147483648"); return this; } int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1 : Integer.stringSize(i); int spaceNeeded = count + appendedLength; ensureCapacityInternal(spaceNeeded); Integer.getChars(i, spaceNeeded, value); count = spaceNeeded; return this; }
/** * Returns a {@code String} object representing the * specified integer. The argument is converted to signed decimal * representation and returned as a string, exactly as if the * argument and radix 10 were given as arguments to the {@link * #toString(int, int)} method. * * @param i an integer to be converted. * @return a string representation of the argument in base 10. */ @JavaScriptBody(args = "i", body = "return i.toString();") public static String toString(int i) { if (i == Integer.MIN_VALUE) return "-2147483648"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); return new String(buf, 0, size); }
// from AbstractStringBuilder public AbstractStringBuilder append(int i) { if (i == Integer.MIN_VALUE) { append("-2147483648"); return this; } int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1 : Integer.stringSize(i); int spaceNeeded = count + appendedLength; ensureCapacityInternal(spaceNeeded); Integer.getChars(i, spaceNeeded, value); count = spaceNeeded; return this; }
/** * Returns a {@code String} object representing the * specified integer. The argument is converted to signed decimal * representation and returned as a string, exactly as if the * argument and radix 10 were given as arguments to the {@link * #toString(int, int)} method. * * @param i an integer to be converted. * @return a string representation of the argument in base 10. */ @JavaScriptBody(args = "i", body = "return i.toString();") public static String toString(int i) { if (i == Integer.MIN_VALUE) return "-2147483648"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); return new String(buf, 0, size); }
605 public AbstractStringBuilder append(int i) { 606 if (i == Integer.MIN_VALUE) { 607 append("-2147483648"); 608 return this; 609 } 610 int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1 611 : Integer.stringSize(i); 612 int spaceNeeded = count + appendedLength; 613 if (spaceNeeded > value.length) 614 expandCapacity(spaceNeeded); 615 Integer.getChars(i, spaceNeeded, value); 616 count = spaceNeeded; 617 return this; 618 } 110 void expandCapacity(int minimumCapacity) { 111 int newCapacity = (value.length + 1) * 2; 112 if (newCapacity < 0) { 113 newCapacity = Integer.MAX_VALUE; 114 } else if (minimumCapacity > newCapacity) { 115 newCapacity = minimumCapacity; 116 } 117 value = Arrays.copyOf(value, newCapacity); 118 }