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) 2016, International Business Machines Corporation and * 7 * others. All Rights Reserved. * 8 ******************************************************************************* 9 */ 10 package android.icu.text; 11 12 import static android.icu.impl.CharacterIteration.DONE32; 13 14 import java.text.CharacterIterator; 15 16 import android.icu.impl.CharacterIteration; 17 import android.icu.lang.UCharacter; 18 import android.icu.lang.UProperty; 19 20 final class UnhandledBreakEngine implements LanguageBreakEngine { 21 // TODO: Use two arrays of UnicodeSet, one with all frozen sets, one with unfrozen. 22 // in handleChar(), update the unfrozen version, clone, freeze, replace the frozen one. 23 private final UnicodeSet[] fHandled = new UnicodeSet[BreakIterator.KIND_TITLE + 1]; UnhandledBreakEngine()24 public UnhandledBreakEngine() { 25 for (int i = 0; i < fHandled.length; i++) { 26 fHandled[i] = new UnicodeSet(); 27 } 28 } 29 handles(int c, int breakType)30 public boolean handles(int c, int breakType) { 31 return (breakType >= 0 && breakType < fHandled.length) && 32 (fHandled[breakType].contains(c)); 33 } 34 findBreaks(CharacterIterator text, int startPos, int endPos, boolean reverse, int breakType, DictionaryBreakEngine.DequeI foundBreaks)35 public int findBreaks(CharacterIterator text, int startPos, int endPos, 36 boolean reverse, int breakType, DictionaryBreakEngine.DequeI foundBreaks) { 37 if (breakType >= 0 && breakType < fHandled.length) { 38 int c = CharacterIteration.current32(text); 39 if (reverse) { 40 while (text.getIndex() > startPos && fHandled[breakType].contains(c)) { 41 CharacterIteration.previous32(text); 42 c = CharacterIteration.current32(text); 43 } 44 } else { 45 while (text.getIndex() < endPos && fHandled[breakType].contains(c)) { 46 CharacterIteration.next32(text); 47 c = CharacterIteration.current32(text); 48 } 49 } 50 } 51 return 0; 52 } 53 handleChar(int c, int breakType)54 public synchronized void handleChar(int c, int breakType) { 55 if (breakType >= 0 && breakType < fHandled.length && c != DONE32) { 56 if (!fHandled[breakType].contains(c)) { 57 int script = UCharacter.getIntPropertyValue(c, UProperty.SCRIPT); 58 fHandled[breakType].applyIntPropertyValue(UProperty.SCRIPT, script); 59 } 60 } 61 } 62 } 63