2657 : StringUTF16.trim(value); 2658 return ret == null ? this : ret; 2659 } 2660 2661 /** 2662 * This object (which is already a string!) is itself returned. 2663 * 2664 * @return the string itself. 2665 */ 2666 public String toString() { 2667 return this; 2668 } 2669 2670 /** 2671 * Returns a stream of {@code int} zero-extending the {@code char} values 2672 * from this sequence. Any char which maps to a <a 2673 * href="{@docRoot}/java/lang/Character.html#unicode">surrogate code 2674 * point</a> is passed through uninterpreted. 2675 * 2676 * @return an IntStream of char values from this sequence 2677 * @since 1.9 2678 */ 2679 @Override 2680 public IntStream chars() { 2681 return StreamSupport.intStream( 2682 isLatin1() ? new StringLatin1.CharsSpliterator(value, Spliterator.IMMUTABLE) 2683 : new StringUTF16.CharsSpliterator(value, Spliterator.IMMUTABLE), 2684 false); 2685 } 2686 2687 2688 /** 2689 * Returns a stream of code point values from this sequence. Any surrogate 2690 * pairs encountered in the sequence are combined as if by {@linkplain 2691 * Character#toCodePoint Character.toCodePoint} and the result is passed 2692 * to the stream. Any other code units, including ordinary BMP characters, 2693 * unpaired surrogates, and undefined code units, are zero-extended to 2694 * {@code int} values which are then passed to the stream. 2695 * 2696 * @return an IntStream of Unicode code points from this sequence 2697 * @since 1.9 2698 */ 2699 @Override 2700 public IntStream codePoints() { 2701 return StreamSupport.intStream( 2702 isLatin1() ? new StringLatin1.CharsSpliterator(value, Spliterator.IMMUTABLE) 2703 : new StringUTF16.CodePointsSpliterator(value, Spliterator.IMMUTABLE), 2704 false); 2705 } 2706 2707 /** 2708 * Converts this string to a new character array. 2709 * 2710 * @return a newly allocated character array whose length is the length 2711 * of this string and whose contents are initialized to contain 2712 * the character sequence represented by this string. 2713 */ 2714 public char[] toCharArray() { 2715 return isLatin1() ? StringLatin1.toChars(value) 2716 : StringUTF16.toChars(value); 2717 } | 2657 : StringUTF16.trim(value); 2658 return ret == null ? this : ret; 2659 } 2660 2661 /** 2662 * This object (which is already a string!) is itself returned. 2663 * 2664 * @return the string itself. 2665 */ 2666 public String toString() { 2667 return this; 2668 } 2669 2670 /** 2671 * Returns a stream of {@code int} zero-extending the {@code char} values 2672 * from this sequence. Any char which maps to a <a 2673 * href="{@docRoot}/java/lang/Character.html#unicode">surrogate code 2674 * point</a> is passed through uninterpreted. 2675 * 2676 * @return an IntStream of char values from this sequence 2677 * @since 9 2678 */ 2679 @Override 2680 public IntStream chars() { 2681 return StreamSupport.intStream( 2682 isLatin1() ? new StringLatin1.CharsSpliterator(value, Spliterator.IMMUTABLE) 2683 : new StringUTF16.CharsSpliterator(value, Spliterator.IMMUTABLE), 2684 false); 2685 } 2686 2687 2688 /** 2689 * Returns a stream of code point values from this sequence. Any surrogate 2690 * pairs encountered in the sequence are combined as if by {@linkplain 2691 * Character#toCodePoint Character.toCodePoint} and the result is passed 2692 * to the stream. Any other code units, including ordinary BMP characters, 2693 * unpaired surrogates, and undefined code units, are zero-extended to 2694 * {@code int} values which are then passed to the stream. 2695 * 2696 * @return an IntStream of Unicode code points from this sequence 2697 * @since 9 2698 */ 2699 @Override 2700 public IntStream codePoints() { 2701 return StreamSupport.intStream( 2702 isLatin1() ? new StringLatin1.CharsSpliterator(value, Spliterator.IMMUTABLE) 2703 : new StringUTF16.CodePointsSpliterator(value, Spliterator.IMMUTABLE), 2704 false); 2705 } 2706 2707 /** 2708 * Converts this string to a new character array. 2709 * 2710 * @return a newly allocated character array whose length is the length 2711 * of this string and whose contents are initialized to contain 2712 * the character sequence represented by this string. 2713 */ 2714 public char[] toCharArray() { 2715 return isLatin1() ? StringLatin1.toChars(value) 2716 : StringUTF16.toChars(value); 2717 } |