~ubuntu-branches/ubuntu/utopic/jing-trang/utopic

« back to all changes in this revision

Viewing changes to mod/util/src/main/com/thaiopensource/xml/sax/Jaxp11XMLReaderCreator.java

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Thibault
  • Date: 2009-09-01 15:53:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090901155303-2kweef05h5v9j3ni
Tags: upstream-20090818
ImportĀ upstreamĀ versionĀ 20090818

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.thaiopensource.xml.sax;
 
2
 
 
3
import javax.xml.parsers.SAXParserFactory;
 
4
import javax.xml.parsers.ParserConfigurationException;
 
5
import org.xml.sax.XMLReader;
 
6
import org.xml.sax.SAXException;
 
7
 
 
8
import com.thaiopensource.xml.sax.XMLReaderCreator;
 
9
 
 
10
/**
 
11
 * An <code>XMLReaderCreator</code> that uses JAXP 1.1 to create <code>XMLReader</code>s.
 
12
 * An instance of this class is <em>not</em> safe for concurrent access by multiple threads.
 
13
 *
 
14
 * @see javax.xml.parsers.SAXParserFactory
 
15
 * @author <a href="mailto:jjc@jclark.com">James Clark</a>
 
16
 */
 
17
public class Jaxp11XMLReaderCreator implements XMLReaderCreator {
 
18
    
 
19
  private final SAXParserFactory factory;
 
20
 
 
21
  /**
 
22
   * Default constructor.
 
23
   */
 
24
  public Jaxp11XMLReaderCreator() {
 
25
    factory = SAXParserFactory.newInstance();
 
26
    factory.setNamespaceAware(true);
 
27
    factory.setValidating(false);
 
28
  }
 
29
 
 
30
  public XMLReader createXMLReader() throws SAXException {
 
31
    try {
 
32
      return factory.newSAXParser().getXMLReader();
 
33
    }
 
34
    catch (ParserConfigurationException e) {
 
35
      throw new SAXException(e);
 
36
    }
 
37
  }
 
38
}