1 16 17 import java.util.LinkedList ; 18 import java.util.Iterator ; 19 20 import org.apache.commons.digester.Digester; 21 import org.apache.commons.digester.plugins.PluginCreateRule; 22 23 31 32 public class CompoundTransform implements Transform { 33 private LinkedList transforms = new LinkedList (); 34 35 public void addTransform(Transform transform) { 36 transforms.add(transform); 37 } 38 39 public String transform(String s) { 40 for(Iterator i = transforms.iterator(); i.hasNext(); ) { 41 Transform t = (Transform) i.next(); 42 s = t.transform(s); 43 } 44 return s; 45 } 46 47 public static void addRules(Digester d, String patternPrefix) { 48 PluginCreateRule pcr = new PluginCreateRule(Transform.class); 49 d.addRule(patternPrefix+"/subtransform", pcr); 50 d.addSetNext(patternPrefix+"/subtransform", "addTransform"); 51 } 52 } 53 | Popular Tags |