1 package gov.nasa.jpf; 20 21 import gov.nasa.jpf.Path; 22 23 import org.xml.sax.*; 24 import org.xml.sax.helpers.*; 25 26 27 30 public class BootstrapXMLTraceHandler extends DefaultHandler { 31 XMLTraceHandler realHandler; 32 Path path; 33 34 public Path getPath () { 35 return path; 36 } 37 38 public void characters (char[] text, int start, int length) { 39 if (realHandler != null) { 40 realHandler.characters(text, start, length); 41 } 42 } 43 44 public void endElement (String namespaceURI, String localName, 45 String qualifiedName) throws SAXException { 46 if (realHandler != null) { 47 realHandler.endElement(namespaceURI, localName, qualifiedName); 48 49 if (localName.equals("Trace")) { 50 path = realHandler.getPath(); 51 } 52 } 53 } 54 55 public void startElement (String namespaceURI, String localName, 56 String qualifiedName, Attributes atts) 57 throws SAXException { 58 if (localName.equals("Trace")) { 59 String clsName = atts.getValue("Handler"); 60 61 try { 62 Class clazz = Class.forName(clsName); 63 realHandler = (XMLTraceHandler) clazz.newInstance(); 64 } catch (Exception x) { 65 throw new JPFException("cannot instantiate traceHandler class " + 66 clsName + " : " + x); 67 } 68 } 69 70 if (realHandler != null) { 72 realHandler.startElement(namespaceURI, localName, qualifiedName, atts); 73 } 74 } 75 } | Popular Tags |