1adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/*
2320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one or more
3320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * contributor license agreements.  See the NOTICE file distributed with
4320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * this work for additional information regarding copyright ownership.
5320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * The ASF licenses this file to You under the Apache License, Version 2.0
6320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * (the "License"); you may not use this file except in compliance with
7320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * the License.  You may obtain a copy of the License at
8adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project *
9320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
10adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project *
11adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
12adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
13adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * See the License for the specific language governing permissions and
15adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * limitations under the License.
16adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */
17adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
18320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson// $Id: SAXParserFactory.java 884950 2009-11-27 18:46:18Z mrglavas $
19320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson
20adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpackage javax.xml.parsers;
21adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
22320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport javax.xml.validation.Schema;
23320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport org.apache.harmony.xml.parsers.SAXParserFactoryImpl;
24320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport org.xml.sax.SAXException;
25adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport org.xml.sax.SAXNotRecognizedException;
26adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport org.xml.sax.SAXNotSupportedException;
27adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
28adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/**
29320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Defines a factory API that enables applications to configure and
30320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * obtain a SAX based parser to parse XML documents.
31320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson *
32320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
33320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @version $Revision: 884950 $, $Date: 2009-11-27 10:46:18 -0800 (Fri, 27 Nov 2009) $
34adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */
35adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpublic abstract class SAXParserFactory {
36adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
37320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    /**
38320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Should Parsers be validating?</p>
39320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     */
40320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    private boolean validating = false;
41f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
42320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    /**
43320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Should Parsers be namespace aware?</p>
44320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     */
45320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    private boolean namespaceAware = false;
46f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
47320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    /**
48320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Protected constructor to force use of {@link #newInstance()}.</p>
49320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     */
50320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    protected SAXParserFactory () {
51f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
52320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    }
53adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
54adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
55320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Returns Android's implementation of {@code SAXParserFactory}. Unlike
56320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * other Java implementations, this method does not consult system
57320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * properties, property files, or the services API.
58320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
59320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return a new SAXParserFactory.
60320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
61320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception FactoryConfigurationError never. Included for API
62320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *     compatibility with other Java implementations.
63adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
64320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public static SAXParserFactory newInstance() {
6555b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        // instantiate the class directly rather than using reflection
66320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        return new SAXParserFactoryImpl();
67adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
68adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
6955b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson    /**
7055b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     * Returns an instance of the named implementation of {@code SAXParserFactory}.
7155b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     *
7255b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     * @throws FactoryConfigurationError if {@code factoryClassName} is not available or cannot be
7355b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     *     instantiated.
7455b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     * @since 1.6
7555b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson     */
7655b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson    public static SAXParserFactory newInstance(String factoryClassName,
7755b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            ClassLoader classLoader) {
7855b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        if (factoryClassName == null) {
7955b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            throw new FactoryConfigurationError("factoryClassName == null");
8055b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        }
8155b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        if (classLoader == null) {
8255b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            classLoader = Thread.currentThread().getContextClassLoader();
8355b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        }
8455b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        try {
8555b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            Class<?> type = classLoader != null
8655b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson                    ? classLoader.loadClass(factoryClassName)
8755b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson                    : Class.forName(factoryClassName);
8855b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            return (SAXParserFactory) type.newInstance();
8955b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        } catch (ClassNotFoundException e) {
9055b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            throw new FactoryConfigurationError(e);
9155b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        } catch (InstantiationException e) {
9255b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            throw new FactoryConfigurationError(e);
9355b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        } catch (IllegalAccessException e) {
9455b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson            throw new FactoryConfigurationError(e);
9555b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson        }
9655b2d1c3f492f6140ad6dd18a4bec4ec2643d664Jesse Wilson    }
97320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson
98adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
99320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Creates a new instance of a SAXParser using the currently
100320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * configured factory parameters.</p>
101adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     *
102320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return A new instance of a SAXParser.
103320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
104320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception ParserConfigurationException if a parser cannot
105320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *   be created which satisfies the requested configuration.
106320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception SAXException for SAX errors.
107adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
108f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
109320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public abstract SAXParser newSAXParser()
110320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throws ParserConfigurationException, SAXException;
111adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
112f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
113adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
114320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Specifies that the parser produced by this code will
115320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * provide support for XML namespaces. By default the value of this is set
116320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * to <code>false</code>.
117320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
118320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param awareness true if the parser produced by this code will
119320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *                  provide support for XML namespaces; false otherwise.
120adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
121f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
122320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public void setNamespaceAware(boolean awareness) {
123320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        this.namespaceAware = awareness;
124adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
125adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
126adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
127320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Specifies that the parser produced by this code will
128320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * validate documents as they are parsed. By default the value of this is
129320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * set to <code>false</code>.
130f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
131320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>
132320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Note that "the validation" here means
133320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <a href="http://www.w3.org/TR/REC-xml#proc-types">a validating
134320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * parser</a> as defined in the XML recommendation.
135320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * In other words, it essentially just controls the DTD validation.
136320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * (except the legacy two properties defined in JAXP 1.2.
137320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * See <a href="#validationCompatibility">here</a> for more details.)
138320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * </p>
139f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
140320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>
141320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * To use modern schema languages such as W3C XML Schema or
142320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * RELAX NG instead of DTD, you can configure your parser to be
143320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * a non-validating parser by leaving the {@link #setValidating(boolean)}
144320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * method <tt>false</tt>, then use the {@link #setSchema(Schema)}
145320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * method to associate a schema to a parser.
146320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * </p>
147320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
148320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param validating true if the parser produced by this code will
149320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *                   validate documents as they are parsed; false otherwise.
150adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
151f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
152320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public void setValidating(boolean validating) {
153320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        this.validating = validating;
154adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
155adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
156adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
157320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Indicates whether or not the factory is configured to produce
158320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * parsers which are namespace aware.
159320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
160320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return true if the factory is configured to produce
161320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *         parsers which are namespace aware; false otherwise.
162adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
163f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
164320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public boolean isNamespaceAware() {
165320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        return namespaceAware;
166adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
167adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
168adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
169320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Indicates whether or not the factory is configured to produce
170320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * parsers which validate the XML content during parse.
171320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
172320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return true if the factory is configured to produce parsers which validate
173320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *         the XML content during parse; false otherwise.
174adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
175f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
176320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public boolean isValidating() {
177320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        return validating;
178adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
179adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
180adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
181320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
182320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Sets the particular feature in the underlying implementation of
183320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * org.xml.sax.XMLReader.
184320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * A list of the core features and properties can be found at
185320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <a href="http://www.saxproject.org/">http://www.saxproject.org/</a></p>
186320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
187d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     * <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
188d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     * When the feature is</p>
189d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     * <ul>
190d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *   <li>
191d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
192d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
193d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     If XML processing is limited for security reasons, it will be reported via a call to the registered
194d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
195d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     See {@link SAXParser} <code>parse</code> methods for handler specification.
196d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *   </li>
197d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *   <li>
198d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     When the feature is <code>false</code>, the implementation will processing XML according to the XML specifications without
199d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *     regard to possible implementation limits.
200d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     *   </li>
201d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott Hughes     * </ul>
202f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
203320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param name The name of the feature to be set.
204320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param value The value of the feature to be set.
205f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
206320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception ParserConfigurationException if a parser cannot
207320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *     be created which satisfies the requested configuration.
208320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception SAXNotRecognizedException When the underlying XMLReader does
209320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *            not recognize the property name.
210320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception SAXNotSupportedException When the underlying XMLReader
211320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *            recognizes the property name but doesn't support the
212320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *            property.
213320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @throws NullPointerException If the <code>name</code> parameter is null.
214320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
215320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @see org.xml.sax.XMLReader#setFeature
216adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
217320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public abstract void setFeature(String name, boolean value)
218320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throws ParserConfigurationException, SAXNotRecognizedException,
219320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson                SAXNotSupportedException;
220adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
221adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
222320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
223320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Returns the particular property requested for in the underlying
224320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * implementation of org.xml.sax.XMLReader.</p>
225320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *
226320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param name The name of the property to be retrieved.
227f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
228320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return Value of the requested property.
229adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     *
230320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
231320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception SAXNotRecognizedException When the underlying XMLReader does not recognize the property name.
232320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @exception SAXNotSupportedException When the underlying XMLReader recognizes the property name but doesn't support the property.
233adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     *
234320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @see org.xml.sax.XMLReader#getProperty
235320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     */
236320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public abstract boolean getFeature(String name)
237320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throws ParserConfigurationException, SAXNotRecognizedException,
238320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson                SAXNotSupportedException;
239f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
240320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    /**
241320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Gets the {@link Schema} object specified through
242320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * the {@link #setSchema(Schema schema)} method.
243f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
244f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
245320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @throws UnsupportedOperationException
246320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      For backward compatibility, when implementations for
247320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      earlier versions of JAXP is used, this exception will be
248320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      thrown.
249f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
250320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return
251320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      the {@link Schema} object that was last set through
252320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      the {@link #setSchema(Schema)} method, or null
253320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      if the method was not invoked since a {@link SAXParserFactory}
254320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      is created.
255f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
256320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @since 1.5
257adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
258320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public Schema getSchema() {
259320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throw new UnsupportedOperationException(
260320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            "This parser does not support specification \""
261320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationTitle()
262320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\" version \""
263320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationVersion()
264320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\""
265320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            );
266320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    }
267f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
268adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
269320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Set the {@link Schema} to be used by parsers created
270320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * from this factory.</p>
271f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
272320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>When a {@link Schema} is non-null, a parser will use a validator
273320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * created from it to validate documents before it passes information
274320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * down to the application.</p>
275f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
276320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>When warnings/errors/fatal errors are found by the validator, the parser must
277f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     * handle them as if those errors were found by the parser itself.
278320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * In other words, if the user-specified {@link org.xml.sax.ErrorHandler}
279320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * is set, it must receive those errors, and if not, they must be
280320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * treated according to the implementation specific
281320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * default error handling rules.
282f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
283320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>A validator may modify the SAX event stream (for example by
284320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * adding default values that were missing in documents), and a parser
285320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * is responsible to make sure that the application will receive
286f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     * those modified event stream.</p>
287f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
288f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     * <p>Initially, <code>null</code> is set as the {@link Schema}.</p>
289f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
290320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>This processing will take effect even if
291320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * the {@link #isValidating()} method returns <code>false</code>.
292f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
293320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>It is an error to use
294320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * the <code>http://java.sun.com/xml/jaxp/properties/schemaSource</code>
295320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * property and/or the <code>http://java.sun.com/xml/jaxp/properties/schemaLanguage</code>
296320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * property in conjunction with a non-null {@link Schema} object.
297320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * Such configuration will cause a {@link SAXException}
298320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * exception when those properties are set on a {@link SAXParser}.</p>
299f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
300320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <h4>Note for implementors</h4>
301320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>
302320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * A parser must be able to work with any {@link Schema}
303320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * implementation. However, parsers and schemas are allowed
304320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * to use implementation-specific custom mechanisms
305320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * as long as they yield the result described in the specification.
306320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * </p>
307f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
308320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param schema <code>Schema</code> to use, <code>null</code> to remove a schema.
309f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
310320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @throws UnsupportedOperationException
311320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      For backward compatibility, when implementations for
312320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      earlier versions of JAXP is used, this exception will be
313320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      thrown.
314f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
315320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @since 1.5
316adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
317320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public void setSchema(Schema schema) {
318320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throw new UnsupportedOperationException(
319320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            "This parser does not support specification \""
320320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationTitle()
321320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\" version \""
322320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationVersion()
323320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\""
324320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            );
325adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
326adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
327adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
328320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Set state of XInclude processing.</p>
329f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
330320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>If XInclude markup is found in the document instance, should it be
331320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * processed as specified in <a href="http://www.w3.org/TR/xinclude/">
332320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * XML Inclusions (XInclude) Version 1.0</a>.</p>
333f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
334320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>XInclude processing defaults to <code>false</code>.</p>
335f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
336320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @param state Set XInclude processing to <code>true</code> or
337320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *   <code>false</code>
338f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
339320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @throws UnsupportedOperationException
340320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      For backward compatibility, when implementations for
341320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      earlier versions of JAXP is used, this exception will be
342320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      thrown.
343f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
344320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @since 1.5
345adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
346320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public void setXIncludeAware(final boolean state) {
347320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throw new UnsupportedOperationException(
348320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            "This parser does not support specification \""
349320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationTitle()
350320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\" version \""
351320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationVersion()
352320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\""
353320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            );
354adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
355adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
356adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
357320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * <p>Get state of XInclude processing.</p>
358f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
359320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @return current state of XInclude processing
360f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
361320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @throws UnsupportedOperationException
362320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      For backward compatibility, when implementations for
363320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      earlier versions of JAXP is used, this exception will be
364320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     *      thrown.
365f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
366320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson     * @since 1.5
367adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
368320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson    public boolean isXIncludeAware() {
369320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson        throw new UnsupportedOperationException(
370320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            "This parser does not support specification \""
371320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationTitle()
372320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\" version \""
373320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + this.getClass().getPackage().getSpecificationVersion()
374320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            + "\""
375320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson            );
376adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
377adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project}
378adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
379