Class SimpleFilteredSentenceBreakIterator
- java.lang.Object
-
- com.ibm.icu.text.BreakIterator
-
- com.ibm.icu.impl.SimpleFilteredSentenceBreakIterator
-
- All Implemented Interfaces:
java.lang.Cloneable
public class SimpleFilteredSentenceBreakIterator extends BreakIterator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleFilteredSentenceBreakIterator.Builder
-
Field Summary
Fields Modifier and Type Field Description private CharsTrie
backwardsTrie
private BreakIterator
delegate
private CharsTrie
forwardsPartialTrie
private UCharacterIterator
text
-
Fields inherited from class com.ibm.icu.text.BreakIterator
DONE, KIND_CHARACTER, KIND_LINE, KIND_SENTENCE, KIND_TITLE, KIND_WORD, WORD_IDEO, WORD_IDEO_LIMIT, WORD_KANA, WORD_KANA_LIMIT, WORD_LETTER, WORD_LETTER_LIMIT, WORD_NONE, WORD_NONE_LIMIT, WORD_NUMBER, WORD_NUMBER_LIMIT
-
-
Constructor Summary
Constructors Constructor Description SimpleFilteredSentenceBreakIterator(BreakIterator adoptBreakIterator, CharsTrie forwardsPartialTrie, CharsTrie backwardsTrie)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
breakExceptionAt(int n)
Is there an exception at this point?java.lang.Object
clone()
Clone method.int
current()
Return the iterator's current position.boolean
equals(java.lang.Object obj)
int
first()
Set the iterator to the first boundary position.int
following(int offset)
Sets the iterator's current iteration position to be the first boundary position following the specified position.java.text.CharacterIterator
getText()
Returns a CharacterIterator over the text being analyzed.int
hashCode()
private int
internalNext(int n)
Given that the delegate has already given its "initial" answer, find the NEXT actual (non-suppressed) break.private int
internalPrev(int n)
Given that the delegate has already given its "initial" answer, find the PREV actual (non-suppressed) break.boolean
isBoundary(int offset)
Return true if the specified position is a boundary position.int
last()
Set the iterator to the last boundary position.int
next()
Advances the iterator forward one boundary.int
next(int n)
Move the iterator by the specified number of steps in the text.int
preceding(int offset)
Sets the iterator's current iteration position to be the last boundary position preceding the specified position.int
previous()
Move the iterator backward one boundary.private void
resetState()
Reset the filter from the delegate.void
setText(java.text.CharacterIterator newText)
Sets the iterator to analyze a new piece of text.-
Methods inherited from class com.ibm.icu.text.BreakIterator
getAvailableLocales, getAvailableULocales, getBreakInstance, getCharacterInstance, getCharacterInstance, getCharacterInstance, getLineInstance, getLineInstance, getLineInstance, getLocale, getRuleStatus, getRuleStatusVec, getSentenceInstance, getSentenceInstance, getSentenceInstance, getTitleInstance, getTitleInstance, getTitleInstance, getWordInstance, getWordInstance, getWordInstance, registerInstance, registerInstance, setText, setText, unregister
-
-
-
-
Field Detail
-
delegate
private BreakIterator delegate
-
text
private UCharacterIterator text
-
backwardsTrie
private CharsTrie backwardsTrie
-
forwardsPartialTrie
private CharsTrie forwardsPartialTrie
-
-
Constructor Detail
-
SimpleFilteredSentenceBreakIterator
public SimpleFilteredSentenceBreakIterator(BreakIterator adoptBreakIterator, CharsTrie forwardsPartialTrie, CharsTrie backwardsTrie)
- Parameters:
adoptBreakIterator
- break iterator to adoptforwardsPartialTrie
- forward & partial char trie to adoptbackwardsTrie
- backward trie to adopt
-
-
Method Detail
-
resetState
private final void resetState()
Reset the filter from the delegate.
-
breakExceptionAt
private final boolean breakExceptionAt(int n)
Is there an exception at this point?- Parameters:
n
- the location of the possible break- Returns:
-
internalNext
private final int internalNext(int n)
Given that the delegate has already given its "initial" answer, find the NEXT actual (non-suppressed) break.- Parameters:
n
- initial position from delegate- Returns:
- new break position or BreakIterator.DONE
-
internalPrev
private final int internalPrev(int n)
Given that the delegate has already given its "initial" answer, find the PREV actual (non-suppressed) break.- Parameters:
n
- initial position from delegate- Returns:
- new break position or BreakIterator.DONE
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
clone
public java.lang.Object clone()
Description copied from class:BreakIterator
Clone method. Creates another BreakIterator with the same behavior and current state as this one.- Overrides:
clone
in classBreakIterator
- Returns:
- The clone.
-
first
public int first()
Description copied from class:BreakIterator
Set the iterator to the first boundary position. This is always the beginning index of the text this iterator iterates over. For example, if the iterator iterates over a whole string, this function will always return 0.- Specified by:
first
in classBreakIterator
- Returns:
- The character offset of the beginning of the stretch of text being broken.
-
preceding
public int preceding(int offset)
Description copied from class:BreakIterator
Sets the iterator's current iteration position to be the last boundary position preceding the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the last boundary before the specified position.) If the specified position is the starting position, returns DONE.- Overrides:
preceding
in classBreakIterator
- Parameters:
offset
- The character position to start searching from.- Returns:
- The position of the last boundary position preceding "offset" (whether of not "offset" itself is a boundary position), or DONE if "offset" is the starting offset of the iterator.
-
previous
public int previous()
Description copied from class:BreakIterator
Move the iterator backward one boundary. The current iteration position is updated to point to the last boundary position before the current position, and this is also the value that is returned. If the current position is equal to the value returned by first(), or to DONE, this function returns DONE and sets the current position to DONE.- Specified by:
previous
in classBreakIterator
- Returns:
- The position of the last boundary position preceding the iteration position.
-
current
public int current()
Description copied from class:BreakIterator
Return the iterator's current position.- Specified by:
current
in classBreakIterator
- Returns:
- The iterator's current position.
-
isBoundary
public boolean isBoundary(int offset)
Description copied from class:BreakIterator
Return true if the specified position is a boundary position. If the function returns true, the current iteration position is set to the specified position; if the function returns false, the current iteration position is set as though following() had been called.- Overrides:
isBoundary
in classBreakIterator
- Parameters:
offset
- the offset to check.- Returns:
- True if "offset" is a boundary position.
-
next
public int next()
Description copied from class:BreakIterator
Advances the iterator forward one boundary. The current iteration position is updated to point to the next boundary position after the current position, and this is also the value that is returned. If the current position is equal to the value returned by last(), or to DONE, this function returns DONE and sets the current position to DONE.- Specified by:
next
in classBreakIterator
- Returns:
- The position of the first boundary position following the iteration position.
-
next
public int next(int n)
Description copied from class:BreakIterator
Move the iterator by the specified number of steps in the text. A positive number moves the iterator forward; a negative number moves the iterator backwards. If this causes the iterator to move off either end of the text, this function returns DONE; otherwise, this function returns the position of the appropriate boundary. Calling this function is equivalent to calling next() or previous() n times.- Specified by:
next
in classBreakIterator
- Parameters:
n
- The number of boundaries to advance over (if positive, moves forward; if negative, moves backwards).- Returns:
- The position of the boundary n boundaries from the current iteration position, or DONE if moving n boundaries causes the iterator to advance off either end of the text.
-
following
public int following(int offset)
Description copied from class:BreakIterator
Sets the iterator's current iteration position to be the first boundary position following the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the first boundary after the specified position.) If the specified position is the past-the-end position, returns DONE.- Specified by:
following
in classBreakIterator
- Parameters:
offset
- The character position to start searching from.- Returns:
- The position of the first boundary position following "offset" (whether or not "offset" itself is a boundary position), or DONE if "offset" is the past-the-end offset.
-
last
public int last()
Description copied from class:BreakIterator
Set the iterator to the last boundary position. This is always the "past-the-end" index of the text this iterator iterates over. For example, if the iterator iterates over a whole string (call it "text"), this function will always return text.length().- Specified by:
last
in classBreakIterator
- Returns:
- The character offset of the end of the stretch of text being broken.
-
getText
public java.text.CharacterIterator getText()
Description copied from class:BreakIterator
Returns a CharacterIterator over the text being analyzed.Caution:The state of the returned CharacterIterator must not be modified in any way while the BreakIterator is still in use. Doing so will lead to undefined behavior of the BreakIterator. Clone the returned CharacterIterator first and work with that.
The returned CharacterIterator is a reference to the actual iterator being used by the BreakIterator. No guarantees are made about the current position of this iterator when it is returned; it may differ from the BreakIterators current position. If you need to move that position to examine the text, clone this function's return value first.
- Specified by:
getText
in classBreakIterator
- Returns:
- A CharacterIterator over the text being analyzed.
-
setText
public void setText(java.text.CharacterIterator newText)
Description copied from class:BreakIterator
Sets the iterator to analyze a new piece of text. This function resets the current iteration position to the beginning of the text. (The old iterator is dropped.)Caution: The supplied CharacterIterator is used directly by the BreakIterator, and must not be altered in any way by code outside of the BreakIterator. Doing so will lead to undefined behavior of the BreakIterator.
- Specified by:
setText
in classBreakIterator
- Parameters:
newText
- A CharacterIterator referring to the text to analyze with this BreakIterator (the iterator's current position is ignored, but its other state is significant).
-
-