/** parse a break iterator type for the specified locale */ protected BreakIterator parseBreakIterator(String type, Locale locale) { if (type == null || "SENTENCE".equals(type)) { return BreakIterator.getSentenceInstance(locale); } else if ("LINE".equals(type)) { return BreakIterator.getLineInstance(locale); } else if ("WORD".equals(type)) { return BreakIterator.getWordInstance(locale); } else if ("CHARACTER".equals(type)) { return BreakIterator.getCharacterInstance(locale); } else if ("WHOLE".equals(type)) { return new WholeBreakIterator(); } else { throw new IllegalArgumentException("Unknown " + HighlightParams.BS_TYPE + ": " + type); } }