1 4 package org.oddjob.arooa.handlers; 5 6 import java.util.HashMap ; 7 import java.util.Iterator ; 8 import java.util.Map ; 9 10 import org.xml.sax.Attributes ; 11 12 15 public class AttributeHelper { 16 17 private Map attributes = new HashMap (); 18 19 public AttributeHelper(String uri, Attributes attrs) { 20 for (int i = 0; i < attrs.getLength(); i++) { 21 String attrUri = attrs.getURI(i); 22 if (attrUri != null 23 && !attrUri.equals("") 24 && !attrUri.equals(uri)) { 25 continue; } 27 String key = attrs.getLocalName(i); 28 String value = attrs.getValue(i); 29 30 attributes.put(key, value); 31 } 32 } 33 34 public String remove(String name) { 35 return (String ) attributes.remove(name); 36 } 37 38 public interface Processor { 39 public void process(String name, String value); 40 } 41 42 public void process(Processor processor) { 43 for (Iterator it = attributes.entrySet().iterator(); it.hasNext(); ) { 44 Map.Entry es = (Map.Entry ) it.next(); 45 processor.process((String ) es.getKey(), (String ) es.getValue()); 46 } 47 } 48 } 49 | Popular Tags |