1 package org.oddjob.arooa.handlers; 2 3 import org.oddjob.arooa.ArooaHandler; 4 import org.oddjob.arooa.ArooaContext; 5 import org.xml.sax.Attributes ; 6 import org.xml.sax.SAXParseException ; 7 8 25 public class MainHandler extends ArooaHandler { 26 27 28 private final String documentTag; 29 30 31 private final ArooaHandler startHandler; 32 39 public MainHandler(ArooaHandler startHandler) { 40 this.documentTag = null; 41 this.startHandler = startHandler; 42 } 43 44 51 public MainHandler(String documentTag, ArooaHandler startHandler) { 52 this.documentTag = documentTag; 53 this.startHandler = startHandler; 54 } 55 56 67 public ArooaHandler onStartChild(String uri, String name, String qname, 68 Attributes attrs, 69 ArooaContext context) 70 throws SAXParseException { 71 72 if (documentTag != null && !name.equals(documentTag)) { 74 throw new SAXParseException ("Unexpected element \"" + qname 75 + "\", expected \"" + documentTag + "\"" , context.getLocator()); 76 } 77 return startHandler; 78 } 79 80 } 81 82 | Popular Tags |