1 package org.oddjob.arooa.handlers; 2 3 import org.oddjob.arooa.ArooaHandler; 4 import org.oddjob.arooa.ArooaContext; 5 import org.oddjob.arooa.ArooaConstants; 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 19 20 abstract public class TypicalElementHandler extends ArooaHandler { 21 22 abstract public void onStartElement(String uri, String tag, String qname, 23 Attributes attrs, 24 ArooaContext context) throws SAXParseException ; 25 26 38 public void characters(char[] buf, int start, int count, 39 ArooaContext context) 40 throws SAXParseException { 41 RuntimeConfiguration wrapper = 42 (RuntimeConfiguration)context.get(ArooaConstants.CURRENTLY_CONFIGURING); 43 wrapper.addText(buf, start, count); 44 } 45 46 57 public ArooaHandler onStartChild(String uri, String tag, String qname, 58 Attributes attrs, 59 ArooaContext context) 60 throws SAXParseException { 61 RuntimeConfiguration currentWrapper 62 = (RuntimeConfiguration ) context.get( 63 ArooaConstants.CURRENTLY_CONFIGURING); 64 Object object = currentWrapper.getWrappedObject(); 65 66 IntrospectionHelper ih = IntrospectionHelper.getHelper(object.getClass()); 67 ArooaHandler nextHandler = ih.provideHandler(object, tag, context); 68 if (nextHandler == null) { 69 throw new IllegalStateException ("No handler for [" + tag 70 + "] in object [" + currentWrapper.getWrappedObject() + "]"); 71 } 72 return nextHandler; 73 } 74 75 } 76 77 | Popular Tags |