SAXParserFactory.java revision d21d78fd49a2d798218e8c8aefbddb26a0e71bbb
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; 23adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 24320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport org.apache.harmony.xml.parsers.SAXParserFactoryImpl; 25320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport org.xml.sax.SAXException; 26adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport org.xml.sax.SAXNotRecognizedException; 27adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport org.xml.sax.SAXNotSupportedException; 28adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 29adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/** 30320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Defines a factory API that enables applications to configure and 31320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * obtain a SAX based parser to parse XML documents. 32320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 33320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a> 34320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @version $Revision: 884950 $, $Date: 2009-11-27 10:46:18 -0800 (Fri, 27 Nov 2009) $ 35adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 36adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpublic abstract class SAXParserFactory { 37adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 38320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 39320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>Should Parsers be validating?</p> 40320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 41320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson private boolean validating = false; 42320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 43320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 44320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>Should Parsers be namespace aware?</p> 45320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 46320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson private boolean namespaceAware = false; 47320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 48320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 49320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>Protected constructor to force use of {@link #newInstance()}.</p> 50320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 51320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson protected SAXParserFactory () { 52320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 53320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson } 54adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 55adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 56320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Returns Android's implementation of {@code SAXParserFactory}. Unlike 57320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * other Java implementations, this method does not consult system 58320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * properties, property files, or the services API. 59320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 60320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @return a new SAXParserFactory. 61320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 62320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @exception FactoryConfigurationError never. Included for API 63320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * compatibility with other Java implementations. 64adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 65320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public static SAXParserFactory newInstance() { 66320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // BEGIN android-changed 67320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // instantiate the class directly rather than using reflection 68320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson return new SAXParserFactoryImpl(); 69320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // END android-changed 70adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 71adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 72320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // BEGIN android-only 73320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // omit this method which wasn't included in Java 5 74320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // /** 75320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // * @return A new instance of a SAXParserFactory. 76320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // * 77320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // * @exception FactoryConfigurationError if the implementation is 78320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // * not available or cannot be instantiated. 79320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // * @since 1.6 80320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // */ 81320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // public static SAXParserFactory newInstance(String factoryClassName, 82320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // ClassLoader classLoader) { 83320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // if (factoryClassName == null) { 84320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // throw new FactoryConfigurationError("factoryClassName cannot be null."); 85320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // } 86320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // if (classLoader == null) { 87320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // classLoader = SecuritySupport.getContextClassLoader(); 88320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // } 89320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // try { 90320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // return (SAXParserFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false); 91320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // } 92320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // catch (FactoryFinder.ConfigurationError e) { 93320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // throw new FactoryConfigurationError(e.getException(), e.getMessage()); 94320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // } 95320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // } 96320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson // END android-only 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 */ 108320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 109320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public abstract SAXParser newSAXParser() 110320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson throws ParserConfigurationException, SAXException; 111adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 112adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 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 */ 121320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 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>. 130adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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> 139adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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 */ 151320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 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 */ 163320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 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 */ 175320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 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> 202d21d78fd49a2d798218e8c8aefbddb26a0e71bbbElliott 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. 205adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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. 227adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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; 239320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 240320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 241320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Gets the {@link Schema} object specified through 242320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * the {@link #setSchema(Schema schema)} method. 243adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 244320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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. 249320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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. 255320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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 } 267320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 268adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 269320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>Set the {@link Schema} to be used by parsers created 270320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * from this factory.</p> 271320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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> 275320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 276320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>When warnings/errors/fatal errors are found by the validator, the parser must 277320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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. 282320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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 286320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * those modified event stream.</p> 287320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 288320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>Initially, <code>null</code> is set as the {@link Schema}.</p> 289adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 290320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>This processing will take effect even if 291320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * the {@link #isValidating()} method returns <code>false</code>. 292adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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> 299320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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> 307320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 308320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @param schema <code>Schema</code> to use, <code>null</code> to remove a schema. 309320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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. 314320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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> 329320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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> 333adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 334320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <p>XInclude processing defaults to <code>false</code>.</p> 335adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 336320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @param state Set XInclude processing to <code>true</code> or 337320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>false</code> 338320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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. 343320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 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> 358320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * 359320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @return current state of XInclude processing 360adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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. 365adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 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