src/share/classes/java/lang/Long.java

Print this page
rev 5431 : 6924259: Remove offset and count fields from java.lang.String
Summary: Removes the use of shared character array buffers by String along with the two fields needed to support the use of shared buffers.
Contributed-by: brian.doherty@oracle.com


 356         } while (i != 0);
 357         return new String(buf, charPos, (64 - charPos));
 358     }
 359 
 360     /**
 361      * Returns a {@code String} object representing the specified
 362      * {@code long}.  The argument is converted to signed decimal
 363      * representation and returned as a string, exactly as if the
 364      * argument and the radix 10 were given as arguments to the {@link
 365      * #toString(long, int)} method.
 366      *
 367      * @param   i   a {@code long} to be converted.
 368      * @return  a string representation of the argument in base 10.
 369      */
 370     public static String toString(long i) {
 371         if (i == Long.MIN_VALUE)
 372             return "-9223372036854775808";
 373         int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
 374         char[] buf = new char[size];
 375         getChars(i, size, buf);
 376         return new String(0, size, buf);
 377     }
 378 
 379     /**
 380      * Returns a string representation of the argument as an unsigned
 381      * decimal value.
 382      *
 383      * The argument is converted to unsigned decimal representation
 384      * and returned as a string exactly as if the argument and radix
 385      * 10 were given as arguments to the {@link #toUnsignedString(long,
 386      * int)} method.
 387      *
 388      * @param   i  an integer to be converted to an unsigned string.
 389      * @return  an unsigned string representation of the argument.
 390      * @see     #toUnsignedString(long, int)
 391      * @since 1.8
 392      */
 393     public static String toUnsignedString(long i) {
 394         return toUnsignedString(i, 10);
 395     }
 396 




 356         } while (i != 0);
 357         return new String(buf, charPos, (64 - charPos));
 358     }
 359 
 360     /**
 361      * Returns a {@code String} object representing the specified
 362      * {@code long}.  The argument is converted to signed decimal
 363      * representation and returned as a string, exactly as if the
 364      * argument and the radix 10 were given as arguments to the {@link
 365      * #toString(long, int)} method.
 366      *
 367      * @param   i   a {@code long} to be converted.
 368      * @return  a string representation of the argument in base&nbsp;10.
 369      */
 370     public static String toString(long i) {
 371         if (i == Long.MIN_VALUE)
 372             return "-9223372036854775808";
 373         int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
 374         char[] buf = new char[size];
 375         getChars(i, size, buf);
 376         return new String(buf, true);
 377     }
 378 
 379     /**
 380      * Returns a string representation of the argument as an unsigned
 381      * decimal value.
 382      *
 383      * The argument is converted to unsigned decimal representation
 384      * and returned as a string exactly as if the argument and radix
 385      * 10 were given as arguments to the {@link #toUnsignedString(long,
 386      * int)} method.
 387      *
 388      * @param   i  an integer to be converted to an unsigned string.
 389      * @return  an unsigned string representation of the argument.
 390      * @see     #toUnsignedString(long, int)
 391      * @since 1.8
 392      */
 393     public static String toUnsignedString(long i) {
 394         return toUnsignedString(i, 10);
 395     }
 396