1 6 package org.logicalcobwebs.dbscript; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 import org.xml.sax.Attributes ; 11 import org.xml.sax.SAXException ; 12 import org.xml.sax.helpers.DefaultHandler ; 13 14 22 class ScriptBuilder extends DefaultHandler { 23 24 private static final Log LOG = LogFactory.getLog(ScriptBuilder.class); 25 26 private Script script = null; 27 28 31 public void startElement(String uri, String localName, 32 String qName, Attributes attributes) 33 throws SAXException { 34 35 if (qName.equals("script")) { 36 script = new Script(); 37 script.setName(attributes.getValue("name")); 38 script.setDriver(attributes.getValue("driver")); 39 script.setUrl(attributes.getValue("url")); 40 41 } else if (qName.equals("info")) { 42 String name = attributes.getValue("name"); 43 String value = attributes.getValue("value"); 44 script.addProperty(name, value); 45 46 } else if (qName.equals("command")) { 47 Command command = new Command(); 48 command.setName(attributes.getValue("name")); 49 command.setSql(attributes.getValue("sql")); 50 if (attributes.getValue("load") != null) { 51 int load = Integer.parseInt(attributes.getValue("load")); 52 command.setLoad(load); 53 } 54 if (attributes.getValue("loops") != null) { 55 int loops = Integer.parseInt(attributes.getValue("loops")); 56 command.setLoops(loops); 57 } 58 if (attributes.getValue("exception") != null) { 59 String exception = attributes.getValue("exception"); 60 command.setException(exception); 61 } 62 script.addCommand(command); 63 } 64 65 } 66 67 71 protected Script getScript() { 72 return script; 73 } 74 75 } 76 77 109 | Popular Tags |