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