KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > aelfred > SAXParserFactoryImpl


1 package com.icl.saxon.aelfred;
2
3 import javax.xml.parsers.*;
4 import org.xml.sax.*;
5
6 /**
7 * Implements the JAXP 1.1 ParserFactory interface.
8 * To use the AElfred parser, set the system property javax.xml.parsers.SAXParserFactory
9 * to the value "com.icl.saxon.aelfred.SAXParserFactoryImpl"; then call
10 * javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().
11 */

12
13 public class SAXParserFactoryImpl extends SAXParserFactory {
14
15     public SAXParserFactoryImpl() {
16         setNamespaceAware(true);
17         setValidating(false);
18     };
19     
20     public boolean getFeature(String JavaDoc name)
21     throws SAXNotRecognizedException, SAXNotSupportedException {
22         return new SAXDriver().getFeature(name);
23     }
24
25     public void setFeature(String JavaDoc name, boolean value)
26     throws SAXNotRecognizedException, SAXNotSupportedException {
27         // the only purpose of the following line is to throw the right exception
28
new SAXDriver().setFeature(name, value);
29     }
30     
31     public SAXParser newSAXParser()
32     throws ParserConfigurationException {
33         if (isValidating()) {
34             throw new ParserConfigurationException("AElfred parser is non-validating");
35         }
36         if (!isNamespaceAware()) {
37             throw new ParserConfigurationException("AElfred parser is namespace-aware");
38         }
39         return new SAXParserImpl();
40     }
41
42 }
43
44 //
45
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
46
// you may not use this file except in compliance with the License. You may obtain a copy of the
47
// License at http://www.mozilla.org/MPL/
48
//
49
// Software distributed under the License is distributed on an "AS IS" basis,
50
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
51
// See the License for the specific language governing rights and limitations under the License.
52
//
53
// The Original Code is: all this file.
54
//
55
// The Initial Developer of the Original Code is
56
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
57
//
58
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
59
//
60
// Contributor(s): none.
61
//
62
Popular Tags