private BreakIterator createTestIterator(int kind) {
final String bname = "com.ibm.icu.dev.test.rbbi.BreakIteratorRules_en_US_TEST";
BreakIterator iter = null;
ListResourceBundle bundle = null;
try {
Class cls = Class.forName(bname);
bundle = (ListResourceBundle)cls.newInstance();
}
catch (Exception e) {
errln("could not create bundle: " + bname + "exception: " + e.getMessage());
return null;
}
final String[] kindNames = {
"Character", "Word", "Line", "Sentence"
};
String rulesName = kindNames[kind] + "BreakRules";
String dictionaryName = kindNames[kind] + "BreakDictionary";
String[] classNames = bundle.getStringArray("BreakIteratorClasses");
String rules = bundle.getString(rulesName);
if (classNames[kind].equals("RuleBasedBreakIterator")) {
iter = new RuleBasedBreakIterator(rules);
}
else if (classNames[kind].equals("DictionaryBasedBreakIterator")) {
try {
String dictionaryPath = bundle.getString(dictionaryName);
InputStream dictionary = bundle.getClass().getResourceAsStream(dictionaryPath);
System.out.println("looking for " + dictionaryPath + " from " + bundle.getClass() + " returned " + dictionary);
iter = new DictionaryBasedBreakIterator(rules, dictionary);
}
catch(IOException e) {
e.printStackTrace();
errln(e.getMessage());