Top Inners Fields Constructors Methods
com.ibm.icu.impl

public Class SimpleFilteredSentenceBreakIterator

extends BreakIterator
Class Inheritance
Imports
java.text.CharacterIterator, java.util.HashSet, .Locale, com.ibm.icu.impl.ICUResourceBundle.OpenType, com.ibm.icu.text.BreakIterator, .FilteredBreakIteratorBuilder, .UCharacterIterator, com.ibm.icu.util.BytesTrie, .CharsTrie, .CharsTrieBuilder, .ICUCloneNotSupportedException, .StringTrieBuilder, .ULocale

Author
tomzhang

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private CharsTrie
private BreakIterator
private CharsTrie
private UCharacterIterator
Inherited from com.ibm.icu.text.BreakIterator:
DONEKIND_CHARACTERKIND_LINEKIND_SENTENCEKIND_TITLEKIND_WORDWORD_IDEOWORD_IDEO_LIMITWORD_KANAWORD_KANA_LIMITWORD_LETTERWORD_LETTER_LIMITWORD_NONEWORD_NONE_LIMITWORD_NUMBERWORD_NUMBER_LIMIT

Constructor Summary

AccessConstructor and Description
public
SimpleFilteredSentenceBreakIterator(BreakIterator
break iterator to adopt
adoptBreakIterator
,
CharsTrie
forward & partial char trie to adopt
forwardsPartialTrie
,
CharsTrie
backward trie to adopt
backwardsTrie
)

Method Summary

Modifier and TypeMethod and Description
private final boolean
breakExceptionAt(int
the location of the possible break
n
)

Is there an exception at this point?

public Object
clone()

Overrides com.ibm.icu.text.BreakIterator.clone.

Clone method.
public int
current()

Implements abstract com.ibm.icu.text.BreakIterator.current.

Return the iterator's current position.
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
first()

Implements abstract com.ibm.icu.text.BreakIterator.first.

Set the iterator to the first boundary position.
public int
following(int
The character position to start searching from.
offset
)

Implements abstract com.ibm.icu.text.BreakIterator.following.

Sets the iterator's current iteration position to be the first boundary position following the specified position.
public CharacterIterator
getText()

Implements abstract com.ibm.icu.text.BreakIterator.getText.

Returns a CharacterIterator over the text being analyzed.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private final int

Returns:

new break position or BreakIterator.DONE
internalNext
(int
initial position from delegate
n
)

Given that the delegate has already given its "initial" answer, find the NEXT actual (non-suppressed) break.

private final int

Returns:

new break position or BreakIterator.DONE
internalPrev
(int
initial position from delegate
n
)

Given that the delegate has already given its "initial" answer, find the PREV actual (non-suppressed) break.

public boolean
isBoundary(int
the offset to check.
offset
)

Overrides com.ibm.icu.text.BreakIterator.isBoundary.

Return true if the specified position is a boundary position.
public int
last()

Implements abstract com.ibm.icu.text.BreakIterator.last.

Set the iterator to the last boundary position.
public int
next()

Implements abstract com.ibm.icu.text.BreakIterator.next.

Advances the iterator forward one boundary.
public int
next(int
The number of boundaries to advance over (if positive, moves forward; if negative, moves backwards).
n
)

Implements abstract com.ibm.icu.text.BreakIterator.next.

Move the iterator by the specified number of steps in the text.
public int
preceding(int
The character position to start searching from.
offset
)

Overrides com.ibm.icu.text.BreakIterator.preceding.

Sets the iterator's current iteration position to be the last boundary position preceding the specified position.
public int
previous()

Implements abstract com.ibm.icu.text.BreakIterator.previous.

Move the iterator backward one boundary.
private final void
resetState()

Reset the filter from the delegate.

