/** * Return the remaining iterator size */ public int remaining() { return limit - position(); }
@Override public int position() { return internal.position(); }
@Override public void position(int position) { internal.position(position); }
/** * Return the final index position */ public int lastPosition() { int p = position(); return (p > -1) ? (p >= limit()) ? p : p - 1 : -1; }
/** * Peek the next chars in the iterator. If the codepoint is not supplemental, the char array will have a single * member. If the codepoint is supplemental, the char array will have two members, representing the high and low * surrogate chars */ public char[] peekChars() throws InvalidCharacterException { return peekChars(position()); }
private boolean isNextSurrogate() { if (!hasNext()) return false; char c = get(position()); return CharUtils.isHighSurrogate(c) || CharUtils.isLowSurrogate(c); }
buf.append((char)delimiter); while (h < chars.length) { ci.position(0); i = -1; m = Integer.MAX_VALUE; delta += (m - n) * (h + 1); n = m; ci.position(0); i = -1; while (ci.hasNext()) { q = (q - t) / (base - t); buf.append((char)encode_digit(q, (case_flags != null) ? case_flags[ci.position() - 1] : false)); bias = adapt(delta, h + 1, h == b); delta = 0;
/** * Return the next chars. If the codepoint is not supplemental, the char array will have a single member. If the * codepoint is supplemental, the char array will have two members, representing the high and low surrogate chars */ public char[] nextChars() throws InvalidCharacterException { if (hasNext()) { if (isNextSurrogate()) { char c1 = get(); if (CharUtils.isHighSurrogate(c1) && position() < limit()) { char c2 = get(); if (CharUtils.isLowSurrogate(c2)) { return new char[] {c1, c2}; } else { throw new InvalidCharacterException(c2); } } else if (CharUtils.isLowSurrogate(c1) && position() > 0) { char c2 = get(position() - 2); if (CharUtils.isHighSurrogate(c2)) { return new char[] {c1, c2}; } else { throw new InvalidCharacterException(c2); } } } return new char[] {get()}; } return null; }