2712 * that is not a {@link Character#isWhitespace(int) white space}. 2713 * <p> 2714 * This method may be used to trim 2715 * {@link Character#isWhitespace(int) white space} from 2716 * the end of a string. 2717 * 2718 * @return a string whose value is this string, with all trailing white 2719 * space removed 2720 * 2721 * @see Character#isWhitespace(int) 2722 * 2723 * @since 11 2724 */ 2725 public String stripTrailing() { 2726 String ret = isLatin1() ? StringLatin1.stripTrailing(value) 2727 : StringUTF16.stripTrailing(value); 2728 return ret == null ? this : ret; 2729 } 2730 2731 /** 2732 * This object (which is already a string!) is itself returned. 2733 * 2734 * @return the string itself. 2735 */ 2736 public String toString() { 2737 return this; 2738 } 2739 2740 /** 2741 * Returns a stream of {@code int} zero-extending the {@code char} values 2742 * from this sequence. Any char which maps to a <a 2743 * href="{@docRoot}/java.base/java/lang/Character.html#unicode">surrogate code 2744 * point</a> is passed through uninterpreted. 2745 * 2746 * @return an IntStream of char values from this sequence 2747 * @since 9 2748 */ 2749 @Override 2750 public IntStream chars() { 2751 return StreamSupport.intStream( | 2712 * that is not a {@link Character#isWhitespace(int) white space}. 2713 * <p> 2714 * This method may be used to trim 2715 * {@link Character#isWhitespace(int) white space} from 2716 * the end of a string. 2717 * 2718 * @return a string whose value is this string, with all trailing white 2719 * space removed 2720 * 2721 * @see Character#isWhitespace(int) 2722 * 2723 * @since 11 2724 */ 2725 public String stripTrailing() { 2726 String ret = isLatin1() ? StringLatin1.stripTrailing(value) 2727 : StringUTF16.stripTrailing(value); 2728 return ret == null ? this : ret; 2729 } 2730 2731 /** 2732 * Returns {@code true} if the string is empty or contains only 2733 * {@link Character#isWhitespace(int) white space} codepoints, 2734 * otherwise {@code false}. 2735 * 2736 * @return {@code true} if the string is empty or contains only 2737 * {@link Character#isWhitespace(int) white space} codepoints, 2738 * otherwise {@code false} 2739 * 2740 * @see Character#isWhitespace(int) 2741 * 2742 * @since 11 2743 */ 2744 public boolean isBlank() { 2745 return indexOfNonWhitespace() == length(); 2746 } 2747 2748 private int indexOfNonWhitespace() { 2749 if (isLatin1()) { 2750 return StringLatin1.indexOfNonWhitespace(value); 2751 } else { 2752 return StringUTF16.indexOfNonWhitespace(value); 2753 } 2754 } 2755 2756 /** 2757 * This object (which is already a string!) is itself returned. 2758 * 2759 * @return the string itself. 2760 */ 2761 public String toString() { 2762 return this; 2763 } 2764 2765 /** 2766 * Returns a stream of {@code int} zero-extending the {@code char} values 2767 * from this sequence. Any char which maps to a <a 2768 * href="{@docRoot}/java.base/java/lang/Character.html#unicode">surrogate code 2769 * point</a> is passed through uninterpreted. 2770 * 2771 * @return an IntStream of char values from this sequence 2772 * @since 9 2773 */ 2774 @Override 2775 public IntStream chars() { 2776 return StreamSupport.intStream( |