/** * Returns the number of Unicode code points in a subarray of the * {@code char} array argument. The {@code offset} * argument is the index of the first {@code char} of the * subarray and the {@code count} argument specifies the * length of the subarray in {@code char}s. Unpaired * surrogates within the subarray count as one code point each. * * @param a the {@code char} array * @param offset the index of the first {@code char} in the * given {@code char} array * @param count the length of the subarray in {@code char}s * @return the number of Unicode code points in the specified subarray * @exception NullPointerException if {@code a} is null. * @exception IndexOutOfBoundsException if {@code offset} or * {@code count} is negative, or if {@code offset + * count} is larger than the length of the given array. * @since 1.5 */ public static int codePointCount(char[] a, int offset, int count) { if (count > a.length - offset || offset < 0 || count < 0) { throw new IndexOutOfBoundsException(); } return codePointCountImpl(a, offset, count); }
/** * Returns the number of Unicode code points in the specified text * range of this sequence. The text range begins at the specified * <code>beginIndex</code> and extends to the <code>char</code> at * index <code>endIndex - 1</code>. Thus the length (in * <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * this sequence count as one code point each. * * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this sequence, or * <code>beginIndex</code> is larger than <code>endIndex</code>. */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(value, beginIndex, endIndex-beginIndex); }
/** * Returns the number of Unicode code points in the specified text * range of this sequence. The text range begins at the specified * <code>beginIndex</code> and extends to the <code>char</code> at * index <code>endIndex - 1</code>. Thus the length (in * <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * this sequence count as one code point each. * * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this sequence, or * <code>beginIndex</code> is larger than <code>endIndex</code>. */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(value, beginIndex, endIndex-beginIndex); }
/** * Returns the number of Unicode code points in a subarray of the * {@code char} array argument. The {@code offset} * argument is the index of the first {@code char} of the * subarray and the {@code count} argument specifies the * length of the subarray in {@code char}s. Unpaired * surrogates within the subarray count as one code point each. * * @param a the {@code char} array * @param offset the index of the first {@code char} in the * given {@code char} array * @param count the length of the subarray in {@code char}s * @return the number of Unicode code points in the specified subarray * @exception NullPointerException if {@code a} is null. * @exception IndexOutOfBoundsException if {@code offset} or * {@code count} is negative, or if {@code offset + * count} is larger than the length of the given array. * @since 1.5 */ public static int codePointCount(char[] a, int offset, int count) { if (count > a.length - offset || offset < 0 || count < 0) { throw new IndexOutOfBoundsException(); } return codePointCountImpl(a, offset, count); }
/** * Returns the number of Unicode code points in the specified text * range of this <code>String</code>. The text range begins at the * specified <code>beginIndex</code> and extends to the * <code>char</code> at index <code>endIndex - 1</code>. Thus the * length (in <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * the text range count as one code point each. * * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this <code>String</code>, or * <code>beginIndex</code> is larger than <code>endIndex</code>. * @since 1.5 */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > length() || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(toCharArray(), offset()+beginIndex, endIndex-beginIndex); }
/** * Returns the number of Unicode code points in the specified text * range of this <code>String</code>. The text range begins at the * specified <code>beginIndex</code> and extends to the * <code>char</code> at index <code>endIndex - 1</code>. Thus the * length (in <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * the text range count as one code point each. * * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this <code>String</code>, or * <code>beginIndex</code> is larger than <code>endIndex</code>. * @since 1.5 */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > length() || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(toCharArray(), offset()+beginIndex, endIndex-beginIndex); }