00001
00006 protected class Builder extends RuleBasedBreakIterator.Builder {
00007
00011 private CharSet dictionaryChars = new CharSet();
00012 private String dictionaryExpression = "";
00013
00017 public Builder() {
00018 }
00019
00026 protected void handleSpecialSubstitution(String replace, String replaceWith,
00027 int startPos, String description) {
00028 super.handleSpecialSubstitution(replace, replaceWith, startPos, description);
00029
00030 if (replace.equals("<dictionary>")) {
00031 if (replaceWith.charAt(0) == '(') {
00032 error("Dictionary group can't be enclosed in (", startPos, description);
00033 }
00034 dictionaryExpression = replaceWith;
00035 dictionaryChars = CharSet.parseString(replaceWith);
00036 }
00037 }
00038
00045 protected void buildCharCategories(Vector tempRuleList) {
00046 super.buildCharCategories(tempRuleList);
00047
00048 categoryFlags = new boolean[categories.size()];
00049 for (int i = 0; i < categories.size(); i++) {
00050 CharSet cs = (CharSet)categories.elementAt(i);
00051 if (!(cs.intersection(dictionaryChars).empty())) {
00052 categoryFlags[i] = true;
00053 }
00054 }
00055 }
00056
00057
00058
00059
00060
00061 protected void mungeExpressionList(Hashtable expressions) {
00062 expressions.put(dictionaryExpression, dictionaryChars);
00063 }
00064 }