You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ed...@apache.org on 2001/10/15 21:11:17 UTC
cvs commit: xml-xerces/java/src/javax/xml/parsers FactoryFinder.java DocumentBuilder.java DocumentBuilderFactory.java FactoryConfigurationError.java ParserConfigurationException.java SAXParser.java SAXParserFactory.java package.html
edwingo 01/10/15 12:11:17
Modified: java/src/javax/xml/parsers DocumentBuilder.java
DocumentBuilderFactory.java
FactoryConfigurationError.java
ParserConfigurationException.java SAXParser.java
SAXParserFactory.java package.html
Added: java/src/javax/xml/parsers FactoryFinder.java
Log:
Synced up javax.xml.parsers package with latest code from xml-commons
module. This fixes a number of bugs such as:
+ Code runs in applets
+ Code runs on non-ASCII platforms such as OS/390
+ Code is parser neutral and does not mention a specific fallback parser
Revision Changes Path
1.8 +78 -85 xml-xerces/java/src/javax/xml/parsers/DocumentBuilder.java
Index: DocumentBuilder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/DocumentBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DocumentBuilder.java 2001/03/14 22:43:48 1.7
+++ DocumentBuilder.java 2001/10/15 19:11:16 1.8
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,76 +48,61 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
-
package javax.xml.parsers;
-import java.io.File;
import java.io.InputStream;
import java.io.IOException;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
+import java.io.File;
+
+import org.xml.sax.Parser;
+import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
/**
- * Instances of <code>DocumentBuilder</code> provide a mechansim for
- * parsing XML documents into a DOM document tree represented by an
- * <code>org.w3c.dom.Document</code> object.
- * <br>
- * A <code>DocumentBuilder</code> instance is obtained from a
- * <code>DocumentBuilderFactory</code> by invoking its
- * <code>newDocumentBuilder()</code> method.
- * <br>
- * <b>NOTE:</b> <code>DocumentBuilder</code> uses several classes from the
- * SAX API. This does not require that the implementor of the
- * underlying DOM implementation use a SAX parser to parse XML content
- * into a <code>org.w3c.dom.Document</code>. It merely requires that
- * the implementation communicate with the application using these
- * existing APIs.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.7 $ $Date: 2001/03/14 22:43:48 $
+ * Defines the API to obtain DOM Document instances from an XML
+ * document. Using this class, an application programmer can obtain a
+ * {@link org.w3c.dom.Document} from XML.<p>
+ *
+ * An instance of this class can be obtained from the
+ * {@link javax.xml.parsers.DocumentBuilderFactory#newDocumentBuilder()
+ * DocumentBuilderFactory.newDocumentBuilder} method. Once
+ * an instance of this class is obtained, XML can be parsed from a
+ * variety of input sources. These input sources are InputStreams,
+ * Files, URLs, and SAX InputSources.<p>
+ *
+ * Note that this class reuses several classes from the SAX API. This
+ * does not require that the implementor of the underlying DOM
+ * implementation use a SAX parser to parse XML document into a
+ * <code>Document</code>. It merely requires that the implementation
+ * communicate with the application using these existing APIs. <p>
+ *
+ * An implementation of <code>DocumentBuilder</code> is <em>NOT</em>
+ * guaranteed to behave as per the specification if it is used concurrently by
+ * two or more threads. It is recommended to have one instance of the
+ * <code>DocumentBuilder</code> per thread or it is upto the application to
+ * make sure about the use of <code>DocumentBuilder</code> from more than one
+ * thread.
+ *
+ * @since JAXP 1.0
+ * @version 1.0
*/
+
public abstract class DocumentBuilder {
protected DocumentBuilder () {
}
/**
- * Parse the content of the given InputStream as an XML document
- * and return a new DOM Document object.
+ * Parse the content of the given <code>InputStream</code> as an XML
+ * document and return a new DOM {@link org.w3c.dom.Document} object.
*
* @param is InputStream containing the content to be parsed.
* @exception IOException If any IO errors occur.
@@ -139,15 +123,16 @@
}
/**
- * Parse the content of the given InputStream as an XML document
- * and return a new DOM Document object.
+ * Parse the content of the given <code>InputStream</code> as an XML
+ * document and return a new DOM {@link org.w3c.dom.Document} object.
*
* @param is InputStream containing the content to be parsed.
- * @param systemId Provide a base for resolving relative URIs.
+ * @param systemId Provide a base for resolving relative URIs.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the InputStream is null
+ * @exception IllegalArgumentException If the InputStream is null.
* @see org.xml.sax.DocumentHandler
+ * @return A new DOM Document object.
*/
public Document parse(InputStream is, String systemId)
@@ -158,19 +143,20 @@
}
InputSource in = new InputSource(is);
- in.setSystemId(systemId);
+ in.setSystemId(systemId);
return parse(in);
}
/**
* Parse the content of the given URI as an XML document
- * and return a new DOM Document object.
+ * and return a new DOM {@link org.w3c.dom.Document} object.
*
* @param uri The location of the content to be parsed.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the URI is null
+ * @exception IllegalArgumentException If the URI is null.
* @see org.xml.sax.DocumentHandler
+ * @return A new DOM Document object.
*/
public Document parse(String uri)
@@ -186,13 +172,14 @@
/**
* Parse the content of the given file as an XML document
- * and return a new DOM Document object.
+ * and return a new DOM {@link org.w3c.dom.Document} object.
*
- * @param f The file containing the XML to parse
+ * @param f The file containing the XML to parse.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the file is null
+ * @exception IllegalArgumentException If the file is null.
* @see org.xml.sax.DocumentHandler
+ * @return A new DOM Document object.
*/
public Document parse(File f)
@@ -203,22 +190,23 @@
}
String uri = "file:" + f.getAbsolutePath();
- if (File.separatorChar == '\\') {
- uri = uri.replace('\\', '/');
- }
+ if (File.separatorChar == '\\') {
+ uri = uri.replace('\\', '/');
+ }
InputSource in = new InputSource(uri);
return parse(in);
}
/**
* Parse the content of the given input source as an XML document
- * and return a new DOM Document object.
+ * and return a new DOM {@link org.w3c.dom.Document} object.
*
* @param is InputSource containing the content to be parsed.
* @exception IOException If any IO errors occur.
* @exception SAXException If any parse errors occur.
- * @exception IllegalArgumentException If the InputSource is null
+ * @exception IllegalArgumentException If the InputSource is null.
* @see org.xml.sax.DocumentHandler
+ * @return A new DOM Document object.
*/
public abstract Document parse(InputSource is)
@@ -228,6 +216,9 @@
/**
* Indicates whether or not this parser is configured to
* understand namespaces.
+ *
+ * @return true if this parser is configured to understand
+ * namespaces; false otherwise.
*/
public abstract boolean isNamespaceAware();
@@ -235,36 +226,37 @@
/**
* Indicates whether or not this parser is configured to
* validate XML documents.
+ *
+ * @return true if this parser is configured to validate
+ * XML documents; false otherwise.
*/
public abstract boolean isValidating();
/**
- * Specify the <code>EntityResolver</code> to be used to resolve
+ * Specify the {@link org.xml.sax.EntityResolver} to be used to resolve
* entities present in the XML document to be parsed. Setting
* this to <code>null</code> will result in the underlying
* implementation using it's own default implementation and
* behavior.
+ *
+ * @param er The <code>EntityResolver</code> to be used to resolve entities
+ * present in the XML document to be parsed.
*/
- // XXX
- // Add that the underlying impl doesn't have to use SAX, but
- // must understand how to resolve entities from this object.
-
public abstract void setEntityResolver(org.xml.sax.EntityResolver er);
/**
- * Specify the <code>ErrorHandler</code> to be used to resolve
- * entities present in the XML document to be parsed. Setting
+ * Specify the {@link org.xml.sax.ErrorHandler} to be used to report
+ * errors present in the XML document to be parsed. Setting
* this to <code>null</code> will result in the underlying
* implementation using it's own default implementation and
* behavior.
+ *
+ * @param eh The <code>ErrorHandler</code> to be used to report errors
+ * present in the XML document to be parsed.
*/
- // XXX
- // Add that the underlying impl doesn't have to use SAX, but
- // must understand how to handle errors using this object.
-
public abstract void setErrorHandler(org.xml.sax.ErrorHandler eh);
/**
@@ -285,5 +277,6 @@
*
* @return A new instance of a <code>DOMImplementation</code>.
*/
+
public abstract DOMImplementation getDOMImplementation();
}
1.8 +132 -196 xml-xerces/java/src/javax/xml/parsers/DocumentBuilderFactory.java
Index: DocumentBuilderFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/DocumentBuilderFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DocumentBuilderFactory.java 2001/06/21 18:28:59 1.7
+++ DocumentBuilderFactory.java 2001/10/15 19:11:17 1.8
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,10 +48,9 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
package javax.xml.parsers;
@@ -67,43 +65,23 @@
import java.io.InputStreamReader;
/**
- * The <code>DocumentBuilderFactory</code> defines a factory API that enables
- * applications to configure and obtain a parser to parse XML documents into
- * a DOM Document tree.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Defines a factory API that enables applications to obtain a
+ * parser that produces DOM object trees from XML documents.
*
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.7 $ $Date: 2001/06/21 18:28:59 $
+ * An implementation of the <code>DocumentBuilderFactory</code> class is
+ * <em>NOT</em> guaranteed to be thread safe. It is up to the user application
+ * to make sure about the use of the <code>DocumentBuilderFactory</code> from
+ * more than one thread. Alternatively the application can have one instance
+ * of the <code>DocumentBuilderFactory</code> per thread.
+ * An application can use the same instance of the factory to obtain one or
+ * more instances of the <code>DocumentBuilder</code> provided the instance
+ * of the factory isn't being used in more than one thread at a time.
+ *
+ * @since JAXP 1.0
+ * @version 1.0
*/
-public abstract class DocumentBuilderFactory {
- /** The default property name according to the JAXP spec */
- private static final String defaultPropName =
- "javax.xml.parsers.DocumentBuilderFactory";
+public abstract class DocumentBuilderFactory {
private boolean validating = false;
private boolean namespaceAware = false;
private boolean whitespace = false;
@@ -118,15 +96,33 @@
/**
* Obtain a new instance of a
* <code>DocumentBuilderFactory</code>. This static method creates
- * a new factory instance based on a System property setting or
- * uses the platform default if no property has been defined.<p>
- *
- * The system property that controls which Factory implementation
- * to create is named
- * "javax.xml.parsers.DocumentBuilderFactory". This
- * property names a class that is a concrete subclass of this
- * abstract class. If no property is defined, a platform default
- * will be used.<p>
+ * a new factory instance.
+ * This method uses the following ordered lookup procedure to determine
+ * the <code>DocumentBuilderFactory</code> implementation class to
+ * load:
+ * <ul>
+ * <li>
+ * Use the <code>javax.xml.parsers.DocumentBuilderFactory</code> system
+ * property.
+ * </li>
+ * <li>
+ * Use the properties file "lib/jaxp.properties" in the JRE directory.
+ * This configuration file is in standard <code>java.util.Properties
+ * </code> format and contains the fully qualified name of the
+ * implementation class with the key being the system property defined
+ * above.
+ * </li>
+ * <li>
+ * Use the Services API (as detailed in the JAR specification), if
+ * available, to determine the classname. The Services API will look
+ * for a classname in the file
+ * <code>META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
+ * in jars available to the runtime.
+ * </li>
+ * <li>
+ * Platform default <code>DocumentBuilderFactory</code> instance.
+ * </li>
+ * </ul>
*
* Once an application has obtained a reference to a
* <code>DocumentBuilderFactory</code> it can use the factory to
@@ -134,38 +130,30 @@
*
* @exception FactoryConfigurationError if the implementation is not
* available or cannot be instantiated.
- */
+ */
- public static DocumentBuilderFactory newInstance() {
- String factoryImplName = findFactory(defaultPropName,
- "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
- // the default can be removed after services are tested well enough
-
- if (factoryImplName == null) {
- throw new FactoryConfigurationError(
- "No default implementation found");
- }
-
- DocumentBuilderFactory factoryImpl;
+ public static DocumentBuilderFactory newInstance()
+ throws FactoryConfigurationError
+ {
try {
- Class clazz = Class.forName(factoryImplName);
- factoryImpl = (DocumentBuilderFactory)clazz.newInstance();
- } catch (ClassNotFoundException cnfe) {
- throw new FactoryConfigurationError(cnfe);
- } catch (IllegalAccessException iae) {
- throw new FactoryConfigurationError(iae);
- } catch (InstantiationException ie) {
- throw new FactoryConfigurationError(ie);
- }
- return factoryImpl;
+ return (DocumentBuilderFactory) FactoryFinder.find(
+ /* The default property name according to the JAXP spec */
+ "javax.xml.parsers.DocumentBuilderFactory",
+ /* The fallback implementation class name */
+ null);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+ }
}
/**
- * Creates a new instance of a DocumentBuilder using the
- * currently configured parameters.
+ * Creates a new instance of a {@link javax.xml.parsers.DocumentBuilder}
+ * using the currently configured parameters.
*
* @exception ParserConfigurationException if a DocumentBuilder
- * cannot be created which satisfies the configuration requested
+ * cannot be created which satisfies the configuration requested.
+ * @return A new instance of a DocumentBuilder.
*/
public abstract DocumentBuilder newDocumentBuilder()
@@ -174,7 +162,11 @@
/**
* Specifies that the parser produced by this code will
- * provide support for XML namespaces.
+ * provide support for XML namespaces. By default the value of this is set
+ * to <code>false</code>
+ *
+ * @param awareness true if the parser produced will provide support
+ * for XML namespaces; false otherwise.
*/
public void setNamespaceAware(boolean awareness) {
@@ -183,7 +175,11 @@
/**
* Specifies that the parser produced by this code will
- * validate documents as they are parsed.
+ * validate documents as they are parsed. By default the value of this
+ * is set to <code>false</code>.
+ *
+ * @param validating true if the parser produced will validate documents
+ * as they are parsed; false otherwise.
*/
public void setValidating(boolean validating) {
@@ -191,18 +187,31 @@
}
/**
- * Specifies that the parser produced by this code will
- * ignore "ignorable whitespace" ONLY when the document is validated as
- * they are parsed.
+ * Specifies that the parsers created by this factory must eliminate
+ * whitespace in element content (sometimes known loosely as
+ * 'ignorable whitespace') when parsing XML documents (see XML Rec
+ * 2.10). Note that only whitespace which is directly contained within
+ * element content that has an element only content model (see XML
+ * Rec 3.2.1) will be eliminated. Due to reliance on the content model
+ * this setting requires the parser to be in validating mode. By default
+ * the value of this is set to <code>false</code>.
+ *
+ * @param whitespace true if the parser created must eliminate whitespace
+ * in the element content when parsing XML documents;
+ * false otherwise.
*/
-
+
public void setIgnoringElementContentWhitespace(boolean whitespace) {
this.whitespace = whitespace;
}
/**
* Specifies that the parser produced by this code will
- * expand entity reference nodes.
+ * expand entity reference nodes. By default the value of this is set to
+ * <code>true</code>
+ *
+ * @param expandEntityRef true if the parser produced will expand entity
+ * reference nodes; false otherwise.
*/
public void setExpandEntityReferences(boolean expandEntityRef) {
@@ -211,7 +220,8 @@
/**
* Specifies that the parser produced by this code will
- * ignore comments.
+ * ignore comments. By default the value of this is set to <code>false
+ * </code>
*/
public void setIgnoringComments(boolean ignoreComments) {
@@ -220,8 +230,13 @@
/**
* Specifies that the parser produced by this code will
- * convert CDATA nodes to Text nodes and append it to the
- * adjacent (if any) text node.
+ * convert CDATA nodes to Text nodes and append it to the
+ * adjacent (if any) text node. By default the value of this is set to
+ * <code>false</code>
+ *
+ * @param coalescing true if the parser produced will convert CDATA nodes
+ * to Text nodes and append it to the adjacent (if any)
+ * text node; false otherwise.
*/
public void setCoalescing(boolean coalescing) {
@@ -231,6 +246,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which are namespace aware.
+ *
+ * @return true if the factory is configured to produce parsers which
+ * are namespace aware; false otherwise.
*/
public boolean isNamespaceAware() {
@@ -240,6 +258,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which validate the XML content during parse.
+ *
+ * @return true if the factory is configured to produce parsers
+ * which validate the XML content during parse; false otherwise.
*/
public boolean isValidating() {
@@ -248,8 +269,11 @@
/**
* Indicates whether or not the factory is configured to produce
- * parsers which ignore "ignorable whitespace" when validated in the XML
- * content during parse.
+ * parsers which ignore ignorable whitespace in element content.
+ *
+ * @return true if the factory is configured to produce parsers
+ * which ignore ignorable whitespace in element content;
+ * false otherwise.
*/
public boolean isIgnoringElementContentWhitespace() {
@@ -259,6 +283,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which expand entity reference nodes.
+ *
+ * @return true if the factory is configured to produce parsers
+ * which expand entity reference nodes; false otherwise.
*/
public boolean isExpandEntityReferences() {
@@ -268,6 +295,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which ignores comments.
+ *
+ * @return true if the factory is configured to produce parsers
+ * which ignores comments; false otherwise.
*/
public boolean isIgnoringComments() {
@@ -278,6 +308,10 @@
* Indicates whether or not the factory is configured to produce
* parsers which converts CDATA nodes to Text nodes and appends it to
* the adjacent (if any) Text node.
+ *
+ * @return true if the factory is configured to produce parsers
+ * which converts CDATA nodes to Text nodes and appends it to
+ * the adjacent (if any) Text node; false otherwise.
*/
public boolean isCoalescing() {
@@ -285,122 +319,24 @@
}
/**
- * Allows the user to set specific attributes on the underlying
+ * Allows the user to set specific attributes on the underlying
* implementation.
* @param name The name of the attribute.
* @param value The value of the attribute.
- * @exception IllegalArgumentException thrown if the underlying
+ * @exception IllegalArgumentException thrown if the underlying
* implementation doesn't recognize the attribute.
*/
- public abstract void setAttribute(String name, Object value)
- throws IllegalArgumentException;
+ public abstract void setAttribute(String name, Object value)
+ throws IllegalArgumentException;
/**
- * Allows the user to retrieve specific attributes on the underlying
+ * Allows the user to retrieve specific attributes on the underlying
* implementation.
* @param name The name of the attribute.
* @return value The value of the attribute.
- * @exception IllegalArgumentException thrown if the underlying
+ * @exception IllegalArgumentException thrown if the underlying
* implementation doesn't recognize the attribute.
*/
public abstract Object getAttribute(String name)
- throws IllegalArgumentException;
-
- // -------------------- private methods --------------------
- // This code is duplicated in all factories.
- // Keep it in sync or move it to a common place
- // Because it's small probably it's easier to keep it here
- /** Avoid reading all the files when the findFactory
- method is called the second time ( cache the result of
- finding the default impl )
- */
- private static String foundFactory=null;
-
- /** Temp debug code - this will be removed after we test everything
- */
- private static final boolean debug=
- System.getProperty( "jaxp.debug" ) != null;
-
- /** Private implementation method - will find the implementation
- class in the specified order.
- @param factoryId Name of the factory interface
- @param xmlProperties Name of the properties file based on JAVA/lib
- @param defaultFactory Default implementation, if nothing else is found
- */
- private static String findFactory(String factoryId,
- String defaultFactory)
- {
- // Use the system property first
- try {
- String systemProp =
- System.getProperty( factoryId );
- if( systemProp!=null) {
- if( debug )
- System.err.println("JAXP: found system property" +
- systemProp );
- return systemProp;
- }
-
- }catch (SecurityException se) {
- }
-
- if( foundFactory!=null)
- return foundFactory;
-
- // try to read from $java.home/lib/xml.properties
- try {
- String javah=System.getProperty( "java.home" );
- String configFile = javah + File.separator +
- "lib" + File.separator + "jaxp.properties";
- File f=new File( configFile );
- if( f.exists()) {
- Properties props=new Properties();
- props.load( new FileInputStream(f));
- foundFactory=props.getProperty( factoryId );
- if( debug )
- System.err.println("JAXP: found java.home property " +
- foundFactory );
- if(foundFactory!=null )
- return foundFactory;
- }
- } catch(Exception ex ) {
- if( debug ) ex.printStackTrace();
- }
-
- String serviceId = "META-INF/services/" + factoryId;
- // try to find services in CLASSPATH
- try {
- ClassLoader cl=DocumentBuilderFactory.class.getClassLoader();
- InputStream is=null;
- if( cl == null ) {
- is=ClassLoader.getSystemResourceAsStream( serviceId );
- } else {
- is=cl.getResourceAsStream( serviceId );
- }
-
- if( is!=null ) {
- if( debug )
- System.err.println("JAXP: found " +
- serviceId);
- BufferedReader rd=new BufferedReader( new
- InputStreamReader(is));
-
- foundFactory=rd.readLine();
- rd.close();
-
- if( debug )
- System.err.println("JAXP: loaded from services: " +
- foundFactory );
- if( foundFactory != null &&
- ! "".equals( foundFactory) ) {
- return foundFactory;
- }
- }
- } catch( Exception ex ) {
- if( debug ) ex.printStackTrace();
- }
-
- return defaultFactory;
- }
-
+ throws IllegalArgumentException;
}
1.4 +27 -50 xml-xerces/java/src/javax/xml/parsers/FactoryConfigurationError.java
Index: FactoryConfigurationError.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/FactoryConfigurationError.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FactoryConfigurationError.java 2000/11/16 00:57:43 1.3
+++ FactoryConfigurationError.java 2001/10/15 19:11:17 1.4
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,53 +48,23 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
package javax.xml.parsers;
/**
- * This error is thrown if there is a configuration problem when creating
- * new factory instances.
- * <br>
- * This error will also be thrown when the class of a Factory specified by
- * a system property, or the class of the default system parser factory,
- * cannot be loaded or instantiated.
- * <br>
- * Implementation or Application developers should never need to directly
- * construct or catch errors of this type.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.3 $ $Date: 2000/11/16 00:57:43 $
+ * Thrown when a problem with configuration with the Parser Factories
+ * exists. This error will typically be thrown when the class of a
+ * parser factory specified in the system properties cannot be found
+ * or instantiated.
+ *
+ * @since JAXP 1.0
+ * @version 1.0
*/
+
public class FactoryConfigurationError extends Error {
private Exception exception;
@@ -132,7 +101,7 @@
*/
public FactoryConfigurationError(Exception e) {
- super();
+ super(e.toString());
this.exception = e;
}
@@ -155,7 +124,9 @@
/**
* Return the message (if any) for this error . If there is no
* message for the exception and there is an encapsulated
- * exception then the message of that exception will be returned.
+ * exception then the message of that exception, if it exists will be
+ * returned. Else the name of the encapsulated exception will be
+ * returned.
*
* @return The error message.
*/
@@ -181,4 +152,10 @@
return exception;
}
}
+
+
+
+
+
+
1.4 +24 -53 xml-xerces/java/src/javax/xml/parsers/ParserConfigurationException.java
Index: ParserConfigurationException.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/ParserConfigurationException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParserConfigurationException.java 2000/11/16 00:57:43 1.3
+++ ParserConfigurationException.java 2001/10/15 19:11:17 1.4
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,69 +48,41 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
package javax.xml.parsers;
/**
- * This exception is thrown if a factory cannot configure a parser given its
- * current configuration parameters.
- * <br>
- * For example, if a parser factory cannot create parsers that validate,
- * but have been configured to do so, it will throw this exception when a
- * parser is requested to via the parser creation methods.
- * <br>
- * Application developers are not expected to construct instances of this
- * exception type, but must catch them in code that obtains parser instances
- * from a factory.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.3 $ $Date: 2000/11/16 00:57:43 $
+ * Indicates a serious configuration error.
+ *
+ * @since JAXP 1.0
+ * @version 1.0
*/
+
public class ParserConfigurationException extends Exception {
/**
- * Constructs a new <code>ParserConfigurationException</code> with no
- * detail message.
+ * Create a new <code>ParserConfigurationException</code> with no
+ * detail mesage.
*/
+
public ParserConfigurationException() {
super();
}
/**
- * Constructs a new <code>ParserConfigurationException</code> with the
- * given detail message.
+ * Create a new <code>ParserConfigurationException</code> with
+ * the <code>String</code> specified as an error message.
+ *
+ * @param msg The error message for the exception.
*/
+
public ParserConfigurationException(String msg) {
super(msg);
}
+
}
+
1.5 +132 -102 xml-xerces/java/src/javax/xml/parsers/SAXParser.java
Index: SAXParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/SAXParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SAXParser.java 2000/11/16 00:57:43 1.4
+++ SAXParser.java 2001/10/15 19:11:17 1.5
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,22 +48,17 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
+
package javax.xml.parsers;
-import java.io.File;
import java.io.InputStream;
import java.io.IOException;
-import java.io.FileInputStream;
-import java.util.Locale;
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
+import java.io.File;
import org.xml.sax.Parser;
import org.xml.sax.XMLReader;
@@ -75,43 +69,40 @@
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
+
/**
- * Implementation instances of the <code>SAXParser</code> abstract class
- * contain an implementation of the <code>org.xml.sax.Parser</code> interface
- * and enables content from a variety of sources to be parsed using the
- * contained parser.
- * <br>
- * Instances of <code>SAXParser</code> are obtained from a
- * <code>SAXParserFactory</code> by invoking its <code>newSAXParser()</code>
- * method.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.4 $ $Date: 2000/11/16 00:57:43 $
+ * Defines the API that wraps an {@link org.xml.sax.XMLReader}
+ * implementation class. In JAXP 1.0, this class wrapped the
+ * {@link org.xml.sax.Parser} interface, however this interface was
+ * replaced by the {@link org.xml.sax.XMLReader}. For ease
+ * of transition, this class continues to support the same name
+ * and interface as well as supporting new methods.
+ *
+ * An instance of this class can be obtained from the
+ * {@link javax.xml.parsers.SAXParserFactory#newSAXParser()} method.
+ * Once an instance of this class is obtained, XML can be parsed from
+ * a variety of input sources. These input sources are InputStreams,
+ * Files, URLs, and SAX InputSources.<p>
+ *
+ *
+ * As the content is parsed by the underlying parser, methods of the
+ * given {@link org.xml.sax.HandlerBase} or the
+ * {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
+ *
+ * Implementors of this class which wrap an underlying implementation
+ * can consider using the {@link org.xml.sax.helpers.ParserAdapter}
+ * class to initially adapt their SAX1 impelemntation to work under
+ * this revised class.<p>
+ *
+ * An implementation of <code>SAXParser</code> is <em>NOT</em>
+ * guaranteed to behave as per the specification if it is used concurrently by
+ * two or more threads. It is recommended to have one instance of the
+ * <code>SAXParser</code> per thread or it is upto the application to
+ * make sure about the use of <code>SAXParser</code> from more than one
+ * thread.
+ *
+ * @since JAXP 1.0
+ * @version 1.0
*/
public abstract class SAXParser {
@@ -121,14 +112,17 @@
}
/**
- * Parse the content of the given <code>java.io.InputStream</code>
- * instance as XML using the specified
- * <code>org.xml.sax.HandlerBase</code>.
+ * Parse the content of the given {@link java.io.InputStream}
+ * instance as XML using the specified {@link org.xml.sax.HandlerBase}.
+ * <i> Use of the DefaultHandler version of this method is recommended as
+ * the HandlerBase class has been deprecated in SAX 2.0</i>
*
* @param is InputStream containing the content to be parsed.
* @param hb The SAX HandlerBase to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the given InputStream is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -144,15 +138,18 @@
}
/**
- * Parse the content of the given <code>java.io.InputStream</code>
- * instance as XML using the specified
- * <code>org.xml.sax.HandlerBase</code>.
+ * Parse the content of the given {@link java.io.InputStream}
+ * instance as XML using the specified {@link org.xml.sax.HandlerBase}.
+ * <i> Use of the DefaultHandler version of this method is recommended as
+ * the HandlerBase class has been deprecated in SAX 2.0</i>
*
* @param is InputStream containing the content to be parsed.
* @param hb The SAX HandlerBase to use.
* @param systemId The systemId which is needed for resolving relative URIs.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the given InputStream is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
* version of this method instead.
*/
@@ -165,19 +162,21 @@
}
InputSource input = new InputSource(is);
- input.setSystemId(systemId);
+ input.setSystemId(systemId);
this.parse(input, hb);
}
/**
- * Parse the content of the given <code>java.io.InputStream</code>
+ * Parse the content of the given {@link java.io.InputStream}
* instance as XML using the specified
- * <code>org.xml.sax.helpers.DefaultHandler</code>.
+ * {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param is InputStream containing the content to be parsed.
- * @param hb The SAX HandlerBase to use.
+ * @param dh The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the given InputStream is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -190,18 +189,20 @@
InputSource input = new InputSource(is);
this.parse(input, dh);
- }
+ }
/**
- * Parse the content of the given <code>java.io.InputStream</code>
+ * Parse the content of the given {@link java.io.InputStream}
* instance as XML using the specified
- * <code>org.xml.sax.helpers.DefaultHandler</code>.
+ * {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param is InputStream containing the content to be parsed.
- * @param hb The SAX HandlerBase to use.
+ * @param dh The SAX DefaultHandler to use.
* @param systemId The systemId which is needed for resolving relative URIs.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the given InputStream is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
* version of this method instead.
*/
@@ -214,19 +215,23 @@
}
InputSource input = new InputSource(is);
- input.setSystemId(systemId);
+ input.setSystemId(systemId);
this.parse(input, dh);
- }
+ }
/**
* Parse the content described by the giving Uniform Resource
* Identifier (URI) as XML using the specified
- * <code>org.xml.sax.HandlerBase</code>.
+ * {@link org.xml.sax.HandlerBase}.
+ * <i> Use of the DefaultHandler version of this method is recommended as
+ * the <code>HandlerBase</code> class has been deprecated in SAX 2.0</i>
*
* @param uri The location of the content to be parsed.
* @param hb The SAX HandlerBase to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the uri is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -244,12 +249,14 @@
/**
* Parse the content described by the giving Uniform Resource
* Identifier (URI) as XML using the specified
- * <code>org.xml.sax.helpers.DefaultHandler</code>.
+ * {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param uri The location of the content to be parsed.
- * @param hb The SAX HandlerBase to use.
+ * @param dh The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the uri is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -266,13 +273,17 @@
/**
* Parse the content of the file specified as XML using the
- * specified <code>org.xml.sax.HandlerBase</code>.
+ * specified {@link org.xml.sax.HandlerBase}.
+ * <i> Use of the DefaultHandler version of this method is recommended as
+ * the HandlerBase class has been deprecated in SAX 2.0</i>
*
* @param f The file containing the XML to parse
* @param hb The SAX HandlerBase to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the File object is null.
* @see org.xml.sax.DocumentHandler
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
*/
public void parse(File f, HandlerBase hb)
@@ -283,21 +294,23 @@
}
String uri = "file:" + f.getAbsolutePath();
- if (File.separatorChar == '\\') {
- uri = uri.replace('\\', '/');
- }
+ if (File.separatorChar == '\\') {
+ uri = uri.replace('\\', '/');
+ }
InputSource input = new InputSource(uri);
this.parse(input, hb);
}
/**
* Parse the content of the file specified as XML using the
- * specified <code>org.xml.sax.helpers.DefaultHandler</code>.
+ * specified {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param f The file containing the XML to parse
- * @param dh The SAX Handler to use.
+ * @param dh The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the File object is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -309,22 +322,26 @@
}
String uri = "file:" + f.getAbsolutePath();
- if (File.separatorChar == '\\') {
- uri = uri.replace('\\', '/');
- }
+ if (File.separatorChar == '\\') {
+ uri = uri.replace('\\', '/');
+ }
InputSource input = new InputSource(uri);
this.parse(input, dh);
}
/**
- * Parse the content given <code>org.xml.sax.InputSource</code>
+ * Parse the content given {@link org.xml.sax.InputSource}
* as XML using the specified
- * <code>org.xml.sax.HandlerBase</code>.
+ * {@link org.xml.sax.HandlerBase}.
+ * <i> Use of the DefaultHandler version of this method is recommended as
+ * the HandlerBase class has been deprecated in SAX 2.0</i>
*
* @param is The InputSource containing the content to be parsed.
* @param hb The SAX HandlerBase to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the InputSource is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -336,24 +353,26 @@
}
Parser parser = this.getParser();
- if (hb != null) {
+ if (hb != null) {
parser.setDocumentHandler(hb);
parser.setEntityResolver(hb);
parser.setErrorHandler(hb);
parser.setDTDHandler(hb);
- }
+ }
parser.parse(is);
}
/**
- * Parse the content given <code>org.xml.sax.InputSource</code>
+ * Parse the content given {@link org.xml.sax.InputSource}
* as XML using the specified
- * <code>org.xml.sax.helpers.DefaultHandler</code>.
+ * {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param is The InputSource containing the content to be parsed.
* @param dh The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the InputSource is null.
+ * @exception SAXException If the underlying parser throws a
+ * SAXException while parsing.
* @see org.xml.sax.DocumentHandler
*/
@@ -365,25 +384,31 @@
}
XMLReader reader = this.getXMLReader();
- if (dh != null) {
+ if (dh != null) {
reader.setContentHandler(dh);
reader.setEntityResolver(dh);
reader.setErrorHandler(dh);
reader.setDTDHandler(dh);
- }
+ }
reader.parse(is);
}
/**
* Returns the SAX parser that is encapsultated by the
* implementation of this class.
+ *
+ * @return The SAX parser that is encapsultated by the
+ * implementation of this class.
*/
public abstract org.xml.sax.Parser getParser() throws SAXException;
/**
- * Returns the XMLReader that is encapsulated by the
+ * Returns the {@link org.xml.sax.XMLReader} that is encapsulated by the
* implementation of this class.
+ *
+ * @return The XMLReader that is encapsulated by the
+ * implementation of this class.
*/
public abstract org.xml.sax.XMLReader getXMLReader() throws SAXException;
@@ -391,6 +416,9 @@
/**
* Indicates whether or not this parser is configured to
* understand namespaces.
+ *
+ * @return true if this parser is configured to
+ * understand namespaces; false otherwise.
*/
public abstract boolean isNamespaceAware();
@@ -398,20 +426,25 @@
/**
* Indicates whether or not this parser is configured to
* validate XML documents.
+ *
+ * @return true if this parser is configured to
+ * validate XML documents; false otherwise.
*/
public abstract boolean isValidating();
/**
- * Sets the particular property in the underlying implementation of
- * org.xml.sax.XMLReader.
+ * Sets the particular property in the underlying implementation of
+ * {@link org.xml.sax.XMLReader}.
+ * A list of the core features and properties can be found at
+ * <a href="http://www.megginson.com/SAX/Java/features.html"> http://www.megginson.com/SAX/Java/features.html </a>
*
* @param name The name of the property to be set.
* @param value The value of the property to be set.
- * @exception SAXNotRecognizedException When the underlying XMLReader does
+ * @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
- * @exception SAXNotSupportedException When the underlying XMLReader
+ * @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
@@ -422,24 +455,21 @@
/**
*
- * returns the particular property requested for in the underlying
- * implementation of org.xml.sax.XMLReader.
+ * Returns the particular property requested for in the underlying
+ * implementation of {@link org.xml.sax.XMLReader}.
*
* @param name The name of the property to be retrieved.
* @return Value of the requested property.
*
- * @exception SAXNotRecognizedException When the underlying XMLReader does
+ * @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
- * @exception SAXNotSupportedException When the underlying XMLReader
+ * @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
* @see org.xml.sax.XMLReader#getProperty
*/
- public abstract Object getProperty(String name)
+ public abstract Object getProperty(String name)
throws SAXNotRecognizedException, SAXNotSupportedException;
-
-
-
}
1.6 +96 -197 xml-xerces/java/src/javax/xml/parsers/SAXParserFactory.java
Index: SAXParserFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/SAXParserFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SAXParserFactory.java 2000/11/16 00:57:43 1.5
+++ SAXParserFactory.java 2001/10/15 19:11:17 1.6
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,16 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
+ * 4. The name "Apache Software Foundation" must not be used to endorse or
+ * promote products derived from this software without prior written
+ * permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
@@ -49,10 +48,9 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999-2000, Pierpaolo
- * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
- * For more information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * originally based on software copyright (c) 1999-2001, Sun Microsystems,
+ * Inc., http://www.sun.com. For more information on the Apache Software
+ * Foundation, please see <http://www.apache.org/>.
*/
package javax.xml.parsers;
@@ -62,55 +60,27 @@
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Locale;
-
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
/**
- * The <code>SAXParserFactory</code> defines a factory API that enables
- * applications to configure and obtain a SAX based parser to parse XML
- * documents.
- * <br>
- * <br>
- * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- * IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- * REQUEST 5 FOUND AT
- * <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- * http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- * </a><br>
- * THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- * SPECIFICATION VERSION 1.1 PUBLIC REVIEW 1 BY JAMES DUNCAN DAVIDSON
- * PUBLISHED BY SUN MICROSYSTEMS ON NOV. 2, 2000 AND FOUND AT
- * <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- * <br>
- * <br>
- * <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Defines a factory API that enables applications to configure and
+ * obtain a SAX based parser to parse XML documents.<p>
+ * An implementation of the <code>SAXParserFactory</code> class is
+ * <em>NOT</em> guaranteed to be thread safe. It is up to the user application
+ * to make sure about the use of the <code>SAXParserFactory</code> from
+ * more than one thread. Alternatively the application can have one instance
+ * of the <code>SAXParserFactory</code> per thread.
+ * An application can use the same instance of the factory to obtain one or
+ * more instances of the <code>SAXParser</code> provided the instance
+ * of the factory isn't being used in more than one thread at a time.
+ * <p>
+ *
+ * The static <code>newInstance</code> method returns a new concrete
+ * implementation of this class.
*
- * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
- * @author Copyright © 2000 The Apache Software Foundation.
- * @version 1.0 CVS $Revision: 1.5 $ $Date: 2000/11/16 00:57:43 $
+ * @since JAXP 1.0
+ * @version 1.0
*/
public abstract class SAXParserFactory {
- /** The default property name according to the JAXP spec */
- private static final String defaultPropName =
- "javax.xml.parsers.SAXParserFactory";
-
private boolean validating = false;
private boolean namespaceAware= false;
@@ -120,53 +90,65 @@
/**
* Obtain a new instance of a <code>SAXParserFactory</code>. This
- * static method creates a new factory instance based on a System
- * property setting or uses the platform default if no property
- * has been defined.<p>
- *
- * The system property that controls which Factory implementation
- * to create is named
- * "javax.xml.parsers.SAXParserFactory". This property
- * names a class that is a concrete subclass of this abstract
- * class. If no property is defined, a platform default will be
- * used.<p>
+ * static method creates a new factory instance
+ * This method uses the following ordered lookup procedure to determine
+ * the <code>SAXParserFactory</code> implementation class to
+ * load:
+ * <ul>
+ * <li>
+ * Use the <code>javax.xml.parsers.SAXParserFactory</code> system
+ * property.
+ * </li>
+ * <li>
+ * Use the properties file "lib/jaxp.properties" in the JRE directory.
+ * This configuration file is in standard <code>java.util.Properties
+ * </code> format and contains the fully qualified name of the
+ * implementation class with the key being the system property defined
+ * above.
+ * </li>
+ * <li>
+ * Use the Services API (as detailed in the JAR specification), if
+ * available, to determine the classname. The Services API will look
+ * for a classname in the file
+ * <code>META-INF/services/javax.xml.parsers.SAXParserFactory</code>
+ * in jars available to the runtime.
+ * </li>
+ * <li>
+ * Platform default <code>SAXParserFactory</code> instance.
+ * </li>
+ * </ul>
*
* Once an application has obtained a reference to a
* <code>SAXParserFactory</code> it can use the factory to
* configure and obtain parser instances.
*
+ * @return A new instance of a SAXParserFactory.
+ *
* @exception FactoryConfigurationError if the implementation is
* not available or cannot be instantiated.
*/
-
- public static SAXParserFactory newInstance() {
- String factoryImplName = findFactory(defaultPropName,
- "org.apache.xerces.jaxp.SAXParserFactoryImpl");
- // the default can be removed after services are tested well enough
-
- if (factoryImplName == null) {
- throw new FactoryConfigurationError(
- "No default implementation found");
- }
- SAXParserFactory factoryImpl = null;
+ public static SAXParserFactory newInstance()
+ throws FactoryConfigurationError
+ {
try {
- Class clazz = Class.forName(factoryImplName);
- factoryImpl = (SAXParserFactory)clazz.newInstance();
- } catch (ClassNotFoundException cnfe) {
- throw new FactoryConfigurationError(cnfe);
- } catch (IllegalAccessException iae) {
- throw new FactoryConfigurationError(iae);
- } catch (InstantiationException ie) {
- throw new FactoryConfigurationError(ie);
- }
- return factoryImpl;
+ return (SAXParserFactory) FactoryFinder.find(
+ /* The default property name according to the JAXP spec */
+ "javax.xml.parsers.SAXParserFactory",
+ /* The fallback implementation class name */
+ null);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+ }
}
/**
* Creates a new instance of a SAXParser using the currently
* configured factory parameters.
*
+ * @return A new instance of a SAXParser.
+ *
* @exception ParserConfigurationException if a parser cannot
* be created which satisfies the requested configuration.
*/
@@ -177,20 +159,28 @@
/**
* Specifies that the parser produced by this code will
- * provide support for XML namespaces.
+ * provide support for XML namespaces. By default the value of this is set
+ * to <code>false</code>.
+ *
+ * @param awareness true if the parser produced by this code will
+ * provide support for XML namespaces; false otherwise.
*/
- public void setNamespaceAware(boolean awareness)
+ public void setNamespaceAware(boolean awareness)
{
this.namespaceAware = awareness;
}
/**
* Specifies that the parser produced by this code will
- * validate documents as they are parsed.
+ * validate documents as they are parsed. By default the value of this is
+ * set to <code>false</code>.
+ *
+ * @param validating true if the parser produced by this code will
+ * validate documents as they are parsed; false otherwise.
*/
- public void setValidating(boolean validating)
+ public void setValidating(boolean validating)
{
this.validating = validating;
}
@@ -198,6 +188,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which are namespace aware.
+ *
+ * @return true if the factory is configured to produce
+ * parsers which are namespace aware; false otherwise.
*/
public boolean isNamespaceAware() {
@@ -207,6 +200,9 @@
/**
* Indicates whether or not the factory is configured to produce
* parsers which validate the XML content during parse.
+ *
+ * @return true if the factory is configured to produce parsers which validate
+ * the XML content during parse; false otherwise.
*/
public boolean isValidating() {
@@ -215,15 +211,17 @@
/**
*
- * Sets the particular feature in the underlying implementation of
+ * Sets the particular feature in the underlying implementation of
* org.xml.sax.XMLReader.
+ * A list of the core features and properties can be found at
+ * <a href="http://www.megginson.com/SAX/Java/features.html"> http://www.megginson.com/SAX/Java/features.html </a>
*
* @param name The name of the feature to be set.
* @param value The value of the feature to be set.
- * @exception SAXNotRecognizedException When the underlying XMLReader does
+ * @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
- * @exception SAXNotSupportedException When the underlying XMLReader
+ * @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
@@ -231,20 +229,20 @@
*/
public abstract void setFeature(String name, boolean value)
throws ParserConfigurationException, SAXNotRecognizedException,
- SAXNotSupportedException;
+ SAXNotSupportedException;
/**
*
- * returns the particular property requested for in the underlying
+ * Returns the particular property requested for in the underlying
* implementation of org.xml.sax.XMLReader.
*
* @param name The name of the property to be retrieved.
* @return Value of the requested property.
*
- * @exception SAXNotRecognizedException When the underlying XMLReader does
+ * @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
- * @exception SAXNotSupportedException When the underlying XMLReader
+ * @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
@@ -252,104 +250,5 @@
*/
public abstract boolean getFeature(String name)
throws ParserConfigurationException, SAXNotRecognizedException,
- SAXNotSupportedException;
-
-
- // -------------------- private methods --------------------
- // This code is duplicated in all factories.
- // Keep it in sync or move it to a common place
- // Because it's small probably it's easier to keep it here
- /** Avoid reading all the files when the findFactory
- method is called the second time ( cache the result of
- finding the default impl )
- */
- private static String foundFactory=null;
-
- /** Temp debug code - this will be removed after we test everything
- */
- private static final boolean debug=
- System.getProperty( "jaxp.debug" ) != null;
-
- /** Private implementation method - will find the implementation
- class in the specified order.
- @param factoryId Name of the factory interface
- @param xmlProperties Name of the properties file based on JAVA/lib
- @param defaultFactory Default implementation, if nothing else is found
- */
- private static String findFactory(String factoryId,
- String defaultFactory)
- {
- // Use the system property first
- try {
- String systemProp =
- System.getProperty( factoryId );
- if( systemProp!=null) {
- if( debug )
- System.err.println("JAXP: found system property" +
- systemProp );
- return systemProp;
- }
-
- }catch (SecurityException se) {
- }
-
-
- if( foundFactory!=null)
- return foundFactory;
-
- // try to read from $java.home/lib/jaxp.properties
- try {
- String javah=System.getProperty( "java.home" );
- String configFile = javah + File.separator +
- "lib" + File.separator + "jaxp.properties";
- File f=new File( configFile );
- if( f.exists()) {
- Properties props=new Properties();
- props.load( new FileInputStream(f));
- foundFactory=props.getProperty( factoryId );
- if( debug )
- System.err.println("JAXP: found java.home property " +
- foundFactory );
- if(foundFactory!=null )
- return foundFactory;
- }
- } catch(Exception ex ) {
- if( debug ) ex.printStackTrace();
- }
-
- String serviceId = "META-INF/services/" + factoryId;
- // try to find services in CLASSPATH
- try {
- ClassLoader cl=SAXParserFactory.class.getClassLoader();
- InputStream is=null;
- if( cl == null ) {
- is=ClassLoader.getSystemResourceAsStream( serviceId );
- } else {
- is=cl.getResourceAsStream( serviceId );
- }
-
- if( is!=null ) {
- if( debug )
- System.err.println("JAXP: found " +
- serviceId);
- BufferedReader rd=new BufferedReader( new
- InputStreamReader(is));
-
- foundFactory=rd.readLine();
- rd.close();
-
- if( debug )
- System.err.println("JAXP: loaded from services: " +
- foundFactory );
- if( foundFactory != null &&
- ! "".equals( foundFactory) ) {
- return foundFactory;
- }
- }
- } catch( Exception ex ) {
- if( debug ) ex.printStackTrace();
- }
-
- return defaultFactory;
- }
+ SAXNotSupportedException;
}
1.3 +12 -37 xml-xerces/java/src/javax/xml/parsers/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/javax/xml/parsers/package.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- package.html 2000/06/02 23:42:21 1.2
+++ package.html 2001/10/15 19:11:17 1.3
@@ -1,39 +1,14 @@
-<!-- CVS $Revision: 1.2 $ $Date: 2000/06/02 23:42:21 $ -->
-<html>
- <body>
- This package provides a Plugability mechanism to allow a compliant SAX or
- DOM parser to be used indipendently by an application.
+<HTML><HEAD>
- <dl>
- <dt><b>Version: </b><dd>1.0 CVS $Revision: 1.2 $ $Date: 2000/06/02 23:42:21 $</dd>
- <dt><b>Author: </b>
- <dd><a href="pier@betaversion.org">Pierpaolo Fumagalli</a></dd>
- <dt><b>Copyright:</b>
- <dd>Copyright © 2000 The Apache Software Foundation.</dd>
- </dl>
+</HEAD><BODY>
- <b>ATTENTION:</b>THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
- IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
- REQUEST 5 FOUND AT
- <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
- http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
- </a>
- <br>
- THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
- SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
- PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
- <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
- <br>
- <br>
- <b>THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- </body>
-</html>
+Provides classes allowing the processing of XML documents. Two types
+of plugable parsers are supported:
+<ul>
+<li>SAX (Simple API for XML)
+<li>DOM (Document Object Model)
+</ul>
+
+
+
+</BODY></HTML>
1.1 xml-xerces/java/src/javax/xml/parsers/FactoryFinder.java
Index: FactoryFinder.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The name "Apache Software Foundation" must not be used to endorse or
* promote products derived from this software without prior written
* permission. For written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999-2001, Sun Microsystems,
* Inc., http://www.sun.com. For more information on the Apache Software
* Foundation, please see <http://www.apache.org/>.
*/
package javax.xml.parsers;
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* This class is duplicated for each JAXP subpackage so keep it in
* sync. It is package private.
*
* This code is designed to implement the JAXP 1.1 spec pluggability
* feature and is designed to run on JDK version 1.1 and later including
* JVMs that perform early linking like the Microsoft JVM in IE 5. Note
* however that it must be compiled on a JDK version 1.2 or later system
* since it calls Thread#getContextClassLoader(). The code also runs both
* as part of an unbundled jar file and when bundled as part of the JDK.
*/
class FactoryFinder {
/** Temp debug code - this will be removed after we test everything
*/
private static boolean debug = false;
static {
// Use try/catch block to support applets
try {
debug = System.getProperty("jaxp.debug") != null;
} catch (Exception x) {
}
}
private static void debugPrintln(String msg) {
if (debug) {
System.err.println("JAXP: " + msg);
}
}
/**
* Figure out which ClassLoader to use. For JDK 1.2 and later use the
* context ClassLoader if possible. Note: we defer linking the class
* that calls an API only in JDK 1.2 until runtime so that we can catch
* LinkageError so that this code will run in older non-Sun JVMs such
* as the Microsoft JVM in IE.
*/
private static ClassLoader findClassLoader()
throws ConfigurationError
{
ClassLoader classLoader;
try {
// Construct the name of the concrete class to instantiate
Class clazz = Class.forName(FactoryFinder.class.getName()
+ "$ClassLoaderFinderConcrete");
ClassLoaderFinder clf = (ClassLoaderFinder) clazz.newInstance();
classLoader = clf.getContextClassLoader();
} catch (LinkageError le) {
// Assume that we are running JDK 1.1, use the current ClassLoader
classLoader = FactoryFinder.class.getClassLoader();
} catch (ClassNotFoundException x) {
// This case should not normally happen. MS IE can throw this
// instead of a LinkageError the second time Class.forName() is
// called so assume that we are running JDK 1.1 and use the
// current ClassLoader
classLoader = FactoryFinder.class.getClassLoader();
} catch (Exception x) {
// Something abnormal happened so throw an error
throw new ConfigurationError(x.toString(), x);
}
return classLoader;
}
/**
* Create an instance of a class using the specified ClassLoader
*/
private static Object newInstance(String className,
ClassLoader classLoader)
throws ConfigurationError
{
try {
Class spiClass;
if (classLoader == null) {
spiClass = Class.forName(className);
} else {
spiClass = classLoader.loadClass(className);
}
return spiClass.newInstance();
} catch (ClassNotFoundException x) {
throw new ConfigurationError(
"Provider " + className + " not found", x);
} catch (Exception x) {
throw new ConfigurationError(
"Provider " + className + " could not be instantiated: " + x,
x);
}
}
/**
* Finds the implementation Class object in the specified order. Main
* entry point.
* @return Class object of factory, never null
*
* @param factoryId Name of the factory to find, same as
* a property name
* @param fallbackClassName Implementation class name, if nothing else
* is found. Use null to mean no fallback.
*
* Package private so this code can be shared.
*/
static Object find(String factoryId, String fallbackClassName)
throws ConfigurationError
{
ClassLoader classLoader = findClassLoader();
// Use the system property first
try {
String systemProp =
System.getProperty( factoryId );
if( systemProp!=null) {
debugPrintln("found system property" + systemProp);
return newInstance(systemProp, classLoader);
}
} catch (SecurityException se) {
}
// try to read from $java.home/lib/xml.properties
try {
String javah=System.getProperty( "java.home" );
String configFile = javah + File.separator +
"lib" + File.separator + "jaxp.properties";
File f=new File( configFile );
if( f.exists()) {
Properties props=new Properties();
props.load( new FileInputStream(f));
String factoryClassName = props.getProperty(factoryId);
debugPrintln("found java.home property " + factoryClassName);
return newInstance(factoryClassName, classLoader);
}
} catch(Exception ex ) {
if( debug ) ex.printStackTrace();
}
String serviceId = "META-INF/services/" + factoryId;
// try to find services in CLASSPATH
try {
InputStream is=null;
if (classLoader == null) {
is=ClassLoader.getSystemResourceAsStream( serviceId );
} else {
is=classLoader.getResourceAsStream( serviceId );
}
if( is!=null ) {
debugPrintln("found " + serviceId);
BufferedReader rd =
new BufferedReader(new InputStreamReader(is, "UTF-8"));
String factoryClassName = rd.readLine();
rd.close();
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
debugPrintln("loaded from services: " + factoryClassName);
return newInstance(factoryClassName, classLoader);
}
}
} catch( Exception ex ) {
if( debug ) ex.printStackTrace();
}
if (fallbackClassName == null) {
throw new ConfigurationError(
"Provider for " + factoryId + " cannot be found", null);
}
debugPrintln("loaded from fallback value: " + fallbackClassName);
return newInstance(fallbackClassName, classLoader);
}
static class ConfigurationError extends Error {
private Exception exception;
/**
* Construct a new instance with the specified detail string and
* exception.
*/
ConfigurationError(String msg, Exception x) {
super(msg);
this.exception = x;
}
Exception getException() {
return exception;
}
}
/*
* The following nested classes allow getContextClassLoader() to be
* called only on JDK 1.2 and yet run in older JDK 1.1 JVMs
*/
private static abstract class ClassLoaderFinder {
abstract ClassLoader getContextClassLoader();
}
static class ClassLoaderFinderConcrete extends ClassLoaderFinder {
ClassLoader getContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org