@Override public boolean hasNext() { return internal.hasNext(); }
private static int length(CodepointIterator ci) { int n = 0; while (ci.hasNext()) { ci.next(); n++; } return n; }
/** * Verifies a sequence of codepoints using the specified filter */ public static void verifyNot(CodepointIterator ci, Filter filter) throws InvalidCharacterException { CodepointIterator rci = ci.restrict(filter, false, true); while (rci.hasNext()) rci.next(); }
/** * Verifies a sequence of codepoints using the specified filter */ public static void verify(CodepointIterator ci, Filter filter) throws InvalidCharacterException { CodepointIterator rci = CodepointIterator.restrict(ci, filter); while (rci.hasNext()) rci.next(); }
/** * Verifies a sequence of codepoints using the specified profile */ public static void verifyNot(CodepointIterator ci, Profile profile) throws InvalidCharacterException { CodepointIterator rci = ci.restrict(profile.filter(), false, true); while (rci.hasNext()) rci.next(); }
/** * Verifies a sequence of codepoints using the specified filter */ public static void verify(CodepointIterator ci, Profile profile) throws InvalidCharacterException { CodepointIterator rci = CodepointIterator.restrict(ci, profile.filter()); while (rci.hasNext()) rci.next(); }
private boolean isNextSurrogate() { if (!hasNext()) return false; char c = get(position()); return CharUtils.isHighSurrogate(c) || CharUtils.isLowSurrogate(c); }
private static void decompose(CharSequence source, Form form, StringBuilder buf) throws IOException { StringBuilder internal = new StringBuilder(); CodepointIterator ci = CodepointIterator.forCharSequence(source); boolean canonical = form.isCanonical(); while (ci.hasNext()) { Codepoint c = ci.next(); internal.setLength(0); UnicodeCharacterDatabase.decompose(c.getValue(), canonical, internal); CodepointIterator ii = CodepointIterator.forCharSequence(internal); while (ii.hasNext()) { Codepoint ch = ii.next(); int i = findInsertionPoint(buf, ch.getValue()); buf.insert(i, CharUtils.toString(ch.getValue())); } } }
/** * Verifies a sequence of codepoints using the specified profile */ public static void verifyNot(char[] array, Profile profile) throws InvalidCharacterException { CodepointIterator rci = CodepointIterator.forCharArray(array).restrict(profile.filter(), false, true); while (rci.hasNext()) rci.next(); }
/** * 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; }