public class BoundedBreakIteratorScanner
extends java.text.BreakIterator
UnifiedHighlighter context.
This class uses a BreakIterator to find the last break after the provided offset
that would create a passage smaller than maxLen.
If the BreakIterator cannot find a passage smaller than the maximum length,
a secondary break iterator is used to re-split the passage at the first boundary after
maximum length.
This is useful to split passages created by BreakIterators like `sentence` that
can create big outliers on semi-structured text.
WARNING: This break iterator is designed to work with the UnifiedHighlighter.
TODO: We should be able to create passages incrementally, starting from the offset of the first match and expanding or not
depending on the offsets of subsequent matches. This is currently impossible because FieldHighlighter uses
only the first matching offset to derive the start and end of each passage.| Modifier and Type | Method | Description |
|---|---|---|
int |
current() |
|
int |
first() |
|
int |
following(int offset) |
Can be invoked only after a call to preceding(offset+1).
|
static java.text.BreakIterator |
getSentence(java.util.Locale locale,
int maxLen) |
Returns a
BreakIterator.getSentenceInstance(Locale) bounded to maxLen. |
java.text.CharacterIterator |
getText() |
|
int |
last() |
|
int |
next() |
|
int |
next(int n) |
|
int |
preceding(int offset) |
Must be called with increasing offset.
|
int |
previous() |
|
void |
setText(java.lang.String newText) |
|
void |
setText(java.text.CharacterIterator newText) |
public java.text.CharacterIterator getText()
getText in class java.text.BreakIteratorpublic void setText(java.text.CharacterIterator newText)
setText in class java.text.BreakIteratorpublic void setText(java.lang.String newText)
setText in class java.text.BreakIteratorpublic int preceding(int offset)
FieldHighlighter for usage.preceding in class java.text.BreakIteratorpublic int following(int offset)
FieldHighlighter for usage.following in class java.text.BreakIteratorpublic static java.text.BreakIterator getSentence(java.util.Locale locale,
int maxLen)
BreakIterator.getSentenceInstance(Locale) bounded to maxLen.
Secondary boundaries are found using a BreakIterator.getWordInstance(Locale).public int current()
current in class java.text.BreakIteratorpublic int first()
first in class java.text.BreakIteratorpublic int next()
next in class java.text.BreakIteratorpublic int last()
last in class java.text.BreakIteratorpublic int next(int n)
next in class java.text.BreakIteratorpublic int previous()
previous in class java.text.BreakIterator