/** * 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; }
/** * Drain all the remaining code points in this iterator to a new string, * inserting the given prefix before every {@code n} code points. * * @param prefix the prefix * @param n the number of code points between each prefix * @return the string */ public String drainToString(final String prefix, final int n) { return hasNext() ? drainTo(new StringBuilder(), prefix, -1, n).toString() : ""; }
/** * Drain all the remaining code points in this iterator to a new string. * * @return the string */ public String drainToString() { return hasNext() ? drainTo(new StringBuilder()).toString() : ""; }
/** * Drain all the remaining code points in this iterator to a new string, * inserting the given delimiter after every {@code n} code points. * * @param delim the delimiter * @param n the number of code points between each delimiter * @return the string */ public String drainToString(final int delim, final int n) { return hasNext() ? drainTo(new StringBuilder(), null, delim, n).toString() : ""; }
/** * Hex-decode the current stream. * * @return an iterator over the decoded bytes */ public ByteIterator hexDecode() { if (! hasNext()) return ByteIterator.EMPTY; return new Base16DecodingByteIterator(this); }
/** * 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; }
/** * Return a copy of this iterator which is limited to the given number of code points after the current one. Advancing * the returned iterator will also advance this one. * * @param size the number of code points * @return the limited code point iterator */ public final CodePointIterator limitedTo(final long size) { if (size <= 0 || ! hasNext()) { return EMPTY; } return new LimitedCodePointIterator(this, size); }
/** * Drain all the remaining code points in this iterator to a new string, * inserting the given prefix and delimiter before and after every {@code n} * code points, respectively. * * @param prefix the prefix * @param delim the delimiter * @param n the number of code points between each prefix and delimiter * @return the string */ public String drainToString(final String prefix, final int delim, final int n) { return hasNext() ? drainTo(new StringBuilder(), prefix, delim, n).toString() : ""; }
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 static CipherSuitePredicate parseAndPredicate(CipherSuitePredicate item, final CodePointIterator i) { final ArrayList<CipherSuitePredicate> list = new ArrayList<>(); list.add(item); do { list.add(getSimplePredicateByName(i.delimitedBy('+', ':', ',', ' ').drainToString())); } while (i.hasNext() && i.next() == '+'); return CipherSuitePredicate.matchAll(list.toArray(new CipherSuitePredicate[list.size()])); }
public int peekNext() throws NoSuchElementException { if (! iter.hasNext()) { throw new NoSuchElementException(); } int next = seekNext(iter.peekNext()); if (! skip(next)) { return next; } return next; }
private int seekNext(int next) throws NoSuchElementException { if (! iter.hasNext()) { return next; } next = iter.next(); if (skip(next)) { return seekNext(next); } iter.previous(); return next; }
private static CipherSuitePredicate parsePredicate(final CodePointIterator i, final String word) { CipherSuitePredicate item = getSimplePredicateByName(word); if (i.hasNext() && i.next() == '+') { if (item == null) { throw ElytronMessages.log.mechSelectorTokenNotAllowed("+", i.getIndex(), i.drainToString()); } return parseAndPredicate(item, i); } else { return item; } }
private static AccessDescription getAccessDescription(final String methodAndTypeAndValue) throws IllegalArgumentException { // method:location-type:location-value final CodePointIterator cpi = CodePointIterator.ofString(methodAndTypeAndValue); final CodePointIterator di = cpi.delimitedBy(':'); if (! di.hasNext()) { throw log.invalidCertificateExtensionStringValue(methodAndTypeAndValue); } final String accessMethodId = oidFromMethod(di.drainToString()); skipDelims(di, cpi, ':'); final String typeAndValue = cpi.drainToString(); final GeneralName accessLocation = getGeneralName(typeAndValue); return new AccessDescription(accessMethodId, accessLocation); }