1 package org.oddjob.arooa.handlers; 2 3 import org.oddjob.arooa.ArooaContext; 4 import org.oddjob.arooa.ArooaConstants; 5 import org.oddjob.arooa.ArooaRuntime; 6 import org.oddjob.arooa.RuntimeConfiguration; 7 import org.oddjob.arooa.reflect.IntrospectionHelper; 8 import org.xml.sax.Attributes ; 9 import org.xml.sax.SAXParseException ; 10 11 12 15 public class NestedElementHandler extends TypicalElementHandler { 16 17 35 public void onStartElement(String uri, String tag, String qname, 36 Attributes attrs, 37 ArooaContext context) 38 throws SAXParseException { 39 RuntimeConfiguration parentWrapper 40 = (RuntimeConfiguration ) context.getParent().get( 41 ArooaConstants.CURRENTLY_CONFIGURING); 42 Object parent = parentWrapper.getWrappedObject(); 43 IntrospectionHelper ih = IntrospectionHelper.getHelper(parent.getClass()); 44 45 Object object = ih.createElement(uri, parent, tag); 46 47 final ArooaRuntime wrapper 48 = new ArooaRuntime(object, tag, context); 49 50 AttributeHelper ah = new AttributeHelper(uri, attrs); 51 52 ah.process(new AttributeHelper.Processor() { 53 public void process(String name, String value) { 54 wrapper.setAttribute(name, value); 55 } 56 }); 57 58 parentWrapper.addChild(wrapper); 59 context.set(ArooaConstants.CURRENTLY_CONFIGURING, wrapper); 60 } 61 62 } 63 | Popular Tags |