@Override public int previous() { if (current == start) { return DONE; } else { return first(); } }
@Override public int next() { if (current == end) { return DONE; } else { return last(); } }
@Override protected BreakIterator getBreakIterator(String field) { if (definition.breakIterator == null) return new WholeBreakIterator(); switch (definition.breakIterator.type) { case character: return BreakIterator.getCharacterInstance(locale); case word: return BreakIterator.getWordInstance(locale); case line: return BreakIterator.getLineInstance(locale); default: case sentence: return BreakIterator.getSentenceInstance(locale); } }
@Override public int preceding(int pos) { if (pos < start || pos > end) { throw new IllegalArgumentException("offset out of bounds"); } else if (pos == start) { // this conflicts with the javadocs, but matches actual behavior (Oracle has a bug in something) // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=9000909 current = start; return DONE; } else { return first(); } }
@Override public int following(int pos) { if (pos < start || pos > end) { throw new IllegalArgumentException("offset out of bounds"); } else if (pos == end) { // this conflicts with the javadocs, but matches actual behavior (Oracle has a bug in something) // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=9000909 current = end; return DONE; } else { return last(); } }