1 10 11 package com.ibm.icu.text; 12 13 20 class FunctionReplacer implements UnicodeReplacer { 21 22 25 private Transliterator translit; 26 27 31 private UnicodeReplacer replacer; 32 33 38 public FunctionReplacer(Transliterator theTranslit, 39 UnicodeReplacer theReplacer) { 40 translit = theTranslit; 41 replacer = theReplacer; 42 } 43 44 47 public int replace(Replaceable text, 48 int start, 49 int limit, 50 int[] cursor) { 51 52 int len = replacer.replace(text, start, limit, cursor); 54 limit = start + len; 55 56 limit = translit.transliterate(text, start, limit); 58 59 return limit - start; 60 } 61 62 65 public String toReplacerPattern(boolean escapeUnprintable) { 66 StringBuffer rule = new StringBuffer ("&"); 67 rule.append(translit.getID()); 68 rule.append("( "); 69 rule.append(replacer.toReplacerPattern(escapeUnprintable)); 70 rule.append(" )"); 71 return rule.toString(); 72 } 73 74 79 public void addReplacementSetTo(UnicodeSet toUnionTo) { 80 toUnionTo.addAll(translit.getTargetSet()); 81 } 82 } 83 84 | Popular Tags |