public int next() throws NoSuchElementException { final int v = CodePointIterator.this.next(); return v > 255 ? '?' : v; }
/** * Skip all the remaining code points in this iterator. * (Useful in combination with {@link #delimitedBy(int...)}) * * @return the same code point iterator */ public CodePointIterator skipAll() { while (hasNext()) next(); return this; }
public int next() { if (! hasNext()) { throw new NoSuchElementException(); } offset ++; return CodePointIterator.this.next(); }
/** * Drain all the remaining code points in this iterator to the given string builder. * * @param b the string builder * @return the same string builder */ public StringBuilder drainTo(StringBuilder b) { while (hasNext()) { b.appendCodePoint(next()); } return b; }
public int next() { if (! hasNext()) { throw new NoSuchElementException(); } offset ++; return CodePointIterator.this.next(); }
public int next() { if (!hasNext()) { throw new NoSuchElementException(); } return CodePointIterator.this.next(); }
public ByteStringBuilder appendAscii(CodePointIterator iterator) { int cp; while (iterator.hasNext()) { cp = iterator.next(); if (cp > 127) throw new IllegalArgumentException(); append((byte) cp); } return this; }
public ByteStringBuilder appendLatin1(CodePointIterator iterator) { int cp; while (iterator.hasNext()) { cp = iterator.next(); if (cp > 255) throw new IllegalArgumentException(); append((byte) cp); } return this; }
public ByteStringBuilder appendUtf8(CodePointIterator iterator) { while (iterator.hasNext()) { appendUtf8Raw(iterator.next()); } return this; }
/** * Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator. If the * contents are not equal, the iterators will be positioned at the location of the first difference (i.e. the code point * returned by {@link #next()} will be the differing code point. If the contents are equal, the iterators will both be * positioned at the end of their contents. * * @param other the other byte iterator * @return {@code true} if the contents are equal, {@code false} otherwise */ public final boolean contentEquals(CodePointIterator other) { for (;;) { if (hasNext()) { if (! other.hasNext()) { return false; } if (peekNext() != other.peekNext()) { return false; } next(); other.next(); } else { return ! other.hasNext(); } } }
private int seekNext(int next) throws NoSuchElementException { if (!CodePointIterator.this.hasNext()) { return next; } next = CodePointIterator.this.next(); if (skip(next)) { return seekNext(next); } CodePointIterator.this.prev(); return next; }
private int seekPrev(int prev) throws NoSuchElementException { if (!CodePointIterator.this.hasPrev()) { return prev; } prev = CodePointIterator.this.prev(); if (skip(prev)) { return seekPrev(prev); } CodePointIterator.this.next(); return prev; }
/** * Drain all the remaining code points in this iterator to the given string builder. * * @param b the string builder * @return the same string builder */ public StringBuilder drainTo(StringBuilder b) { while (hasNext()) { b.appendCodePoint(next()); } return b; }
public int next() { if (! hasNext()) { throw new NoSuchElementException(); } offset ++; return CodePointIterator.this.next(); }
public int next() { if (!hasNext()) { throw new NoSuchElementException(); } return CodePointIterator.this.next(); }
public ByteStringBuilder appendAscii(CodePointIterator iterator) { int cp; while (iterator.hasNext()) { cp = iterator.next(); if (cp > 127) throw new IllegalArgumentException(); append((byte) cp); } return this; }
public ByteStringBuilder appendLatin1(CodePointIterator iterator) { int cp; while (iterator.hasNext()) { cp = iterator.next(); if (cp > 255) throw new IllegalArgumentException(); append((byte) cp); } return this; }
public ByteStringBuilder appendUtf8(CodePointIterator iterator) { while (iterator.hasNext()) { appendUtf8Raw(iterator.next()); } return this; }
private int seekNext(int next) throws NoSuchElementException { if (!CodePointIterator.this.hasNext()) { return next; } next = CodePointIterator.this.next(); if (skip(next)) { return seekNext(next); } CodePointIterator.this.prev(); return next; }