mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-22789 Refactor and move up member field BreakIterator initialization
Move the initialization into the constructor of the concrete Segmenter class, rather than relying on the first line of each relevant helper util class method to do the initialization
This commit is contained in:
parent
1e90edba0c
commit
c3abc328d7
3 changed files with 4 additions and 9 deletions
|
@ -95,6 +95,8 @@ public class LocalizedSegmenter implements Segmenter {
|
|||
this.source = source;
|
||||
this.segmenter = segmenter;
|
||||
this.breakIter = this.segmenter.getNewBreakIterator();
|
||||
|
||||
this.breakIter.setText(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -60,6 +60,8 @@ public class RuleBasedSegmenter implements Segmenter {
|
|||
this.source = source;
|
||||
this.segmenter = segmenter;
|
||||
this.breakIter = this.segmenter.getNewBreakIterator();
|
||||
|
||||
this.breakIter.setText(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,12 +11,9 @@ import java.util.stream.Stream;
|
|||
import java.util.stream.StreamSupport;
|
||||
|
||||
|
||||
// Global TODO: make initialization of breakIterator a prerequisite
|
||||
public class SegmentsImplUtils {
|
||||
|
||||
public static boolean isBoundary(BreakIterator breakIter, CharSequence source, int i) {
|
||||
breakIter.setText(source);
|
||||
|
||||
return breakIter.isBoundary(i);
|
||||
}
|
||||
|
||||
|
@ -25,9 +22,6 @@ public class SegmentsImplUtils {
|
|||
}
|
||||
|
||||
public static Segment segmentAt(BreakIterator breakIter, CharSequence sourceSequence, int i) {
|
||||
// TODO: make initialization of breakIterator a prerequisite
|
||||
breakIter.setText(sourceSequence);
|
||||
|
||||
int start;
|
||||
int limit;
|
||||
|
||||
|
@ -86,9 +80,6 @@ public class SegmentsImplUtils {
|
|||
}
|
||||
|
||||
public static IntStream boundariesBackFrom(BreakIterator breakIter, CharSequence sourceSequence, int i) {
|
||||
// TODO: make initialization of breakIterator a prerequisite
|
||||
breakIter.setText(sourceSequence);
|
||||
|
||||
int sourceLength = sourceSequence.length();
|
||||
if (i < 0) {
|
||||
return IntStream.empty();
|
||||
|
|
Loading…
Add table
Reference in a new issue