1 17 package org.alfresco.config.element; 18 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.alfresco.config.ConfigElement; 23 24 30 public class GenericConfigElement extends ConfigElementAdapter 31 { 32 37 public GenericConfigElement(String name) 38 { 39 super(name); 40 } 41 42 45 public ConfigElement combine(ConfigElement configElement) 46 { 47 GenericConfigElement combined = new GenericConfigElement(this.name); 48 combined.setValue(configElement.getValue()); 49 50 if (this.attributes != null) 52 { 53 Iterator <String > attrs = this.getAttributes().keySet().iterator(); 54 while (attrs.hasNext()) 55 { 56 String attrName = attrs.next(); 57 String attrValue = configElement.getAttribute(attrName); 58 combined.addAttribute(attrName, attrValue); 59 } 60 } 61 62 if (configElement.getAttributes() != null) 64 { 65 Iterator <String > attrs = configElement.getAttributes().keySet().iterator(); 66 while (attrs.hasNext()) 67 { 68 String attrName = attrs.next(); 69 String attrValue = configElement.getAttribute(attrName); 70 combined.addAttribute(attrName, attrValue); 71 } 72 } 73 74 List <ConfigElement> kids = this.getChildren(); 76 if (kids != null) 77 { 78 for (int x = 0; x < kids.size(); x++) 79 { 80 ConfigElement ce = kids.get(x); 81 combined.addChild(ce); 82 } 83 } 84 85 kids = configElement.getChildren(); 87 if (kids != null) 88 { 89 for (int x = 0; x < kids.size(); x++) 90 { 91 ConfigElement ce = kids.get(x); 92 combined.addChild(ce); 93 } 94 } 95 96 return combined; 97 } 98 99 107 public void addAttribute(String name, String value) 108 { 109 this.attributes.put(name, value); 110 } 111 112 118 public void addChild(ConfigElement configElement) 119 { 120 this.children.add(configElement); 121 } 122 } 123 | Popular Tags |