/** * Returns the number of Unicode code points in the given characters sequence, * or 0 if {@code null}. Unpaired surrogates within the text count as one code * point each. * * @param text the character sequence from which to get the count, or {@code null}. * @return the number of Unicode code points, or 0 if the argument is {@code null}. * * @see #codePointCount(CharSequence, int, int) */ public static int codePointCount(final CharSequence text) { if (text == null) return 0; if (text instanceof String) return ((String) text).codePointCount(0, text.length()); if (text instanceof StringBuilder) return ((StringBuilder) text).codePointCount(0, text.length()); if (text instanceof StringBuffer) return ((StringBuffer) text).codePointCount(0, text.length()); if (text instanceof CharBuffer) { final CharBuffer buffer = (CharBuffer) text; if (buffer.hasArray() && !buffer.isReadOnly()) { return Character.codePointCount(buffer.array(), buffer.position(), buffer.limit()); } } return Character.codePointCount(text, 0, text.length()); }
/** * Returns the number of Unicode code points in the given characters sequence, * or 0 if {@code null}. Unpaired surrogates within the text count as one code * point each. * * @param text the character sequence from which to get the count, or {@code null}. * @return the number of Unicode code points, or 0 if the argument is {@code null}. * * @see #codePointCount(CharSequence, int, int) */ public static int codePointCount(final CharSequence text) { if (text == null) return 0; if (text instanceof String) return ((String) text).codePointCount(0, text.length()); if (text instanceof StringBuilder) return ((StringBuilder) text).codePointCount(0, text.length()); if (text instanceof StringBuffer) return ((StringBuffer) text).codePointCount(0, text.length()); if (text instanceof CharBuffer) { final CharBuffer buffer = (CharBuffer) text; if (buffer.hasArray() && !buffer.isReadOnly()) { return Character.codePointCount(buffer.array(), buffer.position(), buffer.limit()); } } return Character.codePointCount(text, 0, text.length()); }
if (text instanceof String) return ((String) text).codePointCount(fromIndex, toIndex); if (text instanceof StringBuilder) return ((StringBuilder) text).codePointCount(fromIndex, toIndex); if (text instanceof StringBuffer) return ((StringBuffer) text).codePointCount(fromIndex, toIndex); if (text instanceof CharBuffer) { final CharBuffer buffer = (CharBuffer) text;
if (text instanceof String) return ((String) text).codePointCount(fromIndex, toIndex); if (text instanceof StringBuilder) return ((StringBuilder) text).codePointCount(fromIndex, toIndex); if (text instanceof StringBuffer) return ((StringBuffer) text).codePointCount(fromIndex, toIndex); if (text instanceof CharBuffer) { final CharBuffer buffer = (CharBuffer) text;
i -= Character.charCount(c); currentLineLength = buffer.codePointCount(i, length);
int available = maximumTotalWidth - toAppendTo.codePointCount(offset, toAppendTo.length()); available -= (width + 1); // Remove the amount of code points that we plan to write. if (suffix != null) {
int available = maximumTotalWidth - toAppendTo.codePointCount(offset, toAppendTo.length()); available -= (width + 1); // Remove the amount of code points that we plan to write. if (suffix != null) {