1 /* 2 ******************************************************************************* 3 * Copyright (C) 2014, International Business Machines Corporation and * 4 * others. All Rights Reserved. * 5 ******************************************************************************* 6 */ 7 package com.ibm.icu.text; 8 9 import static com.ibm.icu.impl.CharacterIteration.DONE32; 10 11 import java.text.CharacterIterator; 12 13 import com.ibm.icu.lang.UCharacter; 14 import com.ibm.icu.lang.UProperty; 15 16 final class UnhandledBreakEngine implements LanguageBreakEngine { 17 // TODO: Use two arrays of UnicodeSet, one with all frozen sets, one with unfrozen. 18 // in handleChar(), update the unfrozen version, clone, freeze, replace the frozen one. 19 private final UnicodeSet[] fHandled = new UnicodeSet[BreakIterator.KIND_TITLE + 1]; UnhandledBreakEngine()20 public UnhandledBreakEngine() { 21 for (int i = 0; i < fHandled.length; i++) { 22 fHandled[i] = new UnicodeSet(); 23 } 24 } 25 handles(int c, int breakType)26 public boolean handles(int c, int breakType) { 27 return (breakType >= 0 && breakType < fHandled.length) && 28 (fHandled[breakType].contains(c)); 29 } 30 findBreaks(CharacterIterator text, int startPos, int endPos, boolean reverse, int breakType, DictionaryBreakEngine.DequeI foundBreaks)31 public int findBreaks(CharacterIterator text, int startPos, int endPos, 32 boolean reverse, int breakType, DictionaryBreakEngine.DequeI foundBreaks) { 33 text.setIndex(endPos); 34 return 0; 35 } 36 handleChar(int c, int breakType)37 public synchronized void handleChar(int c, int breakType) { 38 if (breakType >= 0 && breakType < fHandled.length && c != DONE32) { 39 if (!fHandled[breakType].contains(c)) { 40 int script = UCharacter.getIntPropertyValue(c, UProperty.SCRIPT); 41 fHandled[breakType].applyIntPropertyValue(UProperty.SCRIPT, script); 42 } 43 } 44 } 45 } 46