public void
setText(CharacterIterator
A CharacterIterator referring to the text to analyze with this BreakIterator (the iterator's current position is ignored, but its other state is significant).
newText
)

Implements abstract com.ibm.icu.text.BreakIterator.setText.

Sets the iterator to analyze a new piece of text.
Inherited from com.ibm.icu.text.BreakIterator:
getAvailableLocalesgetAvailableULocalesgetBreakInstancegetCharacterInstancegetCharacterInstancegetCharacterInstancegetLineInstancegetLineInstancegetLineInstancegetLocalegetRuleStatusgetRuleStatusVecgetSentenceInstancegetSentenceInstancegetSentenceInstancegetTitleInstancegetTitleInstancegetTitleInstancegetWordInstancegetWordInstancegetWordInstanceregisterInstanceregisterInstancesetTextsetTextunregister

Field Detail

backwardsTrieback to summary
private CharsTrie backwardsTrie
delegateback to summary
private BreakIterator delegate
forwardsPartialTrieback to summary
private CharsTrie forwardsPartialTrie
textback to summary
private UCharacterIterator text

Constructor Detail

SimpleFilteredSentenceBreakIteratorback to summary
public SimpleFilteredSentenceBreakIterator(BreakIterator adoptBreakIterator, CharsTrie forwardsPartialTrie, CharsTrie backwardsTrie)
Parameters
adoptBreakIterator:BreakIterator

break iterator to adopt

forwardsPartialTrie:CharsTrie

forward & partial char trie to adopt

backwardsTrie:CharsTrie

backward trie to adopt

Method Detail

breakExceptionAtback to summary
private final boolean breakExceptionAt(int n)

Is there an exception at this point?

Parameters
n:int

the location of the possible break

cloneback to summary
public Object clone()

Overrides com.ibm.icu.text.BreakIterator.clone.

Doc from com.ibm.icu.text.BreakIterator.clone.

Clone method. Creates another BreakIterator with the same behavior and current state as this one.

Returns:Object

The clone.

Annotations
@Override
currentback to summary
public int current()

Implements abstract com.ibm.icu.text.BreakIterator.current.

Doc from com.ibm.icu.text.BreakIterator.current.

Return the iterator's current position.

Returns:int

The iterator's current position.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
firstback to summary
public int first()

Implements abstract com.ibm.icu.text.BreakIterator.first.

Doc from com.ibm.icu.text.BreakIterator.first.

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.

Returns:int

The character offset of the beginning of the stretch of text being broken.

Annotations
@Override
followingback to summary
public int following(int offset)

Implements abstract com.ibm.icu.text.BreakIterator.following.

Doc from com.ibm.icu.text.BreakIterator.following.

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.

Parameters
offset:int

The character position to start searching from.

Returns:int

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.

Annotations
@Override
getTextback to summary
public CharacterIterator getText()

Implements abstract com.ibm.icu.text.BreakIterator.getText.

Doc from com.ibm.icu.text.BreakIterator.getText.

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.

Returns:CharacterIterator

A CharacterIterator over the text being analyzed.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
internalNextback to summary
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:int

initial position from delegate

Returns:int

new break position or BreakIterator.DONE

internalPrevback to summary
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:int

initial position from delegate

Returns:int

new break position or BreakIterator.DONE

isBoundaryback to summary
public boolean isBoundary(int offset)

Overrides com.ibm.icu.text.BreakIterator.isBoundary.

Doc from com.ibm.icu.text.BreakIterator.isBoundary.

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.

Parameters
offset:int

the offset to check.

Returns:boolean

True if "offset" is a boundary position.

Annotations
@Override
lastback to summary
public int last()

Implements abstract com.ibm.icu.text.BreakIterator.last.

Doc from com.ibm.icu.text.BreakIterator.last.

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().

Returns:int

The character offset of the end of the stretch of text being broken.

Annotations
@Override
nextback to summary
public int next()

Implements abstract com.ibm.icu.text.BreakIterator.next.

Doc from com.ibm.icu.text.BreakIterator.next.

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.

Returns:int

The position of the first boundary position following the iteration position.

Annotations
@Override
nextback to summary
public int next(int n)

Implements abstract com.ibm.icu.text.BreakIterator.next.

Doc from com.ibm.icu.text.BreakIterator.next.

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.

Parameters
n:int

The number of boundaries to advance over (if positive, moves forward; if negative, moves backwards).

Returns:int

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.

Annotations
@Override
precedingback to summary
public int preceding(int offset)

Overrides com.ibm.icu.text.BreakIterator.preceding.

Doc from com.ibm.icu.text.BreakIterator.preceding.

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.

Parameters
offset:int

The character position to start searching from.

Returns:int

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.

Annotations
@Override
previousback to summary
public int previous()

Implements abstract com.ibm.icu.text.BreakIterator.previous.

Doc from com.ibm.icu.text.BreakIterator.previous.

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.

Returns:int

The position of the last boundary position preceding the iteration position.

Annotations
@Override
resetStateback to summary
private final void resetState()

Reset the filter from the delegate.

setTextback to summary
public void setText(CharacterIterator newText)

Implements abstract com.ibm.icu.text.BreakIterator.setText.

Doc from com.ibm.icu.text.BreakIterator.setText.

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.

Parameters
newText:CharacterIterator

A CharacterIterator referring to the text to analyze with this BreakIterator (the iterator's current position is ignored, but its other state is significant).

Annotations
@Override
com.ibm.icu.impl back to summary

public Class SimpleFilteredSentenceBreakIterator.Builder

extends FilteredBreakIteratorBuilder
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final int
private HashSet<CharSequence>
filterSet

filter set to store all exceptions

pack-priv static final int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public
public
Builder(ULocale
the locale to get filtered iterators
loc
)

Create SimpleFilteredBreakIteratorBuilder using given locale

public
Builder()

Create SimpleFilteredBreakIteratorBuilder with no exception

Method Summary

Modifier and TypeMethod and Description
public boolean
suppressBreakAfter(CharSequence
the string to suppress, such as "Mr."
str
)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.suppressBreakAfter.

Suppress a certain string from being the end of a segment.
public boolean
unsuppressBreakAfter(CharSequence
the str the string to unsuppress, such as "Mr."
str
)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.unsuppressBreakAfter.

Stop suppressing a certain string from being the end of the segment.
public BreakIterator
wrapIteratorWithFilter(BreakIterator
the break iterator to wrap
adoptBreakIterator
)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.wrapIteratorWithFilter.

Wrap (adopt) an existing break iterator in a new filtered instance.
Inherited from com.ibm.icu.text.FilteredBreakIteratorBuilder:
getEmptyInstancegetInstancegetInstance

Field Detail

AddToForwardback to summary
pack-priv static final int AddToForward
filterSetback to summary
private HashSet<CharSequence> filterSet

filter set to store all exceptions

MATCHback to summary
pack-priv static final int MATCH
PARTIALback to summary
pack-priv static final int PARTIAL
SuppressInReverseback to summary
pack-priv static final int SuppressInReverse

Constructor Detail

Builderback to summary
public Builder(Locale loc)
Builderback to summary
public Builder(ULocale loc)

Create SimpleFilteredBreakIteratorBuilder using given locale

Parameters
loc:ULocale

the locale to get filtered iterators

Builderback to summary
public Builder()

Create SimpleFilteredBreakIteratorBuilder with no exception

Method Detail

suppressBreakAfterback to summary
public boolean suppressBreakAfter(CharSequence str)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.suppressBreakAfter.

Doc from com.ibm.icu.text.FilteredBreakIteratorBuilder.suppressBreakAfter.

Suppress a certain string from being the end of a segment. For example, suppressing "Mr.", then segments ending in "Mr." will not be returned by the iterator.

Parameters
str:CharSequence

the string to suppress, such as "Mr."

Returns:boolean

true if the string was not present and now added, false if the call was a no-op because the string was already being suppressed.

Annotations
@Override
unsuppressBreakAfterback to summary
public boolean unsuppressBreakAfter(CharSequence str)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.unsuppressBreakAfter.

Doc from com.ibm.icu.text.FilteredBreakIteratorBuilder.unsuppressBreakAfter.

Stop suppressing a certain string from being the end of the segment. This function does not create any new segment boundaries, but only serves to un-do the effect of earlier calls to suppressBreakAfter, or to un-do the effect of locale data which may be suppressing certain strings.

Parameters
str:CharSequence

the str the string to unsuppress, such as "Mr."

Returns:boolean

true if the string was present and now removed, false if the call was a no-op because the string was not being suppressed.

Annotations
@Override
wrapIteratorWithFilterback to summary
public BreakIterator wrapIteratorWithFilter(BreakIterator adoptBreakIterator)

Implements abstract com.ibm.icu.text.FilteredBreakIteratorBuilder.wrapIteratorWithFilter.

Doc from com.ibm.icu.text.FilteredBreakIteratorBuilder.wrapIteratorWithFilter.

Wrap (adopt) an existing break iterator in a new filtered instance. Note that the wrappedBreakIterator is adopted by the new BreakIterator and should no longer be used by the caller. The FilteredBreakIteratorBuilder may be reused.

Parameters
adoptBreakIterator:BreakIterator

the break iterator to wrap

Returns:BreakIterator

the new BreakIterator

Annotations
@Override