View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.saxbenchmark;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.xml.sax.SAXException;
22  import org.xml.sax.XMLReader;
23  import org.xml.sax.helpers.XMLReaderFactory;
24  
25  /***
26   * @author JMcCrindle
27   */
28  public class DefaultReaderSupplier implements ReaderSupplier {
29  
30      /* (non-Javadoc)
31       * @see org.saxbenchmark.ReaderSupplier#getBenchmarkReaders()
32       */
33      public List getBenchmarkReaders() throws SAXException {
34          List results = new ArrayList();
35          
36          XMLReader tagSoupDefault = XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
37          results.add(new BenchmarkReaderWriter(
38                  tagSoupDefault, 
39                  "TagSoup Parser (Default)"));
40          XMLReader tagSoupNotBogonsEmpty = XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
41          tagSoupNotBogonsEmpty.setFeature("http://www.ccil.org/~cowan/tagsoup/features/bogons-empty", false);
42          results.add(new BenchmarkReaderWriter(
43                  tagSoupNotBogonsEmpty, 
44                  "TagSoup Parser (NotBogonsEmpty)"));
45          XMLReader tagSoupIgnoreBogons = XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
46          tagSoupIgnoreBogons.setFeature("http://www.ccil.org/~cowan/tagsoup/features/ignore-bogons", true);
47          results.add(new BenchmarkReaderWriter(
48                  tagSoupIgnoreBogons, 
49                  "TagSoup Parser (IgnoreBogons)"));
50          XMLReader htmlParserReaderDefault = XMLReaderFactory.createXMLReader("org.saxbenchmark.htmlparser.HTMLParserXMLReader");
51          results.add(new BenchmarkReaderWriter(
52                  htmlParserReaderDefault, 
53                  "HTMLParser (Default)"));
54          XMLReader htmlParserReaderNamespaces = XMLReaderFactory.createXMLReader("org.saxbenchmark.htmlparser.HTMLParserXMLReader");
55          htmlParserReaderNamespaces.setFeature("http://xml.org/sax/features/namespaces", false);
56          htmlParserReaderNamespaces.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
57          results.add(new BenchmarkReaderWriter(
58                  htmlParserReaderNamespaces, 
59                  "HTMLParser (Namespaces)"));
60          XMLReader cyberNekoDefault = XMLReaderFactory.createXMLReader("org.cyberneko.html.parsers.SAXParser");
61          results.add(new BenchmarkReaderWriter(
62                  cyberNekoDefault,   
63                  "CyberNeko Parser (Default)"));
64          XMLReader cyberNekoNoBalancing = XMLReaderFactory.createXMLReader("org.cyberneko.html.parsers.SAXParser");
65          cyberNekoNoBalancing.setFeature("http://cyberneko.org/html/features/balance-tags", false);
66          results.add(new BenchmarkReaderWriter(
67                  cyberNekoNoBalancing,   
68                  "CyberNeko Parser (No Balancing)"));
69          results.add(new BenchmarkReaderWriter(
70                  XMLReaderFactory.createXMLReader("hotsax.html.sax.SaxParser"), 
71                  "HotSax Parser (Default)"));
72          
73          return results;
74      }
75  
76  }