/** * Finds the number of subsequent next iteration marks * * @return number of iteration marks starting at the current buffer position * @throws IOException If there is a low-level I/O error. */ private int nextIterationMarkSpanSize() throws IOException { int spanSize = 0; for (int i = bufferPosition; buffer.get(i) != -1 && isIterationMark((char) (buffer.get(i))); i++) { spanSize++; } // Restrict span size so that we don't go past the previous end position if (bufferPosition - spanSize < iterationMarkSpanEndPosition) { spanSize = bufferPosition - iterationMarkSpanEndPosition; } return spanSize; }
@Override public int read() throws IOException { int ic = buffer.get(bufferPosition); // End of input if (ic == -1) { buffer.freeBefore(bufferPosition); return ic; } char c = (char) ic; // Skip surrogate pair characters if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { iterationMarkSpanEndPosition = bufferPosition + 1; } // Free rolling buffer on full stop if (c == FULL_STOP_PUNCTUATION) { buffer.freeBefore(bufferPosition); iterationMarkSpanEndPosition = bufferPosition + 1; } // Normalize iteration mark if (isIterationMark(c)) { c = normalizeIterationMark(c); } bufferPosition++; return c; }