1 package nbbuild.misc.bugcompare; 2 3 21 22 public class ChangelogRecognizer_1 implements org.xml.sax.DocumentHandler { 23 private java.lang.StringBuffer buffer; 24 25 private ChangelogParslet parslet; 26 27 private ChangelogHandler handler; 28 29 private java.util.Stack context; 30 31 public ChangelogRecognizer_1(final ChangelogHandler handler, final ChangelogParslet parslet) { 32 this.parslet = parslet; 33 this.handler = handler; 34 buffer = new StringBuffer (111); 35 context = new java.util.Stack (); 36 } 37 38 public void setDocumentLocator(org.xml.sax.Locator locator) { 39 } 40 41 public void startDocument() throws org.xml.sax.SAXException { 42 } 43 44 public void endDocument() throws org.xml.sax.SAXException { 45 } 46 47 public void startElement(java.lang.String name, org.xml.sax.AttributeList attrs) throws org.xml.sax.SAXException { 48 dispatch(true); 49 context.push(new Object [] {name, new org.xml.sax.helpers.AttributeListImpl (attrs)}); 50 } 51 52 public void endElement(java.lang.String name) throws org.xml.sax.SAXException { 53 dispatch(false); 54 context.pop(); 55 } 56 57 public void characters(char[] chars, int start, int len) throws org.xml.sax.SAXException { 58 buffer.append(chars, start, len); 59 } 60 61 public void ignorableWhitespace(char[] chars, int start, int len) throws org.xml.sax.SAXException { 62 } 63 64 public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException { 65 } 66 67 private void dispatch(final boolean fireOnlyIfMixed) throws org.xml.sax.SAXException { 68 if (fireOnlyIfMixed && buffer.length() == 0) return; 70 Object [] ctx = (Object []) context.peek(); 71 String here = (String ) ctx[0]; 72 org.xml.sax.AttributeList attrs = (org.xml.sax.AttributeList ) ctx[1]; 73 if ("author".equals(here)) { 74 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 75 handler.handle_author(buffer.length() == 0 ? null : buffer.toString(), attrs); 76 } else if ("branch".equals(here)) { 77 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 78 handler.handle_branch(buffer.length() == 0 ? null : buffer.toString(), attrs); 79 } else if ("branchroot".equals(here)) { 80 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 81 handler.handle_branchroot(buffer.length() == 0 ? null : buffer.toString(), attrs); 82 } else if ("changelog".equals(here)) { 83 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 84 handler.handle_changelog(buffer.length() == 0 ? null : buffer.toString(), attrs); 85 } else if ("commondir".equals(here)) { 86 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 87 handler.handle_commondir(buffer.length() == 0 ? null : buffer.toString(), attrs); 88 } else if ("date".equals(here)) { 89 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 90 handler.handle_date(buffer.length() == 0 ? null : buffer.toString(), attrs); 91 } else if ("entry".equals(here)) { 92 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 93 handler.handle_entry(buffer.length() == 0 ? null : buffer.toString(), attrs); 94 } else if ("file".equals(here)) { 95 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 96 handler.handle_file(buffer.length() == 0 ? null : buffer.toString(), attrs); 97 } else if ("msg".equals(here)) { 98 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 99 handler.handle_msg(buffer.length() == 0 ? null : buffer.toString(), attrs); 100 } else if ("name".equals(here)) { 101 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 102 handler.handle_name(buffer.length() == 0 ? null : buffer.toString(), attrs); 103 } else if ("revision".equals(here)) { 104 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 105 handler.handle_revision(buffer.length() == 0 ? null : buffer.toString(), attrs); 106 } else if ("tag".equals(here)) { 107 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 108 handler.handle_tag(buffer.length() == 0 ? null : buffer.toString(), attrs); 109 } else if ("time".equals(here)) { 110 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 111 handler.handle_time(buffer.length() == 0 ? null : buffer.toString(), attrs); 112 } else if ("utag".equals(here)) { 113 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 114 handler.handle_utag(buffer.length() == 0 ? null : buffer.toString(), attrs); 115 } else if ("weekday".equals(here)) { 116 if (fireOnlyIfMixed) throw new IllegalStateException ("Unexpected mixed content element or a parser reporting whitespaces via characters() event!"); 117 handler.handle_weekday(buffer.length() == 0 ? null : buffer.toString(), attrs); 118 } else { 119 } 121 buffer.delete(0, buffer.length()); 122 } 123 124 132 public void parse(final org.xml.sax.InputSource input) throws org.xml.sax.SAXException , javax.xml.parsers.ParserConfigurationException , java.io.IOException { 133 parse(input, this); 134 } 135 136 144 public void parse(final java.net.URL url) throws org.xml.sax.SAXException , javax.xml.parsers.ParserConfigurationException , java.io.IOException { 145 parse(new org.xml.sax.InputSource (url.toExternalForm()), this); 146 } 147 148 156 public static void parse(final org.xml.sax.InputSource input, final ChangelogHandler handler, final ChangelogParslet parslet) throws org.xml.sax.SAXException , javax.xml.parsers.ParserConfigurationException , java.io.IOException { 157 parse(input, new ChangelogRecognizer(handler, parslet)); 158 } 159 160 168 public static void parse(final java.net.URL url, final ChangelogHandler handler, final ChangelogParslet parslet) throws org.xml.sax.SAXException , javax.xml.parsers.ParserConfigurationException , java.io.IOException { 169 parse(new org.xml.sax.InputSource (url.toExternalForm()), handler, parslet); 170 } 171 172 private static void parse(final org.xml.sax.InputSource input, final ChangelogRecognizer recognizer) throws org.xml.sax.SAXException , javax.xml.parsers.ParserConfigurationException , java.io.IOException { 173 javax.xml.parsers.SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance(); 174 factory.setValidating(false); factory.setNamespaceAware(false); org.xml.sax.Parser parser = factory.newSAXParser().getParser(); 177 parser.setDocumentHandler(recognizer); 178 parser.parse(input); 179 } 180 181 182 } | Popular Tags |