1 4 package org.oddjob.designer.arooa; 5 6 import org.oddjob.arooa.ArooaException; 7 import org.oddjob.arooa.reflect.BeanUtilsHelper; 8 import org.oddjob.designer.model.DesignAttribute; 9 import org.xml.sax.Attributes ; 10 11 14 public class HandlerUtils { 15 16 public static void setAttributes(String uri, Attributes attrs, Object obj) 17 throws ArooaException { 18 for (int i = 0; i < attrs.getLength(); i++) { 19 String attrUri = attrs.getURI(i); 20 if (attrUri != null 21 && !attrUri.equals("") 22 && !attrUri.equals(uri)) { 23 continue; } 25 String name = attrs.getLocalName(i); 26 String value = attrs.getValue(i); 27 28 Class attributeClass = null; 29 attributeClass = BeanUtilsHelper.getPropertyType(obj, name); 30 31 if (DesignAttribute.class.isAssignableFrom(attributeClass)) { 33 DesignAttribute de = null; 34 try { 35 de = (DesignAttribute) attributeClass.newInstance(); 36 } 37 catch (Exception e) { 38 throw new ArooaException("Failed to create [" + attributeClass + "]", e); 39 } 40 de.attribute(value); 41 BeanUtilsHelper.setProperty(obj, name, de); 42 } 43 else { 45 BeanUtilsHelper.setProperty(obj, name, value); 46 } 47 } 48 49 } 50 } 51 | Popular Tags |