Home | History | Annotate | Download | only in text
      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 android.icu.text;
     11 
     12 import java.util.Locale;
     13 
     14 import android.icu.impl.SimpleFilteredSentenceBreakIterator;
     15 import android.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 Only a subset of ICU is exposed in Android
     29  * @hide draft / provisional / internal are hidden on Android
     30  */
     31 public abstract class FilteredBreakIteratorBuilder {
     32 
     33     /**
     34      * Construct a FilteredBreakIteratorBuilder based on sentence break exception rules in a locale.
     35      * The rules are taken from CLDR exception data for the locale,
     36      * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions
     37      * This is the equivalent of calling createInstance(UErrorCode&amp;)
     38      * and then repeatedly calling addNoBreakAfter(...) with the contents
     39      * of the CLDR exception data.
     40      * @param where the locale.
     41      * @return the new builder
     42      * @hide draft / provisional / internal are hidden on Android
     43      */
     44     public static final FilteredBreakIteratorBuilder getInstance(Locale where) {
     45         return new SimpleFilteredSentenceBreakIterator.Builder(where);
     46     }
     47 
     48     /**
     49      * Construct a FilteredBreakIteratorBuilder based on sentence break exception rules in a locale.
     50      * The rules are taken from CLDR exception data for the locale,
     51      * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions
     52      * This is the equivalent of calling createInstance(UErrorCode&amp;)
     53      * and then repeatedly calling addNoBreakAfter(...) with the contents
     54      * of the CLDR exception data.
     55      * @param where the locale.
     56      * @return the new builder
     57      * @hide draft / provisional / internal are hidden on Android
     58      */
     59     public static final FilteredBreakIteratorBuilder getInstance(ULocale where) {
     60         return new SimpleFilteredSentenceBreakIterator.Builder(where);
     61     }
     62 
     63     /**
     64      * Construct an empty FilteredBreakIteratorBuilder.
     65      * In this state, it will not suppress any segment boundaries.
     66      * @return the new builder
     67      * @hide draft / provisional / internal are hidden on Android
     68      */
     69     public static final FilteredBreakIteratorBuilder getEmptyInstance() {
     70         return new SimpleFilteredSentenceBreakIterator.Builder();
     71     }
     72 
     73     /**
     74      * Suppress a certain string from being the end of a segment.
     75      * For example, suppressing "Mr.", then segments ending in "Mr." will not be returned
     76      * by the iterator.
     77      * @param str the string to suppress, such as "Mr."
     78      * @return true if the string was not present and now added,
     79      * false if the call was a no-op because the string was already being suppressed.
     80      * @hide draft / provisional / internal are hidden on Android
     81      */
     82     public abstract boolean suppressBreakAfter(CharSequence str);
     83 
     84     /**
     85      * Stop suppressing a certain string from being the end of the segment.
     86      * This function does not create any new segment boundaries, but only serves to un-do
     87      * the effect of earlier calls to suppressBreakAfter, or to un-do the effect of
     88      * locale data which may be suppressing certain strings.
     89      * @param str the str the string to unsuppress, such as "Mr."
     90      * @return true if the string was present and now removed,
     91      * false if the call was a no-op because the string was not being suppressed.
     92      * @hide draft / provisional / internal are hidden on Android
     93      */
     94     public abstract boolean unsuppressBreakAfter(CharSequence str);
     95 
     96     /**
     97      * Wrap (adopt) an existing break iterator in a new filtered instance.
     98      * Note that the wrappedBreakIterator is adopted by the new BreakIterator
     99      * and should no longer be used by the caller.
    100      * The FilteredBreakIteratorBuilder may be reused.
    101      * @param wrappedBreakIterator the break iterator to wrap
    102      * @return the new BreakIterator
    103      * @hide draft / provisional / internal are hidden on Android
    104      */
    105     public abstract BreakIterator wrapIteratorWithFilter(BreakIterator wrappedBreakIterator);
    106 
    107     /**
    108      * For subclass use
    109      * @deprecated internal to ICU
    110      * @hide draft / provisional / internal are hidden on Android
    111      */
    112     @Deprecated
    113     protected FilteredBreakIteratorBuilder() {
    114     }
    115 }