• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2016 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 /*
5  *******************************************************************************
6  * Copyright (C) 2014-2016, International Business Machines Corporation and
7  * others. All Rights Reserved.
8  *******************************************************************************
9  */
10 package ohos.global.icu.text;
11 
12 import java.util.Locale;
13 
14 import ohos.global.icu.impl.SimpleFilteredSentenceBreakIterator;
15 import ohos.global.icu.util.ULocale;
16 
17 /**
18  * The BreakIteratorFilter is used to modify the behavior of a BreakIterator
19  *  by constructing a new BreakIterator which suppresses certain segment boundaries.
20  *  See  http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions .
21  *  For example, a typical English Sentence Break Iterator would break on the space
22  *  in the string "Mr. Smith" (resulting in two segments),
23  *  but with "Mr." as an exception, a filtered break iterator
24  *  would consider the string "Mr. Smith" to be a single segment.
25  *
26  * <p>This class is not intended for public subclassing.
27  *
28  * @hide exposed on OHOS
29  */
30 public abstract class FilteredBreakIteratorBuilder {
31 
32     /**
33      * Construct a FilteredBreakIteratorBuilder based on sentence break exception rules in a locale.
34      * The rules are taken from CLDR exception data for the locale,
35      * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions
36      * This is the equivalent of calling createInstance(UErrorCode&amp;)
37      * and then repeatedly calling addNoBreakAfter(...) with the contents
38      * of the CLDR exception data.
39      * @param where the locale.
40      * @return the new builder
41      */
getInstance(Locale where)42     public static final FilteredBreakIteratorBuilder getInstance(Locale where) {
43         return new SimpleFilteredSentenceBreakIterator.Builder(where);
44     }
45 
46     /**
47      * Construct a FilteredBreakIteratorBuilder based on sentence break exception rules in a locale.
48      * The rules are taken from CLDR exception data for the locale,
49      * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions
50      * This is the equivalent of calling createInstance(UErrorCode&amp;)
51      * and then repeatedly calling addNoBreakAfter(...) with the contents
52      * of the CLDR exception data.
53      * @param where the locale.
54      * @return the new builder
55      */
getInstance(ULocale where)56     public static final FilteredBreakIteratorBuilder getInstance(ULocale where) {
57         return new SimpleFilteredSentenceBreakIterator.Builder(where);
58     }
59 
60     /**
61      * Construct an empty FilteredBreakIteratorBuilder.
62      * In this state, it will not suppress any segment boundaries.
63      * @return the new builder
64      */
getEmptyInstance()65     public static final FilteredBreakIteratorBuilder getEmptyInstance() {
66         return new SimpleFilteredSentenceBreakIterator.Builder();
67     }
68 
69     /**
70      * Suppress a certain string from being the end of a segment.
71      * For example, suppressing "Mr.", then segments ending in "Mr." will not be returned
72      * by the iterator.
73      * @param str the string to suppress, such as "Mr."
74      * @return true if the string was not present and now added,
75      * false if the call was a no-op because the string was already being suppressed.
76      */
suppressBreakAfter(CharSequence str)77     public abstract boolean suppressBreakAfter(CharSequence str);
78 
79     /**
80      * Stop suppressing a certain string from being the end of the segment.
81      * This function does not create any new segment boundaries, but only serves to un-do
82      * the effect of earlier calls to suppressBreakAfter, or to un-do the effect of
83      * locale data which may be suppressing certain strings.
84      * @param str the str the string to unsuppress, such as "Mr."
85      * @return true if the string was present and now removed,
86      * false if the call was a no-op because the string was not being suppressed.
87      */
unsuppressBreakAfter(CharSequence str)88     public abstract boolean unsuppressBreakAfter(CharSequence str);
89 
90     /**
91      * Wrap (adopt) an existing break iterator in a new filtered instance.
92      * Note that the wrappedBreakIterator is adopted by the new BreakIterator
93      * and should no longer be used by the caller.
94      * The FilteredBreakIteratorBuilder may be reused.
95      * @param wrappedBreakIterator the break iterator to wrap
96      * @return the new BreakIterator
97      */
wrapIteratorWithFilter(BreakIterator wrappedBreakIterator)98     public abstract BreakIterator wrapIteratorWithFilter(BreakIterator wrappedBreakIterator);
99 
100     /**
101      * For subclass use
102      * @deprecated internal to ICU
103      * @hide draft / provisional / internal are hidden on OHOS
104      */
105     @Deprecated
FilteredBreakIteratorBuilder()106     protected FilteredBreakIteratorBuilder() {
107     }
108 }