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.io.Writer;
19  
20  import org.ccil.cowan.tagsoup.XMLWriter;
21  import org.xml.sax.ContentHandler;
22  
23  /***
24   * @author JMcCrindle
25   */
26  public class TagsoupOutputterFactory implements OutputterFactory {
27  
28      /* (non-Javadoc)
29       * @see org.saxbenchmark.OutputterFactory#getHtmlWriter()
30       */
31      public Outputter getHtmlWriter() {
32          final XMLWriter xmlWriter = new XMLWriter();
33          xmlWriter.setHTMLMode(true);
34          return new Outputter() {
35              /* (non-Javadoc)
36               * @see org.saxbenchmark.Outputter#asContentHandler()
37               */
38              public ContentHandler asContentHandler() throws Exception {
39                  return xmlWriter;
40              }
41  
42              /* (non-Javadoc)
43               * @see org.saxbenchmark.Outputter#setWriter(java.io.Writer)
44               */
45              public void setWriter(Writer writer) throws Exception {
46                  xmlWriter.setOutput(writer);
47              }
48          };
49      }
50  
51      /* (non-Javadoc)
52       * @see org.saxbenchmark.OutputterFactory#getName()
53       */
54      public String getName() {
55          return "org.ccil.cowan.tagsoup.XMLWriter";
56      }
57  
58      /* (non-Javadoc)
59       * @see org.saxbenchmark.OutputterFactory#getName()
60       */
61      public String getShortName() {
62          return "XMLWriter";
63      }
64      
65  }