+2002-12-19 Anthony Green <green@redhat.com>
+
+ * Makefile.am (ordinary_java_source_files): Add
+ org/xml/sax/helpers/NewInstance.java.
+ * Makefile.in: Rebuilt.
+ * org/xml/sax/package.html, org/xml/sax/ext/package.html,
+ org/xml/sax/helpers/package.html: New files.
+ * org/xml/sax/*: Upgrade to SAX 2.0.1 release from
+ http://www.saxproject.org.
+
2002-12-19 Andrew Haley <aph@redhat.com>
* java/util/natResourceBundle.cc: Include
org/xml/sax/helpers/DefaultHandler.java \
org/xml/sax/helpers/LocatorImpl.java \
org/xml/sax/helpers/NamespaceSupport.java \
+org/xml/sax/helpers/NewInstance.java \
org/xml/sax/helpers/ParserAdapter.java \
org/xml/sax/helpers/ParserFactory.java \
org/xml/sax/helpers/XMLFilterImpl.java \
org/xml/sax/helpers/DefaultHandler.java \
org/xml/sax/helpers/LocatorImpl.java \
org/xml/sax/helpers/NamespaceSupport.java \
+org/xml/sax/helpers/NewInstance.java \
org/xml/sax/helpers/ParserAdapter.java \
org/xml/sax/helpers/ParserFactory.java \
org/xml/sax/helpers/XMLFilterImpl.java \
.deps/org/xml/sax/helpers/DefaultHandler.P \
.deps/org/xml/sax/helpers/LocatorImpl.P \
.deps/org/xml/sax/helpers/NamespaceSupport.P \
+.deps/org/xml/sax/helpers/NewInstance.P \
.deps/org/xml/sax/helpers/ParserAdapter.P \
.deps/org/xml/sax/helpers/ParserFactory.P \
.deps/org/xml/sax/helpers/XMLFilterImpl.P \
-// SAX Attribute List Interface.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: AttributeList.java,v 1.1 2000/10/02 02:43:16 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Interface for an element's attribute specifications.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This is the original SAX1 interface for reporting an element's\r
- * attributes. Unlike the new {@link org.xml.sax.Attributes Attributes}\r
- * interface, it does not support Namespace-related information.</p>\r
- *\r
- * <p>When an attribute list is supplied as part of a\r
- * {@link org.xml.sax.DocumentHandler#startElement startElement}\r
- * event, the list will return valid results only during the\r
- * scope of the event; once the event handler returns control\r
- * to the parser, the attribute list is invalid. To save a\r
- * persistent copy of the attribute list, use the SAX1\r
- * {@link org.xml.sax.helpers.AttributeListImpl AttributeListImpl}\r
- * helper class.</p>\r
- *\r
- * <p>An attribute list includes only attributes that have been\r
- * specified or defaulted: #IMPLIED attributes will not be included.</p>\r
- *\r
- * <p>There are two ways for the SAX application to obtain information\r
- * from the AttributeList. First, it can iterate through the entire\r
- * list:</p>\r
- *\r
- * <pre>\r
- * public void startElement (String name, AttributeList atts) {\r
- * for (int i = 0; i < atts.getLength(); i++) {\r
- * String name = atts.getName(i);\r
- * String type = atts.getType(i);\r
- * String value = atts.getValue(i);\r
- * [...]\r
- * }\r
- * }\r
- * </pre>\r
- *\r
- * <p>(Note that the result of getLength() will be zero if there\r
- * are no attributes.)\r
- *\r
- * <p>As an alternative, the application can request the value or\r
- * type of specific attributes:</p>\r
- *\r
- * <pre>\r
- * public void startElement (String name, AttributeList atts) {\r
- * String identifier = atts.getValue("id");\r
- * String label = atts.getValue("label");\r
- * [...]\r
- * }\r
- * </pre>\r
- *\r
- * @deprecated This interface has been replaced by the SAX2\r
- * {@link org.xml.sax.Attributes Attributes}\r
- * interface, which includes Namespace support.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.DocumentHandler#startElement startElement\r
- * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl\r
- */\r
-public interface AttributeList {\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Iteration methods.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
-\r
- /**\r
- * Return the number of attributes in this list.\r
- *\r
- * <p>The SAX parser may provide attributes in any\r
- * arbitrary order, regardless of the order in which they were\r
- * declared or specified. The number of attributes may be\r
- * zero.</p>\r
- *\r
- * @return The number of attributes in the list. \r
- */\r
- public abstract int getLength ();\r
- \r
- \r
- /**\r
- * Return the name of an attribute in this list (by position).\r
- *\r
- * <p>The names must be unique: the SAX parser shall not include the\r
- * same attribute twice. Attributes without values (those declared\r
- * #IMPLIED without a value specified in the start tag) will be\r
- * omitted from the list.</p>\r
- *\r
- * <p>If the attribute name has a namespace prefix, the prefix\r
- * will still be attached.</p>\r
- *\r
- * @param i The index of the attribute in the list (starting at 0).\r
- * @return The name of the indexed attribute, or null\r
- * if the index is out of range.\r
- * @see #getLength \r
- */\r
- public abstract String getName (int i);\r
- \r
- \r
- /**\r
- * Return the type of an attribute in the list (by position).\r
- *\r
- * <p>The attribute type is one of the strings "CDATA", "ID",\r
- * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",\r
- * or "NOTATION" (always in upper case).</p>\r
- *\r
- * <p>If the parser has not read a declaration for the attribute,\r
- * or if the parser does not report attribute types, then it must\r
- * return the value "CDATA" as stated in the XML 1.0 Recommentation\r
- * (clause 3.3.3, "Attribute-Value Normalization").</p>\r
- *\r
- * <p>For an enumerated attribute that is not a notation, the\r
- * parser will report the type as "NMTOKEN".</p>\r
- *\r
- * @param i The index of the attribute in the list (starting at 0).\r
- * @return The attribute type as a string, or\r
- * null if the index is out of range.\r
- * @see #getLength \r
- * @see #getType(java.lang.String)\r
- */\r
- public abstract String getType (int i);\r
- \r
- \r
- /**\r
- * Return the value of an attribute in the list (by position).\r
- *\r
- * <p>If the attribute value is a list of tokens (IDREFS,\r
- * ENTITIES, or NMTOKENS), the tokens will be concatenated\r
- * into a single string separated by whitespace.</p>\r
- *\r
- * @param i The index of the attribute in the list (starting at 0).\r
- * @return The attribute value as a string, or\r
- * null if the index is out of range.\r
- * @see #getLength\r
- * @see #getValue(java.lang.String)\r
- */\r
- public abstract String getValue (int i);\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Lookup methods.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Return the type of an attribute in the list (by name).\r
- *\r
- * <p>The return value is the same as the return value for\r
- * getType(int).</p>\r
- *\r
- * <p>If the attribute name has a namespace prefix in the document,\r
- * the application must include the prefix here.</p>\r
- *\r
- * @param name The name of the attribute.\r
- * @return The attribute type as a string, or null if no\r
- * such attribute exists.\r
- * @see #getType(int)\r
- */\r
- public abstract String getType (String name);\r
- \r
- \r
- /**\r
- * Return the value of an attribute in the list (by name).\r
- *\r
- * <p>The return value is the same as the return value for\r
- * getValue(int).</p>\r
- *\r
- * <p>If the attribute name has a namespace prefix in the document,\r
- * the application must include the prefix here.</p>\r
- *\r
- * @param i The index of the attribute in the list.\r
- * @return The attribute value as a string, or null if\r
- * no such attribute exists.\r
- * @see #getValue(int)\r
- */\r
- public abstract String getValue (String name);\r
- \r
-}\r
-\r
-// end of AttributeList.java\r
+// SAX Attribute List Interface.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: AttributeList.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Interface for an element's attribute specifications.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This is the original SAX1 interface for reporting an element's
+ * attributes. Unlike the new {@link org.xml.sax.Attributes Attributes}
+ * interface, it does not support Namespace-related information.</p>
+ *
+ * <p>When an attribute list is supplied as part of a
+ * {@link org.xml.sax.DocumentHandler#startElement startElement}
+ * event, the list will return valid results only during the
+ * scope of the event; once the event handler returns control
+ * to the parser, the attribute list is invalid. To save a
+ * persistent copy of the attribute list, use the SAX1
+ * {@link org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
+ * helper class.</p>
+ *
+ * <p>An attribute list includes only attributes that have been
+ * specified or defaulted: #IMPLIED attributes will not be included.</p>
+ *
+ * <p>There are two ways for the SAX application to obtain information
+ * from the AttributeList. First, it can iterate through the entire
+ * list:</p>
+ *
+ * <pre>
+ * public void startElement (String name, AttributeList atts) {
+ * for (int i = 0; i < atts.getLength(); i++) {
+ * String name = atts.getName(i);
+ * String type = atts.getType(i);
+ * String value = atts.getValue(i);
+ * [...]
+ * }
+ * }
+ * </pre>
+ *
+ * <p>(Note that the result of getLength() will be zero if there
+ * are no attributes.)
+ *
+ * <p>As an alternative, the application can request the value or
+ * type of specific attributes:</p>
+ *
+ * <pre>
+ * public void startElement (String name, AttributeList atts) {
+ * String identifier = atts.getValue("id");
+ * String label = atts.getValue("label");
+ * [...]
+ * }
+ * </pre>
+ *
+ * @deprecated This interface has been replaced by the SAX2
+ * {@link org.xml.sax.Attributes Attributes}
+ * interface, which includes Namespace support.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.DocumentHandler#startElement startElement
+ * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
+ */
+public interface AttributeList {
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Iteration methods.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the number of attributes in this list.
+ *
+ * <p>The SAX parser may provide attributes in any
+ * arbitrary order, regardless of the order in which they were
+ * declared or specified. The number of attributes may be
+ * zero.</p>
+ *
+ * @return The number of attributes in the list.
+ */
+ public abstract int getLength ();
+
+
+ /**
+ * Return the name of an attribute in this list (by position).
+ *
+ * <p>The names must be unique: the SAX parser shall not include the
+ * same attribute twice. Attributes without values (those declared
+ * #IMPLIED without a value specified in the start tag) will be
+ * omitted from the list.</p>
+ *
+ * <p>If the attribute name has a namespace prefix, the prefix
+ * will still be attached.</p>
+ *
+ * @param i The index of the attribute in the list (starting at 0).
+ * @return The name of the indexed attribute, or null
+ * if the index is out of range.
+ * @see #getLength
+ */
+ public abstract String getName (int i);
+
+
+ /**
+ * Return the type of an attribute in the list (by position).
+ *
+ * <p>The attribute type is one of the strings "CDATA", "ID",
+ * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
+ * or "NOTATION" (always in upper case).</p>
+ *
+ * <p>If the parser has not read a declaration for the attribute,
+ * or if the parser does not report attribute types, then it must
+ * return the value "CDATA" as stated in the XML 1.0 Recommentation
+ * (clause 3.3.3, "Attribute-Value Normalization").</p>
+ *
+ * <p>For an enumerated attribute that is not a notation, the
+ * parser will report the type as "NMTOKEN".</p>
+ *
+ * @param i The index of the attribute in the list (starting at 0).
+ * @return The attribute type as a string, or
+ * null if the index is out of range.
+ * @see #getLength
+ * @see #getType(java.lang.String)
+ */
+ public abstract String getType (int i);
+
+
+ /**
+ * Return the value of an attribute in the list (by position).
+ *
+ * <p>If the attribute value is a list of tokens (IDREFS,
+ * ENTITIES, or NMTOKENS), the tokens will be concatenated
+ * into a single string separated by whitespace.</p>
+ *
+ * @param i The index of the attribute in the list (starting at 0).
+ * @return The attribute value as a string, or
+ * null if the index is out of range.
+ * @see #getLength
+ * @see #getValue(java.lang.String)
+ */
+ public abstract String getValue (int i);
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Lookup methods.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the type of an attribute in the list (by name).
+ *
+ * <p>The return value is the same as the return value for
+ * getType(int).</p>
+ *
+ * <p>If the attribute name has a namespace prefix in the document,
+ * the application must include the prefix here.</p>
+ *
+ * @param name The name of the attribute.
+ * @return The attribute type as a string, or null if no
+ * such attribute exists.
+ * @see #getType(int)
+ */
+ public abstract String getType (String name);
+
+
+ /**
+ * Return the value of an attribute in the list (by name).
+ *
+ * <p>The return value is the same as the return value for
+ * getValue(int).</p>
+ *
+ * <p>If the attribute name has a namespace prefix in the document,
+ * the application must include the prefix here.</p>
+ *
+ * @param i The index of the attribute in the list.
+ * @return The attribute value as a string, or null if
+ * no such attribute exists.
+ * @see #getValue(int)
+ */
+ public abstract String getValue (String name);
+
+}
+
+// end of AttributeList.java
-// Attributes.java - attribute list with Namespace support\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: Attributes.java,v 1.1 2000/10/02 02:43:16 sboag Exp $\r
-\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Interface for a list of XML attributes.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This interface allows access to a list of attributes in\r
- * three different ways:</p>\r
- *\r
- * <ol>\r
- * <li>by attribute index;</li>\r
- * <li>by Namespace-qualified name; or</li>\r
- * <li>by qualified (prefixed) name.</li>\r
- * </ol>\r
- *\r
- * <p>The list will not contain attributes that were declared\r
- * #IMPLIED but not specified in the start tag. It will also not\r
- * contain attributes used as Namespace declarations (xmlns*) unless\r
- * the <code>http://xml.org/sax/features/namespace-prefixes</code> \r
- * feature is set to <var>true</var> (it is <var>false</var> by \r
- * default).</p>\r
- *\r
- * <p>If the namespace-prefixes feature (see above) is <var>false</var>, \r
- * access by qualified name may not be available; if the \r
- * <code>http://xml.org/sax/features/namespaces</code>\r
- * feature is <var>false</var>, access by Namespace-qualified names \r
- * may not be available.</p>\r
- *\r
- * <p>This interface replaces the now-deprecated SAX1 {@link\r
- * org.xml.sax.AttributeList AttributeList} interface, which does not \r
- * contain Namespace support. In addition to Namespace support, it \r
- * adds the <var>getIndex</var> methods (below).</p>\r
- *\r
- * <p>The order of attributes in the list is unspecified, and will\r
- * vary from implementation to implementation.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.helpers.AttributeListImpl\r
- */\r
-public interface Attributes\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Indexed access.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Return the number of attributes in the list.\r
- *\r
- * <p>Once you know the number of attributes, you can iterate\r
- * through the list.</p>\r
- *\r
- * @return The number of attributes in the list.\r
- * @see #getURI(int)\r
- * @see #getLocalName(int)\r
- * @see #getQName(int)\r
- * @see #getType(int)\r
- * @see #getValue(int)\r
- */\r
- public abstract int getLength ();\r
-\r
-\r
- /**\r
- * Look up an attribute's Namespace URI by index.\r
- *\r
- * @param index The attribute index (zero-based).\r
- * @return The Namespace URI, or the empty string if none\r
- * is available, or null if the index is out of\r
- * range.\r
- * @see #getLength\r
- */\r
- public abstract String getURI (int index);\r
-\r
-\r
- /**\r
- * Look up an attribute's local name by index.\r
- *\r
- * @param index The attribute index (zero-based).\r
- * @return The local name, or the empty string if Namespace\r
- * processing is not being performed, or null\r
- * if the index is out of range.\r
- * @see #getLength\r
- */\r
- public abstract String getLocalName (int index);\r
-\r
-\r
- /**\r
- * Look up an attribute's XML 1.0 qualified name by index.\r
- *\r
- * @param index The attribute index (zero-based).\r
- * @return The XML 1.0 qualified name, or the empty string\r
- * if none is available, or null if the index\r
- * is out of range.\r
- * @see #getLength\r
- */\r
- public abstract String getQName (int index);\r
-\r
-\r
- /**\r
- * Look up an attribute's type by index.\r
- *\r
- * <p>The attribute type is one of the strings "CDATA", "ID",\r
- * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",\r
- * or "NOTATION" (always in upper case).</p>\r
- *\r
- * <p>If the parser has not read a declaration for the attribute,\r
- * or if the parser does not report attribute types, then it must\r
- * return the value "CDATA" as stated in the XML 1.0 Recommentation\r
- * (clause 3.3.3, "Attribute-Value Normalization").</p>\r
- *\r
- * <p>For an enumerated attribute that is not a notation, the\r
- * parser will report the type as "NMTOKEN".</p>\r
- *\r
- * @param index The attribute index (zero-based).\r
- * @return The attribute's type as a string, or null if the\r
- * index is out of range.\r
- * @see #getLength\r
- */\r
- public abstract String getType (int index);\r
-\r
-\r
- /**\r
- * Look up an attribute's value by index.\r
- *\r
- * <p>If the attribute value is a list of tokens (IDREFS,\r
- * ENTITIES, or NMTOKENS), the tokens will be concatenated\r
- * into a single string with each token separated by a\r
- * single space.</p>\r
- *\r
- * @param index The attribute index (zero-based).\r
- * @return The attribute's value as a string, or null if the\r
- * index is out of range.\r
- * @see #getLength\r
- */\r
- public abstract String getValue (int index);\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Name-based query.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Look up the index of an attribute by Namespace name.\r
- *\r
- * @param uri The Namespace URI, or the empty string if\r
- * the name has no Namespace URI.\r
- * @param localName The attribute's local name.\r
- * @return The index of the attribute, or -1 if it does not\r
- * appear in the list.\r
- */\r
- public int getIndex (String uri, String localPart);\r
-\r
-\r
- /**\r
- * Look up the index of an attribute by XML 1.0 qualified name.\r
- *\r
- * @param qName The qualified (prefixed) name.\r
- * @return The index of the attribute, or -1 if it does not\r
- * appear in the list.\r
- */\r
- public int getIndex (String qName);\r
-\r
-\r
- /**\r
- * Look up an attribute's type by Namespace name.\r
- *\r
- * <p>See {@link #getType(int) getType(int)} for a description\r
- * of the possible types.</p>\r
- *\r
- * @param uri The Namespace URI, or the empty String if the\r
- * name has no Namespace URI.\r
- * @param localName The local name of the attribute.\r
- * @return The attribute type as a string, or null if the\r
- * attribute is not in the list or if Namespace\r
- * processing is not being performed.\r
- */\r
- public abstract String getType (String uri, String localName);\r
-\r
-\r
- /**\r
- * Look up an attribute's type by XML 1.0 qualified name.\r
- *\r
- * <p>See {@link #getType(int) getType(int)} for a description\r
- * of the possible types.</p>\r
- *\r
- * @param qName The XML 1.0 qualified name.\r
- * @return The attribute type as a string, or null if the\r
- * attribute is not in the list or if qualified names\r
- * are not available.\r
- */\r
- public abstract String getType (String qName);\r
-\r
-\r
- /**\r
- * Look up an attribute's value by Namespace name.\r
- *\r
- * <p>See {@link #getValue(int) getValue(int)} for a description\r
- * of the possible values.</p>\r
- *\r
- * @param uri The Namespace URI, or the empty String if the\r
- * name has no Namespace URI.\r
- * @param localName The local name of the attribute.\r
- * @return The attribute value as a string, or null if the\r
- * attribute is not in the list.\r
- */\r
- public abstract String getValue (String uri, String localName);\r
-\r
-\r
- /**\r
- * Look up an attribute's value by XML 1.0 qualified name.\r
- *\r
- * <p>See {@link #getValue(int) getValue(int)} for a description\r
- * of the possible values.</p>\r
- *\r
- * @param qName The XML 1.0 qualified name.\r
- * @return The attribute value as a string, or null if the\r
- * attribute is not in the list or if qualified names\r
- * are not available.\r
- */\r
- public abstract String getValue (String qName);\r
-\r
-}\r
-\r
-// end of Attributes.java\r
+// Attributes.java - attribute list with Namespace support
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: Attributes.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+
+package org.xml.sax;
+
+
+/**
+ * Interface for a list of XML attributes.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This interface allows access to a list of attributes in
+ * three different ways:</p>
+ *
+ * <ol>
+ * <li>by attribute index;</li>
+ * <li>by Namespace-qualified name; or</li>
+ * <li>by qualified (prefixed) name.</li>
+ * </ol>
+ *
+ * <p>The list will not contain attributes that were declared
+ * #IMPLIED but not specified in the start tag. It will also not
+ * contain attributes used as Namespace declarations (xmlns*) unless
+ * the <code>http://xml.org/sax/features/namespace-prefixes</code>
+ * feature is set to <var>true</var> (it is <var>false</var> by
+ * default).
+ * Because SAX2 conforms to the "Namespaces in XML" specification,
+ * it does not give namespace declaration attributes a namespace URI.
+ * Some other W3C specifications are in conflict with that, expecting
+ * these declarations to be in a namespace.
+ * Handler code may need to resolve that conflict.
+ * </p>
+ *
+ * <p>If the namespace-prefixes feature (see above) is <var>false</var>,
+ * access by qualified name may not be available; if the
+ * <code>http://xml.org/sax/features/namespaces</code>
+ * feature is <var>false</var>, access by Namespace-qualified names
+ * may not be available.</p>
+ *
+ * <p>This interface replaces the now-deprecated SAX1 {@link
+ * org.xml.sax.AttributeList AttributeList} interface, which does not
+ * contain Namespace support. In addition to Namespace support, it
+ * adds the <var>getIndex</var> methods (below).</p>
+ *
+ * <p>The order of attributes in the list is unspecified, and will
+ * vary from implementation to implementation.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.helpers.AttributesImpl
+ * @see org.xml.sax.ext.DeclHandler#attributeDecl
+ */
+public interface Attributes
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Indexed access.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the number of attributes in the list.
+ *
+ * <p>Once you know the number of attributes, you can iterate
+ * through the list.</p>
+ *
+ * @return The number of attributes in the list.
+ * @see #getURI(int)
+ * @see #getLocalName(int)
+ * @see #getQName(int)
+ * @see #getType(int)
+ * @see #getValue(int)
+ */
+ public abstract int getLength ();
+
+
+ /**
+ * Look up an attribute's Namespace URI by index.
+ *
+ * @param index The attribute index (zero-based).
+ * @return The Namespace URI, or the empty string if none
+ * is available, or null if the index is out of
+ * range.
+ * @see #getLength
+ */
+ public abstract String getURI (int index);
+
+
+ /**
+ * Look up an attribute's local name by index.
+ *
+ * @param index The attribute index (zero-based).
+ * @return The local name, or the empty string if Namespace
+ * processing is not being performed, or null
+ * if the index is out of range.
+ * @see #getLength
+ */
+ public abstract String getLocalName (int index);
+
+
+ /**
+ * Look up an attribute's XML 1.0 qualified name by index.
+ *
+ * @param index The attribute index (zero-based).
+ * @return The XML 1.0 qualified name, or the empty string
+ * if none is available, or null if the index
+ * is out of range.
+ * @see #getLength
+ */
+ public abstract String getQName (int index);
+
+
+ /**
+ * Look up an attribute's type by index.
+ *
+ * <p>The attribute type is one of the strings "CDATA", "ID",
+ * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
+ * or "NOTATION" (always in upper case).</p>
+ *
+ * <p>If the parser has not read a declaration for the attribute,
+ * or if the parser does not report attribute types, then it must
+ * return the value "CDATA" as stated in the XML 1.0 Recommentation
+ * (clause 3.3.3, "Attribute-Value Normalization").</p>
+ *
+ * <p>For an enumerated attribute that is not a notation, the
+ * parser will report the type as "NMTOKEN".</p>
+ *
+ * @param index The attribute index (zero-based).
+ * @return The attribute's type as a string, or null if the
+ * index is out of range.
+ * @see #getLength
+ */
+ public abstract String getType (int index);
+
+
+ /**
+ * Look up an attribute's value by index.
+ *
+ * <p>If the attribute value is a list of tokens (IDREFS,
+ * ENTITIES, or NMTOKENS), the tokens will be concatenated
+ * into a single string with each token separated by a
+ * single space.</p>
+ *
+ * @param index The attribute index (zero-based).
+ * @return The attribute's value as a string, or null if the
+ * index is out of range.
+ * @see #getLength
+ */
+ public abstract String getValue (int index);
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Name-based query.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Look up the index of an attribute by Namespace name.
+ *
+ * @param uri The Namespace URI, or the empty string if
+ * the name has no Namespace URI.
+ * @param localName The attribute's local name.
+ * @return The index of the attribute, or -1 if it does not
+ * appear in the list.
+ */
+ public int getIndex (String uri, String localName);
+
+
+ /**
+ * Look up the index of an attribute by XML 1.0 qualified name.
+ *
+ * @param qName The qualified (prefixed) name.
+ * @return The index of the attribute, or -1 if it does not
+ * appear in the list.
+ */
+ public int getIndex (String qName);
+
+
+ /**
+ * Look up an attribute's type by Namespace name.
+ *
+ * <p>See {@link #getType(int) getType(int)} for a description
+ * of the possible types.</p>
+ *
+ * @param uri The Namespace URI, or the empty String if the
+ * name has no Namespace URI.
+ * @param localName The local name of the attribute.
+ * @return The attribute type as a string, or null if the
+ * attribute is not in the list or if Namespace
+ * processing is not being performed.
+ */
+ public abstract String getType (String uri, String localName);
+
+
+ /**
+ * Look up an attribute's type by XML 1.0 qualified name.
+ *
+ * <p>See {@link #getType(int) getType(int)} for a description
+ * of the possible types.</p>
+ *
+ * @param qName The XML 1.0 qualified name.
+ * @return The attribute type as a string, or null if the
+ * attribute is not in the list or if qualified names
+ * are not available.
+ */
+ public abstract String getType (String qName);
+
+
+ /**
+ * Look up an attribute's value by Namespace name.
+ *
+ * <p>See {@link #getValue(int) getValue(int)} for a description
+ * of the possible values.</p>
+ *
+ * @param uri The Namespace URI, or the empty String if the
+ * name has no Namespace URI.
+ * @param localName The local name of the attribute.
+ * @return The attribute value as a string, or null if the
+ * attribute is not in the list.
+ */
+ public abstract String getValue (String uri, String localName);
+
+
+ /**
+ * Look up an attribute's value by XML 1.0 qualified name.
+ *
+ * <p>See {@link #getValue(int) getValue(int)} for a description
+ * of the possible values.</p>
+ *
+ * @param qName The XML 1.0 qualified name.
+ * @return The attribute value as a string, or null if the
+ * attribute is not in the list or if qualified names
+ * are not available.
+ */
+ public abstract String getValue (String qName);
+
+}
+
+// end of Attributes.java
-// ContentHandler.java - handle main document content.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: ContentHandler.java,v 1.1 2000/10/02 02:43:16 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Receive notification of the logical content of a document.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This is the main interface that most SAX applications\r
- * implement: if the application needs to be informed of basic parsing \r
- * events, it implements this interface and registers an instance with \r
- * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler \r
- * setContentHandler} method. The parser uses the instance to report \r
- * basic document-related events like the start and end of elements \r
- * and character data.</p>\r
- *\r
- * <p>The order of events in this interface is very important, and\r
- * mirrors the order of information in the document itself. For\r
- * example, all of an element's content (character data, processing\r
- * instructions, and/or subelements) will appear, in order, between\r
- * the startElement event and the corresponding endElement event.</p>\r
- *\r
- * <p>This interface is similar to the now-deprecated SAX 1.0\r
- * DocumentHandler interface, but it adds support for Namespaces\r
- * and for reporting skipped entities (in non-validating XML\r
- * processors).</p>\r
- *\r
- * <p>Implementors should note that there is also a Java class\r
- * {@link java.net.ContentHandler ContentHandler} in the java.net\r
- * package; that means that it's probably a bad idea to do</p>\r
- *\r
- * <blockquote>\r
- * import java.net.*;\r
- * import org.xml.sax.*;\r
- * </blockquote>\r
- *\r
- * <p>In fact, "import ...*" is usually a sign of sloppy programming\r
- * anyway, so the user should consider this a feature rather than a\r
- * bug.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.XMLReader\r
- * @see org.xml.sax.DTDHandler\r
- * @see org.xml.sax.ErrorHandler\r
- */\r
-public interface ContentHandler\r
-{\r
-\r
- /**\r
- * Receive an object for locating the origin of SAX document events.\r
- *\r
- * <p>SAX parsers are strongly encouraged (though not absolutely\r
- * required) to supply a locator: if it does so, it must supply\r
- * the locator to the application by invoking this method before\r
- * invoking any of the other methods in the ContentHandler\r
- * interface.</p>\r
- *\r
- * <p>The locator allows the application to determine the end\r
- * position of any document-related event, even if the parser is\r
- * not reporting an error. Typically, the application will\r
- * use this information for reporting its own errors (such as\r
- * character content that does not match an application's\r
- * business rules). The information returned by the locator\r
- * is probably not sufficient for use with a search engine.</p>\r
- *\r
- * <p>Note that the locator will return correct information only\r
- * during the invocation of the events in this interface. The\r
- * application should not attempt to use it at any other time.</p>\r
- *\r
- * @param locator An object that can return the location of\r
- * any SAX document event.\r
- * @see org.xml.sax.Locator\r
- */\r
- public void setDocumentLocator (Locator locator);\r
-\r
-\r
- /**\r
- * Receive notification of the beginning of a document.\r
- *\r
- * <p>The SAX parser will invoke this method only once, before any\r
- * other methods in this interface or in {@link org.xml.sax.DTDHandler\r
- * DTDHandler} (except for {@link #setDocumentLocator \r
- * setDocumentLocator}).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #endDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of the end of a document.\r
- *\r
- * <p>The SAX parser will invoke this method only once, and it will\r
- * be the last method invoked during the parse. The parser shall\r
- * not invoke this method until it has either abandoned parsing\r
- * (because of an unrecoverable error) or reached the end of\r
- * input.</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #startDocument\r
- */\r
- public void endDocument()\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Begin the scope of a prefix-URI Namespace mapping.\r
- *\r
- * <p>The information from this event is not necessary for\r
- * normal Namespace processing: the SAX XML reader will \r
- * automatically replace prefixes for element and attribute\r
- * names when the <code>http://xml.org/sax/features/namespaces</code>\r
- * feature is <var>true</var> (the default).</p>\r
- *\r
- * <p>There are cases, however, when applications need to\r
- * use prefixes in character data or in attribute values,\r
- * where they cannot safely be expanded automatically; the\r
- * start/endPrefixMapping event supplies the information\r
- * to the application to expand prefixes in those contexts\r
- * itself, if necessary.</p>\r
- *\r
- * <p>Note that start/endPrefixMapping events are not\r
- * guaranteed to be properly nested relative to each-other:\r
- * all startPrefixMapping events will occur before the\r
- * corresponding {@link #startElement startElement} event, \r
- * and all {@link #endPrefixMapping endPrefixMapping}\r
- * events will occur after the corresponding {@link #endElement\r
- * endElement} event, but their order is not otherwise \r
- * guaranteed.</p>\r
- *\r
- * <p>There should never be start/endPrefixMapping events for the\r
- * "xml" prefix, since it is predeclared and immutable.</p>\r
- *\r
- * @param prefix The Namespace prefix being declared.\r
- * @param uri The Namespace URI the prefix is mapped to.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see #endPrefixMapping\r
- * @see #startElement\r
- */\r
- public void startPrefixMapping (String prefix, String uri)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * End the scope of a prefix-URI mapping.\r
- *\r
- * <p>See {@link #startPrefixMapping startPrefixMapping} for \r
- * details. This event will always occur after the corresponding \r
- * {@link #endElement endElement} event, but the order of \r
- * {@link #endPrefixMapping endPrefixMapping} events is not otherwise\r
- * guaranteed.</p>\r
- *\r
- * @param prefix The prefix that was being mapping.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see #startPrefixMapping\r
- * @see #endElement\r
- */\r
- public void endPrefixMapping (String prefix)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of the beginning of an element.\r
- *\r
- * <p>The Parser will invoke this method at the beginning of every\r
- * element in the XML document; there will be a corresponding\r
- * {@link #endElement endElement} event for every startElement event\r
- * (even when the element is empty). All of the element's content will be\r
- * reported, in order, before the corresponding endElement\r
- * event.</p>\r
- *\r
- * <p>This event allows up to three name components for each\r
- * element:</p>\r
- *\r
- * <ol>\r
- * <li>the Namespace URI;</li>\r
- * <li>the local name; and</li>\r
- * <li>the qualified (prefixed) name.</li>\r
- * </ol>\r
- *\r
- * <p>Any or all of these may be provided, depending on the\r
- * values of the <var>http://xml.org/sax/features/namespaces</var>\r
- * and the <var>http://xml.org/sax/features/namespace-prefixes</var>\r
- * properties:</p>\r
- *\r
- * <ul>\r
- * <li>the Namespace URI and local name are required when \r
- * the namespaces property is <var>true</var> (the default), and are\r
- * optional when the namespaces property is <var>false</var> (if one is\r
- * specified, both must be);</li>\r
- * <li>the qualified name is required when the namespace-prefixes property\r
- * is <var>true</var>, and is optional when the namespace-prefixes property\r
- * is <var>false</var> (the default).</li>\r
- * </ul>\r
- *\r
- * <p>Note that the attribute list provided will contain only\r
- * attributes with explicit values (specified or defaulted):\r
- * #IMPLIED attributes will be omitted. The attribute list\r
- * will contain attributes used for Namespace declarations\r
- * (xmlns* attributes) only if the\r
- * <code>http://xml.org/sax/features/namespace-prefixes</code>\r
- * property is true (it is false by default, and support for a \r
- * true value is optional).</p>\r
- *\r
- * @param uri The Namespace URI, or the empty string if the\r
- * element has no Namespace URI or if Namespace\r
- * processing is not being performed.\r
- * @param localName The local name (without prefix), or the\r
- * empty string if Namespace processing is not being\r
- * performed.\r
- * @param qName The qualified name (with prefix), or the\r
- * empty string if qualified names are not available.\r
- * @param atts The attributes attached to the element. If\r
- * there are no attributes, it shall be an empty\r
- * Attributes object.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #endElement\r
- * @see org.xml.sax.Attributes\r
- */\r
- public void startElement (String namespaceURI, String localName,\r
- String qName, Attributes atts)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of the end of an element.\r
- *\r
- * <p>The SAX parser will invoke this method at the end of every\r
- * element in the XML document; there will be a corresponding\r
- * {@link #startElement startElement} event for every endElement \r
- * event (even when the element is empty).</p>\r
- *\r
- * <p>For information on the names, see startElement.</p>\r
- *\r
- * @param uri The Namespace URI, or the empty string if the\r
- * element has no Namespace URI or if Namespace\r
- * processing is not being performed.\r
- * @param localName The local name (without prefix), or the\r
- * empty string if Namespace processing is not being\r
- * performed.\r
- * @param qName The qualified XML 1.0 name (with prefix), or the\r
- * empty string if qualified names are not available.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public void endElement (String namespaceURI, String localName,\r
- String qName)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of character data.\r
- *\r
- * <p>The Parser will call this method to report each chunk of\r
- * character data. SAX parsers may return all contiguous character\r
- * data in a single chunk, or they may split it into several\r
- * chunks; however, all of the characters in any single event\r
- * must come from the same external entity so that the Locator\r
- * provides useful information.</p>\r
- *\r
- * <p>The application must not attempt to read from the array\r
- * outside of the specified range.</p>\r
- *\r
- * <p>Note that some parsers will report whitespace in element\r
- * content using the {@link #ignorableWhitespace ignorableWhitespace}\r
- * method rather than this one (validating parsers <em>must</em> \r
- * do so).</p>\r
- *\r
- * @param ch The characters from the XML document.\r
- * @param start The start position in the array.\r
- * @param length The number of characters to read from the array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #ignorableWhitespace \r
- * @see org.xml.sax.Locator\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of ignorable whitespace in element content.\r
- *\r
- * <p>Validating Parsers must use this method to report each chunk\r
- * of whitespace in element content (see the W3C XML 1.0 recommendation,\r
- * section 2.10): non-validating parsers may also use this method\r
- * if they are capable of parsing and using content models.</p>\r
- *\r
- * <p>SAX parsers may return all contiguous whitespace in a single\r
- * chunk, or they may split it into several chunks; however, all of\r
- * the characters in any single event must come from the same\r
- * external entity, so that the Locator provides useful\r
- * information.</p>\r
- *\r
- * <p>The application must not attempt to read from the array\r
- * outside of the specified range.</p>\r
- *\r
- * @param ch The characters from the XML document.\r
- * @param start The start position in the array.\r
- * @param length The number of characters to read from the array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #characters\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of a processing instruction.\r
- *\r
- * <p>The Parser will invoke this method once for each processing\r
- * instruction found: note that processing instructions may occur\r
- * before or after the main document element.</p>\r
- *\r
- * <p>A SAX parser must never report an XML declaration (XML 1.0,\r
- * section 2.8) or a text declaration (XML 1.0, section 4.3.1)\r
- * using this method.</p>\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The processing instruction data, or null if\r
- * none was supplied. The data does not include any\r
- * whitespace separating it from the target.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Receive notification of a skipped entity.\r
- *\r
- * <p>The Parser will invoke this method once for each entity\r
- * skipped. Non-validating processors may skip entities if they\r
- * have not seen the declarations (because, for example, the\r
- * entity was declared in an external DTD subset). All processors\r
- * may skip external entities, depending on the values of the\r
- * <code>http://xml.org/sax/features/external-general-entities</code>\r
- * and the\r
- * <code>http://xml.org/sax/features/external-parameter-entities</code>\r
- * properties.</p>\r
- *\r
- * @param name The name of the skipped entity. If it is a \r
- * parameter entity, the name will begin with '%', and if\r
- * it is the external DTD subset, it will be the string\r
- * "[dtd]".\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public void skippedEntity (String name)\r
- throws SAXException;\r
-}\r
-\r
-// end of ContentHandler.java\r
+// ContentHandler.java - handle main document content.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: ContentHandler.java,v 1.4.2.9 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+
+/**
+ * Receive notification of the logical content of a document.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This is the main interface that most SAX applications
+ * implement: if the application needs to be informed of basic parsing
+ * events, it implements this interface and registers an instance with
+ * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler
+ * setContentHandler} method. The parser uses the instance to report
+ * basic document-related events like the start and end of elements
+ * and character data.</p>
+ *
+ * <p>The order of events in this interface is very important, and
+ * mirrors the order of information in the document itself. For
+ * example, all of an element's content (character data, processing
+ * instructions, and/or subelements) will appear, in order, between
+ * the startElement event and the corresponding endElement event.</p>
+ *
+ * <p>This interface is similar to the now-deprecated SAX 1.0
+ * DocumentHandler interface, but it adds support for Namespaces
+ * and for reporting skipped entities (in non-validating XML
+ * processors).</p>
+ *
+ * <p>Implementors should note that there is also a Java class
+ * {@link java.net.ContentHandler ContentHandler} in the java.net
+ * package; that means that it's probably a bad idea to do</p>
+ *
+ * <blockquote>
+ * import java.net.*;
+ * import org.xml.sax.*;
+ * </blockquote>
+ *
+ * <p>In fact, "import ...*" is usually a sign of sloppy programming
+ * anyway, so the user should consider this a feature rather than a
+ * bug.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLReader
+ * @see org.xml.sax.DTDHandler
+ * @see org.xml.sax.ErrorHandler
+ */
+public interface ContentHandler
+{
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ *
+ * <p>SAX parsers are strongly encouraged (though not absolutely
+ * required) to supply a locator: if it does so, it must supply
+ * the locator to the application by invoking this method before
+ * invoking any of the other methods in the ContentHandler
+ * interface.</p>
+ *
+ * <p>The locator allows the application to determine the end
+ * position of any document-related event, even if the parser is
+ * not reporting an error. Typically, the application will
+ * use this information for reporting its own errors (such as
+ * character content that does not match an application's
+ * business rules). The information returned by the locator
+ * is probably not sufficient for use with a search engine.</p>
+ *
+ * <p>Note that the locator will return correct information only
+ * during the invocation of the events in this interface. The
+ * application should not attempt to use it at any other time.</p>
+ *
+ * @param locator An object that can return the location of
+ * any SAX document event.
+ * @see org.xml.sax.Locator
+ */
+ public void setDocumentLocator (Locator locator);
+
+
+ /**
+ * Receive notification of the beginning of a document.
+ *
+ * <p>The SAX parser will invoke this method only once, before any
+ * other event callbacks (except for {@link #setDocumentLocator
+ * setDocumentLocator}).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #endDocument
+ */
+ public void startDocument ()
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the end of a document.
+ *
+ * <p>The SAX parser will invoke this method only once, and it will
+ * be the last method invoked during the parse. The parser shall
+ * not invoke this method until it has either abandoned parsing
+ * (because of an unrecoverable error) or reached the end of
+ * input.</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #startDocument
+ */
+ public void endDocument()
+ throws SAXException;
+
+
+ /**
+ * Begin the scope of a prefix-URI Namespace mapping.
+ *
+ * <p>The information from this event is not necessary for
+ * normal Namespace processing: the SAX XML reader will
+ * automatically replace prefixes for element and attribute
+ * names when the <code>http://xml.org/sax/features/namespaces</code>
+ * feature is <var>true</var> (the default).</p>
+ *
+ * <p>There are cases, however, when applications need to
+ * use prefixes in character data or in attribute values,
+ * where they cannot safely be expanded automatically; the
+ * start/endPrefixMapping event supplies the information
+ * to the application to expand prefixes in those contexts
+ * itself, if necessary.</p>
+ *
+ * <p>Note that start/endPrefixMapping events are not
+ * guaranteed to be properly nested relative to each other:
+ * all startPrefixMapping events will occur immediately before the
+ * corresponding {@link #startElement startElement} event,
+ * and all {@link #endPrefixMapping endPrefixMapping}
+ * events will occur immediately after the corresponding
+ * {@link #endElement endElement} event,
+ * but their order is not otherwise
+ * guaranteed.</p>
+ *
+ * <p>There should never be start/endPrefixMapping events for the
+ * "xml" prefix, since it is predeclared and immutable.</p>
+ *
+ * @param prefix The Namespace prefix being declared.
+ * An empty string is used for the default element namespace,
+ * which has no prefix.
+ * @param uri The Namespace URI the prefix is mapped to.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ * @see #endPrefixMapping
+ * @see #startElement
+ */
+ public void startPrefixMapping (String prefix, String uri)
+ throws SAXException;
+
+
+ /**
+ * End the scope of a prefix-URI mapping.
+ *
+ * <p>See {@link #startPrefixMapping startPrefixMapping} for
+ * details. These events will always occur immediately after the
+ * corresponding {@link #endElement endElement} event, but the order of
+ * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
+ * guaranteed.</p>
+ *
+ * @param prefix The prefix that was being mapping.
+ * This is the empty string when a default mapping scope ends.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ * @see #startPrefixMapping
+ * @see #endElement
+ */
+ public void endPrefixMapping (String prefix)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the beginning of an element.
+ *
+ * <p>The Parser will invoke this method at the beginning of every
+ * element in the XML document; there will be a corresponding
+ * {@link #endElement endElement} event for every startElement event
+ * (even when the element is empty). All of the element's content will be
+ * reported, in order, before the corresponding endElement
+ * event.</p>
+ *
+ * <p>This event allows up to three name components for each
+ * element:</p>
+ *
+ * <ol>
+ * <li>the Namespace URI;</li>
+ * <li>the local name; and</li>
+ * <li>the qualified (prefixed) name.</li>
+ * </ol>
+ *
+ * <p>Any or all of these may be provided, depending on the
+ * values of the <var>http://xml.org/sax/features/namespaces</var>
+ * and the <var>http://xml.org/sax/features/namespace-prefixes</var>
+ * properties:</p>
+ *
+ * <ul>
+ * <li>the Namespace URI and local name are required when
+ * the namespaces property is <var>true</var> (the default), and are
+ * optional when the namespaces property is <var>false</var> (if one is
+ * specified, both must be);</li>
+ * <li>the qualified name is required when the namespace-prefixes property
+ * is <var>true</var>, and is optional when the namespace-prefixes property
+ * is <var>false</var> (the default).</li>
+ * </ul>
+ *
+ * <p>Note that the attribute list provided will contain only
+ * attributes with explicit values (specified or defaulted):
+ * #IMPLIED attributes will be omitted. The attribute list
+ * will contain attributes used for Namespace declarations
+ * (xmlns* attributes) only if the
+ * <code>http://xml.org/sax/features/namespace-prefixes</code>
+ * property is true (it is false by default, and support for a
+ * true value is optional).</p>
+ *
+ * <p>Like {@link #characters characters()}, attribute values may have
+ * characters that need more than one <code>char</code> value. </p>
+ *
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
+ * @param atts The attributes attached to the element. If
+ * there are no attributes, it shall be an empty
+ * Attributes object.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #endElement
+ * @see org.xml.sax.Attributes
+ */
+ public void startElement (String uri, String localName,
+ String qName, Attributes atts)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the end of an element.
+ *
+ * <p>The SAX parser will invoke this method at the end of every
+ * element in the XML document; there will be a corresponding
+ * {@link #startElement startElement} event for every endElement
+ * event (even when the element is empty).</p>
+ *
+ * <p>For information on the names, see startElement.</p>
+ *
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified XML 1.0 name (with prefix), or the
+ * empty string if qualified names are not available.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public void endElement (String uri, String localName,
+ String qName)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of character data.
+ *
+ * <p>The Parser will call this method to report each chunk of
+ * character data. SAX parsers may return all contiguous character
+ * data in a single chunk, or they may split it into several
+ * chunks; however, all of the characters in any single event
+ * must come from the same external entity so that the Locator
+ * provides useful information.</p>
+ *
+ * <p>The application must not attempt to read from the array
+ * outside of the specified range.</p>
+ *
+ * <p>Individual characters may consist of more than one Java
+ * <code>char</code> value. There are two important cases where this
+ * happens, because characters can't be represented in just sixteen bits.
+ * In one case, characters are represented in a <em>Surrogate Pair</em>,
+ * using two special Unicode values. Such characters are in the so-called
+ * "Astral Planes", with a code point above U+FFFF. A second case involves
+ * composite characters, such as a base character combining with one or
+ * more accent characters. </p>
+ *
+ * <p> Your code should not assume that algorithms using
+ * <code>char</code>-at-a-time idioms will be working in character
+ * units; in some cases they will split characters. This is relevant
+ * wherever XML permits arbitrary characters, such as attribute values,
+ * processing instruction data, and comments as well as in data reported
+ * from this method. It's also generally relevant whenever Java code
+ * manipulates internationalized text; the issue isn't unique to XML.</p>
+ *
+ * <p>Note that some parsers will report whitespace in element
+ * content using the {@link #ignorableWhitespace ignorableWhitespace}
+ * method rather than this one (validating parsers <em>must</em>
+ * do so).</p>
+ *
+ * @param ch The characters from the XML document.
+ * @param start The start position in the array.
+ * @param length The number of characters to read from the array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #ignorableWhitespace
+ * @see org.xml.sax.Locator
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ *
+ * <p>Validating Parsers must use this method to report each chunk
+ * of whitespace in element content (see the W3C XML 1.0 recommendation,
+ * section 2.10): non-validating parsers may also use this method
+ * if they are capable of parsing and using content models.</p>
+ *
+ * <p>SAX parsers may return all contiguous whitespace in a single
+ * chunk, or they may split it into several chunks; however, all of
+ * the characters in any single event must come from the same
+ * external entity, so that the Locator provides useful
+ * information.</p>
+ *
+ * <p>The application must not attempt to read from the array
+ * outside of the specified range.</p>
+ *
+ * @param ch The characters from the XML document.
+ * @param start The start position in the array.
+ * @param length The number of characters to read from the array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #characters
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of a processing instruction.
+ *
+ * <p>The Parser will invoke this method once for each processing
+ * instruction found: note that processing instructions may occur
+ * before or after the main document element.</p>
+ *
+ * <p>A SAX parser must never report an XML declaration (XML 1.0,
+ * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
+ * using this method.</p>
+ *
+ * <p>Like {@link #characters characters()}, processing instruction
+ * data may have characters that need more than one <code>char</code>
+ * value. </p>
+ *
+ * @param target The processing instruction target.
+ * @param data The processing instruction data, or null if
+ * none was supplied. The data does not include any
+ * whitespace separating it from the target.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of a skipped entity.
+ * This is not called for entity references within markup constructs
+ * such as element start tags or markup declarations. (The XML
+ * recommendation requires reporting skipped external entities.
+ * SAX also reports internal entity expansion/non-expansion, except
+ * within markup constructs.)
+ *
+ * <p>The Parser will invoke this method each time the entity is
+ * skipped. Non-validating processors may skip entities if they
+ * have not seen the declarations (because, for example, the
+ * entity was declared in an external DTD subset). All processors
+ * may skip external entities, depending on the values of the
+ * <code>http://xml.org/sax/features/external-general-entities</code>
+ * and the
+ * <code>http://xml.org/sax/features/external-parameter-entities</code>
+ * properties.</p>
+ *
+ * @param name The name of the skipped entity. If it is a
+ * parameter entity, the name will begin with '%', and if
+ * it is the external DTD subset, it will be the string
+ * "[dtd]".
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public void skippedEntity (String name)
+ throws SAXException;
+}
+
+// end of ContentHandler.java
-// SAX DTD handler.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: DTDHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Receive notification of basic DTD-related events.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>If a SAX application needs information about notations and\r
- * unparsed entities, then the application implements this \r
- * interface and registers an instance with the SAX parser using \r
- * the parser's setDTDHandler method. The parser uses the \r
- * instance to report notation and unparsed entity declarations to \r
- * the application.</p>\r
- *\r
- * <p>Note that this interface includes only those DTD events that\r
- * the XML recommendation <em>requires</em> processors to report:\r
- * notation and unparsed entity declarations.</p>\r
- *\r
- * <p>The SAX parser may report these events in any order, regardless\r
- * of the order in which the notations and unparsed entities were\r
- * declared; however, all DTD events must be reported after the\r
- * document handler's startDocument event, and before the first\r
- * startElement event.</p>\r
- *\r
- * <p>It is up to the application to store the information for \r
- * future use (perhaps in a hash table or object tree).\r
- * If the application encounters attributes of type "NOTATION",\r
- * "ENTITY", or "ENTITIES", it can use the information that it\r
- * obtained through this interface to find the entity and/or\r
- * notation corresponding with the attribute value.</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#setDTDHandler\r
- * @see org.xml.sax.HandlerBase \r
- */\r
-public interface DTDHandler {\r
- \r
- \r
- /**\r
- * Receive notification of a notation declaration event.\r
- *\r
- * <p>It is up to the application to record the notation for later\r
- * reference, if necessary.</p>\r
- *\r
- * <p>At least one of publicId and systemId must be non-null.\r
- * If a system identifier is present, and it is a URL, the SAX\r
- * parser must resolve it fully before passing it to the\r
- * application through this event.</p>\r
- *\r
- * <p>There is no guarantee that the notation declaration will be\r
- * reported before any unparsed entities that use it.</p>\r
- *\r
- * @param name The notation name.\r
- * @param publicId The notation's public identifier, or null if\r
- * none was given.\r
- * @param systemId The notation's system identifier, or null if\r
- * none was given.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #unparsedEntityDecl\r
- * @see org.xml.sax.AttributeList\r
- */\r
- public abstract void notationDecl (String name,\r
- String publicId,\r
- String systemId)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of an unparsed entity declaration event.\r
- *\r
- * <p>Note that the notation name corresponds to a notation\r
- * reported by the {@link #notationDecl notationDecl} event. \r
- * It is up to the application to record the entity for later \r
- * reference, if necessary.</p>\r
- *\r
- * <p>If the system identifier is a URL, the parser must resolve it\r
- * fully before passing it to the application.</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @param name The unparsed entity's name.\r
- * @param publicId The entity's public identifier, or null if none\r
- * was given.\r
- * @param systemId The entity's system identifier.\r
- * @param notation name The name of the associated notation.\r
- * @see #notationDecl\r
- * @see org.xml.sax.AttributeList\r
- */\r
- public abstract void unparsedEntityDecl (String name,\r
- String publicId,\r
- String systemId,\r
- String notationName)\r
- throws SAXException;\r
- \r
-}\r
-\r
-// end of DTDHandler.java\r
+// SAX DTD handler.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: DTDHandler.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Receive notification of basic DTD-related events.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>If a SAX application needs information about notations and
+ * unparsed entities, then the application implements this
+ * interface and registers an instance with the SAX parser using
+ * the parser's setDTDHandler method. The parser uses the
+ * instance to report notation and unparsed entity declarations to
+ * the application.</p>
+ *
+ * <p>Note that this interface includes only those DTD events that
+ * the XML recommendation <em>requires</em> processors to report:
+ * notation and unparsed entity declarations.</p>
+ *
+ * <p>The SAX parser may report these events in any order, regardless
+ * of the order in which the notations and unparsed entities were
+ * declared; however, all DTD events must be reported after the
+ * document handler's startDocument event, and before the first
+ * startElement event.
+ * (If the {@link org.xml.sax.ext.LexicalHandler LexicalHandler} is
+ * used, these events must also be reported before the endDTD event.)
+ * </p>
+ *
+ * <p>It is up to the application to store the information for
+ * future use (perhaps in a hash table or object tree).
+ * If the application encounters attributes of type "NOTATION",
+ * "ENTITY", or "ENTITIES", it can use the information that it
+ * obtained through this interface to find the entity and/or
+ * notation corresponding with the attribute value.</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLReader#setDTDHandler
+ */
+public interface DTDHandler {
+
+
+ /**
+ * Receive notification of a notation declaration event.
+ *
+ * <p>It is up to the application to record the notation for later
+ * reference, if necessary;
+ * notations may appear as attribute values and in unparsed entity
+ * declarations, and are sometime used with processing instruction
+ * target names.</p>
+ *
+ * <p>At least one of publicId and systemId must be non-null.
+ * If a system identifier is present, and it is a URL, the SAX
+ * parser must resolve it fully before passing it to the
+ * application through this event.</p>
+ *
+ * <p>There is no guarantee that the notation declaration will be
+ * reported before any unparsed entities that use it.</p>
+ *
+ * @param name The notation name.
+ * @param publicId The notation's public identifier, or null if
+ * none was given.
+ * @param systemId The notation's system identifier, or null if
+ * none was given.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #unparsedEntityDecl
+ * @see org.xml.sax.Attributes
+ */
+ public abstract void notationDecl (String name,
+ String publicId,
+ String systemId)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of an unparsed entity declaration event.
+ *
+ * <p>Note that the notation name corresponds to a notation
+ * reported by the {@link #notationDecl notationDecl} event.
+ * It is up to the application to record the entity for later
+ * reference, if necessary;
+ * unparsed entities may appear as attribute values.
+ * </p>
+ *
+ * <p>If the system identifier is a URL, the parser must resolve it
+ * fully before passing it to the application.</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @param name The unparsed entity's name.
+ * @param publicId The entity's public identifier, or null if none
+ * was given.
+ * @param systemId The entity's system identifier.
+ * @param notationName The name of the associated notation.
+ * @see #notationDecl
+ * @see org.xml.sax.Attributes
+ */
+ public abstract void unparsedEntityDecl (String name,
+ String publicId,
+ String systemId,
+ String notationName)
+ throws SAXException;
+
+}
+
+// end of DTDHandler.java
-// SAX document handler.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: DocumentHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Receive notification of general document events.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This was the main event-handling interface for SAX1; in\r
- * SAX2, it has been replaced by {@link org.xml.sax.ContentHandler\r
- * ContentHandler}, which provides Namespace support and reporting\r
- * of skipped entities. This interface is included in SAX2 only\r
- * to support legacy SAX1 applications.</p>\r
- *\r
- * <p>The order of events in this interface is very important, and\r
- * mirrors the order of information in the document itself. For\r
- * example, all of an element's content (character data, processing\r
- * instructions, and/or subelements) will appear, in order, between\r
- * the startElement event and the corresponding endElement event.</p>\r
- *\r
- * <p>Application writers who do not want to implement the entire\r
- * interface can derive a class from HandlerBase, which implements\r
- * the default functionality; parser writers can instantiate\r
- * HandlerBase to obtain a default handler. The application can find\r
- * the location of any document event using the Locator interface\r
- * supplied by the Parser through the setDocumentLocator method.</p>\r
- *\r
- * @deprecated This interface has been replaced by the SAX2\r
- * {@link org.xml.sax.ContentHandler ContentHandler}\r
- * interface, which includes Namespace support.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#setDocumentHandler\r
- * @see org.xml.sax.Locator\r
- * @see org.xml.sax.HandlerBase\r
- */\r
-public interface DocumentHandler {\r
- \r
- \r
- /**\r
- * Receive an object for locating the origin of SAX document events.\r
- *\r
- * <p>SAX parsers are strongly encouraged (though not absolutely\r
- * required) to supply a locator: if it does so, it must supply\r
- * the locator to the application by invoking this method before\r
- * invoking any of the other methods in the DocumentHandler\r
- * interface.</p>\r
- *\r
- * <p>The locator allows the application to determine the end\r
- * position of any document-related event, even if the parser is\r
- * not reporting an error. Typically, the application will\r
- * use this information for reporting its own errors (such as\r
- * character content that does not match an application's\r
- * business rules). The information returned by the locator\r
- * is probably not sufficient for use with a search engine.</p>\r
- *\r
- * <p>Note that the locator will return correct information only\r
- * during the invocation of the events in this interface. The\r
- * application should not attempt to use it at any other time.</p>\r
- *\r
- * @param locator An object that can return the location of\r
- * any SAX document event.\r
- * @see org.xml.sax.Locator\r
- */\r
- public abstract void setDocumentLocator (Locator locator);\r
- \r
- \r
- /**\r
- * Receive notification of the beginning of a document.\r
- *\r
- * <p>The SAX parser will invoke this method only once, before any\r
- * other methods in this interface or in DTDHandler (except for\r
- * setDocumentLocator).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public abstract void startDocument ()\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of the end of a document.\r
- *\r
- * <p>The SAX parser will invoke this method only once, and it will\r
- * be the last method invoked during the parse. The parser shall\r
- * not invoke this method until it has either abandoned parsing\r
- * (because of an unrecoverable error) or reached the end of\r
- * input.</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public abstract void endDocument ()\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of the beginning of an element.\r
- *\r
- * <p>The Parser will invoke this method at the beginning of every\r
- * element in the XML document; there will be a corresponding\r
- * endElement() event for every startElement() event (even when the\r
- * element is empty). All of the element's content will be\r
- * reported, in order, before the corresponding endElement()\r
- * event.</p>\r
- *\r
- * <p>If the element name has a namespace prefix, the prefix will\r
- * still be attached. Note that the attribute list provided will\r
- * contain only attributes with explicit values (specified or\r
- * defaulted): #IMPLIED attributes will be omitted.</p>\r
- *\r
- * @param name The element type name.\r
- * @param atts The attributes attached to the element, if any.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #endElement\r
- * @see org.xml.sax.AttributeList \r
- */\r
- public abstract void startElement (String name, AttributeList atts)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of the end of an element.\r
- *\r
- * <p>The SAX parser will invoke this method at the end of every\r
- * element in the XML document; there will be a corresponding\r
- * startElement() event for every endElement() event (even when the\r
- * element is empty).</p>\r
- *\r
- * <p>If the element name has a namespace prefix, the prefix will\r
- * still be attached to the name.</p>\r
- *\r
- * @param name The element type name\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public abstract void endElement (String name)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of character data.\r
- *\r
- * <p>The Parser will call this method to report each chunk of\r
- * character data. SAX parsers may return all contiguous character\r
- * data in a single chunk, or they may split it into several\r
- * chunks; however, all of the characters in any single event\r
- * must come from the same external entity, so that the Locator\r
- * provides useful information.</p>\r
- *\r
- * <p>The application must not attempt to read from the array\r
- * outside of the specified range.</p>\r
- *\r
- * <p>Note that some parsers will report whitespace using the\r
- * ignorableWhitespace() method rather than this one (validating\r
- * parsers must do so).</p>\r
- *\r
- * @param ch The characters from the XML document.\r
- * @param start The start position in the array.\r
- * @param length The number of characters to read from the array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #ignorableWhitespace \r
- * @see org.xml.sax.Locator\r
- */\r
- public abstract void characters (char ch[], int start, int length)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of ignorable whitespace in element content.\r
- *\r
- * <p>Validating Parsers must use this method to report each chunk\r
- * of ignorable whitespace (see the W3C XML 1.0 recommendation,\r
- * section 2.10): non-validating parsers may also use this method\r
- * if they are capable of parsing and using content models.</p>\r
- *\r
- * <p>SAX parsers may return all contiguous whitespace in a single\r
- * chunk, or they may split it into several chunks; however, all of\r
- * the characters in any single event must come from the same\r
- * external entity, so that the Locator provides useful\r
- * information.</p>\r
- *\r
- * <p>The application must not attempt to read from the array\r
- * outside of the specified range.</p>\r
- *\r
- * @param ch The characters from the XML document.\r
- * @param start The start position in the array.\r
- * @param length The number of characters to read from the array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see #characters\r
- */\r
- public abstract void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of a processing instruction.\r
- *\r
- * <p>The Parser will invoke this method once for each processing\r
- * instruction found: note that processing instructions may occur\r
- * before or after the main document element.</p>\r
- *\r
- * <p>A SAX parser should never report an XML declaration (XML 1.0,\r
- * section 2.8) or a text declaration (XML 1.0, section 4.3.1)\r
- * using this method.</p>\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The processing instruction data, or null if\r
- * none was supplied.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- */\r
- public abstract void processingInstruction (String target, String data)\r
- throws SAXException;\r
- \r
-}\r
-\r
-// end of DocumentHandler.java\r
+// SAX document handler.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: DocumentHandler.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Receive notification of general document events.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This was the main event-handling interface for SAX1; in
+ * SAX2, it has been replaced by {@link org.xml.sax.ContentHandler
+ * ContentHandler}, which provides Namespace support and reporting
+ * of skipped entities. This interface is included in SAX2 only
+ * to support legacy SAX1 applications.</p>
+ *
+ * <p>The order of events in this interface is very important, and
+ * mirrors the order of information in the document itself. For
+ * example, all of an element's content (character data, processing
+ * instructions, and/or subelements) will appear, in order, between
+ * the startElement event and the corresponding endElement event.</p>
+ *
+ * <p>Application writers who do not want to implement the entire
+ * interface can derive a class from HandlerBase, which implements
+ * the default functionality; parser writers can instantiate
+ * HandlerBase to obtain a default handler. The application can find
+ * the location of any document event using the Locator interface
+ * supplied by the Parser through the setDocumentLocator method.</p>
+ *
+ * @deprecated This interface has been replaced by the SAX2
+ * {@link org.xml.sax.ContentHandler ContentHandler}
+ * interface, which includes Namespace support.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.Parser#setDocumentHandler
+ * @see org.xml.sax.Locator
+ * @see org.xml.sax.HandlerBase
+ */
+public interface DocumentHandler {
+
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ *
+ * <p>SAX parsers are strongly encouraged (though not absolutely
+ * required) to supply a locator: if it does so, it must supply
+ * the locator to the application by invoking this method before
+ * invoking any of the other methods in the DocumentHandler
+ * interface.</p>
+ *
+ * <p>The locator allows the application to determine the end
+ * position of any document-related event, even if the parser is
+ * not reporting an error. Typically, the application will
+ * use this information for reporting its own errors (such as
+ * character content that does not match an application's
+ * business rules). The information returned by the locator
+ * is probably not sufficient for use with a search engine.</p>
+ *
+ * <p>Note that the locator will return correct information only
+ * during the invocation of the events in this interface. The
+ * application should not attempt to use it at any other time.</p>
+ *
+ * @param locator An object that can return the location of
+ * any SAX document event.
+ * @see org.xml.sax.Locator
+ */
+ public abstract void setDocumentLocator (Locator locator);
+
+
+ /**
+ * Receive notification of the beginning of a document.
+ *
+ * <p>The SAX parser will invoke this method only once, before any
+ * other methods in this interface or in DTDHandler (except for
+ * setDocumentLocator).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public abstract void startDocument ()
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the end of a document.
+ *
+ * <p>The SAX parser will invoke this method only once, and it will
+ * be the last method invoked during the parse. The parser shall
+ * not invoke this method until it has either abandoned parsing
+ * (because of an unrecoverable error) or reached the end of
+ * input.</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public abstract void endDocument ()
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the beginning of an element.
+ *
+ * <p>The Parser will invoke this method at the beginning of every
+ * element in the XML document; there will be a corresponding
+ * endElement() event for every startElement() event (even when the
+ * element is empty). All of the element's content will be
+ * reported, in order, before the corresponding endElement()
+ * event.</p>
+ *
+ * <p>If the element name has a namespace prefix, the prefix will
+ * still be attached. Note that the attribute list provided will
+ * contain only attributes with explicit values (specified or
+ * defaulted): #IMPLIED attributes will be omitted.</p>
+ *
+ * @param name The element type name.
+ * @param atts The attributes attached to the element, if any.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #endElement
+ * @see org.xml.sax.AttributeList
+ */
+ public abstract void startElement (String name, AttributeList atts)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of the end of an element.
+ *
+ * <p>The SAX parser will invoke this method at the end of every
+ * element in the XML document; there will be a corresponding
+ * startElement() event for every endElement() event (even when the
+ * element is empty).</p>
+ *
+ * <p>If the element name has a namespace prefix, the prefix will
+ * still be attached to the name.</p>
+ *
+ * @param name The element type name
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public abstract void endElement (String name)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of character data.
+ *
+ * <p>The Parser will call this method to report each chunk of
+ * character data. SAX parsers may return all contiguous character
+ * data in a single chunk, or they may split it into several
+ * chunks; however, all of the characters in any single event
+ * must come from the same external entity, so that the Locator
+ * provides useful information.</p>
+ *
+ * <p>The application must not attempt to read from the array
+ * outside of the specified range.</p>
+ *
+ * <p>Note that some parsers will report whitespace using the
+ * ignorableWhitespace() method rather than this one (validating
+ * parsers must do so).</p>
+ *
+ * @param ch The characters from the XML document.
+ * @param start The start position in the array.
+ * @param length The number of characters to read from the array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #ignorableWhitespace
+ * @see org.xml.sax.Locator
+ */
+ public abstract void characters (char ch[], int start, int length)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ *
+ * <p>Validating Parsers must use this method to report each chunk
+ * of ignorable whitespace (see the W3C XML 1.0 recommendation,
+ * section 2.10): non-validating parsers may also use this method
+ * if they are capable of parsing and using content models.</p>
+ *
+ * <p>SAX parsers may return all contiguous whitespace in a single
+ * chunk, or they may split it into several chunks; however, all of
+ * the characters in any single event must come from the same
+ * external entity, so that the Locator provides useful
+ * information.</p>
+ *
+ * <p>The application must not attempt to read from the array
+ * outside of the specified range.</p>
+ *
+ * @param ch The characters from the XML document.
+ * @param start The start position in the array.
+ * @param length The number of characters to read from the array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see #characters
+ */
+ public abstract void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of a processing instruction.
+ *
+ * <p>The Parser will invoke this method once for each processing
+ * instruction found: note that processing instructions may occur
+ * before or after the main document element.</p>
+ *
+ * <p>A SAX parser should never report an XML declaration (XML 1.0,
+ * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
+ * using this method.</p>
+ *
+ * @param target The processing instruction target.
+ * @param data The processing instruction data, or null if
+ * none was supplied.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ public abstract void processingInstruction (String target, String data)
+ throws SAXException;
+
+}
+
+// end of DocumentHandler.java
-// SAX entity resolver.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: EntityResolver.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-import java.io.IOException;\r
-\r
-\r
-/**\r
- * Basic interface for resolving entities.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>If a SAX application needs to implement customized handling\r
- * for external entities, it must implement this interface and\r
- * register an instance with the SAX driver using the\r
- * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver}\r
- * method.</p>\r
- *\r
- * <p>The XML reader will then allow the application to intercept any\r
- * external entities (including the external DTD subset and external\r
- * parameter entities, if any) before including them.</p>\r
- *\r
- * <p>Many SAX applications will not need to implement this interface,\r
- * but it will be especially useful for applications that build\r
- * XML documents from databases or other specialised input sources,\r
- * or for applications that use URI types other than URLs.</p>\r
- *\r
- * <p>The following resolver would provide the application\r
- * with a special character stream for the entity with the system\r
- * identifier "http://www.myhost.com/today":</p>\r
- *\r
- * <pre>\r
- * import org.xml.sax.EntityResolver;\r
- * import org.xml.sax.InputSource;\r
- *\r
- * public class MyResolver implements EntityResolver {\r
- * public InputSource resolveEntity (String publicId, String systemId)\r
- * {\r
- * if (systemId.equals("http://www.myhost.com/today")) {\r
- * // return a special input source\r
- * MyReader reader = new MyReader();\r
- * return new InputSource(reader);\r
- * } else {\r
- * // use the default behaviour\r
- * return null;\r
- * }\r
- * }\r
- * }\r
- * </pre>\r
- *\r
- * <p>The application can also use this interface to redirect system\r
- * identifiers to local URIs or to look up replacements in a catalog\r
- * (possibly by using the public identifier).</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#setEntityResolver\r
- * @see org.xml.sax.InputSource\r
- */\r
-public interface EntityResolver {\r
- \r
- \r
- /**\r
- * Allow the application to resolve external entities.\r
- *\r
- * <p>The Parser will call this method before opening any external\r
- * entity except the top-level document entity (including the\r
- * external DTD subset, external entities referenced within the\r
- * DTD, and external entities referenced within the document\r
- * element): the application may request that the parser resolve\r
- * the entity itself, that it use an alternative URI, or that it\r
- * use an entirely different input source.</p>\r
- *\r
- * <p>Application writers can use this method to redirect external\r
- * system identifiers to secure and/or local URIs, to look up\r
- * public identifiers in a catalogue, or to read an entity from a\r
- * database or other input source (including, for example, a dialog\r
- * box).</p>\r
- *\r
- * <p>If the system identifier is a URL, the SAX parser must\r
- * resolve it fully before reporting it to the application.</p>\r
- *\r
- * @param publicId The public identifier of the external entity\r
- * being referenced, or null if none was supplied.\r
- * @param systemId The system identifier of the external entity\r
- * being referenced.\r
- * @return An InputSource object describing the new input source,\r
- * or null to request that the parser open a regular\r
- * URI connection to the system identifier.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException A Java-specific IO exception,\r
- * possibly the result of creating a new InputStream\r
- * or Reader for the InputSource.\r
- * @see org.xml.sax.InputSource\r
- */\r
- public abstract InputSource resolveEntity (String publicId,\r
- String systemId)\r
- throws SAXException, IOException;\r
- \r
-}\r
-\r
-// end of EntityResolver.java\r
+// SAX entity resolver.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: EntityResolver.java,v 1.7.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+import java.io.IOException;
+
+
+/**
+ * Basic interface for resolving entities.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>If a SAX application needs to implement customized handling
+ * for external entities, it must implement this interface and
+ * register an instance with the SAX driver using the
+ * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver}
+ * method.</p>
+ *
+ * <p>The XML reader will then allow the application to intercept any
+ * external entities (including the external DTD subset and external
+ * parameter entities, if any) before including them.</p>
+ *
+ * <p>Many SAX applications will not need to implement this interface,
+ * but it will be especially useful for applications that build
+ * XML documents from databases or other specialised input sources,
+ * or for applications that use URI types other than URLs.</p>
+ *
+ * <p>The following resolver would provide the application
+ * with a special character stream for the entity with the system
+ * identifier "http://www.myhost.com/today":</p>
+ *
+ * <pre>
+ * import org.xml.sax.EntityResolver;
+ * import org.xml.sax.InputSource;
+ *
+ * public class MyResolver implements EntityResolver {
+ * public InputSource resolveEntity (String publicId, String systemId)
+ * {
+ * if (systemId.equals("http://www.myhost.com/today")) {
+ * // return a special input source
+ * MyReader reader = new MyReader();
+ * return new InputSource(reader);
+ * } else {
+ * // use the default behaviour
+ * return null;
+ * }
+ * }
+ * }
+ * </pre>
+ *
+ * <p>The application can also use this interface to redirect system
+ * identifiers to local URIs or to look up replacements in a catalog
+ * (possibly by using the public identifier).</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLReader#setEntityResolver
+ * @see org.xml.sax.InputSource
+ */
+public interface EntityResolver {
+
+
+ /**
+ * Allow the application to resolve external entities.
+ *
+ * <p>The parser will call this method before opening any external
+ * entity except the top-level document entity. Such entities include
+ * the external DTD subset and external parameter entities referenced
+ * within the DTD (in either case, only if the parser reads external
+ * parameter entities), and external general entities referenced
+ * within the document element (if the parser reads external general
+ * entities). The application may request that the parser locate
+ * the entity itself, that it use an alternative URI, or that it
+ * use data provided by the application (as a character or byte
+ * input stream).</p>
+ *
+ * <p>Application writers can use this method to redirect external
+ * system identifiers to secure and/or local URIs, to look up
+ * public identifiers in a catalogue, or to read an entity from a
+ * database or other input source (including, for example, a dialog
+ * box). Neither XML nor SAX specifies a preferred policy for using
+ * public or system IDs to resolve resources. However, SAX specifies
+ * how to interpret any InputSource returned by this method, and that
+ * if none is returned, then the system ID will be dereferenced as
+ * a URL. </p>
+ *
+ * <p>If the system identifier is a URL, the SAX parser must
+ * resolve it fully before reporting it to the application.</p>
+ *
+ * @param publicId The public identifier of the external entity
+ * being referenced, or null if none was supplied.
+ * @param systemId The system identifier of the external entity
+ * being referenced.
+ * @return An InputSource object describing the new input source,
+ * or null to request that the parser open a regular
+ * URI connection to the system identifier.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException A Java-specific IO exception,
+ * possibly the result of creating a new InputStream
+ * or Reader for the InputSource.
+ * @see org.xml.sax.InputSource
+ */
+ public abstract InputSource resolveEntity (String publicId,
+ String systemId)
+ throws SAXException, IOException;
+
+}
+
+// end of EntityResolver.java
-// SAX error handler.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: ErrorHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Basic interface for SAX error handlers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>If a SAX application needs to implement customized error\r
- * handling, it must implement this interface and then register an\r
- * instance with the XML reader using the\r
- * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}\r
- * method. The parser will then report all errors and warnings\r
- * through this interface.</p>\r
- *\r
- * <p><strong>WARNING:</strong> If an application does <em>not</em>\r
- * register an ErrorHandler, XML parsing errors will go unreported\r
- * and bizarre behaviour may result.</p>\r
- *\r
- * <p>For XML processing errors, a SAX driver must use this interface \r
- * instead of throwing an exception: it is up to the application \r
- * to decide whether to throw an exception for different types of \r
- * errors and warnings. Note, however, that there is no requirement that \r
- * the parser continue to provide useful information after a call to \r
- * {@link #fatalError fatalError} (in other words, a SAX driver class \r
- * could catch an exception and report a fatalError).</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#setErrorHandler\r
- * @see org.xml.sax.SAXParseException \r
- */\r
-public interface ErrorHandler {\r
- \r
- \r
- /**\r
- * Receive notification of a warning.\r
- *\r
- * <p>SAX parsers will use this method to report conditions that\r
- * are not errors or fatal errors as defined by the XML 1.0\r
- * recommendation. The default behaviour is to take no action.</p>\r
- *\r
- * <p>The SAX parser must continue to provide normal parsing events\r
- * after invoking this method: it should still be possible for the\r
- * application to process the document through to the end.</p>\r
- *\r
- * <p>Filters may use this method to report other, non-XML warnings\r
- * as well.</p>\r
- *\r
- * @param exception The warning information encapsulated in a\r
- * SAX parse exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.SAXParseException \r
- */\r
- public abstract void warning (SAXParseException exception)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of a recoverable error.\r
- *\r
- * <p>This corresponds to the definition of "error" in section 1.2\r
- * of the W3C XML 1.0 Recommendation. For example, a validating\r
- * parser would use this callback to report the violation of a\r
- * validity constraint. The default behaviour is to take no\r
- * action.</p>\r
- *\r
- * <p>The SAX parser must continue to provide normal parsing events\r
- * after invoking this method: it should still be possible for the\r
- * application to process the document through to the end. If the\r
- * application cannot do so, then the parser should report a fatal\r
- * error even if the XML 1.0 recommendation does not require it to\r
- * do so.</p>\r
- *\r
- * <p>Filters may use this method to report other, non-XML errors\r
- * as well.</p>\r
- *\r
- * @param exception The error information encapsulated in a\r
- * SAX parse exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.SAXParseException \r
- */\r
- public abstract void error (SAXParseException exception)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Receive notification of a non-recoverable error.\r
- *\r
- * <p>This corresponds to the definition of "fatal error" in\r
- * section 1.2 of the W3C XML 1.0 Recommendation. For example, a\r
- * parser would use this callback to report the violation of a\r
- * well-formedness constraint.</p>\r
- *\r
- * <p>The application must assume that the document is unusable\r
- * after the parser has invoked this method, and should continue\r
- * (if at all) only for the sake of collecting addition error\r
- * messages: in fact, SAX parsers are free to stop reporting any\r
- * other events once this method has been invoked.</p>\r
- *\r
- * @param exception The error information encapsulated in a\r
- * SAX parse exception. \r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public abstract void fatalError (SAXParseException exception)\r
- throws SAXException;\r
- \r
-}\r
-\r
-// end of ErrorHandler.java\r
+// SAX error handler.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: ErrorHandler.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+
+/**
+ * Basic interface for SAX error handlers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>If a SAX application needs to implement customized error
+ * handling, it must implement this interface and then register an
+ * instance with the XML reader using the
+ * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}
+ * method. The parser will then report all errors and warnings
+ * through this interface.</p>
+ *
+ * <p><strong>WARNING:</strong> If an application does <em>not</em>
+ * register an ErrorHandler, XML parsing errors will go unreported
+ * and bizarre behaviour may result.</p>
+ *
+ * <p>For XML processing errors, a SAX driver must use this interface
+ * instead of throwing an exception: it is up to the application
+ * to decide whether to throw an exception for different types of
+ * errors and warnings. Note, however, that there is no requirement that
+ * the parser continue to provide useful information after a call to
+ * {@link #fatalError fatalError} (in other words, a SAX driver class
+ * could catch an exception and report a fatalError).</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLReader#setErrorHandler
+ * @see org.xml.sax.SAXParseException
+ */
+public interface ErrorHandler {
+
+
+ /**
+ * Receive notification of a warning.
+ *
+ * <p>SAX parsers will use this method to report conditions that
+ * are not errors or fatal errors as defined by the XML 1.0
+ * recommendation. The default behaviour is to take no action.</p>
+ *
+ * <p>The SAX parser must continue to provide normal parsing events
+ * after invoking this method: it should still be possible for the
+ * application to process the document through to the end.</p>
+ *
+ * <p>Filters may use this method to report other, non-XML warnings
+ * as well.</p>
+ *
+ * @param exception The warning information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public abstract void warning (SAXParseException exception)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of a recoverable error.
+ *
+ * <p>This corresponds to the definition of "error" in section 1.2
+ * of the W3C XML 1.0 Recommendation. For example, a validating
+ * parser would use this callback to report the violation of a
+ * validity constraint. The default behaviour is to take no
+ * action.</p>
+ *
+ * <p>The SAX parser must continue to provide normal parsing events
+ * after invoking this method: it should still be possible for the
+ * application to process the document through to the end. If the
+ * application cannot do so, then the parser should report a fatal
+ * error even if the XML 1.0 recommendation does not require it to
+ * do so.</p>
+ *
+ * <p>Filters may use this method to report other, non-XML errors
+ * as well.</p>
+ *
+ * @param exception The error information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public abstract void error (SAXParseException exception)
+ throws SAXException;
+
+
+ /**
+ * Receive notification of a non-recoverable error.
+ *
+ * <p>This corresponds to the definition of "fatal error" in
+ * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
+ * parser would use this callback to report the violation of a
+ * well-formedness constraint.</p>
+ *
+ * <p>The application must assume that the document is unusable
+ * after the parser has invoked this method, and should continue
+ * (if at all) only for the sake of collecting addition error
+ * messages: in fact, SAX parsers are free to stop reporting any
+ * other events once this method has been invoked.</p>
+ *
+ * @param exception The error information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public abstract void fatalError (SAXParseException exception)
+ throws SAXException;
+
+}
+
+// end of ErrorHandler.java
-// SAX default handler base class.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: HandlerBase.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Default base class for handlers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class implements the default behaviour for four SAX1\r
- * interfaces: EntityResolver, DTDHandler, DocumentHandler,\r
- * and ErrorHandler. It is now obsolete, but is included in SAX2 to\r
- * support legacy SAX1 applications. SAX2 applications should use\r
- * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}\r
- * class instead.</p>\r
- *\r
- * <p>Application writers can extend this class when they need to\r
- * implement only part of an interface; parser writers can\r
- * instantiate this class to provide default handlers when the\r
- * application has not supplied its own.</p>\r
- *\r
- * <p>Note that the use of this class is optional.</p>\r
- *\r
- * @deprecated This class works with the deprecated\r
- * {@link org.xml.sax.DocumentHandler DocumentHandler}\r
- * interface. It has been replaced by the SAX2\r
- * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}\r
- * class.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.EntityResolver\r
- * @see org.xml.sax.DTDHandler\r
- * @see org.xml.sax.DocumentHandler\r
- * @see org.xml.sax.ErrorHandler\r
- */\r
-public class HandlerBase\r
- implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler\r
-{\r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of the EntityResolver interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- /**\r
- * Resolve an external entity.\r
- *\r
- * <p>Always return null, so that the parser will use the system\r
- * identifier provided in the XML document. This method implements\r
- * the SAX default behaviour: application writers can override it\r
- * in a subclass to do special translations such as catalog lookups\r
- * or URI redirection.</p>\r
- *\r
- * @param publicId The public identifier, or null if none is\r
- * available.\r
- * @param systemId The system identifier provided in the XML \r
- * document.\r
- * @return The new input source, or null to require the\r
- * default behaviour.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.EntityResolver#resolveEntity\r
- */\r
- public InputSource resolveEntity (String publicId, String systemId)\r
- throws SAXException\r
- {\r
- return null;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of DTDHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive notification of a notation declaration.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass if they wish to keep track of the notations\r
- * declared in a document.</p>\r
- *\r
- * @param name The notation name.\r
- * @param publicId The notation public identifier, or null if not\r
- * available.\r
- * @param systemId The notation system identifier.\r
- * @see org.xml.sax.DTDHandler#notationDecl\r
- */\r
- public void notationDecl (String name, String publicId, String systemId)\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of an unparsed entity declaration.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to keep track of the unparsed entities\r
- * declared in a document.</p>\r
- *\r
- * @param name The entity name.\r
- * @param publicId The entity public identifier, or null if not\r
- * available.\r
- * @param systemId The entity system identifier.\r
- * @param notationName The name of the associated notation.\r
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl\r
- */\r
- public void unparsedEntityDecl (String name, String publicId,\r
- String systemId, String notationName)\r
- {\r
- // no op\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of DocumentHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive a Locator object for document events.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass if they wish to store the locator for use\r
- * with other document events.</p>\r
- *\r
- * @param locator A locator for all SAX document events.\r
- * @see org.xml.sax.DocumentHandler#setDocumentLocator\r
- * @see org.xml.sax.Locator\r
- */\r
- public void setDocumentLocator (Locator locator)\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the beginning of the document.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the beginning\r
- * of a document (such as allocating the root node of a tree or\r
- * creating an output file).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#startDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the end of the document.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the beginning\r
- * of a document (such as finalising a tree or closing an output\r
- * file).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#endDocument\r
- */\r
- public void endDocument ()\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the start of an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the start of\r
- * each element (such as allocating a new tree node or writing\r
- * output to a file).</p>\r
- *\r
- * @param name The element type name.\r
- * @param attributes The specified or defaulted attributes.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#startElement\r
- */\r
- public void startElement (String name, AttributeList attributes)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the end of an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the end of\r
- * each element (such as finalising a tree node or writing\r
- * output to a file).</p>\r
- *\r
- * @param name The element type name.\r
- * @param attributes The specified or defaulted attributes.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#endElement\r
- */\r
- public void endElement (String name)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of character data inside an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method to take specific actions for each chunk of character data\r
- * (such as adding the data to a node or buffer, or printing it to\r
- * a file).</p>\r
- *\r
- * @param ch The characters.\r
- * @param start The start position in the character array.\r
- * @param length The number of characters to use from the\r
- * character array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#characters\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of ignorable whitespace in element content.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method to take specific actions for each chunk of ignorable\r
- * whitespace (such as adding data to a node or buffer, or printing\r
- * it to a file).</p>\r
- *\r
- * @param ch The whitespace characters.\r
- * @param start The start position in the character array.\r
- * @param length The number of characters to use from the\r
- * character array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#ignorableWhitespace\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of a processing instruction.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions for each\r
- * processing instruction, such as setting status variables or\r
- * invoking other methods.</p>\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The processing instruction data, or null if\r
- * none is supplied.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DocumentHandler#processingInstruction\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of the ErrorHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive notification of a parser warning.\r
- *\r
- * <p>The default implementation does nothing. Application writers\r
- * may override this method in a subclass to take specific actions\r
- * for each warning, such as inserting the message in a log file or\r
- * printing it to the console.</p>\r
- *\r
- * @param e The warning information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#warning\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void warning (SAXParseException e)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of a recoverable parser error.\r
- *\r
- * <p>The default implementation does nothing. Application writers\r
- * may override this method in a subclass to take specific actions\r
- * for each error, such as inserting the message in a log file or\r
- * printing it to the console.</p>\r
- *\r
- * @param e The warning information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#warning\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void error (SAXParseException e)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Report a fatal XML parsing error.\r
- *\r
- * <p>The default implementation throws a SAXParseException.\r
- * Application writers may override this method in a subclass if\r
- * they need to take specific actions for each fatal error (such as\r
- * collecting all of the errors into a single report): in any case,\r
- * the application must stop all regular processing when this\r
- * method is invoked, since the document is no longer reliable, and\r
- * the parser may no longer report parsing events.</p>\r
- *\r
- * @param e The error information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#fatalError\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void fatalError (SAXParseException e)\r
- throws SAXException\r
- {\r
- throw e;\r
- }\r
- \r
-}\r
-\r
-// end of HandlerBase.java\r
+// SAX default handler base class.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: HandlerBase.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Default base class for handlers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class implements the default behaviour for four SAX1
+ * interfaces: EntityResolver, DTDHandler, DocumentHandler,
+ * and ErrorHandler. It is now obsolete, but is included in SAX2 to
+ * support legacy SAX1 applications. SAX2 applications should use
+ * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
+ * class instead.</p>
+ *
+ * <p>Application writers can extend this class when they need to
+ * implement only part of an interface; parser writers can
+ * instantiate this class to provide default handlers when the
+ * application has not supplied its own.</p>
+ *
+ * <p>Note that the use of this class is optional.</p>
+ *
+ * @deprecated This class works with the deprecated
+ * {@link org.xml.sax.DocumentHandler DocumentHandler}
+ * interface. It has been replaced by the SAX2
+ * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
+ * class.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.EntityResolver
+ * @see org.xml.sax.DTDHandler
+ * @see org.xml.sax.DocumentHandler
+ * @see org.xml.sax.ErrorHandler
+ */
+public class HandlerBase
+ implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of the EntityResolver interface.
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Resolve an external entity.
+ *
+ * <p>Always return null, so that the parser will use the system
+ * identifier provided in the XML document. This method implements
+ * the SAX default behaviour: application writers can override it
+ * in a subclass to do special translations such as catalog lookups
+ * or URI redirection.</p>
+ *
+ * @param publicId The public identifer, or null if none is
+ * available.
+ * @param systemId The system identifier provided in the XML
+ * document.
+ * @return The new input source, or null to require the
+ * default behaviour.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.EntityResolver#resolveEntity
+ */
+ public InputSource resolveEntity (String publicId, String systemId)
+ throws SAXException
+ {
+ return null;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of DTDHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive notification of a notation declaration.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass if they wish to keep track of the notations
+ * declared in a document.</p>
+ *
+ * @param name The notation name.
+ * @param publicId The notation public identifier, or null if not
+ * available.
+ * @param systemId The notation system identifier.
+ * @see org.xml.sax.DTDHandler#notationDecl
+ */
+ public void notationDecl (String name, String publicId, String systemId)
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of an unparsed entity declaration.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to keep track of the unparsed entities
+ * declared in a document.</p>
+ *
+ * @param name The entity name.
+ * @param publicId The entity public identifier, or null if not
+ * available.
+ * @param systemId The entity system identifier.
+ * @param notationName The name of the associated notation.
+ * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+ */
+ public void unparsedEntityDecl (String name, String publicId,
+ String systemId, String notationName)
+ {
+ // no op
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of DocumentHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive a Locator object for document events.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass if they wish to store the locator for use
+ * with other document events.</p>
+ *
+ * @param locator A locator for all SAX document events.
+ * @see org.xml.sax.DocumentHandler#setDocumentLocator
+ * @see org.xml.sax.Locator
+ */
+ public void setDocumentLocator (Locator locator)
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the beginning of the document.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the beginning
+ * of a document (such as allocating the root node of a tree or
+ * creating an output file).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#startDocument
+ */
+ public void startDocument ()
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the end of the document.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the beginning
+ * of a document (such as finalising a tree or closing an output
+ * file).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#endDocument
+ */
+ public void endDocument ()
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the start of an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the start of
+ * each element (such as allocating a new tree node or writing
+ * output to a file).</p>
+ *
+ * @param name The element type name.
+ * @param attributes The specified or defaulted attributes.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#startElement
+ */
+ public void startElement (String name, AttributeList attributes)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the end of an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the end of
+ * each element (such as finalising a tree node or writing
+ * output to a file).</p>
+ *
+ * @param name The element type name.
+ * @param attributes The specified or defaulted attributes.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#endElement
+ */
+ public void endElement (String name)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of character data inside an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method to take specific actions for each chunk of character data
+ * (such as adding the data to a node or buffer, or printing it to
+ * a file).</p>
+ *
+ * @param ch The characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#characters
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method to take specific actions for each chunk of ignorable
+ * whitespace (such as adding data to a node or buffer, or printing
+ * it to a file).</p>
+ *
+ * @param ch The whitespace characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#ignorableWhitespace
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of a processing instruction.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions for each
+ * processing instruction, such as setting status variables or
+ * invoking other methods.</p>
+ *
+ * @param target The processing instruction target.
+ * @param data The processing instruction data, or null if
+ * none is supplied.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DocumentHandler#processingInstruction
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of the ErrorHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive notification of a parser warning.
+ *
+ * <p>The default implementation does nothing. Application writers
+ * may override this method in a subclass to take specific actions
+ * for each warning, such as inserting the message in a log file or
+ * printing it to the console.</p>
+ *
+ * @param e The warning information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#warning
+ * @see org.xml.sax.SAXParseException
+ */
+ public void warning (SAXParseException e)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of a recoverable parser error.
+ *
+ * <p>The default implementation does nothing. Application writers
+ * may override this method in a subclass to take specific actions
+ * for each error, such as inserting the message in a log file or
+ * printing it to the console.</p>
+ *
+ * @param e The warning information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#warning
+ * @see org.xml.sax.SAXParseException
+ */
+ public void error (SAXParseException e)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Report a fatal XML parsing error.
+ *
+ * <p>The default implementation throws a SAXParseException.
+ * Application writers may override this method in a subclass if
+ * they need to take specific actions for each fatal error (such as
+ * collecting all of the errors into a single report): in any case,
+ * the application must stop all regular processing when this
+ * method is invoked, since the document is no longer reliable, and
+ * the parser may no longer report parsing events.</p>
+ *
+ * @param e The error information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#fatalError
+ * @see org.xml.sax.SAXParseException
+ */
+ public void fatalError (SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+}
+
+// end of HandlerBase.java
-// SAX input source.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-import java.io.Reader;\r
-import java.io.InputStream;\r
-\r
-/**\r
- * A single input source for an XML entity.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class allows a SAX application to encapsulate information\r
- * about an input source in a single object, which may include\r
- * a public identifier, a system identifier, a byte stream (possibly\r
- * with a specified encoding), and/or a character stream.</p>\r
- *\r
- * <p>There are two places that the application will deliver this\r
- * input source to the parser: as the argument to the Parser.parse\r
- * method, or as the return value of the EntityResolver.resolveEntity\r
- * method.</p>\r
- *\r
- * <p>The SAX parser will use the InputSource object to determine how\r
- * to read XML input. If there is a character stream available, the\r
- * parser will read that stream directly; if not, the parser will use\r
- * a byte stream, if available; if neither a character stream nor a\r
- * byte stream is available, the parser will attempt to open a URI\r
- * connection to the resource identified by the system\r
- * identifier.</p>\r
- *\r
- * <p>An InputSource object belongs to the application: the SAX parser\r
- * shall never modify it in any way (it may modify a copy if \r
- * necessary).</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#parse\r
- * @see org.xml.sax.EntityResolver#resolveEntity\r
- * @see java.io.InputStream\r
- * @see java.io.Reader\r
- */\r
-public class InputSource {\r
- \r
- /**\r
- * Zero-argument default constructor.\r
- *\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- * @see #setEncoding\r
- */\r
- public InputSource ()\r
- {\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a system identifier.\r
- *\r
- * <p>Applications may use setPublicId to include a \r
- * public identifier as well, or setEncoding to specify\r
- * the character encoding, if known.</p>\r
- *\r
- * <p>If the system identifier is a URL, it must be full resolved.</p>\r
- *\r
- * @param systemId The system identifier (URI).\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setEncoding\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (String systemId)\r
- {\r
- setSystemId(systemId);\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a byte stream.\r
- *\r
- * <p>Application writers may use setSystemId to provide a base \r
- * for resolving relative URIs, setPublicId to include a \r
- * public identifier, and/or setEncoding to specify the object's\r
- * character encoding.</p>\r
- *\r
- * @param byteStream The raw byte stream containing the document.\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setEncoding\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (InputStream byteStream)\r
- {\r
- setByteStream(byteStream);\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a character stream.\r
- *\r
- * <p>Application writers may use setSystemId() to provide a base \r
- * for resolving relative URIs, and setPublicId to include a \r
- * public identifier.</p>\r
- *\r
- * <p>The character stream shall not include a byte order mark.</p>\r
- *\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (Reader characterStream)\r
- {\r
- setCharacterStream(characterStream);\r
- }\r
- \r
- \r
- /**\r
- * Set the public identifier for this input source.\r
- *\r
- * <p>The public identifier is always optional: if the application\r
- * writer includes one, it will be provided as part of the\r
- * location information.</p>\r
- *\r
- * @param publicId The public identifier as a string.\r
- * @see #getPublicId\r
- * @see org.xml.sax.Locator#getPublicId\r
- * @see org.xml.sax.SAXParseException#getPublicId\r
- */\r
- public void setPublicId (String publicId)\r
- {\r
- this.publicId = publicId;\r
- }\r
- \r
- \r
- /**\r
- * Get the public identifier for this input source.\r
- *\r
- * @return The public identifier, or null if none was supplied.\r
- * @see #setPublicId\r
- */\r
- public String getPublicId ()\r
- {\r
- return publicId;\r
- }\r
- \r
- \r
- /**\r
- * Set the system identifier for this input source.\r
- *\r
- * <p>The system identifier is optional if there is a byte stream\r
- * or a character stream, but it is still useful to provide one,\r
- * since the application can use it to resolve relative URIs\r
- * and can include it in error messages and warnings (the parser\r
- * will attempt to open a connection to the URI only if\r
- * there is no byte stream or character stream specified).</p>\r
- *\r
- * <p>If the application knows the character encoding of the\r
- * object pointed to by the system identifier, it can register\r
- * the encoding using the setEncoding method.</p>\r
- *\r
- * <p>If the system ID is a URL, it must be fully resolved.</p>\r
- *\r
- * @param systemId The system identifier as a string.\r
- * @see #setEncoding\r
- * @see #getSystemId\r
- * @see org.xml.sax.Locator#getSystemId\r
- * @see org.xml.sax.SAXParseException#getSystemId\r
- */\r
- public void setSystemId (String systemId)\r
- {\r
- this.systemId = systemId;\r
- }\r
- \r
- \r
- /**\r
- * Get the system identifier for this input source.\r
- *\r
- * <p>The getEncoding method will return the character encoding\r
- * of the object pointed to, or null if unknown.</p>\r
- *\r
- * <p>If the system ID is a URL, it will be fully resolved.</p>\r
- *\r
- * @return The system identifier.\r
- * @see #setSystemId\r
- * @see #getEncoding\r
- */\r
- public String getSystemId ()\r
- {\r
- return systemId;\r
- }\r
- \r
- \r
- /**\r
- * Set the byte stream for this input source.\r
- *\r
- * <p>The SAX parser will ignore this if there is also a character\r
- * stream specified, but it will use a byte stream in preference\r
- * to opening a URI connection itself.</p>\r
- *\r
- * <p>If the application knows the character encoding of the\r
- * byte stream, it should set it with the setEncoding method.</p>\r
- *\r
- * @param byteStream A byte stream containing an XML document or\r
- * other entity.\r
- * @see #setEncoding\r
- * @see #getByteStream\r
- * @see #getEncoding\r
- * @see java.io.InputStream\r
- */\r
- public void setByteStream (InputStream byteStream)\r
- {\r
- this.byteStream = byteStream;\r
- }\r
- \r
- \r
- /**\r
- * Get the byte stream for this input source.\r
- *\r
- * <p>The getEncoding method will return the character\r
- * encoding for this byte stream, or null if unknown.</p>\r
- *\r
- * @return The byte stream, or null if none was supplied.\r
- * @see #getEncoding\r
- * @see #setByteStream\r
- */\r
- public InputStream getByteStream ()\r
- {\r
- return byteStream;\r
- }\r
- \r
- \r
- /** \r
- * Set the character encoding, if known.\r
- *\r
- * <p>The encoding must be a string acceptable for an\r
- * XML encoding declaration (see section 4.3.3 of the XML 1.0\r
- * recommendation).</p>\r
- *\r
- * <p>This method has no effect when the application provides a\r
- * character stream.</p>\r
- *\r
- * @param encoding A string describing the character encoding.\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #getEncoding\r
- */\r
- public void setEncoding (String encoding)\r
- {\r
- this.encoding = encoding;\r
- }\r
- \r
- \r
- /**\r
- * Get the character encoding for a byte stream or URI.\r
- *\r
- * @return The encoding, or null if none was supplied.\r
- * @see #setByteStream\r
- * @see #getSystemId\r
- * @see #getByteStream\r
- */\r
- public String getEncoding ()\r
- {\r
- return encoding;\r
- }\r
- \r
- \r
- /**\r
- * Set the character stream for this input source.\r
- *\r
- * <p>If there is a character stream specified, the SAX parser\r
- * will ignore any byte stream and will not attempt to open\r
- * a URI connection to the system identifier.</p>\r
- *\r
- * @param characterStream The character stream containing the\r
- * XML document or other entity.\r
- * @see #getCharacterStream\r
- * @see java.io.Reader\r
- */\r
- public void setCharacterStream (Reader characterStream)\r
- {\r
- this.characterStream = characterStream;\r
- }\r
- \r
- \r
- /**\r
- * Get the character stream for this input source.\r
- *\r
- * @return The character stream, or null if none was supplied.\r
- * @see #setCharacterStream\r
- */\r
- public Reader getCharacterStream ()\r
- {\r
- return characterStream;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- private String publicId;\r
- private String systemId;\r
- private InputStream byteStream;\r
- private String encoding;\r
- private Reader characterStream;\r
- \r
-}\r
-\r
-// end of InputSource.java\r
+// SAX input source.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: InputSource.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+import java.io.Reader;
+import java.io.InputStream;
+
+/**
+ * A single input source for an XML entity.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class allows a SAX application to encapsulate information
+ * about an input source in a single object, which may include
+ * a public identifier, a system identifier, a byte stream (possibly
+ * with a specified encoding), and/or a character stream.</p>
+ *
+ * <p>There are two places that the application can deliver an
+ * input source to the parser: as the argument to the Parser.parse
+ * method, or as the return value of the EntityResolver.resolveEntity
+ * method.</p>
+ *
+ * <p>The SAX parser will use the InputSource object to determine how
+ * to read XML input. If there is a character stream available, the
+ * parser will read that stream directly, disregarding any text
+ * encoding declaration found in that stream.
+ * If there is no character stream, but there is
+ * a byte stream, the parser will use that byte stream, using the
+ * encoding specified in the InputSource or else (if no encoding is
+ * specified) autodetecting the character encoding using an algorithm
+ * such as the one in the XML specification. If neither a character
+ * stream nor a
+ * byte stream is available, the parser will attempt to open a URI
+ * connection to the resource identified by the system
+ * identifier.</p>
+ *
+ * <p>An InputSource object belongs to the application: the SAX parser
+ * shall never modify it in any way (it may modify a copy if
+ * necessary). However, standard processing of both byte and
+ * character streams is to close them on as part of end-of-parse cleanup,
+ * so applications should not attempt to re-use such streams after they
+ * have been handed to a parser. </p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
+ * @see org.xml.sax.EntityResolver#resolveEntity
+ * @see java.io.InputStream
+ * @see java.io.Reader
+ */
+public class InputSource {
+
+ /**
+ * Zero-argument default constructor.
+ *
+ * @see #setPublicId
+ * @see #setSystemId
+ * @see #setByteStream
+ * @see #setCharacterStream
+ * @see #setEncoding
+ */
+ public InputSource ()
+ {
+ }
+
+
+ /**
+ * Create a new input source with a system identifier.
+ *
+ * <p>Applications may use setPublicId to include a
+ * public identifier as well, or setEncoding to specify
+ * the character encoding, if known.</p>
+ *
+ * <p>If the system identifier is a URL, it must be fully
+ * resolved (it may not be a relative URL).</p>
+ *
+ * @param systemId The system identifier (URI).
+ * @see #setPublicId
+ * @see #setSystemId
+ * @see #setByteStream
+ * @see #setEncoding
+ * @see #setCharacterStream
+ */
+ public InputSource (String systemId)
+ {
+ setSystemId(systemId);
+ }
+
+
+ /**
+ * Create a new input source with a byte stream.
+ *
+ * <p>Application writers should use setSystemId() to provide a base
+ * for resolving relative URIs, may use setPublicId to include a
+ * public identifier, and may use setEncoding to specify the object's
+ * character encoding.</p>
+ *
+ * @param byteStream The raw byte stream containing the document.
+ * @see #setPublicId
+ * @see #setSystemId
+ * @see #setEncoding
+ * @see #setByteStream
+ * @see #setCharacterStream
+ */
+ public InputSource (InputStream byteStream)
+ {
+ setByteStream(byteStream);
+ }
+
+
+ /**
+ * Create a new input source with a character stream.
+ *
+ * <p>Application writers should use setSystemId() to provide a base
+ * for resolving relative URIs, and may use setPublicId to include a
+ * public identifier.</p>
+ *
+ * <p>The character stream shall not include a byte order mark.</p>
+ *
+ * @see #setPublicId
+ * @see #setSystemId
+ * @see #setByteStream
+ * @see #setCharacterStream
+ */
+ public InputSource (Reader characterStream)
+ {
+ setCharacterStream(characterStream);
+ }
+
+
+ /**
+ * Set the public identifier for this input source.
+ *
+ * <p>The public identifier is always optional: if the application
+ * writer includes one, it will be provided as part of the
+ * location information.</p>
+ *
+ * @param publicId The public identifier as a string.
+ * @see #getPublicId
+ * @see org.xml.sax.Locator#getPublicId
+ * @see org.xml.sax.SAXParseException#getPublicId
+ */
+ public void setPublicId (String publicId)
+ {
+ this.publicId = publicId;
+ }
+
+
+ /**
+ * Get the public identifier for this input source.
+ *
+ * @return The public identifier, or null if none was supplied.
+ * @see #setPublicId
+ */
+ public String getPublicId ()
+ {
+ return publicId;
+ }
+
+
+ /**
+ * Set the system identifier for this input source.
+ *
+ * <p>The system identifier is optional if there is a byte stream
+ * or a character stream, but it is still useful to provide one,
+ * since the application can use it to resolve relative URIs
+ * and can include it in error messages and warnings (the parser
+ * will attempt to open a connection to the URI only if
+ * there is no byte stream or character stream specified).</p>
+ *
+ * <p>If the application knows the character encoding of the
+ * object pointed to by the system identifier, it can register
+ * the encoding using the setEncoding method.</p>
+ *
+ * <p>If the system identifier is a URL, it must be fully
+ * resolved (it may not be a relative URL).</p>
+ *
+ * @param systemId The system identifier as a string.
+ * @see #setEncoding
+ * @see #getSystemId
+ * @see org.xml.sax.Locator#getSystemId
+ * @see org.xml.sax.SAXParseException#getSystemId
+ */
+ public void setSystemId (String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+
+ /**
+ * Get the system identifier for this input source.
+ *
+ * <p>The getEncoding method will return the character encoding
+ * of the object pointed to, or null if unknown.</p>
+ *
+ * <p>If the system ID is a URL, it will be fully resolved.</p>
+ *
+ * @return The system identifier, or null if none was supplied.
+ * @see #setSystemId
+ * @see #getEncoding
+ */
+ public String getSystemId ()
+ {
+ return systemId;
+ }
+
+
+ /**
+ * Set the byte stream for this input source.
+ *
+ * <p>The SAX parser will ignore this if there is also a character
+ * stream specified, but it will use a byte stream in preference
+ * to opening a URI connection itself.</p>
+ *
+ * <p>If the application knows the character encoding of the
+ * byte stream, it should set it with the setEncoding method.</p>
+ *
+ * @param byteStream A byte stream containing an XML document or
+ * other entity.
+ * @see #setEncoding
+ * @see #getByteStream
+ * @see #getEncoding
+ * @see java.io.InputStream
+ */
+ public void setByteStream (InputStream byteStream)
+ {
+ this.byteStream = byteStream;
+ }
+
+
+ /**
+ * Get the byte stream for this input source.
+ *
+ * <p>The getEncoding method will return the character
+ * encoding for this byte stream, or null if unknown.</p>
+ *
+ * @return The byte stream, or null if none was supplied.
+ * @see #getEncoding
+ * @see #setByteStream
+ */
+ public InputStream getByteStream ()
+ {
+ return byteStream;
+ }
+
+
+ /**
+ * Set the character encoding, if known.
+ *
+ * <p>The encoding must be a string acceptable for an
+ * XML encoding declaration (see section 4.3.3 of the XML 1.0
+ * recommendation).</p>
+ *
+ * <p>This method has no effect when the application provides a
+ * character stream.</p>
+ *
+ * @param encoding A string describing the character encoding.
+ * @see #setSystemId
+ * @see #setByteStream
+ * @see #getEncoding
+ */
+ public void setEncoding (String encoding)
+ {
+ this.encoding = encoding;
+ }
+
+
+ /**
+ * Get the character encoding for a byte stream or URI.
+ * This value will be ignored when the application provides a
+ * character stream.
+ *
+ * @return The encoding, or null if none was supplied.
+ * @see #setByteStream
+ * @see #getSystemId
+ * @see #getByteStream
+ */
+ public String getEncoding ()
+ {
+ return encoding;
+ }
+
+
+ /**
+ * Set the character stream for this input source.
+ *
+ * <p>If there is a character stream specified, the SAX parser
+ * will ignore any byte stream and will not attempt to open
+ * a URI connection to the system identifier.</p>
+ *
+ * @param characterStream The character stream containing the
+ * XML document or other entity.
+ * @see #getCharacterStream
+ * @see java.io.Reader
+ */
+ public void setCharacterStream (Reader characterStream)
+ {
+ this.characterStream = characterStream;
+ }
+
+
+ /**
+ * Get the character stream for this input source.
+ *
+ * @return The character stream, or null if none was supplied.
+ * @see #setCharacterStream
+ */
+ public Reader getCharacterStream ()
+ {
+ return characterStream;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ private String publicId;
+ private String systemId;
+ private InputStream byteStream;
+ private String encoding;
+ private Reader characterStream;
+
+}
+
+// end of InputSource.java
-// SAX locator interface for document events.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: Locator.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Interface for associating a SAX event with a document location.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>If a SAX parser provides location information to the SAX\r
- * application, it does so by implementing this interface and then\r
- * passing an instance to the application using the content\r
- * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator\r
- * setDocumentLocator} method. The application can use the\r
- * object to obtain the location of any other content handler event\r
- * in the XML source document.</p>\r
- *\r
- * <p>Note that the results returned by the object will be valid only\r
- * during the scope of each content handler method: the application\r
- * will receive unpredictable results if it attempts to use the\r
- * locator at any other time.</p>\r
- *\r
- * <p>SAX parsers are not required to supply a locator, but they are\r
- * very strongly encouraged to do so. If the parser supplies a\r
- * locator, it must do so before reporting any other document events.\r
- * If no locator has been set by the time the application receives\r
- * the {@link org.xml.sax.ContentHandler#startDocument startDocument}\r
- * event, the application should assume that a locator is not \r
- * available.</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.ContentHandler#setDocumentLocator \r
- */\r
-public interface Locator {\r
- \r
- \r
- /**\r
- * Return the public identifier for the current document event.\r
- *\r
- * <p>The return value is the public identifier of the document\r
- * entity or of the external parsed entity in which the markup\r
- * triggering the event appears.</p>\r
- *\r
- * @return A string containing the public identifier, or\r
- * null if none is available.\r
- * @see #getSystemId\r
- */\r
- public abstract String getPublicId ();\r
- \r
- \r
- /**\r
- * Return the system identifier for the current document event.\r
- *\r
- * <p>The return value is the system identifier of the document\r
- * entity or of the external parsed entity in which the markup\r
- * triggering the event appears.</p>\r
- *\r
- * <p>If the system identifier is a URL, the parser must resolve it\r
- * fully before passing it to the application.</p>\r
- *\r
- * @return A string containing the system identifier, or null\r
- * if none is available.\r
- * @see #getPublicId\r
- */\r
- public abstract String getSystemId ();\r
- \r
- \r
- /**\r
- * Return the line number where the current document event ends.\r
- *\r
- * <p><strong>Warning:</strong> The return value from the method\r
- * is intended only as an approximation for the sake of error\r
- * reporting; it is not intended to provide sufficient information\r
- * to edit the character content of the original XML document.</p>\r
- *\r
- * <p>The return value is an approximation of the line number\r
- * in the document entity or external parsed entity where the\r
- * markup triggering the event appears.</p>\r
- *\r
- * <p>If possible, the SAX driver should provide the line position \r
- * of the first character after the text associated with the document \r
- * event. The first line in the document is line 1.</p>\r
- *\r
- * @return The line number, or -1 if none is available.\r
- * @see #getColumnNumber\r
- */\r
- public abstract int getLineNumber ();\r
- \r
- \r
- /**\r
- * Return the column number where the current document event ends.\r
- *\r
- * <p><strong>Warning:</strong> The return value from the method\r
- * is intended only as an approximation for the sake of error\r
- * reporting; it is not intended to provide sufficient information\r
- * to edit the character content of the original XML document.</p>\r
- *\r
- * <p>The return value is an approximation of the column number\r
- * in the document entity or external parsed entity where the\r
- * markup triggering the event appears.</p>\r
- *\r
- * <p>If possible, the SAX driver should provide the line position \r
- * of the first character after the text associated with the document \r
- * event.</p>\r
- *\r
- * <p>If possible, the SAX driver should provide the line position \r
- * of the first character after the text associated with the document \r
- * event. The first column in each line is column 1.</p>\r
- *\r
- * @return The column number, or -1 if none is available.\r
- * @see #getLineNumber\r
- */\r
- public abstract int getColumnNumber ();\r
- \r
-}\r
-\r
-// end of Locator.java\r
+// SAX locator interface for document events.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: Locator.java,v 1.4.2.5 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+
+/**
+ * Interface for associating a SAX event with a document location.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>If a SAX parser provides location information to the SAX
+ * application, it does so by implementing this interface and then
+ * passing an instance to the application using the content
+ * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
+ * setDocumentLocator} method. The application can use the
+ * object to obtain the location of any other SAX event
+ * in the XML source document.</p>
+ *
+ * <p>Note that the results returned by the object will be valid only
+ * during the scope of each callback method: the application
+ * will receive unpredictable results if it attempts to use the
+ * locator at any other time, or after parsing completes.</p>
+ *
+ * <p>SAX parsers are not required to supply a locator, but they are
+ * very strongly encouraged to do so. If the parser supplies a
+ * locator, it must do so before reporting any other document events.
+ * If no locator has been set by the time the application receives
+ * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
+ * event, the application should assume that a locator is not
+ * available.</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
+ */
+public interface Locator {
+
+
+ /**
+ * Return the public identifier for the current document event.
+ *
+ * <p>The return value is the public identifier of the document
+ * entity or of the external parsed entity in which the markup
+ * triggering the event appears.</p>
+ *
+ * @return A string containing the public identifier, or
+ * null if none is available.
+ * @see #getSystemId
+ */
+ public abstract String getPublicId ();
+
+
+ /**
+ * Return the system identifier for the current document event.
+ *
+ * <p>The return value is the system identifier of the document
+ * entity or of the external parsed entity in which the markup
+ * triggering the event appears.</p>
+ *
+ * <p>If the system identifier is a URL, the parser must resolve it
+ * fully before passing it to the application. For example, a file
+ * name must always be provided as a <em>file:...</em> URL, and other
+ * kinds of relative URI are also resolved against their bases.</p>
+ *
+ * @return A string containing the system identifier, or null
+ * if none is available.
+ * @see #getPublicId
+ */
+ public abstract String getSystemId ();
+
+
+ /**
+ * Return the line number where the current document event ends.
+ * Lines are delimited by line ends, which are defined in
+ * the XML specification.
+ *
+ * <p><strong>Warning:</strong> The return value from the method
+ * is intended only as an approximation for the sake of diagnostics;
+ * it is not intended to provide sufficient information
+ * to edit the character content of the original XML document.
+ * In some cases, these "line" numbers match what would be displayed
+ * as columns, and in others they may not match the source text
+ * due to internal entity expansion. </p>
+ *
+ * <p>The return value is an approximation of the line number
+ * in the document entity or external parsed entity where the
+ * markup triggering the event appears.</p>
+ *
+ * <p>If possible, the SAX driver should provide the line position
+ * of the first character after the text associated with the document
+ * event. The first line is line 1.</p>
+ *
+ * @return The line number, or -1 if none is available.
+ * @see #getColumnNumber
+ */
+ public abstract int getLineNumber ();
+
+
+ /**
+ * Return the column number where the current document event ends.
+ * This is one-based number of Java <code>char</code> values since
+ * the last line end.
+ *
+ * <p><strong>Warning:</strong> The return value from the method
+ * is intended only as an approximation for the sake of diagnostics;
+ * it is not intended to provide sufficient information
+ * to edit the character content of the original XML document.
+ * For example, when lines contain combining character sequences, wide
+ * characters, surrogate pairs, or bi-directional text, the value may
+ * not correspond to the column in a text editor's display. </p>
+ *
+ * <p>The return value is an approximation of the column number
+ * in the document entity or external parsed entity where the
+ * markup triggering the event appears.</p>
+ *
+ * <p>If possible, the SAX driver should provide the line position
+ * of the first character after the text associated with the document
+ * event. The first column in each line is column 1.</p>
+ *
+ * @return The column number, or -1 if none is available.
+ * @see #getLineNumber
+ */
+ public abstract int getColumnNumber ();
+
+}
+
+// end of Locator.java
-// SAX parser interface.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: Parser.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-import java.io.IOException;\r
-import java.util.Locale;\r
-\r
-\r
-/**\r
- * Basic interface for SAX (Simple API for XML) parsers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This was the main event supplier interface for SAX1; it has\r
- * been replaced in SAX2 by {@link org.xml.sax.XMLReader XMLReader},\r
- * which includes Namespace support and sophisticated configurability\r
- * and extensibility.</p>\r
- *\r
- * <p>All SAX1 parsers must implement this basic interface: it allows\r
- * applications to register handlers for different types of events\r
- * and to initiate a parse from a URI, or a character stream.</p>\r
- *\r
- * <p>All SAX1 parsers must also implement a zero-argument constructor\r
- * (though other constructors are also allowed).</p>\r
- *\r
- * <p>SAX1 parsers are reusable but not re-entrant: the application\r
- * may reuse a parser object (possibly with a different input source)\r
- * once the first parse has completed successfully, but it may not\r
- * invoke the parse() methods recursively within a parse.</p>\r
- *\r
- * @deprecated This interface has been replaced by the SAX2\r
- * {@link org.xml.sax.XMLReader XMLReader}\r
- * interface, which includes Namespace support.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.EntityResolver\r
- * @see org.xml.sax.DTDHandler\r
- * @see org.xml.sax.DocumentHandler\r
- * @see org.xml.sax.ErrorHandler\r
- * @see org.xml.sax.HandlerBase\r
- * @see org.xml.sax.InputSource\r
- */\r
-public interface Parser \r
-{\r
- \r
- /**\r
- * Allow an application to request a locale for errors and warnings.\r
- *\r
- * <p>SAX parsers are not required to provide localisation for errors\r
- * and warnings; if they cannot support the requested locale,\r
- * however, they must throw a SAX exception. Applications may\r
- * not request a locale change in the middle of a parse.</p>\r
- *\r
- * @param locale A Java Locale object.\r
- * @exception org.xml.sax.SAXException Throws an exception\r
- * (using the previous or default locale) if the \r
- * requested locale is not supported.\r
- * @see org.xml.sax.SAXException\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public abstract void setLocale (Locale locale)\r
- throws SAXException;\r
- \r
- \r
- /**\r
- * Allow an application to register a custom entity resolver.\r
- *\r
- * <p>If the application does not register an entity resolver, the\r
- * SAX parser will resolve system identifiers and open connections\r
- * to entities itself (this is the default behaviour implemented in\r
- * HandlerBase).</p>\r
- *\r
- * <p>Applications may register a new or different entity resolver\r
- * in the middle of a parse, and the SAX parser must begin using\r
- * the new resolver immediately.</p>\r
- *\r
- * @param resolver The object for resolving entities.\r
- * @see EntityResolver\r
- * @see HandlerBase\r
- */\r
- public abstract void setEntityResolver (EntityResolver resolver);\r
- \r
- \r
- /**\r
- * Allow an application to register a DTD event handler.\r
- *\r
- * <p>If the application does not register a DTD handler, all DTD\r
- * events reported by the SAX parser will be silently\r
- * ignored (this is the default behaviour implemented by\r
- * HandlerBase).</p>\r
- *\r
- * <p>Applications may register a new or different\r
- * handler in the middle of a parse, and the SAX parser must\r
- * begin using the new handler immediately.</p>\r
- *\r
- * @param handler The DTD handler.\r
- * @see DTDHandler\r
- * @see HandlerBase\r
- */\r
- public abstract void setDTDHandler (DTDHandler handler);\r
- \r
- \r
- /**\r
- * Allow an application to register a document event handler.\r
- *\r
- * <p>If the application does not register a document handler, all\r
- * document events reported by the SAX parser will be silently\r
- * ignored (this is the default behaviour implemented by\r
- * HandlerBase).</p>\r
- *\r
- * <p>Applications may register a new or different handler in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * handler immediately.</p>\r
- *\r
- * @param handler The document handler.\r
- * @see DocumentHandler\r
- * @see HandlerBase\r
- */\r
- public abstract void setDocumentHandler (DocumentHandler handler);\r
- \r
- \r
- /**\r
- * Allow an application to register an error event handler.\r
- *\r
- * <p>If the application does not register an error event handler,\r
- * all error events reported by the SAX parser will be silently\r
- * ignored, except for fatalError, which will throw a SAXException\r
- * (this is the default behaviour implemented by HandlerBase).</p>\r
- *\r
- * <p>Applications may register a new or different handler in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * handler immediately.</p>\r
- *\r
- * @param handler The error handler.\r
- * @see ErrorHandler\r
- * @see SAXException\r
- * @see HandlerBase\r
- */\r
- public abstract void setErrorHandler (ErrorHandler handler);\r
- \r
- \r
- /**\r
- * Parse an XML document.\r
- *\r
- * <p>The application can use this method to instruct the SAX parser\r
- * to begin parsing an XML document from any valid input\r
- * source (a character stream, a byte stream, or a URI).</p>\r
- *\r
- * <p>Applications may not invoke this method while a parse is in\r
- * progress (they should create a new Parser instead for each\r
- * additional XML document). Once a parse is complete, an\r
- * application may reuse the same Parser object, possibly with a\r
- * different input source.</p>\r
- *\r
- * @param source The input source for the top-level of the\r
- * XML document.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see org.xml.sax.InputSource\r
- * @see #parse(java.lang.String)\r
- * @see #setEntityResolver\r
- * @see #setDTDHandler\r
- * @see #setDocumentHandler\r
- * @see #setErrorHandler\r
- */\r
- public abstract void parse (InputSource source)\r
- throws SAXException, IOException;\r
- \r
- \r
- /**\r
- * Parse an XML document from a system identifier (URI).\r
- *\r
- * <p>This method is a shortcut for the common case of reading a\r
- * document from a system identifier. It is the exact\r
- * equivalent of the following:</p>\r
- *\r
- * <pre>\r
- * parse(new InputSource(systemId));\r
- * </pre>\r
- *\r
- * <p>If the system identifier is a URL, it must be fully resolved\r
- * by the application before it is passed to the parser.</p>\r
- *\r
- * @param systemId The system identifier (URI).\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see #parse(org.xml.sax.InputSource)\r
- */\r
- public abstract void parse (String systemId)\r
- throws SAXException, IOException;\r
- \r
-}\r
-\r
-// end of Parser.java\r
+// SAX parser interface.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: Parser.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+import java.io.IOException;
+import java.util.Locale;
+
+
+/**
+ * Basic interface for SAX (Simple API for XML) parsers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This was the main event supplier interface for SAX1; it has
+ * been replaced in SAX2 by {@link org.xml.sax.XMLReader XMLReader},
+ * which includes Namespace support and sophisticated configurability
+ * and extensibility.</p>
+ *
+ * <p>All SAX1 parsers must implement this basic interface: it allows
+ * applications to register handlers for different types of events
+ * and to initiate a parse from a URI, or a character stream.</p>
+ *
+ * <p>All SAX1 parsers must also implement a zero-argument constructor
+ * (though other constructors are also allowed).</p>
+ *
+ * <p>SAX1 parsers are reusable but not re-entrant: the application
+ * may reuse a parser object (possibly with a different input source)
+ * once the first parse has completed successfully, but it may not
+ * invoke the parse() methods recursively within a parse.</p>
+ *
+ * @deprecated This interface has been replaced by the SAX2
+ * {@link org.xml.sax.XMLReader XMLReader}
+ * interface, which includes Namespace support.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.EntityResolver
+ * @see org.xml.sax.DTDHandler
+ * @see org.xml.sax.DocumentHandler
+ * @see org.xml.sax.ErrorHandler
+ * @see org.xml.sax.HandlerBase
+ * @see org.xml.sax.InputSource
+ */
+public interface Parser
+{
+
+ /**
+ * Allow an application to request a locale for errors and warnings.
+ *
+ * <p>SAX parsers are not required to provide localisation for errors
+ * and warnings; if they cannot support the requested locale,
+ * however, they must throw a SAX exception. Applications may
+ * not request a locale change in the middle of a parse.</p>
+ *
+ * @param locale A Java Locale object.
+ * @exception org.xml.sax.SAXException Throws an exception
+ * (using the previous or default locale) if the
+ * requested locale is not supported.
+ * @see org.xml.sax.SAXException
+ * @see org.xml.sax.SAXParseException
+ */
+ public abstract void setLocale (Locale locale)
+ throws SAXException;
+
+
+ /**
+ * Allow an application to register a custom entity resolver.
+ *
+ * <p>If the application does not register an entity resolver, the
+ * SAX parser will resolve system identifiers and open connections
+ * to entities itself (this is the default behaviour implemented in
+ * HandlerBase).</p>
+ *
+ * <p>Applications may register a new or different entity resolver
+ * in the middle of a parse, and the SAX parser must begin using
+ * the new resolver immediately.</p>
+ *
+ * @param resolver The object for resolving entities.
+ * @see EntityResolver
+ * @see HandlerBase
+ */
+ public abstract void setEntityResolver (EntityResolver resolver);
+
+
+ /**
+ * Allow an application to register a DTD event handler.
+ *
+ * <p>If the application does not register a DTD handler, all DTD
+ * events reported by the SAX parser will be silently
+ * ignored (this is the default behaviour implemented by
+ * HandlerBase).</p>
+ *
+ * <p>Applications may register a new or different
+ * handler in the middle of a parse, and the SAX parser must
+ * begin using the new handler immediately.</p>
+ *
+ * @param handler The DTD handler.
+ * @see DTDHandler
+ * @see HandlerBase
+ */
+ public abstract void setDTDHandler (DTDHandler handler);
+
+
+ /**
+ * Allow an application to register a document event handler.
+ *
+ * <p>If the application does not register a document handler, all
+ * document events reported by the SAX parser will be silently
+ * ignored (this is the default behaviour implemented by
+ * HandlerBase).</p>
+ *
+ * <p>Applications may register a new or different handler in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * handler immediately.</p>
+ *
+ * @param handler The document handler.
+ * @see DocumentHandler
+ * @see HandlerBase
+ */
+ public abstract void setDocumentHandler (DocumentHandler handler);
+
+
+ /**
+ * Allow an application to register an error event handler.
+ *
+ * <p>If the application does not register an error event handler,
+ * all error events reported by the SAX parser will be silently
+ * ignored, except for fatalError, which will throw a SAXException
+ * (this is the default behaviour implemented by HandlerBase).</p>
+ *
+ * <p>Applications may register a new or different handler in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * handler immediately.</p>
+ *
+ * @param handler The error handler.
+ * @see ErrorHandler
+ * @see SAXException
+ * @see HandlerBase
+ */
+ public abstract void setErrorHandler (ErrorHandler handler);
+
+
+ /**
+ * Parse an XML document.
+ *
+ * <p>The application can use this method to instruct the SAX parser
+ * to begin parsing an XML document from any valid input
+ * source (a character stream, a byte stream, or a URI).</p>
+ *
+ * <p>Applications may not invoke this method while a parse is in
+ * progress (they should create a new Parser instead for each
+ * additional XML document). Once a parse is complete, an
+ * application may reuse the same Parser object, possibly with a
+ * different input source.</p>
+ *
+ * @param source The input source for the top-level of the
+ * XML document.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ * @see org.xml.sax.InputSource
+ * @see #parse(java.lang.String)
+ * @see #setEntityResolver
+ * @see #setDTDHandler
+ * @see #setDocumentHandler
+ * @see #setErrorHandler
+ */
+ public abstract void parse (InputSource source)
+ throws SAXException, IOException;
+
+
+ /**
+ * Parse an XML document from a system identifier (URI).
+ *
+ * <p>This method is a shortcut for the common case of reading a
+ * document from a system identifier. It is the exact
+ * equivalent of the following:</p>
+ *
+ * <pre>
+ * parse(new InputSource(systemId));
+ * </pre>
+ *
+ * <p>If the system identifier is a URL, it must be fully resolved
+ * by the application before it is passed to the parser.</p>
+ *
+ * @param systemId The system identifier (URI).
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ * @see #parse(org.xml.sax.InputSource)
+ */
+ public abstract void parse (String systemId)
+ throws SAXException, IOException;
+
+}
+
+// end of Parser.java
-// SAX exception class.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: SAXException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Encapsulate a general SAX error or warning.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class can contain basic error or warning information from\r
- * either the XML parser or the application: a parser writer or\r
- * application writer can subclass it to provide additional\r
- * functionality. SAX handlers may throw this exception or\r
- * any exception subclassed from it.</p>\r
- *\r
- * <p>If the application needs to pass through other types of\r
- * exceptions, it must wrap those exceptions in a SAXException\r
- * or an exception derived from a SAXException.</p>\r
- *\r
- * <p>If the parser or application needs to include information about a\r
- * specific location in an XML document, it should use the\r
- * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.SAXParseException\r
- */\r
-public class SAXException extends Exception {\r
- \r
- \r
- /**\r
- * Create a new SAXException.\r
- *\r
- * @param message The error or warning message.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public SAXException (String message) {\r
- super(message);\r
- this.exception = null;\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAXException wrapping an existing exception.\r
- *\r
- * <p>The existing exception will be embedded in the new\r
- * one, and its message will become the default message for\r
- * the SAXException.</p>\r
- *\r
- * @param e The exception to be wrapped in a SAXException.\r
- */\r
- public SAXException (Exception e)\r
- {\r
- super();\r
- this.exception = e;\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAXException from an existing exception.\r
- *\r
- * <p>The existing exception will be embedded in the new\r
- * one, but the new exception will have its own message.</p>\r
- *\r
- * @param message The detail message.\r
- * @param e The exception to be wrapped in a SAXException.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public SAXException (String message, Exception e)\r
- {\r
- super(message);\r
- this.exception = e;\r
- }\r
- \r
- \r
- /**\r
- * Return a detail message for this exception.\r
- *\r
- * <p>If there is an embedded exception, and if the SAXException\r
- * has no detail message of its own, this method will return\r
- * the detail message from the embedded exception.</p>\r
- *\r
- * @return The error or warning message.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public String getMessage ()\r
- {\r
- String message = super.getMessage();\r
- \r
- if (message == null && exception != null) {\r
- return exception.getMessage();\r
- } else {\r
- return message;\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Return the embedded exception, if any.\r
- *\r
- * @return The embedded exception, or null if there is none.\r
- */\r
- public Exception getException ()\r
- {\r
- return exception;\r
- }\r
-\r
-\r
- /**\r
- * Override toString to pick up any embedded exception.\r
- *\r
- * @return A string representation of this exception.\r
- */\r
- public String toString ()\r
- {\r
- if (exception != null) {\r
- return exception.toString();\r
- } else {\r
- return super.toString();\r
- }\r
- }\r
- \r
- \r
- \f\r
- //////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- //////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * @serial The embedded exception if tunnelling, or null.\r
- */ \r
- private Exception exception;\r
- \r
-}\r
-\r
-// end of SAXException.java\r
+// SAX exception class.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: SAXException.java,v 1.4.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Encapsulate a general SAX error or warning.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class can contain basic error or warning information from
+ * either the XML parser or the application: a parser writer or
+ * application writer can subclass it to provide additional
+ * functionality. SAX handlers may throw this exception or
+ * any exception subclassed from it.</p>
+ *
+ * <p>If the application needs to pass through other types of
+ * exceptions, it must wrap those exceptions in a SAXException
+ * or an exception derived from a SAXException.</p>
+ *
+ * <p>If the parser or application needs to include information about a
+ * specific location in an XML document, it should use the
+ * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.SAXParseException
+ */
+public class SAXException extends Exception {
+
+
+ /**
+ * Create a new SAXException.
+ */
+ public SAXException ()
+ {
+ super();
+ this.exception = null;
+ }
+
+
+ /**
+ * Create a new SAXException.
+ *
+ * @param message The error or warning message.
+ */
+ public SAXException (String message) {
+ super(message);
+ this.exception = null;
+ }
+
+
+ /**
+ * Create a new SAXException wrapping an existing exception.
+ *
+ * <p>The existing exception will be embedded in the new
+ * one, and its message will become the default message for
+ * the SAXException.</p>
+ *
+ * @param e The exception to be wrapped in a SAXException.
+ */
+ public SAXException (Exception e)
+ {
+ super();
+ this.exception = e;
+ }
+
+
+ /**
+ * Create a new SAXException from an existing exception.
+ *
+ * <p>The existing exception will be embedded in the new
+ * one, but the new exception will have its own message.</p>
+ *
+ * @param message The detail message.
+ * @param e The exception to be wrapped in a SAXException.
+ */
+ public SAXException (String message, Exception e)
+ {
+ super(message);
+ this.exception = e;
+ }
+
+
+ /**
+ * Return a detail message for this exception.
+ *
+ * <p>If there is an embedded exception, and if the SAXException
+ * has no detail message of its own, this method will return
+ * the detail message from the embedded exception.</p>
+ *
+ * @return The error or warning message.
+ */
+ public String getMessage ()
+ {
+ String message = super.getMessage();
+
+ if (message == null && exception != null) {
+ return exception.getMessage();
+ } else {
+ return message;
+ }
+ }
+
+
+ /**
+ * Return the embedded exception, if any.
+ *
+ * @return The embedded exception, or null if there is none.
+ */
+ public Exception getException ()
+ {
+ return exception;
+ }
+
+
+ /**
+ * Override toString to pick up any embedded exception.
+ *
+ * @return A string representation of this exception.
+ */
+ public String toString ()
+ {
+ if (exception != null) {
+ return exception.toString();
+ } else {
+ return super.toString();
+ }
+ }
+
+
+ \f
+ //////////////////////////////////////////////////////////////////////
+ // Internal state.
+ //////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * @serial The embedded exception if tunnelling, or null.
+ */
+ private Exception exception;
+
+}
+
+// end of SAXException.java
-// SAXNotRecognizedException.java - unrecognized feature or value.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: SAXNotRecognizedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Exception class for an unrecognized identifier.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>An XMLReader will throw this exception when it finds an\r
- * unrecognized feature or property identifier; SAX applications and\r
- * extensions may use this class for other, similar purposes.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.SAXNotSupportedException\r
- */\r
-public class SAXNotRecognizedException extends SAXException\r
-{\r
-\r
- /**\r
- * Construct a new exception with the given message.\r
- *\r
- * @param message The text message of the exception.\r
- */\r
- public SAXNotRecognizedException (String message)\r
- {\r
- super(message);\r
- }\r
-\r
-}\r
-\r
-// end of SAXNotRecognizedException.java\r
+// SAXNotRecognizedException.java - unrecognized feature or value.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: SAXNotRecognizedException.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+
+package org.xml.sax;
+
+
+/**
+ * Exception class for an unrecognized identifier.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>An XMLReader will throw this exception when it finds an
+ * unrecognized feature or property identifier; SAX applications and
+ * extensions may use this class for other, similar purposes.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.SAXNotSupportedException
+ */
+public class SAXNotRecognizedException extends SAXException
+{
+
+ /**
+ * Default constructor.
+ */
+ public SAXNotRecognizedException ()
+ {
+ super();
+ }
+
+
+ /**
+ * Construct a new exception with the given message.
+ *
+ * @param message The text message of the exception.
+ */
+ public SAXNotRecognizedException (String message)
+ {
+ super(message);
+ }
+
+}
+
+// end of SAXNotRecognizedException.java
-// SAXNotSupportedException.java - unsupported feature or value.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: SAXNotSupportedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Exception class for an unsupported operation.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>An XMLReader will throw this exception when it recognizes a\r
- * feature or property identifier, but cannot perform the requested\r
- * operation (setting a state or value). Other SAX2 applications and\r
- * extensions may use this class for similar purposes.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.SAXNotRecognizedException \r
- */\r
-public class SAXNotSupportedException extends SAXException\r
-{\r
-\r
- /**\r
- * Construct a new exception with the given message.\r
- *\r
- * @param message The text message of the exception.\r
- */\r
- public SAXNotSupportedException (String message)\r
- {\r
- super(message);\r
- }\r
-\r
-}\r
-\r
-// end of SAXNotSupportedException.java\r
+// SAXNotSupportedException.java - unsupported feature or value.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: SAXNotSupportedException.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+
+package org.xml.sax;
+
+/**
+ * Exception class for an unsupported operation.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>An XMLReader will throw this exception when it recognizes a
+ * feature or property identifier, but cannot perform the requested
+ * operation (setting a state or value). Other SAX2 applications and
+ * extensions may use this class for similar purposes.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.SAXNotRecognizedException
+ */
+public class SAXNotSupportedException extends SAXException
+{
+
+ /**
+ * Construct a new exception with no message.
+ */
+ public SAXNotSupportedException ()
+ {
+ super();
+ }
+
+
+ /**
+ * Construct a new exception with the given message.
+ *
+ * @param message The text message of the exception.
+ */
+ public SAXNotSupportedException (String message)
+ {
+ super(message);
+ }
+
+}
+
+// end of SAXNotSupportedException.java
-// SAX exception class.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: SAXParseException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-/**\r
- * Encapsulate an XML parse error or warning.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This exception will include information for locating the error\r
- * in the original XML document. Note that although the application\r
- * will receive a SAXParseException as the argument to the handlers\r
- * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface, \r
- * the application is not actually required to throw the exception; \r
- * instead, it can simply read the information in it and take a \r
- * different action.</p>\r
- *\r
- * <p>Since this exception is a subclass of {@link org.xml.sax.SAXException \r
- * SAXException}, it inherits the ability to wrap another exception.</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.SAXException\r
- * @see org.xml.sax.Locator\r
- * @see org.xml.sax.ErrorHandler\r
- */\r
-public class SAXParseException extends SAXException {\r
- \r
- \f\r
- //////////////////////////////////////////////////////////////////////\r
- // Constructors.\r
- //////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Create a new SAXParseException from a message and a Locator.\r
- *\r
- * <p>This constructor is especially useful when an application is\r
- * creating its own exception from within a {@link org.xml.sax.ContentHandler\r
- * ContentHandler} callback.</p>\r
- *\r
- * @param message The error or warning message.\r
- * @param locator The locator object for the error or warning (may be\r
- * null).\r
- * @see org.xml.sax.Locator\r
- * @see org.xml.sax.Parser#setLocale \r
- */\r
- public SAXParseException (String message, Locator locator) {\r
- super(message);\r
- if (locator != null) {\r
- init(locator.getPublicId(), locator.getSystemId(),\r
- locator.getLineNumber(), locator.getColumnNumber());\r
- } else {\r
- init(null, null, -1, -1);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Wrap an existing exception in a SAXParseException.\r
- *\r
- * <p>This constructor is especially useful when an application is\r
- * creating its own exception from within a {@link org.xml.sax.ContentHandler\r
- * ContentHandler} callback, and needs to wrap an existing exception that is not a\r
- * subclass of {@link org.xml.sax.SAXException SAXException}.</p>\r
- *\r
- * @param message The error or warning message, or null to\r
- * use the message from the embedded exception.\r
- * @param locator The locator object for the error or warning (may be\r
- * null).\r
- * @param e Any exception.\r
- * @see org.xml.sax.Locator\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public SAXParseException (String message, Locator locator,\r
- Exception e) {\r
- super(message, e);\r
- if (locator != null) {\r
- init(locator.getPublicId(), locator.getSystemId(),\r
- locator.getLineNumber(), locator.getColumnNumber());\r
- } else {\r
- init(null, null, -1, -1);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAXParseException.\r
- *\r
- * <p>This constructor is most useful for parser writers.</p>\r
- *\r
- * <p>If the system identifier is a URL, the parser must resolve it\r
- * fully before creating the exception.</p>\r
- *\r
- * @param message The error or warning message.\r
- * @param publicId The public identifier of the entity that generated\r
- * the error or warning.\r
- * @param systemId The system identifier of the entity that generated\r
- * the error or warning.\r
- * @param lineNumber The line number of the end of the text that\r
- * caused the error or warning.\r
- * @param columnNumber The column number of the end of the text that\r
- * cause the error or warning.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public SAXParseException (String message, String publicId, String systemId,\r
- int lineNumber, int columnNumber)\r
- {\r
- super(message);\r
- init(publicId, systemId, lineNumber, columnNumber);\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAXParseException with an embedded exception.\r
- *\r
- * <p>This constructor is most useful for parser writers who\r
- * need to wrap an exception that is not a subclass of\r
- * {@link org.xml.sax.SAXException SAXException}.</p>\r
- *\r
- * <p>If the system identifier is a URL, the parser must resolve it\r
- * fully before creating the exception.</p>\r
- *\r
- * @param message The error or warning message, or null to use\r
- * the message from the embedded exception.\r
- * @param publicId The public identifier of the entity that generated\r
- * the error or warning.\r
- * @param systemId The system identifier of the entity that generated\r
- * the error or warning.\r
- * @param lineNumber The line number of the end of the text that\r
- * caused the error or warning.\r
- * @param columnNumber The column number of the end of the text that\r
- * cause the error or warning.\r
- * @param e Another exception to embed in this one.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public SAXParseException (String message, String publicId, String systemId,\r
- int lineNumber, int columnNumber, Exception e)\r
- {\r
- super(message, e);\r
- init(publicId, systemId, lineNumber, columnNumber);\r
- }\r
-\r
-\r
- /**\r
- * Internal initialization method.\r
- *\r
- * @param publicId The public identifier of the entity which generated the exception,\r
- * or null.\r
- * @param systemId The system identifier of the entity which generated the exception,\r
- * or null.\r
- * @param lineNumber The line number of the error, or -1.\r
- * @param columnNumber The column number of the error, or -1.\r
- */\r
- private void init (String publicId, String systemId,\r
- int lineNumber, int columnNumber)\r
- {\r
- this.publicId = publicId;\r
- this.systemId = systemId;\r
- this.lineNumber = lineNumber;\r
- this.columnNumber = columnNumber;\r
- }\r
- \r
- \r
- /**\r
- * Get the public identifier of the entity where the exception occurred.\r
- *\r
- * @return A string containing the public identifier, or null\r
- * if none is available.\r
- * @see org.xml.sax.Locator#getPublicId\r
- */\r
- public String getPublicId ()\r
- {\r
- return this.publicId;\r
- }\r
- \r
- \r
- /**\r
- * Get the system identifier of the entity where the exception occurred.\r
- *\r
- * <p>If the system identifier is a URL, it will be resolved\r
- * fully.</p>\r
- *\r
- * @return A string containing the system identifier, or null\r
- * if none is available.\r
- * @see org.xml.sax.Locator#getSystemId\r
- */\r
- public String getSystemId ()\r
- {\r
- return this.systemId;\r
- }\r
- \r
- \r
- /**\r
- * The line number of the end of the text where the exception occurred.\r
- *\r
- * @return An integer representing the line number, or -1\r
- * if none is available.\r
- * @see org.xml.sax.Locator#getLineNumber\r
- */\r
- public int getLineNumber ()\r
- {\r
- return this.lineNumber;\r
- }\r
- \r
- \r
- /**\r
- * The column number of the end of the text where the exception occurred.\r
- *\r
- * <p>The first column in a line is position 1.</p>\r
- *\r
- * @return An integer representing the column number, or -1\r
- * if none is available.\r
- * @see org.xml.sax.Locator#getColumnNumber\r
- */\r
- public int getColumnNumber ()\r
- {\r
- return this.columnNumber;\r
- }\r
- \r
- \r
- \f\r
- //////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- //////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * @serial The public identifier, or null.\r
- * @see #getPublicId\r
- */ \r
- private String publicId;\r
-\r
-\r
- /**\r
- * @serial The system identifier, or null.\r
- * @see #getSystemId\r
- */\r
- private String systemId;\r
-\r
-\r
- /**\r
- * @serial The line number, or -1.\r
- * @see #getLineNumber\r
- */\r
- private int lineNumber;\r
-\r
-\r
- /**\r
- * @serial The column number, or -1.\r
- * @see #getColumnNumber\r
- */\r
- private int columnNumber;\r
- \r
-}\r
-\r
-// end of SAXParseException.java\r
+// SAX exception class.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: SAXParseException.java,v 1.3.2.5 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+/**
+ * Encapsulate an XML parse error or warning.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This exception may include information for locating the error
+ * in the original XML document, as if it came from a {@link Locator}
+ * object. Note that although the application
+ * will receive a SAXParseException as the argument to the handlers
+ * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface,
+ * the application is not actually required to throw the exception;
+ * instead, it can simply read the information in it and take a
+ * different action.</p>
+ *
+ * <p>Since this exception is a subclass of {@link org.xml.sax.SAXException
+ * SAXException}, it inherits the ability to wrap another exception.</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.SAXException
+ * @see org.xml.sax.Locator
+ * @see org.xml.sax.ErrorHandler
+ */
+public class SAXParseException extends SAXException {
+
+ \f
+ //////////////////////////////////////////////////////////////////////
+ // Constructors.
+ //////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Create a new SAXParseException from a message and a Locator.
+ *
+ * <p>This constructor is especially useful when an application is
+ * creating its own exception from within a {@link org.xml.sax.ContentHandler
+ * ContentHandler} callback.</p>
+ *
+ * @param message The error or warning message.
+ * @param locator The locator object for the error or warning (may be
+ * null).
+ * @see org.xml.sax.Locator
+ */
+ public SAXParseException (String message, Locator locator) {
+ super(message);
+ if (locator != null) {
+ init(locator.getPublicId(), locator.getSystemId(),
+ locator.getLineNumber(), locator.getColumnNumber());
+ } else {
+ init(null, null, -1, -1);
+ }
+ }
+
+
+ /**
+ * Wrap an existing exception in a SAXParseException.
+ *
+ * <p>This constructor is especially useful when an application is
+ * creating its own exception from within a {@link org.xml.sax.ContentHandler
+ * ContentHandler} callback, and needs to wrap an existing exception that is not a
+ * subclass of {@link org.xml.sax.SAXException SAXException}.</p>
+ *
+ * @param message The error or warning message, or null to
+ * use the message from the embedded exception.
+ * @param locator The locator object for the error or warning (may be
+ * null).
+ * @param e Any exception.
+ * @see org.xml.sax.Locator
+ */
+ public SAXParseException (String message, Locator locator,
+ Exception e) {
+ super(message, e);
+ if (locator != null) {
+ init(locator.getPublicId(), locator.getSystemId(),
+ locator.getLineNumber(), locator.getColumnNumber());
+ } else {
+ init(null, null, -1, -1);
+ }
+ }
+
+
+ /**
+ * Create a new SAXParseException.
+ *
+ * <p>This constructor is most useful for parser writers.</p>
+ *
+ * <p>All parameters except the message are as if
+ * they were provided by a {@link Locator}. For example, if the
+ * system identifier is a URL (including relative filename), the
+ * caller must resolve it fully before creating the exception.</p>
+ *
+ *
+ * @param message The error or warning message.
+ * @param publicId The public identifer of the entity that generated
+ * the error or warning.
+ * @param systemId The system identifer of the entity that generated
+ * the error or warning.
+ * @param lineNumber The line number of the end of the text that
+ * caused the error or warning.
+ * @param columnNumber The column number of the end of the text that
+ * cause the error or warning.
+ */
+ public SAXParseException (String message, String publicId, String systemId,
+ int lineNumber, int columnNumber)
+ {
+ super(message);
+ init(publicId, systemId, lineNumber, columnNumber);
+ }
+
+
+ /**
+ * Create a new SAXParseException with an embedded exception.
+ *
+ * <p>This constructor is most useful for parser writers who
+ * need to wrap an exception that is not a subclass of
+ * {@link org.xml.sax.SAXException SAXException}.</p>
+ *
+ * <p>All parameters except the message and exception are as if
+ * they were provided by a {@link Locator}. For example, if the
+ * system identifier is a URL (including relative filename), the
+ * caller must resolve it fully before creating the exception.</p>
+ *
+ * @param message The error or warning message, or null to use
+ * the message from the embedded exception.
+ * @param publicId The public identifer of the entity that generated
+ * the error or warning.
+ * @param systemId The system identifer of the entity that generated
+ * the error or warning.
+ * @param lineNumber The line number of the end of the text that
+ * caused the error or warning.
+ * @param columnNumber The column number of the end of the text that
+ * cause the error or warning.
+ * @param e Another exception to embed in this one.
+ */
+ public SAXParseException (String message, String publicId, String systemId,
+ int lineNumber, int columnNumber, Exception e)
+ {
+ super(message, e);
+ init(publicId, systemId, lineNumber, columnNumber);
+ }
+
+
+ /**
+ * Internal initialization method.
+ *
+ * @param publicId The public identifier of the entity which generated the exception,
+ * or null.
+ * @param systemId The system identifier of the entity which generated the exception,
+ * or null.
+ * @param lineNumber The line number of the error, or -1.
+ * @param columnNumber The column number of the error, or -1.
+ */
+ private void init (String publicId, String systemId,
+ int lineNumber, int columnNumber)
+ {
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.lineNumber = lineNumber;
+ this.columnNumber = columnNumber;
+ }
+
+
+ /**
+ * Get the public identifier of the entity where the exception occurred.
+ *
+ * @return A string containing the public identifier, or null
+ * if none is available.
+ * @see org.xml.sax.Locator#getPublicId
+ */
+ public String getPublicId ()
+ {
+ return this.publicId;
+ }
+
+
+ /**
+ * Get the system identifier of the entity where the exception occurred.
+ *
+ * <p>If the system identifier is a URL, it will have been resolved
+ * fully.</p>
+ *
+ * @return A string containing the system identifier, or null
+ * if none is available.
+ * @see org.xml.sax.Locator#getSystemId
+ */
+ public String getSystemId ()
+ {
+ return this.systemId;
+ }
+
+
+ /**
+ * The line number of the end of the text where the exception occurred.
+ *
+ * <p>The first line is line 1.</p>
+ *
+ * @return An integer representing the line number, or -1
+ * if none is available.
+ * @see org.xml.sax.Locator#getLineNumber
+ */
+ public int getLineNumber ()
+ {
+ return this.lineNumber;
+ }
+
+
+ /**
+ * The column number of the end of the text where the exception occurred.
+ *
+ * <p>The first column in a line is position 1.</p>
+ *
+ * @return An integer representing the column number, or -1
+ * if none is available.
+ * @see org.xml.sax.Locator#getColumnNumber
+ */
+ public int getColumnNumber ()
+ {
+ return this.columnNumber;
+ }
+
+
+ \f
+ //////////////////////////////////////////////////////////////////////
+ // Internal state.
+ //////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * @serial The public identifier, or null.
+ * @see #getPublicId
+ */
+ private String publicId;
+
+
+ /**
+ * @serial The system identifier, or null.
+ * @see #getSystemId
+ */
+ private String systemId;
+
+
+ /**
+ * @serial The line number, or -1.
+ * @see #getLineNumber
+ */
+ private int lineNumber;
+
+
+ /**
+ * @serial The column number, or -1.
+ * @see #getColumnNumber
+ */
+ private int columnNumber;
+
+}
+
+// end of SAXParseException.java
-// XMLFilter.java - filter SAX2 events.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: XMLFilter.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-\r
-package org.xml.sax;\r
-\r
-\r
-/**\r
- * Interface for an XML filter.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>An XML filter is like an XML reader, except that it obtains its\r
- * events from another XML reader rather than a primary source like\r
- * an XML document or database. Filters can modify a stream of\r
- * events as they pass on to the final application.</p>\r
- *\r
- * <p>The XMLFilterImpl helper class provides a convenient base\r
- * for creating SAX2 filters, by passing on all {@link org.xml.sax.EntityResolver\r
- * EntityResolver}, {@link org.xml.sax.DTDHandler DTDHandler},\r
- * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler\r
- * ErrorHandler} events automatically.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.helpers.XMLFilterImpl\r
- */\r
-public interface XMLFilter extends XMLReader\r
-{\r
-\r
- /**\r
- * Set the parent reader.\r
- *\r
- * <p>This method allows the application to link the filter to\r
- * a parent reader (which may be another filter). The argument\r
- * may not be null.</p>\r
- *\r
- * @param parent The parent reader.\r
- */\r
- public abstract void setParent (XMLReader parent);\r
-\r
-\r
- /**\r
- * Get the parent reader.\r
- *\r
- * <p>This method allows the application to query the parent\r
- * reader (which may be another filter). It is generally a\r
- * bad idea to perform any operations on the parent reader\r
- * directly: they should all pass through this filter.</p>\r
- *\r
- * @return The parent filter, or null if none has been set.\r
- */\r
- public abstract XMLReader getParent ();\r
-\r
-}\r
-\r
-// end of XMLFilter.java\r
+// XMLFilter.java - filter SAX2 events.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: XMLFilter.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+
+package org.xml.sax;
+
+
+/**
+ * Interface for an XML filter.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>An XML filter is like an XML reader, except that it obtains its
+ * events from another XML reader rather than a primary source like
+ * an XML document or database. Filters can modify a stream of
+ * events as they pass on to the final application.</p>
+ *
+ * <p>The XMLFilterImpl helper class provides a convenient base
+ * for creating SAX2 filters, by passing on all {@link org.xml.sax.EntityResolver
+ * EntityResolver}, {@link org.xml.sax.DTDHandler DTDHandler},
+ * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler
+ * ErrorHandler} events automatically.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.helpers.XMLFilterImpl
+ */
+public interface XMLFilter extends XMLReader
+{
+
+ /**
+ * Set the parent reader.
+ *
+ * <p>This method allows the application to link the filter to
+ * a parent reader (which may be another filter). The argument
+ * may not be null.</p>
+ *
+ * @param parent The parent reader.
+ */
+ public abstract void setParent (XMLReader parent);
+
+
+ /**
+ * Get the parent reader.
+ *
+ * <p>This method allows the application to query the parent
+ * reader (which may be another filter). It is generally a
+ * bad idea to perform any operations on the parent reader
+ * directly: they should all pass through this filter.</p>
+ *
+ * @return The parent filter, or null if none has been set.
+ */
+ public abstract XMLReader getParent ();
+
+}
+
+// end of XMLFilter.java
-// XMLReader.java - read an XML document.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: XMLReader.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-import java.io.IOException;\r
-\r
-\r
-/**\r
- * Interface for reading an XML document using callbacks.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p><strong>Note:</strong> despite its name, this interface does \r
- * <em>not</em> extend the standard Java {@link java.io.Reader Reader} \r
- * interface, because reading XML is a fundamentally different activity \r
- * than reading character data.</p>\r
- *\r
- * <p>XMLReader is the interface that an XML parser's SAX2 driver must\r
- * implement. This interface allows an application to set and\r
- * query features and properties in the parser, to register\r
- * event handlers for document processing, and to initiate\r
- * a document parse.</p>\r
- *\r
- * <p>All SAX interfaces are assumed to be synchronous: the\r
- * {@link #parse parse} methods must not return until parsing\r
- * is complete, and readers must wait for an event-handler callback\r
- * to return before reporting the next event.</p>\r
- *\r
- * <p>This interface replaces the (now deprecated) SAX 1.0 {@link\r
- * org.xml.sax.Parser Parser} interface. The XMLReader interface\r
- * contains two important enhancements over the old Parser\r
- * interface:</p>\r
- *\r
- * <ol>\r
- * <li>it adds a standard way to query and set features and \r
- * properties; and</li>\r
- * <li>it adds Namespace support, which is required for many\r
- * higher-level XML standards.</li>\r
- * </ol>\r
- *\r
- * <p>There are adapters available to convert a SAX1 Parser to\r
- * a SAX2 XMLReader and vice-versa.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.XMLFilter\r
- * @see org.xml.sax.helpers.ParserAdapter\r
- * @see org.xml.sax.helpers.XMLReaderAdapter \r
- */\r
-public interface XMLReader\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Configuration.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Look up the value of a feature.\r
- *\r
- * <p>The feature name is any fully-qualified URI. It is\r
- * possible for an XMLReader to recognize a feature name but\r
- * to be unable to return its value; this is especially true\r
- * in the case of an adapter for a SAX1 Parser, which has\r
- * no way of knowing whether the underlying parser is\r
- * performing validation or expanding external entities.</p>\r
- *\r
- * <p>All XMLReaders are required to recognize the\r
- * http://xml.org/sax/features/namespaces and the\r
- * http://xml.org/sax/features/namespace-prefixes feature names.</p>\r
- *\r
- * <p>Some feature values may be available only in specific\r
- * contexts, such as before, during, or after a parse.</p>\r
- *\r
- * <p>Typical usage is something like this:</p>\r
- *\r
- * <pre>\r
- * XMLReader r = new MySAXDriver();\r
- *\r
- * // try to activate validation\r
- * try {\r
- * r.setFeature("http://xml.org/sax/features/validation", true);\r
- * } catch (SAXException e) {\r
- * System.err.println("Cannot activate validation."); \r
- * }\r
- *\r
- * // register event handlers\r
- * r.setContentHandler(new MyContentHandler());\r
- * r.setErrorHandler(new MyErrorHandler());\r
- *\r
- * // parse the first document\r
- * try {\r
- * r.parse("http://www.foo.com/mydoc.xml");\r
- * } catch (IOException e) {\r
- * System.err.println("I/O exception reading XML document");\r
- * } catch (SAXException e) {\r
- * System.err.println("XML exception reading document.");\r
- * }\r
- * </pre>\r
- *\r
- * <p>Implementors are free (and encouraged) to invent their own features,\r
- * using names built on their own URIs.</p>\r
- *\r
- * @param name The feature name, which is a fully-qualified URI.\r
- * @return The current state of the feature (true or false).\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the feature name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the feature name but \r
- * cannot determine its value at this time.\r
- * @see #setFeature\r
- */\r
- public boolean getFeature (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException;\r
-\r
-\r
- /**\r
- * Set the state of a feature.\r
- *\r
- * <p>The feature name is any fully-qualified URI. It is\r
- * possible for an XMLReader to recognize a feature name but\r
- * to be unable to set its value; this is especially true\r
- * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},\r
- * which has no way of affecting whether the underlying parser is\r
- * validating, for example.</p>\r
- *\r
- * <p>All XMLReaders are required to support setting\r
- * http://xml.org/sax/features/namespaces to true and\r
- * http://xml.org/sax/features/namespace-prefixes to false.</p>\r
- *\r
- * <p>Some feature values may be immutable or mutable only \r
- * in specific contexts, such as before, during, or after \r
- * a parse.</p>\r
- *\r
- * @param name The feature name, which is a fully-qualified URI.\r
- * @param state The requested state of the feature (true or false).\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the feature name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the feature name but \r
- * cannot set the requested value.\r
- * @see #getFeature\r
- */\r
- public void setFeature (String name, boolean value)\r
- throws SAXNotRecognizedException, SAXNotSupportedException;\r
-\r
-\r
- /**\r
- * Look up the value of a property.\r
- *\r
- * <p>The property name is any fully-qualified URI. It is\r
- * possible for an XMLReader to recognize a property name but\r
- * to be unable to return its state; this is especially true\r
- * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser\r
- * Parser}.</p>\r
- *\r
- * <p>XMLReaders are not required to recognize any specific\r
- * property names, though an initial core set is documented for\r
- * SAX2.</p>\r
- *\r
- * <p>Some property values may be available only in specific\r
- * contexts, such as before, during, or after a parse.</p>\r
- *\r
- * <p>Implementors are free (and encouraged) to invent their own properties,\r
- * using names built on their own URIs.</p>\r
- *\r
- * @param name The property name, which is a fully-qualified URI.\r
- * @return The current value of the property.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the property name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the property name but \r
- * cannot determine its value at this time.\r
- * @see #setProperty\r
- */\r
- public Object getProperty (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException;\r
-\r
-\r
- /**\r
- * Set the value of a property.\r
- *\r
- * <p>The property name is any fully-qualified URI. It is\r
- * possible for an XMLReader to recognize a property name but\r
- * to be unable to set its value; this is especially true\r
- * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser\r
- * Parser}.</p>\r
- *\r
- * <p>XMLReaders are not required to recognize setting\r
- * any specific property names, though a core set is provided with \r
- * SAX2.</p>\r
- *\r
- * <p>Some property values may be immutable or mutable only \r
- * in specific contexts, such as before, during, or after \r
- * a parse.</p>\r
- *\r
- * <p>This method is also the standard mechanism for setting\r
- * extended handlers.</p>\r
- *\r
- * @param name The property name, which is a fully-qualified URI.\r
- * @param state The requested value for the property.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the property name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the property name but \r
- * cannot set the requested value.\r
- */\r
- public void setProperty (String name, Object value)\r
- throws SAXNotRecognizedException, SAXNotSupportedException;\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Event handlers.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Allow an application to register an entity resolver.\r
- *\r
- * <p>If the application does not register an entity resolver,\r
- * the XMLReader will perform its own default resolution.</p>\r
- *\r
- * <p>Applications may register a new or different resolver in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * resolver immediately.</p>\r
- *\r
- * @param resolver The entity resolver.\r
- * @exception java.lang.NullPointerException If the resolver \r
- * argument is null.\r
- * @see #getEntityResolver\r
- */\r
- public void setEntityResolver (EntityResolver resolver);\r
-\r
-\r
- /**\r
- * Return the current entity resolver.\r
- *\r
- * @return The current entity resolver, or null if none\r
- * has been registered.\r
- * @see #setEntityResolver\r
- */\r
- public EntityResolver getEntityResolver ();\r
-\r
-\r
- /**\r
- * Allow an application to register a DTD event handler.\r
- *\r
- * <p>If the application does not register a DTD handler, all DTD\r
- * events reported by the SAX parser will be silently ignored.</p>\r
- *\r
- * <p>Applications may register a new or different handler in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * handler immediately.</p>\r
- *\r
- * @param handler The DTD handler.\r
- * @exception java.lang.NullPointerException If the handler \r
- * argument is null.\r
- * @see #getDTDHandler\r
- */\r
- public void setDTDHandler (DTDHandler handler);\r
-\r
-\r
- /**\r
- * Return the current DTD handler.\r
- *\r
- * @return The current DTD handler, or null if none\r
- * has been registered.\r
- * @see #setDTDHandler\r
- */\r
- public DTDHandler getDTDHandler ();\r
-\r
-\r
- /**\r
- * Allow an application to register a content event handler.\r
- *\r
- * <p>If the application does not register a content handler, all\r
- * content events reported by the SAX parser will be silently\r
- * ignored.</p>\r
- *\r
- * <p>Applications may register a new or different handler in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * handler immediately.</p>\r
- *\r
- * @param handler The content handler.\r
- * @exception java.lang.NullPointerException If the handler \r
- * argument is null.\r
- * @see #getContentHandler\r
- */\r
- public void setContentHandler (ContentHandler handler);\r
-\r
-\r
- /**\r
- * Return the current content handler.\r
- *\r
- * @return The current content handler, or null if none\r
- * has been registered.\r
- * @see #setContentHandler\r
- */\r
- public ContentHandler getContentHandler ();\r
-\r
-\r
- /**\r
- * Allow an application to register an error event handler.\r
- *\r
- * <p>If the application does not register an error handler, all\r
- * error events reported by the SAX parser will be silently\r
- * ignored; however, normal processing may not continue. It is\r
- * highly recommended that all SAX applications implement an\r
- * error handler to avoid unexpected bugs.</p>\r
- *\r
- * <p>Applications may register a new or different handler in the\r
- * middle of a parse, and the SAX parser must begin using the new\r
- * handler immediately.</p>\r
- *\r
- * @param handler The error handler.\r
- * @exception java.lang.NullPointerException If the handler \r
- * argument is null.\r
- * @see #getErrorHandler\r
- */\r
- public void setErrorHandler (ErrorHandler handler);\r
-\r
-\r
- /**\r
- * Return the current error handler.\r
- *\r
- * @return The current error handler, or null if none\r
- * has been registered.\r
- * @see #setErrorHandler\r
- */\r
- public ErrorHandler getErrorHandler ();\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Parsing.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- /**\r
- * Parse an XML document.\r
- *\r
- * <p>The application can use this method to instruct the XML\r
- * reader to begin parsing an XML document from any valid input\r
- * source (a character stream, a byte stream, or a URI).</p>\r
- *\r
- * <p>Applications may not invoke this method while a parse is in\r
- * progress (they should create a new XMLReader instead for each\r
- * nested XML document). Once a parse is complete, an\r
- * application may reuse the same XMLReader object, possibly with a\r
- * different input source.</p>\r
- *\r
- * <p>During the parse, the XMLReader will provide information\r
- * about the XML document through the registered event\r
- * handlers.</p>\r
- *\r
- * <p>This method is synchronous: it will not return until parsing\r
- * has ended. If a client application wants to terminate \r
- * parsing early, it should throw an exception.</p>\r
- *\r
- * @param source The input source for the top-level of the\r
- * XML document.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see org.xml.sax.InputSource\r
- * @see #parse(java.lang.String)\r
- * @see #setEntityResolver\r
- * @see #setDTDHandler\r
- * @see #setContentHandler\r
- * @see #setErrorHandler \r
- */\r
- public void parse (InputSource input)\r
- throws IOException, SAXException;\r
-\r
-\r
- /**\r
- * Parse an XML document from a system identifier (URI).\r
- *\r
- * <p>This method is a shortcut for the common case of reading a\r
- * document from a system identifier. It is the exact\r
- * equivalent of the following:</p>\r
- *\r
- * <pre>\r
- * parse(new InputSource(systemId));\r
- * </pre>\r
- *\r
- * <p>If the system identifier is a URL, it must be fully resolved\r
- * by the application before it is passed to the parser.</p>\r
- *\r
- * @param systemId The system identifier (URI).\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see #parse(org.xml.sax.InputSource)\r
- */\r
- public void parse (String systemId)\r
- throws IOException, SAXException;\r
-\r
-}\r
-\r
-// end of XMLReader.java\r
+// XMLReader.java - read an XML document.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: XMLReader.java,v 1.3.2.5 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax;
+
+import java.io.IOException;
+
+
+/**
+ * Interface for reading an XML document using callbacks.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p><strong>Note:</strong> despite its name, this interface does
+ * <em>not</em> extend the standard Java {@link java.io.Reader Reader}
+ * interface, because reading XML is a fundamentally different activity
+ * than reading character data.</p>
+ *
+ * <p>XMLReader is the interface that an XML parser's SAX2 driver must
+ * implement. This interface allows an application to set and
+ * query features and properties in the parser, to register
+ * event handlers for document processing, and to initiate
+ * a document parse.</p>
+ *
+ * <p>All SAX interfaces are assumed to be synchronous: the
+ * {@link #parse parse} methods must not return until parsing
+ * is complete, and readers must wait for an event-handler callback
+ * to return before reporting the next event.</p>
+ *
+ * <p>This interface replaces the (now deprecated) SAX 1.0 {@link
+ * org.xml.sax.Parser Parser} interface. The XMLReader interface
+ * contains two important enhancements over the old Parser
+ * interface (as well as some minor ones):</p>
+ *
+ * <ol>
+ * <li>it adds a standard way to query and set features and
+ * properties; and</li>
+ * <li>it adds Namespace support, which is required for many
+ * higher-level XML standards.</li>
+ * </ol>
+ *
+ * <p>There are adapters available to convert a SAX1 Parser to
+ * a SAX2 XMLReader and vice-versa.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLFilter
+ * @see org.xml.sax.helpers.ParserAdapter
+ * @see org.xml.sax.helpers.XMLReaderAdapter
+ */
+public interface XMLReader
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Configuration.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Look up the value of a feature flag.
+ *
+ * <p>The feature name is any fully-qualified URI. It is
+ * possible for an XMLReader to recognize a feature name but
+ * temporarily be unable to return its value.
+ * Some feature values may be available only in specific
+ * contexts, such as before, during, or after a parse.
+ * Also, some feature values may not be programmatically accessible.
+ * (In the case of an adapter for SAX1 {@link Parser}, there is no
+ * implementation-independent way to expose whether the underlying
+ * parser is performing validation, expanding external entities,
+ * and so forth.) </p>
+ *
+ * <p>All XMLReaders are required to recognize the
+ * http://xml.org/sax/features/namespaces and the
+ * http://xml.org/sax/features/namespace-prefixes feature names.</p>
+ *
+ * <p>Typical usage is something like this:</p>
+ *
+ * <pre>
+ * XMLReader r = new MySAXDriver();
+ *
+ * // try to activate validation
+ * try {
+ * r.setFeature("http://xml.org/sax/features/validation", true);
+ * } catch (SAXException e) {
+ * System.err.println("Cannot activate validation.");
+ * }
+ *
+ * // register event handlers
+ * r.setContentHandler(new MyContentHandler());
+ * r.setErrorHandler(new MyErrorHandler());
+ *
+ * // parse the first document
+ * try {
+ * r.parse("http://www.foo.com/mydoc.xml");
+ * } catch (IOException e) {
+ * System.err.println("I/O exception reading XML document");
+ * } catch (SAXException e) {
+ * System.err.println("XML exception reading document.");
+ * }
+ * </pre>
+ *
+ * <p>Implementors are free (and encouraged) to invent their own features,
+ * using names built on their own URIs.</p>
+ *
+ * @param name The feature name, which is a fully-qualified URI.
+ * @return The current value of the feature (true or false).
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the feature name but
+ * cannot determine its value at this time.
+ * @see #setFeature
+ */
+ public boolean getFeature (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+
+ /**
+ * Set the value of a feature flag.
+ *
+ * <p>The feature name is any fully-qualified URI. It is
+ * possible for an XMLReader to expose a feature value but
+ * to be unable to change the current value.
+ * Some feature values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a parse.</p>
+ *
+ * <p>All XMLReaders are required to support setting
+ * http://xml.org/sax/features/namespaces to true and
+ * http://xml.org/sax/features/namespace-prefixes to false.</p>
+ *
+ * @param name The feature name, which is a fully-qualified URI.
+ * @param value The requested value of the feature (true or false).
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the feature name but
+ * cannot set the requested value.
+ * @see #getFeature
+ */
+ public void setFeature (String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+
+ /**
+ * Look up the value of a property.
+ *
+ * <p>The property name is any fully-qualified URI. It is
+ * possible for an XMLReader to recognize a property name but
+ * temporarily be unable to return its value.
+ * Some property values may be available only in specific
+ * contexts, such as before, during, or after a parse.</p>
+ *
+ * <p>XMLReaders are not required to recognize any specific
+ * property names, though an initial core set is documented for
+ * SAX2.</p>
+ *
+ * <p>Implementors are free (and encouraged) to invent their own properties,
+ * using names built on their own URIs.</p>
+ *
+ * @param name The property name, which is a fully-qualified URI.
+ * @return The current value of the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the property name but
+ * cannot determine its value at this time.
+ * @see #setProperty
+ */
+ public Object getProperty (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+
+ /**
+ * Set the value of a property.
+ *
+ * <p>The property name is any fully-qualified URI. It is
+ * possible for an XMLReader to recognize a property name but
+ * to be unable to change the current value.
+ * Some property values may be immutable or mutable only
+ * in specific contexts, such as before, during, or after
+ * a parse.</p>
+ *
+ * <p>XMLReaders are not required to recognize setting
+ * any specific property names, though a core set is defined by
+ * SAX2.</p>
+ *
+ * <p>This method is also the standard mechanism for setting
+ * extended handlers.</p>
+ *
+ * @param name The property name, which is a fully-qualified URI.
+ * @param value The requested value for the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * XMLReader recognizes the property name but
+ * cannot set the requested value.
+ */
+ public void setProperty (String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Event handlers.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Allow an application to register an entity resolver.
+ *
+ * <p>If the application does not register an entity resolver,
+ * the XMLReader will perform its own default resolution.</p>
+ *
+ * <p>Applications may register a new or different resolver in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * resolver immediately.</p>
+ *
+ * @param resolver The entity resolver.
+ * @see #getEntityResolver
+ */
+ public void setEntityResolver (EntityResolver resolver);
+
+
+ /**
+ * Return the current entity resolver.
+ *
+ * @return The current entity resolver, or null if none
+ * has been registered.
+ * @see #setEntityResolver
+ */
+ public EntityResolver getEntityResolver ();
+
+
+ /**
+ * Allow an application to register a DTD event handler.
+ *
+ * <p>If the application does not register a DTD handler, all DTD
+ * events reported by the SAX parser will be silently ignored.</p>
+ *
+ * <p>Applications may register a new or different handler in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * handler immediately.</p>
+ *
+ * @param handler The DTD handler.
+ * @see #getDTDHandler
+ */
+ public void setDTDHandler (DTDHandler handler);
+
+
+ /**
+ * Return the current DTD handler.
+ *
+ * @return The current DTD handler, or null if none
+ * has been registered.
+ * @see #setDTDHandler
+ */
+ public DTDHandler getDTDHandler ();
+
+
+ /**
+ * Allow an application to register a content event handler.
+ *
+ * <p>If the application does not register a content handler, all
+ * content events reported by the SAX parser will be silently
+ * ignored.</p>
+ *
+ * <p>Applications may register a new or different handler in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * handler immediately.</p>
+ *
+ * @param handler The content handler.
+ * @see #getContentHandler
+ */
+ public void setContentHandler (ContentHandler handler);
+
+
+ /**
+ * Return the current content handler.
+ *
+ * @return The current content handler, or null if none
+ * has been registered.
+ * @see #setContentHandler
+ */
+ public ContentHandler getContentHandler ();
+
+
+ /**
+ * Allow an application to register an error event handler.
+ *
+ * <p>If the application does not register an error handler, all
+ * error events reported by the SAX parser will be silently
+ * ignored; however, normal processing may not continue. It is
+ * highly recommended that all SAX applications implement an
+ * error handler to avoid unexpected bugs.</p>
+ *
+ * <p>Applications may register a new or different handler in the
+ * middle of a parse, and the SAX parser must begin using the new
+ * handler immediately.</p>
+ *
+ * @param handler The error handler.
+ * @see #getErrorHandler
+ */
+ public void setErrorHandler (ErrorHandler handler);
+
+
+ /**
+ * Return the current error handler.
+ *
+ * @return The current error handler, or null if none
+ * has been registered.
+ * @see #setErrorHandler
+ */
+ public ErrorHandler getErrorHandler ();
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Parsing.
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Parse an XML document.
+ *
+ * <p>The application can use this method to instruct the XML
+ * reader to begin parsing an XML document from any valid input
+ * source (a character stream, a byte stream, or a URI).</p>
+ *
+ * <p>Applications may not invoke this method while a parse is in
+ * progress (they should create a new XMLReader instead for each
+ * nested XML document). Once a parse is complete, an
+ * application may reuse the same XMLReader object, possibly with a
+ * different input source.</p>
+ *
+ * <p>During the parse, the XMLReader will provide information
+ * about the XML document through the registered event
+ * handlers.</p>
+ *
+ * <p>This method is synchronous: it will not return until parsing
+ * has ended. If a client application wants to terminate
+ * parsing early, it should throw an exception.</p>
+ *
+ * @param source The input source for the top-level of the
+ * XML document.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ * @see org.xml.sax.InputSource
+ * @see #parse(java.lang.String)
+ * @see #setEntityResolver
+ * @see #setDTDHandler
+ * @see #setContentHandler
+ * @see #setErrorHandler
+ */
+ public void parse (InputSource input)
+ throws IOException, SAXException;
+
+
+ /**
+ * Parse an XML document from a system identifier (URI).
+ *
+ * <p>This method is a shortcut for the common case of reading a
+ * document from a system identifier. It is the exact
+ * equivalent of the following:</p>
+ *
+ * <pre>
+ * parse(new InputSource(systemId));
+ * </pre>
+ *
+ * <p>If the system identifier is a URL, it must be fully resolved
+ * by the application before it is passed to the parser.</p>
+ *
+ * @param systemId The system identifier (URI).
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ * @see #parse(org.xml.sax.InputSource)
+ */
+ public void parse (String systemId)
+ throws IOException, SAXException;
+
+}
-// DeclHandler.java - Optional handler for DTD declaration events.\r
-// Public Domain: no warranty.\r
-// $Id: DeclHandler.java,v 1.1 2000/10/02 02:43:19 sboag Exp $\r
-\r
-package org.xml.sax.ext;\r
-\r
-import org.xml.sax.SAXException;\r
-\r
-\r
-/**\r
- * SAX2 extension handler for DTD declaration events.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This is an optional extension handler for SAX2 to provide\r
- * information about DTD declarations in an XML document. XML\r
- * readers are not required to support this handler.</p>\r
- *\r
- * <p>Note that data-related DTD declarations (unparsed entities and\r
- * notations) are already reported through the {@link\r
- * org.xml.sax.DTDHandler DTDHandler} interface.</p>\r
- *\r
- * <p>If you are using the declaration handler together with a lexical\r
- * handler, all of the events will occur between the\r
- * {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the\r
- * {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.</p>\r
- *\r
- * <p>To set the DeclHandler for an XML reader, use the\r
- * {@link org.xml.sax.XMLReader#setProperty setProperty} method\r
- * with the propertyId "http://xml.org/sax/handlers/DeclHandler".\r
- * If the reader does not support declaration events, it will throw a\r
- * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}\r
- * or a\r
- * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}\r
- * when you attempt to register the handler.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0beta\r
- * @see org.xml.sax.XMLReader\r
- */\r
-public interface DeclHandler\r
-{\r
-\r
- /**\r
- * Report an element type declaration.\r
- *\r
- * <p>The content model will consist of the string "EMPTY", the\r
- * string "ANY", or a parenthesised group, optionally followed\r
- * by an occurrence indicator. The model will be normalized so\r
- * that all whitespace is removed,and will include the enclosing\r
- * parentheses.</p>\r
- *\r
- * @param name The element type name.\r
- * @param model The content model as a normalized string.\r
- * @exception SAXException The application may raise an exception.\r
- */\r
- public abstract void elementDecl (String name, String model)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report an attribute type declaration.\r
- *\r
- * <p>Only the effective (first) declaration for an attribute will\r
- * be reported. The type will be one of the strings "CDATA",\r
- * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",\r
- * "ENTITIES", or "NOTATION", or a parenthesized token group with \r
- * the separator "|" and all whitespace removed.</p>\r
- *\r
- * @param eName The name of the associated element.\r
- * @param aName The name of the attribute.\r
- * @param type A string representing the attribute type.\r
- * @param valueDefault A string representing the attribute default\r
- * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if\r
- * none of these applies.\r
- * @param value A string representing the attribute's default value,\r
- * or null if there is none.\r
- * @exception SAXException The application may raise an exception.\r
- */\r
- public abstract void attributeDecl (String eName,\r
- String aName,\r
- String type,\r
- String valueDefault,\r
- String value)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report an internal entity declaration.\r
- *\r
- * <p>Only the effective (first) declaration for each entity\r
- * will be reported.</p>\r
- *\r
- * @param name The name of the entity. If it is a parameter\r
- * entity, the name will begin with '%'.\r
- * @param value The replacement text of the entity.\r
- * @exception SAXException The application may raise an exception.\r
- * @see #externalEntityDecl\r
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl\r
- */\r
- public abstract void internalEntityDecl (String name, String value)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report a parsed external entity declaration.\r
- *\r
- * <p>Only the effective (first) declaration for each entity\r
- * will be reported.</p>\r
- *\r
- * @param name The name of the entity. If it is a parameter\r
- * entity, the name will begin with '%'.\r
- * @param publicId The declared public identifier of the entity, or\r
- * null if none was declared.\r
- * @param systemId The declared system identifier of the entity.\r
- * @exception SAXException The application may raise an exception.\r
- * @see #internalEntityDecl\r
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl\r
- */\r
- public abstract void externalEntityDecl (String name, String publicId,\r
- String systemId)\r
- throws SAXException;\r
-\r
-}\r
-\r
-// end of DeclHandler.java\r
+// DeclHandler.java - Optional handler for DTD declaration events.
+// http://www.saxproject.org
+// Public Domain: no warranty.
+// $Id: DeclHandler.java,v 1.2.2.5 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.ext;
+
+import org.xml.sax.SAXException;
+
+
+/**
+ * SAX2 extension handler for DTD declaration events.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This is an optional extension handler for SAX2 to provide more
+ * complete information about DTD declarations in an XML document.
+ * XML readers are not required to recognize this handler, and it
+ * is not part of core-only SAX2 distributions.</p>
+ *
+ * <p>Note that data-related DTD declarations (unparsed entities and
+ * notations) are already reported through the {@link
+ * org.xml.sax.DTDHandler DTDHandler} interface.</p>
+ *
+ * <p>If you are using the declaration handler together with a lexical
+ * handler, all of the events will occur between the
+ * {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the
+ * {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.</p>
+ *
+ * <p>To set the DeclHandler for an XML reader, use the
+ * {@link org.xml.sax.XMLReader#setProperty setProperty} method
+ * with the property name
+ * <code>http://xml.org/sax/properties/declaration-handler</code>
+ * and an object implementing this interface (or null) as the value.
+ * If the reader does not report declaration events, it will throw a
+ * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
+ * when you attempt to register the handler.</p>
+ *
+ * @since SAX 2.0 (extensions 1.0)
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ */
+public interface DeclHandler
+{
+
+ /**
+ * Report an element type declaration.
+ *
+ * <p>The content model will consist of the string "EMPTY", the
+ * string "ANY", or a parenthesised group, optionally followed
+ * by an occurrence indicator. The model will be normalized so
+ * that all parameter entities are fully resolved and all whitespace
+ * is removed,and will include the enclosing parentheses. Other
+ * normalization (such as removing redundant parentheses or
+ * simplifying occurrence indicators) is at the discretion of the
+ * parser.</p>
+ *
+ * @param name The element type name.
+ * @param model The content model as a normalized string.
+ * @exception SAXException The application may raise an exception.
+ */
+ public abstract void elementDecl (String name, String model)
+ throws SAXException;
+
+
+ /**
+ * Report an attribute type declaration.
+ *
+ * <p>Only the effective (first) declaration for an attribute will
+ * be reported. The type will be one of the strings "CDATA",
+ * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
+ * "ENTITIES", a parenthesized token group with
+ * the separator "|" and all whitespace removed, or the word
+ * "NOTATION" followed by a space followed by a parenthesized
+ * token group with all whitespace removed.</p>
+ *
+ * <p>The value will be the value as reported to applications,
+ * appropriately normalized and with entity and character
+ * references expanded. </p>
+ *
+ * @param eName The name of the associated element.
+ * @param aName The name of the attribute.
+ * @param type A string representing the attribute type.
+ * @param mode A string representing the attribute defaulting mode
+ * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
+ * none of these applies.
+ * @param value A string representing the attribute's default value,
+ * or null if there is none.
+ * @exception SAXException The application may raise an exception.
+ */
+ public abstract void attributeDecl (String eName,
+ String aName,
+ String type,
+ String mode,
+ String value)
+ throws SAXException;
+
+
+ /**
+ * Report an internal entity declaration.
+ *
+ * <p>Only the effective (first) declaration for each entity
+ * will be reported. All parameter entities in the value
+ * will be expanded, but general entities will not.</p>
+ *
+ * @param name The name of the entity. If it is a parameter
+ * entity, the name will begin with '%'.
+ * @param value The replacement text of the entity.
+ * @exception SAXException The application may raise an exception.
+ * @see #externalEntityDecl
+ * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+ */
+ public abstract void internalEntityDecl (String name, String value)
+ throws SAXException;
+
+
+ /**
+ * Report a parsed external entity declaration.
+ *
+ * <p>Only the effective (first) declaration for each entity
+ * will be reported.</p>
+ *
+ * @param name The name of the entity. If it is a parameter
+ * entity, the name will begin with '%'.
+ * @param publicId The declared public identifier of the entity, or
+ * null if none was declared.
+ * @param systemId The declared system identifier of the entity.
+ * @exception SAXException The application may raise an exception.
+ * @see #internalEntityDecl
+ * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+ */
+ public abstract void externalEntityDecl (String name, String publicId,
+ String systemId)
+ throws SAXException;
+
+}
+
+// end of DeclHandler.java
-// LexicalHandler.java - optional handler for lexical parse events.\r
-// Public Domain: no warranty.\r
-// $Id: LexicalHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.ext;\r
-\r
-import org.xml.sax.SAXException;\r
-\r
-/**\r
- * SAX2 extension handler for lexical events.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This is an optional extension handler for SAX2 to provide\r
- * lexical information about an XML document, such as comments\r
- * and CDATA section boundaries; XML readers are not required to \r
- * support this handler.</p>\r
- *\r
- * <p>The events in the lexical handler apply to the entire document,\r
- * not just to the document element, and all lexical handler events\r
- * must appear between the content handler's startDocument and\r
- * endDocument events.</p>\r
- *\r
- * <p>To set the LexicalHandler for an XML reader, use the\r
- * {@link org.xml.sax.XMLReader#setProperty setProperty} method\r
- * with the propertyId "http://xml.org/sax/handlers/LexicalHandler".\r
- * If the reader does not support lexical events, it will throw a\r
- * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}\r
- * or a\r
- * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}\r
- * when you attempt to register the handler.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0beta\r
- * @see org.xml.sax.XMLReader#setProperty\r
- * @see org.xml.sax.SAXNotRecognizedException\r
- * @see org.xml.sax.SAXNotSupportedException\r
- */\r
-public interface LexicalHandler\r
-{\r
-\r
- /**\r
- * Report the start of DTD declarations, if any.\r
- *\r
- * <p>Any declarations are assumed to be in the internal subset\r
- * unless otherwise indicated by a {@link #startEntity startEntity}\r
- * event.</p>\r
- *\r
- * <p>Note that the start/endDTD events will appear within\r
- * the start/endDocument events from ContentHandler and\r
- * before the first startElement event.</p>\r
- *\r
- * @param name The document type name.\r
- * @param publicId The declared public identifier for the\r
- * external DTD subset, or null if none was declared.\r
- * @param systemId The declared system identifier for the\r
- * external DTD subset, or null if none was declared.\r
- * @exception SAXException The application may raise an\r
- * exception.\r
- * @see #endDTD\r
- * @see #startEntity\r
- */\r
- public abstract void startDTD (String name, String publicId,\r
- String systemId)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report the end of DTD declarations.\r
- *\r
- * @exception SAXException The application may raise an exception.\r
- * @see #startDTD\r
- */\r
- public abstract void endDTD ()\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report the beginning of an entity in content.\r
- *\r
- * <p><strong>NOTE:</entity> entity references in attribute\r
- * values -- and the start and end of the document entity --\r
- * are never reported.</p>\r
- *\r
- * <p>The start and end of the external DTD subset are reported\r
- * using the pseudo-name "[dtd]". All other events must be\r
- * properly nested within start/end entity events.</p>\r
- *\r
- * <p>Note that skipped entities will be reported through the\r
- * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}\r
- * event, which is part of the ContentHandler interface.</p>\r
- *\r
- * @param name The name of the entity. If it is a parameter\r
- * entity, the name will begin with '%'.\r
- * @exception SAXException The application may raise an exception.\r
- * @see #endEntity\r
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl\r
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl\r
- */\r
- public abstract void startEntity (String name)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report the end of an entity.\r
- *\r
- * @param name The name of the entity that is ending.\r
- * @exception SAXException The application may raise an exception.\r
- * @see #startEntity\r
- */\r
- public abstract void endEntity (String name)\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report the start of a CDATA section.\r
- *\r
- * <p>The contents of the CDATA section will be reported through\r
- * the regular {@link org.xml.sax.ContentHandler#characters\r
- * characters} event.</p>\r
- *\r
- * @exception SAXException The application may raise an exception.\r
- * @see #endCDATA\r
- */\r
- public abstract void startCDATA ()\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report the end of a CDATA section.\r
- *\r
- * @exception SAXException The application may raise an exception.\r
- * @see #startCDATA\r
- */\r
- public abstract void endCDATA ()\r
- throws SAXException;\r
-\r
-\r
- /**\r
- * Report an XML comment anywhere in the document.\r
- *\r
- * <p>This callback will be used for comments inside or outside the\r
- * document element, including comments in the external DTD\r
- * subset (if read).</p>\r
- *\r
- * @param ch An array holding the characters in the comment.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use from the array.\r
- * @exception SAXException The application may raise an exception.\r
- */\r
- public abstract void comment (char ch[], int start, int length)\r
- throws SAXException;\r
-\r
-}\r
-\r
-// end of LexicalHandler.java\r
+// LexicalHandler.java - optional handler for lexical parse events.
+// http://www.saxproject.org
+// Public Domain: no warranty.
+// $Id: LexicalHandler.java,v 1.2.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.ext;
+
+import org.xml.sax.SAXException;
+
+/**
+ * SAX2 extension handler for lexical events.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This is an optional extension handler for SAX2 to provide
+ * lexical information about an XML document, such as comments
+ * and CDATA section boundaries.
+ * XML readers are not required to recognize this handler, and it
+ * is not part of core-only SAX2 distributions.</p>
+ *
+ * <p>The events in the lexical handler apply to the entire document,
+ * not just to the document element, and all lexical handler events
+ * must appear between the content handler's startDocument and
+ * endDocument events.</p>
+ *
+ * <p>To set the LexicalHandler for an XML reader, use the
+ * {@link org.xml.sax.XMLReader#setProperty setProperty} method
+ * with the property name
+ * <code>http://xml.org/sax/properties/lexical-handler</code>
+ * and an object implementing this interface (or null) as the value.
+ * If the reader does not report lexical events, it will throw a
+ * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
+ * when you attempt to register the handler.</p>
+ *
+ * @since SAX 2.0 (extensions 1.0)
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ */
+public interface LexicalHandler
+{
+
+ /**
+ * Report the start of DTD declarations, if any.
+ *
+ * <p>This method is intended to report the beginning of the
+ * DOCTYPE declaration; if the document has no DOCTYPE declaration,
+ * this method will not be invoked.</p>
+ *
+ * <p>All declarations reported through
+ * {@link org.xml.sax.DTDHandler DTDHandler} or
+ * {@link org.xml.sax.ext.DeclHandler DeclHandler} events must appear
+ * between the startDTD and {@link #endDTD endDTD} events.
+ * Declarations are assumed to belong to the internal DTD subset
+ * unless they appear between {@link #startEntity startEntity}
+ * and {@link #endEntity endEntity} events. Comments and
+ * processing instructions from the DTD should also be reported
+ * between the startDTD and endDTD events, in their original
+ * order of (logical) occurrence; they are not required to
+ * appear in their correct locations relative to DTDHandler
+ * or DeclHandler events, however.</p>
+ *
+ * <p>Note that the start/endDTD events will appear within
+ * the start/endDocument events from ContentHandler and
+ * before the first
+ * {@link org.xml.sax.ContentHandler#startElement startElement}
+ * event.</p>
+ *
+ * @param name The document type name.
+ * @param publicId The declared public identifier for the
+ * external DTD subset, or null if none was declared.
+ * @param systemId The declared system identifier for the
+ * external DTD subset, or null if none was declared.
+ * (Note that this is not resolved against the document
+ * base URI.)
+ * @exception SAXException The application may raise an
+ * exception.
+ * @see #endDTD
+ * @see #startEntity
+ */
+ public abstract void startDTD (String name, String publicId,
+ String systemId)
+ throws SAXException;
+
+
+ /**
+ * Report the end of DTD declarations.
+ *
+ * <p>This method is intended to report the end of the
+ * DOCTYPE declaration; if the document has no DOCTYPE declaration,
+ * this method will not be invoked.</p>
+ *
+ * @exception SAXException The application may raise an exception.
+ * @see #startDTD
+ */
+ public abstract void endDTD ()
+ throws SAXException;
+
+
+ /**
+ * Report the beginning of some internal and external XML entities.
+ *
+ * <p>The reporting of parameter entities (including
+ * the external DTD subset) is optional, and SAX2 drivers that
+ * report LexicalHandler events may not implement it; you can use the
+ * <code
+ * >http://xml.org/sax/features/lexical-handler/parameter-entities</code>
+ * feature to query or control the reporting of parameter entities.</p>
+ *
+ * <p>General entities are reported with their regular names,
+ * parameter entities have '%' prepended to their names, and
+ * the external DTD subset has the pseudo-entity name "[dtd]".</p>
+ *
+ * <p>When a SAX2 driver is providing these events, all other
+ * events must be properly nested within start/end entity
+ * events. There is no additional requirement that events from
+ * {@link org.xml.sax.ext.DeclHandler DeclHandler} or
+ * {@link org.xml.sax.DTDHandler DTDHandler} be properly ordered.</p>
+ *
+ * <p>Note that skipped entities will be reported through the
+ * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
+ * event, which is part of the ContentHandler interface.</p>
+ *
+ * <p>Because of the streaming event model that SAX uses, some
+ * entity boundaries cannot be reported under any
+ * circumstances:</p>
+ *
+ * <ul>
+ * <li>general entities within attribute values</li>
+ * <li>parameter entities within declarations</li>
+ * </ul>
+ *
+ * <p>These will be silently expanded, with no indication of where
+ * the original entity boundaries were.</p>
+ *
+ * <p>Note also that the boundaries of character references (which
+ * are not really entities anyway) are not reported.</p>
+ *
+ * <p>All start/endEntity events must be properly nested.
+ *
+ * @param name The name of the entity. If it is a parameter
+ * entity, the name will begin with '%', and if it is the
+ * external DTD subset, it will be "[dtd]".
+ * @exception SAXException The application may raise an exception.
+ * @see #endEntity
+ * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
+ * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
+ */
+ public abstract void startEntity (String name)
+ throws SAXException;
+
+
+ /**
+ * Report the end of an entity.
+ *
+ * @param name The name of the entity that is ending.
+ * @exception SAXException The application may raise an exception.
+ * @see #startEntity
+ */
+ public abstract void endEntity (String name)
+ throws SAXException;
+
+
+ /**
+ * Report the start of a CDATA section.
+ *
+ * <p>The contents of the CDATA section will be reported through
+ * the regular {@link org.xml.sax.ContentHandler#characters
+ * characters} event; this event is intended only to report
+ * the boundary.</p>
+ *
+ * @exception SAXException The application may raise an exception.
+ * @see #endCDATA
+ */
+ public abstract void startCDATA ()
+ throws SAXException;
+
+
+ /**
+ * Report the end of a CDATA section.
+ *
+ * @exception SAXException The application may raise an exception.
+ * @see #startCDATA
+ */
+ public abstract void endCDATA ()
+ throws SAXException;
+
+
+ /**
+ * Report an XML comment anywhere in the document.
+ *
+ * <p>This callback will be used for comments inside or outside the
+ * document element, including comments in the external DTD
+ * subset (if read). Comments in the DTD must be properly
+ * nested inside start/endDTD and start/endEntity events (if
+ * used).</p>
+ *
+ * @param ch An array holding the characters in the comment.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use from the array.
+ * @exception SAXException The application may raise an exception.
+ */
+ public abstract void comment (char ch[], int start, int length)
+ throws SAXException;
+
+}
+
+// end of LexicalHandler.java
--- /dev/null
+<HTML><HEAD>
+
+</HEAD><BODY>
+
+<p>
+This package contains interfaces to optional SAX2 handlers.
+
+<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+for more information about SAX.</p>
+
+<p>
+The package is independent of the SAX2 core, though the functionality
+exposed generally needs to be implemented within a parser.
+That independence has several consequences:</p>
+
+<ul>
+
+<li>SAX2 drivers are <em>not</em> required to recognize these handlers,
+and you cannot assume that the class files will be present in every SAX2
+installation.</li>
+
+<li>This package may be updated independently of SAX2 (i.e. new
+handlers may be added without updating SAX2 itself).</li>
+
+<li>The handlers are not implemented by the SAX2
+<code>org.xml.sax.helpers.DefaultHandler</code> or
+<code>org.xml.sax.helpers.XMLFilterImpl</code> classes.
+You can subclass these if you need such behaviour.</li>
+
+<li>The handlers need to be registered differently than regular SAX2
+handlers.</li>
+
+</ul>
+
+<p>This package, SAX2-ext, is a standardized extension to SAX2. It is
+designed both to allow SAX parsers to pass certain types of information
+to applications, and to serve as a simple model for other SAX2 parser
+extension packages. Not all such extension packages should need to
+be recognized directly by parsers, however.
+As an example, most schema systems can be cleanly layered on top
+of parsers supporting the standardized SAX2 interfaces. </p>
+
+<p><strong>NOTE:</strong> this package alone does add any
+functionality; it simply provides optional interfaces for SAX2 drivers
+to use. You must use a SAX2 driver that recognizes these interfaces if
+you actually want to have access to lexical and declaration
+information.</p>
+
+</BODY></HTML>
-// SAX default implementation for AttributeList.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: AttributeListImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import org.xml.sax.AttributeList;\r
-\r
-import java.util.Vector;\r
-\r
-\r
-/**\r
- * Default implementation for AttributeList.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>AttributeList implements the deprecated SAX1 {@link\r
- * org.xml.sax.AttributeList AttributeList} interface, and has been\r
- * replaced by the new SAX2 {@link org.xml.sax.helpers.AttributesImpl\r
- * AttributesImpl} interface.</p>\r
- *\r
- * <p>This class provides a convenience implementation of the SAX\r
- * {@link org.xml.sax.AttributeList AttributeList} interface. This \r
- * implementation is useful both for SAX parser writers, who can use \r
- * it to provide attributes to the application, and for SAX application \r
- * writers, who can use it to create a persistent copy of an element's \r
- * attribute specifications:</p>\r
- *\r
- * <pre>\r
- * private AttributeList myatts;\r
- *\r
- * public void startElement (String name, AttributeList atts)\r
- * {\r
- * // create a persistent copy of the attribute list\r
- * // for use outside this method\r
- * myatts = new AttributeListImpl(atts);\r
- * [...]\r
- * }\r
- * </pre>\r
- *\r
- * <p>Please note that SAX parsers are not required to use this\r
- * class to provide an implementation of AttributeList; it is\r
- * supplied only as an optional convenience. In particular, \r
- * parser writers are encouraged to invent more efficient\r
- * implementations.</p>\r
- *\r
- * @deprecated This class implements a deprecated interface,\r
- * {@link org.xml.sax.AttributeList AttributeList};\r
- * that interface has been replaced by\r
- * {@link org.xml.sax.Attributes Attributes},\r
- * which is implemented in the\r
- * {@link org.xml.sax.helpers.AttributesImpl \r
- * AttributesImpl} helper class.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.AttributeList\r
- * @see org.xml.sax.DocumentHandler#startElement \r
- */\r
-public class AttributeListImpl implements AttributeList\r
-{\r
- \r
- /**\r
- * Create an empty attribute list.\r
- *\r
- * <p>This constructor is most useful for parser writers, who\r
- * will use it to create a single, reusable attribute list that\r
- * can be reset with the clear method between elements.</p>\r
- *\r
- * @see #addAttribute\r
- * @see #clear\r
- */\r
- public AttributeListImpl ()\r
- {\r
- }\r
- \r
- \r
- /**\r
- * Construct a persistent copy of an existing attribute list.\r
- *\r
- * <p>This constructor is most useful for application writers,\r
- * who will use it to create a persistent copy of an existing\r
- * attribute list.</p>\r
- *\r
- * @param atts The attribute list to copy\r
- * @see org.xml.sax.DocumentHandler#startElement\r
- */\r
- public AttributeListImpl (AttributeList atts)\r
- {\r
- setAttributeList(atts);\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Methods specific to this class.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Set the attribute list, discarding previous contents.\r
- *\r
- * <p>This method allows an application writer to reuse an\r
- * attribute list easily.</p>\r
- *\r
- * @param atts The attribute list to copy.\r
- */\r
- public void setAttributeList (AttributeList atts)\r
- {\r
- int count = atts.getLength();\r
- \r
- clear();\r
- \r
- for (int i = 0; i < count; i++) {\r
- addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Add an attribute to an attribute list.\r
- *\r
- * <p>This method is provided for SAX parser writers, to allow them\r
- * to build up an attribute list incrementally before delivering\r
- * it to the application.</p>\r
- *\r
- * @param name The attribute name.\r
- * @param type The attribute type ("NMTOKEN" for an enumeration).\r
- * @param value The attribute value (must not be null).\r
- * @see #removeAttribute\r
- * @see org.xml.sax.DocumentHandler#startElement\r
- */\r
- public void addAttribute (String name, String type, String value)\r
- {\r
- names.addElement(name);\r
- types.addElement(type);\r
- values.addElement(value);\r
- }\r
- \r
- \r
- /**\r
- * Remove an attribute from the list.\r
- *\r
- * <p>SAX application writers can use this method to filter an\r
- * attribute out of an AttributeList. Note that invoking this\r
- * method will change the length of the attribute list and\r
- * some of the attribute's indices.</p>\r
- *\r
- * <p>If the requested attribute is not in the list, this is\r
- * a no-op.</p>\r
- *\r
- * @param name The attribute name.\r
- * @see #addAttribute\r
- */\r
- public void removeAttribute (String name)\r
- {\r
- int i = names.indexOf(name);\r
- \r
- if (i >= 0) {\r
- names.removeElementAt(i);\r
- types.removeElementAt(i);\r
- values.removeElementAt(i);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Clear the attribute list.\r
- *\r
- * <p>SAX parser writers can use this method to reset the attribute\r
- * list between DocumentHandler.startElement events. Normally,\r
- * it will make sense to reuse the same AttributeListImpl object\r
- * rather than allocating a new one each time.</p>\r
- *\r
- * @see org.xml.sax.DocumentHandler#startElement\r
- */\r
- public void clear ()\r
- {\r
- names.removeAllElements();\r
- types.removeAllElements();\r
- values.removeAllElements();\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.AttributeList\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Return the number of attributes in the list.\r
- *\r
- * @return The number of attributes in the list.\r
- * @see org.xml.sax.AttributeList#getLength\r
- */\r
- public int getLength ()\r
- {\r
- return names.size();\r
- }\r
- \r
- \r
- /**\r
- * Get the name of an attribute (by position).\r
- *\r
- * @param i The position of the attribute in the list.\r
- * @return The attribute name as a string, or null if there\r
- * is no attribute at that position.\r
- * @see org.xml.sax.AttributeList#getName(int)\r
- */\r
- public String getName (int i)\r
- {\r
- if (i < 0) {\r
- return null;\r
- }\r
- try {\r
- return (String)names.elementAt(i);\r
- } catch (ArrayIndexOutOfBoundsException e) {\r
- return null;\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Get the type of an attribute (by position).\r
- *\r
- * @param i The position of the attribute in the list.\r
- * @return The attribute type as a string ("NMTOKEN" for an\r
- * enumeration, and "CDATA" if no declaration was\r
- * read), or null if there is no attribute at\r
- * that position.\r
- * @see org.xml.sax.AttributeList#getType(int)\r
- */\r
- public String getType (int i)\r
- {\r
- if (i < 0) {\r
- return null;\r
- }\r
- try {\r
- return (String)types.elementAt(i);\r
- } catch (ArrayIndexOutOfBoundsException e) {\r
- return null;\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Get the value of an attribute (by position).\r
- *\r
- * @param i The position of the attribute in the list.\r
- * @return The attribute value as a string, or null if\r
- * there is no attribute at that position.\r
- * @see org.xml.sax.AttributeList#getValue(int)\r
- */\r
- public String getValue (int i)\r
- {\r
- if (i < 0) {\r
- return null;\r
- }\r
- try {\r
- return (String)values.elementAt(i);\r
- } catch (ArrayIndexOutOfBoundsException e) {\r
- return null;\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Get the type of an attribute (by name).\r
- *\r
- * @param name The attribute name.\r
- * @return The attribute type as a string ("NMTOKEN" for an\r
- * enumeration, and "CDATA" if no declaration was\r
- * read).\r
- * @see org.xml.sax.AttributeList#getType(java.lang.String)\r
- */\r
- public String getType (String name)\r
- {\r
- return getType(names.indexOf(name));\r
- }\r
- \r
- \r
- /**\r
- * Get the value of an attribute (by name).\r
- *\r
- * @param name The attribute name.\r
- * @see org.xml.sax.AttributeList#getValue(java.lang.String)\r
- */\r
- public String getValue (String name)\r
- {\r
- return getValue(names.indexOf(name));\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- Vector names = new Vector();\r
- Vector types = new Vector();\r
- Vector values = new Vector();\r
-\r
-}\r
-\r
-// end of AttributeListImpl.java\r
+// SAX default implementation for AttributeList.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: AttributeListImpl.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import org.xml.sax.AttributeList;
+
+import java.util.Vector;
+
+
+/**
+ * Default implementation for AttributeList.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>AttributeList implements the deprecated SAX1 {@link
+ * org.xml.sax.AttributeList AttributeList} interface, and has been
+ * replaced by the new SAX2 {@link org.xml.sax.helpers.AttributesImpl
+ * AttributesImpl} interface.</p>
+ *
+ * <p>This class provides a convenience implementation of the SAX
+ * {@link org.xml.sax.AttributeList AttributeList} interface. This
+ * implementation is useful both for SAX parser writers, who can use
+ * it to provide attributes to the application, and for SAX application
+ * writers, who can use it to create a persistent copy of an element's
+ * attribute specifications:</p>
+ *
+ * <pre>
+ * private AttributeList myatts;
+ *
+ * public void startElement (String name, AttributeList atts)
+ * {
+ * // create a persistent copy of the attribute list
+ * // for use outside this method
+ * myatts = new AttributeListImpl(atts);
+ * [...]
+ * }
+ * </pre>
+ *
+ * <p>Please note that SAX parsers are not required to use this
+ * class to provide an implementation of AttributeList; it is
+ * supplied only as an optional convenience. In particular,
+ * parser writers are encouraged to invent more efficient
+ * implementations.</p>
+ *
+ * @deprecated This class implements a deprecated interface,
+ * {@link org.xml.sax.AttributeList AttributeList};
+ * that interface has been replaced by
+ * {@link org.xml.sax.Attributes Attributes},
+ * which is implemented in the
+ * {@link org.xml.sax.helpers.AttributesImpl
+ * AttributesImpl} helper class.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.AttributeList
+ * @see org.xml.sax.DocumentHandler#startElement
+ */
+public class AttributeListImpl implements AttributeList
+{
+
+ /**
+ * Create an empty attribute list.
+ *
+ * <p>This constructor is most useful for parser writers, who
+ * will use it to create a single, reusable attribute list that
+ * can be reset with the clear method between elements.</p>
+ *
+ * @see #addAttribute
+ * @see #clear
+ */
+ public AttributeListImpl ()
+ {
+ }
+
+
+ /**
+ * Construct a persistent copy of an existing attribute list.
+ *
+ * <p>This constructor is most useful for application writers,
+ * who will use it to create a persistent copy of an existing
+ * attribute list.</p>
+ *
+ * @param atts The attribute list to copy
+ * @see org.xml.sax.DocumentHandler#startElement
+ */
+ public AttributeListImpl (AttributeList atts)
+ {
+ setAttributeList(atts);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Methods specific to this class.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set the attribute list, discarding previous contents.
+ *
+ * <p>This method allows an application writer to reuse an
+ * attribute list easily.</p>
+ *
+ * @param atts The attribute list to copy.
+ */
+ public void setAttributeList (AttributeList atts)
+ {
+ int count = atts.getLength();
+
+ clear();
+
+ for (int i = 0; i < count; i++) {
+ addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
+ }
+ }
+
+
+ /**
+ * Add an attribute to an attribute list.
+ *
+ * <p>This method is provided for SAX parser writers, to allow them
+ * to build up an attribute list incrementally before delivering
+ * it to the application.</p>
+ *
+ * @param name The attribute name.
+ * @param type The attribute type ("NMTOKEN" for an enumeration).
+ * @param value The attribute value (must not be null).
+ * @see #removeAttribute
+ * @see org.xml.sax.DocumentHandler#startElement
+ */
+ public void addAttribute (String name, String type, String value)
+ {
+ names.addElement(name);
+ types.addElement(type);
+ values.addElement(value);
+ }
+
+
+ /**
+ * Remove an attribute from the list.
+ *
+ * <p>SAX application writers can use this method to filter an
+ * attribute out of an AttributeList. Note that invoking this
+ * method will change the length of the attribute list and
+ * some of the attribute's indices.</p>
+ *
+ * <p>If the requested attribute is not in the list, this is
+ * a no-op.</p>
+ *
+ * @param name The attribute name.
+ * @see #addAttribute
+ */
+ public void removeAttribute (String name)
+ {
+ int i = names.indexOf(name);
+
+ if (i >= 0) {
+ names.removeElementAt(i);
+ types.removeElementAt(i);
+ values.removeElementAt(i);
+ }
+ }
+
+
+ /**
+ * Clear the attribute list.
+ *
+ * <p>SAX parser writers can use this method to reset the attribute
+ * list between DocumentHandler.startElement events. Normally,
+ * it will make sense to reuse the same AttributeListImpl object
+ * rather than allocating a new one each time.</p>
+ *
+ * @see org.xml.sax.DocumentHandler#startElement
+ */
+ public void clear ()
+ {
+ names.removeAllElements();
+ types.removeAllElements();
+ values.removeAllElements();
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.AttributeList
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the number of attributes in the list.
+ *
+ * @return The number of attributes in the list.
+ * @see org.xml.sax.AttributeList#getLength
+ */
+ public int getLength ()
+ {
+ return names.size();
+ }
+
+
+ /**
+ * Get the name of an attribute (by position).
+ *
+ * @param i The position of the attribute in the list.
+ * @return The attribute name as a string, or null if there
+ * is no attribute at that position.
+ * @see org.xml.sax.AttributeList#getName(int)
+ */
+ public String getName (int i)
+ {
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)names.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Get the type of an attribute (by position).
+ *
+ * @param i The position of the attribute in the list.
+ * @return The attribute type as a string ("NMTOKEN" for an
+ * enumeration, and "CDATA" if no declaration was
+ * read), or null if there is no attribute at
+ * that position.
+ * @see org.xml.sax.AttributeList#getType(int)
+ */
+ public String getType (int i)
+ {
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)types.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Get the value of an attribute (by position).
+ *
+ * @param i The position of the attribute in the list.
+ * @return The attribute value as a string, or null if
+ * there is no attribute at that position.
+ * @see org.xml.sax.AttributeList#getValue(int)
+ */
+ public String getValue (int i)
+ {
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)values.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Get the type of an attribute (by name).
+ *
+ * @param name The attribute name.
+ * @return The attribute type as a string ("NMTOKEN" for an
+ * enumeration, and "CDATA" if no declaration was
+ * read).
+ * @see org.xml.sax.AttributeList#getType(java.lang.String)
+ */
+ public String getType (String name)
+ {
+ return getType(names.indexOf(name));
+ }
+
+
+ /**
+ * Get the value of an attribute (by name).
+ *
+ * @param name The attribute name.
+ * @see org.xml.sax.AttributeList#getValue(java.lang.String)
+ */
+ public String getValue (String name)
+ {
+ return getValue(names.indexOf(name));
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ Vector names = new Vector();
+ Vector types = new Vector();
+ Vector values = new Vector();
+
+}
+
+// end of AttributeListImpl.java
-// AttributesImpl.java - default implementation of Attributes.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: AttributesImpl.java,v 1.2 2001/05/31 16:03:17 garyp Exp $\r
-\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import org.xml.sax.Attributes;\r
-\r
-\r
-/**\r
- * Default implementation of the Attributes interface.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class provides a default implementation of the SAX2\r
- * {@link org.xml.sax.Attributes Attributes} interface, with the \r
- * addition of manipulators so that the list can be modified or \r
- * reused.</p>\r
- *\r
- * <p>There are two typical uses of this class:</p>\r
- *\r
- * <ol>\r
- * <li>to take a persistent snapshot of an Attributes object\r
- * in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>\r
- * <li>to construct or modify an Attributes object in a SAX2 driver or filter.</li>\r
- * </ol>\r
- *\r
- * <p>This class replaces the now-deprecated SAX1 {@link \r
- * org.xml.sax.helpers.AttributeListImpl AttributeListImpl}\r
- * class; in addition to supporting the updated Attributes\r
- * interface rather than the deprecated {@link org.xml.sax.AttributeList\r
- * AttributeList} interface, it also includes a much more efficient \r
- * implementation using a single array rather than a set of Vectors.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- */\r
-public class AttributesImpl implements Attributes\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constructors.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Construct a new, empty AttributesImpl object.\r
- */\r
- public AttributesImpl ()\r
- {\r
- length = 0;\r
- data = null;\r
- }\r
-\r
-\r
- /**\r
- * Copy an existing Attributes object.\r
- *\r
- * <p>This constructor is especially useful inside a\r
- * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>\r
- *\r
- * @param atts The existing Attributes object.\r
- */\r
- public AttributesImpl (Attributes atts)\r
- {\r
- setAttributes(atts);\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.Attributes.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Return the number of attributes in the list.\r
- *\r
- * @return The number of attributes in the list.\r
- * @see org.xml.sax.Attributes#getLength\r
- */\r
- public int getLength ()\r
- {\r
- return length;\r
- }\r
-\r
-\r
- /**\r
- * Return an attribute's Namespace URI.\r
- *\r
- * @param index The attribute's index (zero-based).\r
- * @return The Namespace URI, the empty string if none is\r
- * available, or null if the index is out of range.\r
- * @see org.xml.sax.Attributes#getURI\r
- */\r
- public String getURI (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- return data[index*5];\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Return an attribute's local name.\r
- *\r
- * @param index The attribute's index (zero-based).\r
- * @return The attribute's local name, the empty string if \r
- * none is available, or null if the index if out of range.\r
- * @see org.xml.sax.Attributes#getLocalName\r
- */\r
- public String getLocalName (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- return data[index*5+1];\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Return an attribute's qualified (prefixed) name.\r
- *\r
- * @param index The attribute's index (zero-based).\r
- * @return The attribute's qualified name, the empty string if \r
- * none is available, or null if the index is out of bounds.\r
- * @see org.xml.sax.Attributes#getQName\r
- */\r
- public String getQName (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- return data[index*5+2];\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Return an attribute's type by index.\r
- *\r
- * @param index The attribute's index (zero-based).\r
- * @return The attribute's type, "CDATA" if the type is unknown, or null\r
- * if the index is out of bounds.\r
- * @see org.xml.sax.Attributes#getType(int)\r
- */\r
- public String getType (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- return data[index*5+3];\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Return an attribute's value by index.\r
- *\r
- * @param index The attribute's index (zero-based).\r
- * @return The attribute's value or null if the index is out of bounds.\r
- * @see org.xml.sax.Attributes#getValue(int)\r
- */\r
- public String getValue (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- return data[index*5+4];\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's index by Namespace name.\r
- *\r
- * <p>In many cases, it will be more efficient to look up the name once and\r
- * use the index query methods rather than using the name query methods\r
- * repeatedly.</p>\r
- *\r
- * @param uri The attribute's Namespace URI, or the empty\r
- * string if none is available.\r
- * @param localName The attribute's local name.\r
- * @return The attribute's index, or -1 if none matches.\r
- * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)\r
- */\r
- public int getIndex (String uri, String localName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i].equals(uri) && data[i+1].equals(localName)) {\r
- return i / 5;\r
- }\r
- } \r
- return -1;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's index by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attribute's index, or -1 if none matches.\r
- * @see org.xml.sax.Attributes#getIndex(java.lang.String)\r
- */\r
- public int getIndex (String qName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i+2].equals(qName)) {\r
- return i / 5;\r
- }\r
- } \r
- return -1;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's type by Namespace-qualified name.\r
- *\r
- * @param uri The Namespace URI, or the empty string for a name\r
- * with no explicit Namespace URI.\r
- * @param localName The local name.\r
- * @return The attribute's type, or null if there is no\r
- * matching attribute.\r
- * @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String)\r
- */\r
- public String getType (String uri, String localName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i].equals(uri) && data[i+1].equals(localName)) {\r
- return data[i+3];\r
- }\r
- } \r
- return null;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's type by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attribute's type, or null if there is no\r
- * matching attribute.\r
- * @see org.xml.sax.Attributes#getType(java.lang.String)\r
- */\r
- public String getType (String qName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i+2].equals(qName)) {\r
- return data[i+3];\r
- }\r
- }\r
- return null;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's value by Namespace-qualified name.\r
- *\r
- * @param uri The Namespace URI, or the empty string for a name\r
- * with no explicit Namespace URI.\r
- * @param localName The local name.\r
- * @return The attribute's value, or null if there is no\r
- * matching attribute.\r
- * @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String)\r
- */\r
- public String getValue (String uri, String localName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i].equals(uri) && data[i+1].equals(localName)) {\r
- return data[i+4];\r
- }\r
- }\r
- return null;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute's value by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attribute's value, or null if there is no\r
- * matching attribute.\r
- * @see org.xml.sax.Attributes#getValue(java.lang.String)\r
- */\r
- public String getValue (String qName)\r
- {\r
- int max = length * 5;\r
- for (int i = 0; i < max; i += 5) {\r
- if (data[i+2].equals(qName)) {\r
- return data[i+4];\r
- }\r
- }\r
- return null;\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Manipulators.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Clear the attribute list for reuse.\r
- *\r
- * <p>Note that no memory is actually freed by this call:\r
- * the current arrays are kept so that they can be \r
- * reused.</p>\r
- */\r
- public void clear ()\r
- {\r
- length = 0;\r
- }\r
-\r
-\r
- /**\r
- * Copy an entire Attributes object.\r
- *\r
- * <p>It may be more efficient to reuse an existing object\r
- * rather than constantly allocating new ones.</p>\r
- * \r
- * @param atts The attributes to copy.\r
- */\r
- public void setAttributes (Attributes atts)\r
- {\r
- clear();\r
- length = atts.getLength();\r
- data = new String[length*5]; \r
- for (int i = 0; i < length; i++) {\r
- data[i*5] = atts.getURI(i);\r
- data[i*5+1] = atts.getLocalName(i);\r
- data[i*5+2] = atts.getQName(i);\r
- data[i*5+3] = atts.getType(i);\r
- data[i*5+4] = atts.getValue(i);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Add an attribute to the end of the list.\r
- *\r
- * <p>For the sake of speed, this method does no checking\r
- * to see if the attribute is already in the list: that is\r
- * the responsibility of the application.</p>\r
- *\r
- * @param uri The Namespace URI, or the empty string if\r
- * none is available or Namespace processing is not\r
- * being performed.\r
- * @param localName The local name, or the empty string if\r
- * Namespace processing is not being performed.\r
- * @param qName The qualified (prefixed) name, or the empty string\r
- * if qualified names are not available.\r
- * @param type The attribute type as a string.\r
- * @param value The attribute value.\r
- */\r
- public void addAttribute (String uri, String localName, String qName,\r
- String type, String value)\r
- {\r
- ensureCapacity(length+1);\r
- data[length*5] = uri;\r
- data[length*5+1] = localName;\r
- data[length*5+2] = qName;\r
- data[length*5+3] = type;\r
- data[length*5+4] = value;\r
- length++;\r
- }\r
-\r
-\r
- /**\r
- * Set an attribute in the list.\r
- *\r
- * <p>For the sake of speed, this method does no checking\r
- * for name conflicts or well-formedness: such checks are the\r
- * responsibility of the application.</p>\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param uri The Namespace URI, or the empty string if\r
- * none is available or Namespace processing is not\r
- * being performed.\r
- * @param localName The local name, or the empty string if\r
- * Namespace processing is not being performed.\r
- * @param qName The qualified name, or the empty string\r
- * if qualified names are not available.\r
- * @param type The attribute type as a string.\r
- * @param value The attribute value.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setAttribute (int index, String uri, String localName,\r
- String qName, String type, String value)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5] = uri;\r
- data[index*5+1] = localName;\r
- data[index*5+2] = qName;\r
- data[index*5+3] = type;\r
- data[index*5+4] = value;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Remove an attribute from the list.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void removeAttribute (int index)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5] = null;\r
- data[index*5+1] = null;\r
- data[index*5+2] = null;\r
- data[index*5+3] = null;\r
- data[index*5+4] = null;\r
- if (index < length - 1) {\r
- System.arraycopy(data, (index+1)*5, data, index*5,\r
- (length-index-1)*5);\r
- }\r
- length--;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the Namespace URI of a specific attribute.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param uri The attribute's Namespace URI, or the empty\r
- * string for none.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setURI (int index, String uri)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5] = uri;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the local name of a specific attribute.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param localName The attribute's local name, or the empty\r
- * string for none.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setLocalName (int index, String localName)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5+1] = localName;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the qualified name of a specific attribute.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param qName The attribute's qualified name, or the empty\r
- * string for none.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setQName (int index, String qName)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5+2] = qName;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the type of a specific attribute.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param type The attribute's type.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setType (int index, String type)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5+3] = type;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the value of a specific attribute.\r
- *\r
- * @param index The index of the attribute (zero-based).\r
- * @param value The attribute's value.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException When the\r
- * supplied index does not point to an attribute\r
- * in the list.\r
- */\r
- public void setValue (int index, String value)\r
- {\r
- if (index >= 0 && index < length) {\r
- data[index*5+4] = value;\r
- } else {\r
- badIndex(index);\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal methods.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Ensure the internal array's capacity.\r
- *\r
- * @param n The minimum number of attributes that the array must\r
- * be able to hold.\r
- */\r
- private void ensureCapacity (int n)\r
- {\r
- if (n > 0 && data == null) {\r
- data = new String[25];\r
- }\r
-\r
- int max = data.length;\r
- if (max >= n * 5) {\r
- return;\r
- }\r
-\r
-\r
- while (max < n * 5) {\r
- max *= 2;\r
- }\r
- String newData[] = new String[max];\r
- System.arraycopy(data, 0, newData, 0, length*5);\r
- data = newData;\r
- }\r
-\r
-\r
- /**\r
- * Report a bad array index in a manipulator.\r
- *\r
- * @param index The index to report.\r
- * @exception java.lang.ArrayIndexOutOfBoundsException Always.\r
- */\r
- private void badIndex (int index)\r
- throws ArrayIndexOutOfBoundsException\r
- {\r
- String msg =\r
- "Attempt to modify attribute at illegal index: " + index;\r
- throw new ArrayIndexOutOfBoundsException(msg);\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- int length;\r
- String data [];\r
-\r
-}\r
-\r
-// end of AttributesImpl.java\r
-\r
+// AttributesImpl.java - default implementation of Attributes.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: AttributesImpl.java,v 1.6.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+
+package org.xml.sax.helpers;
+
+import org.xml.sax.Attributes;
+
+
+/**
+ * Default implementation of the Attributes interface.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class provides a default implementation of the SAX2
+ * {@link org.xml.sax.Attributes Attributes} interface, with the
+ * addition of manipulators so that the list can be modified or
+ * reused.</p>
+ *
+ * <p>There are two typical uses of this class:</p>
+ *
+ * <ol>
+ * <li>to take a persistent snapshot of an Attributes object
+ * in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>
+ * <li>to construct or modify an Attributes object in a SAX2 driver or filter.</li>
+ * </ol>
+ *
+ * <p>This class replaces the now-deprecated SAX1 {@link
+ * org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
+ * class; in addition to supporting the updated Attributes
+ * interface rather than the deprecated {@link org.xml.sax.AttributeList
+ * AttributeList} interface, it also includes a much more efficient
+ * implementation using a single array rather than a set of Vectors.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ */
+public class AttributesImpl implements Attributes
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constructors.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Construct a new, empty AttributesImpl object.
+ */
+ public AttributesImpl ()
+ {
+ length = 0;
+ data = null;
+ }
+
+
+ /**
+ * Copy an existing Attributes object.
+ *
+ * <p>This constructor is especially useful inside a
+ * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
+ *
+ * @param atts The existing Attributes object.
+ */
+ public AttributesImpl (Attributes atts)
+ {
+ setAttributes(atts);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.Attributes.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the number of attributes in the list.
+ *
+ * @return The number of attributes in the list.
+ * @see org.xml.sax.Attributes#getLength
+ */
+ public int getLength ()
+ {
+ return length;
+ }
+
+
+ /**
+ * Return an attribute's Namespace URI.
+ *
+ * @param index The attribute's index (zero-based).
+ * @return The Namespace URI, the empty string if none is
+ * available, or null if the index is out of range.
+ * @see org.xml.sax.Attributes#getURI
+ */
+ public String getURI (int index)
+ {
+ if (index >= 0 && index < length) {
+ return data[index*5];
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Return an attribute's local name.
+ *
+ * @param index The attribute's index (zero-based).
+ * @return The attribute's local name, the empty string if
+ * none is available, or null if the index if out of range.
+ * @see org.xml.sax.Attributes#getLocalName
+ */
+ public String getLocalName (int index)
+ {
+ if (index >= 0 && index < length) {
+ return data[index*5+1];
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Return an attribute's qualified (prefixed) name.
+ *
+ * @param index The attribute's index (zero-based).
+ * @return The attribute's qualified name, the empty string if
+ * none is available, or null if the index is out of bounds.
+ * @see org.xml.sax.Attributes#getQName
+ */
+ public String getQName (int index)
+ {
+ if (index >= 0 && index < length) {
+ return data[index*5+2];
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Return an attribute's type by index.
+ *
+ * @param index The attribute's index (zero-based).
+ * @return The attribute's type, "CDATA" if the type is unknown, or null
+ * if the index is out of bounds.
+ * @see org.xml.sax.Attributes#getType(int)
+ */
+ public String getType (int index)
+ {
+ if (index >= 0 && index < length) {
+ return data[index*5+3];
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Return an attribute's value by index.
+ *
+ * @param index The attribute's index (zero-based).
+ * @return The attribute's value or null if the index is out of bounds.
+ * @see org.xml.sax.Attributes#getValue(int)
+ */
+ public String getValue (int index)
+ {
+ if (index >= 0 && index < length) {
+ return data[index*5+4];
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Look up an attribute's index by Namespace name.
+ *
+ * <p>In many cases, it will be more efficient to look up the name once and
+ * use the index query methods rather than using the name query methods
+ * repeatedly.</p>
+ *
+ * @param uri The attribute's Namespace URI, or the empty
+ * string if none is available.
+ * @param localName The attribute's local name.
+ * @return The attribute's index, or -1 if none matches.
+ * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
+ */
+ public int getIndex (String uri, String localName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i].equals(uri) && data[i+1].equals(localName)) {
+ return i / 5;
+ }
+ }
+ return -1;
+ }
+
+
+ /**
+ * Look up an attribute's index by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attribute's index, or -1 if none matches.
+ * @see org.xml.sax.Attributes#getIndex(java.lang.String)
+ */
+ public int getIndex (String qName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i+2].equals(qName)) {
+ return i / 5;
+ }
+ }
+ return -1;
+ }
+
+
+ /**
+ * Look up an attribute's type by Namespace-qualified name.
+ *
+ * @param uri The Namespace URI, or the empty string for a name
+ * with no explicit Namespace URI.
+ * @param localName The local name.
+ * @return The attribute's type, or null if there is no
+ * matching attribute.
+ * @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String)
+ */
+ public String getType (String uri, String localName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i].equals(uri) && data[i+1].equals(localName)) {
+ return data[i+3];
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Look up an attribute's type by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attribute's type, or null if there is no
+ * matching attribute.
+ * @see org.xml.sax.Attributes#getType(java.lang.String)
+ */
+ public String getType (String qName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i+2].equals(qName)) {
+ return data[i+3];
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Look up an attribute's value by Namespace-qualified name.
+ *
+ * @param uri The Namespace URI, or the empty string for a name
+ * with no explicit Namespace URI.
+ * @param localName The local name.
+ * @return The attribute's value, or null if there is no
+ * matching attribute.
+ * @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String)
+ */
+ public String getValue (String uri, String localName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i].equals(uri) && data[i+1].equals(localName)) {
+ return data[i+4];
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Look up an attribute's value by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attribute's value, or null if there is no
+ * matching attribute.
+ * @see org.xml.sax.Attributes#getValue(java.lang.String)
+ */
+ public String getValue (String qName)
+ {
+ int max = length * 5;
+ for (int i = 0; i < max; i += 5) {
+ if (data[i+2].equals(qName)) {
+ return data[i+4];
+ }
+ }
+ return null;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Manipulators.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Clear the attribute list for reuse.
+ *
+ * <p>Note that little memory is freed by this call:
+ * the current array is kept so it can be
+ * reused.</p>
+ */
+ public void clear ()
+ {
+ if (data != null) {
+ for (int i = 0; i < (length * 5); i++)
+ data [i] = null;
+ }
+ length = 0;
+ }
+
+
+ /**
+ * Copy an entire Attributes object.
+ *
+ * <p>It may be more efficient to reuse an existing object
+ * rather than constantly allocating new ones.</p>
+ *
+ * @param atts The attributes to copy.
+ */
+ public void setAttributes (Attributes atts)
+ {
+ clear();
+ length = atts.getLength();
+ if (length > 0) {
+ data = new String[length*5];
+ for (int i = 0; i < length; i++) {
+ data[i*5] = atts.getURI(i);
+ data[i*5+1] = atts.getLocalName(i);
+ data[i*5+2] = atts.getQName(i);
+ data[i*5+3] = atts.getType(i);
+ data[i*5+4] = atts.getValue(i);
+ }
+ }
+ }
+
+
+ /**
+ * Add an attribute to the end of the list.
+ *
+ * <p>For the sake of speed, this method does no checking
+ * to see if the attribute is already in the list: that is
+ * the responsibility of the application.</p>
+ *
+ * @param uri The Namespace URI, or the empty string if
+ * none is available or Namespace processing is not
+ * being performed.
+ * @param localName The local name, or the empty string if
+ * Namespace processing is not being performed.
+ * @param qName The qualified (prefixed) name, or the empty string
+ * if qualified names are not available.
+ * @param type The attribute type as a string.
+ * @param value The attribute value.
+ */
+ public void addAttribute (String uri, String localName, String qName,
+ String type, String value)
+ {
+ ensureCapacity(length+1);
+ data[length*5] = uri;
+ data[length*5+1] = localName;
+ data[length*5+2] = qName;
+ data[length*5+3] = type;
+ data[length*5+4] = value;
+ length++;
+ }
+
+
+ /**
+ * Set an attribute in the list.
+ *
+ * <p>For the sake of speed, this method does no checking
+ * for name conflicts or well-formedness: such checks are the
+ * responsibility of the application.</p>
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param uri The Namespace URI, or the empty string if
+ * none is available or Namespace processing is not
+ * being performed.
+ * @param localName The local name, or the empty string if
+ * Namespace processing is not being performed.
+ * @param qName The qualified name, or the empty string
+ * if qualified names are not available.
+ * @param type The attribute type as a string.
+ * @param value The attribute value.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setAttribute (int index, String uri, String localName,
+ String qName, String type, String value)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5] = uri;
+ data[index*5+1] = localName;
+ data[index*5+2] = qName;
+ data[index*5+3] = type;
+ data[index*5+4] = value;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Remove an attribute from the list.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void removeAttribute (int index)
+ {
+ if (index >= 0 && index < length) {
+ if (index < length - 1) {
+ System.arraycopy(data, (index+1)*5, data, index*5,
+ (length-index-1)*5);
+ }
+ index = (length - 1) * 5;
+ data [index++] = null;
+ data [index++] = null;
+ data [index++] = null;
+ data [index++] = null;
+ data [index] = null;
+ length--;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Set the Namespace URI of a specific attribute.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param uri The attribute's Namespace URI, or the empty
+ * string for none.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setURI (int index, String uri)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5] = uri;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Set the local name of a specific attribute.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param localName The attribute's local name, or the empty
+ * string for none.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setLocalName (int index, String localName)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5+1] = localName;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Set the qualified name of a specific attribute.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param qName The attribute's qualified name, or the empty
+ * string for none.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setQName (int index, String qName)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5+2] = qName;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Set the type of a specific attribute.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param type The attribute's type.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setType (int index, String type)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5+3] = type;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+ /**
+ * Set the value of a specific attribute.
+ *
+ * @param index The index of the attribute (zero-based).
+ * @param value The attribute's value.
+ * @exception java.lang.ArrayIndexOutOfBoundsException When the
+ * supplied index does not point to an attribute
+ * in the list.
+ */
+ public void setValue (int index, String value)
+ {
+ if (index >= 0 && index < length) {
+ data[index*5+4] = value;
+ } else {
+ badIndex(index);
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal methods.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Ensure the internal array's capacity.
+ *
+ * @param n The minimum number of attributes that the array must
+ * be able to hold.
+ */
+ private void ensureCapacity (int n) {
+ if (n <= 0) {
+ return;
+ }
+ int max;
+ if (data == null || data.length == 0) {
+ max = 25;
+ }
+ else if (data.length >= n * 5) {
+ return;
+ }
+ else {
+ max = data.length;
+ }
+ while (max < n * 5) {
+ max *= 2;
+ }
+
+ String newData[] = new String[max];
+ if (length > 0) {
+ System.arraycopy(data, 0, newData, 0, length*5);
+ }
+ data = newData;
+ }
+
+
+ /**
+ * Report a bad array index in a manipulator.
+ *
+ * @param index The index to report.
+ * @exception java.lang.ArrayIndexOutOfBoundsException Always.
+ */
+ private void badIndex (int index)
+ throws ArrayIndexOutOfBoundsException
+ {
+ String msg =
+ "Attempt to modify attribute at illegal index: " + index;
+ throw new ArrayIndexOutOfBoundsException(msg);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ int length;
+ String data [];
+
+}
+
+// end of AttributesImpl.java
+
-// DefaultHandler.java - default implementation of the core handlers.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: DefaultHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.Locator;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.DTDHandler;\r
-import org.xml.sax.ContentHandler;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-\r
-/**\r
- * Default base class for SAX2 event handlers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class is available as a convenience base class for SAX2\r
- * applications: it provides default implementations for all of the\r
- * callbacks in the four core SAX2 handler classes:</p>\r
- *\r
- * <ul>\r
- * <li>{@link org.xml.sax.EntityResolver EntityResolver}</li>\r
- * <li>{@link org.xml.sax.DTDHandler DTDHandler}</li>\r
- * <li>{@link org.xml.sax.ContentHandler ContentHandler}</li>\r
- * <li>{@link org.xml.sax.ErrorHandler ErrorHandler}</li>\r
- * </ul>\r
- *\r
- * <p>Application writers can extend this class when they need to\r
- * implement only part of an interface; parser writers can\r
- * instantiate this class to provide default handlers when the\r
- * application has not supplied its own.</p>\r
- *\r
- * <p>This class replaces the deprecated SAX1\r
- * {@link org.xml.sax.HandlerBase HandlerBase} class.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.EntityResolver\r
- * @see org.xml.sax.DTDHandler\r
- * @see org.xml.sax.ContentHandler\r
- * @see org.xml.sax.ErrorHandler\r
- */\r
-public class DefaultHandler\r
- implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler\r
-{\r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of the EntityResolver interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- /**\r
- * Resolve an external entity.\r
- *\r
- * <p>Always return null, so that the parser will use the system\r
- * identifier provided in the XML document. This method implements\r
- * the SAX default behaviour: application writers can override it\r
- * in a subclass to do special translations such as catalog lookups\r
- * or URI redirection.</p>\r
- *\r
- * @param publicId The public identifier, or null if none is\r
- * available.\r
- * @param systemId The system identifier provided in the XML \r
- * document.\r
- * @return The new input source, or null to require the\r
- * default behaviour.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.EntityResolver#resolveEntity\r
- */\r
- public InputSource resolveEntity (String publicId, String systemId)\r
- throws SAXException\r
- {\r
- return null;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of DTDHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive notification of a notation declaration.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass if they wish to keep track of the notations\r
- * declared in a document.</p>\r
- *\r
- * @param name The notation name.\r
- * @param publicId The notation public identifier, or null if not\r
- * available.\r
- * @param systemId The notation system identifier.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DTDHandler#notationDecl\r
- */\r
- public void notationDecl (String name, String publicId, String systemId)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of an unparsed entity declaration.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to keep track of the unparsed entities\r
- * declared in a document.</p>\r
- *\r
- * @param name The entity name.\r
- * @param publicId The entity public identifier, or null if not\r
- * available.\r
- * @param systemId The entity system identifier.\r
- * @param notationName The name of the associated notation.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl\r
- */\r
- public void unparsedEntityDecl (String name, String publicId,\r
- String systemId, String notationName)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of ContentHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive a Locator object for document events.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass if they wish to store the locator for use\r
- * with other document events.</p>\r
- *\r
- * @param locator A locator for all SAX document events.\r
- * @see org.xml.sax.ContentHandler#setDocumentLocator\r
- * @see org.xml.sax.Locator\r
- */\r
- public void setDocumentLocator (Locator locator)\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the beginning of the document.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the beginning\r
- * of a document (such as allocating the root node of a tree or\r
- * creating an output file).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#startDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the end of the document.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the end\r
- * of a document (such as finalising a tree or closing an output\r
- * file).</p>\r
- *\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#endDocument\r
- */\r
- public void endDocument ()\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
-\r
-\r
- /**\r
- * Receive notification of the start of a Namespace mapping.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the start of\r
- * each Namespace prefix scope (such as storing the prefix mapping).</p>\r
- *\r
- * @param prefix The Namespace prefix being declared.\r
- * @param uri The Namespace URI mapped to the prefix.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#startPrefixMapping\r
- */\r
- public void startPrefixMapping (String prefix, String uri)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
-\r
-\r
- /**\r
- * Receive notification of the end of a Namespace mapping.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the end of\r
- * each prefix mapping.</p>\r
- *\r
- * @param prefix The Namespace prefix being declared.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#endPrefixMapping\r
- */\r
- public void endPrefixMapping (String prefix)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the start of an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the start of\r
- * each element (such as allocating a new tree node or writing\r
- * output to a file).</p>\r
- *\r
- * @param name The element type name.\r
- * @param attributes The specified or defaulted attributes.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#startElement\r
- */\r
- public void startElement (String uri, String localName,\r
- String qName, Attributes attributes)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of the end of an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions at the end of\r
- * each element (such as finalising a tree node or writing\r
- * output to a file).</p>\r
- *\r
- * @param name The element type name.\r
- * @param attributes The specified or defaulted attributes.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#endElement\r
- */\r
- public void endElement (String uri, String localName, String qName)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of character data inside an element.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method to take specific actions for each chunk of character data\r
- * (such as adding the data to a node or buffer, or printing it to\r
- * a file).</p>\r
- *\r
- * @param ch The characters.\r
- * @param start The start position in the character array.\r
- * @param length The number of characters to use from the\r
- * character array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#characters\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of ignorable whitespace in element content.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method to take specific actions for each chunk of ignorable\r
- * whitespace (such as adding data to a node or buffer, or printing\r
- * it to a file).</p>\r
- *\r
- * @param ch The whitespace characters.\r
- * @param start The start position in the character array.\r
- * @param length The number of characters to use from the\r
- * character array.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#ignorableWhitespace\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of a processing instruction.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions for each\r
- * processing instruction, such as setting status variables or\r
- * invoking other methods.</p>\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The processing instruction data, or null if\r
- * none is supplied.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#processingInstruction\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
-\r
-\r
- /**\r
- * Receive notification of a skipped entity.\r
- *\r
- * <p>By default, do nothing. Application writers may override this\r
- * method in a subclass to take specific actions for each\r
- * processing instruction, such as setting status variables or\r
- * invoking other methods.</p>\r
- *\r
- * @param name The name of the skipped entity.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ContentHandler#processingInstruction\r
- */\r
- public void skippedEntity (String name)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Default implementation of the ErrorHandler interface.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Receive notification of a parser warning.\r
- *\r
- * <p>The default implementation does nothing. Application writers\r
- * may override this method in a subclass to take specific actions\r
- * for each warning, such as inserting the message in a log file or\r
- * printing it to the console.</p>\r
- *\r
- * @param e The warning information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#warning\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void warning (SAXParseException e)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Receive notification of a recoverable parser error.\r
- *\r
- * <p>The default implementation does nothing. Application writers\r
- * may override this method in a subclass to take specific actions\r
- * for each error, such as inserting the message in a log file or\r
- * printing it to the console.</p>\r
- *\r
- * @param e The warning information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#warning\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void error (SAXParseException e)\r
- throws SAXException\r
- {\r
- // no op\r
- }\r
- \r
- \r
- /**\r
- * Report a fatal XML parsing error.\r
- *\r
- * <p>The default implementation throws a SAXParseException.\r
- * Application writers may override this method in a subclass if\r
- * they need to take specific actions for each fatal error (such as\r
- * collecting all of the errors into a single report): in any case,\r
- * the application must stop all regular processing when this\r
- * method is invoked, since the document is no longer reliable, and\r
- * the parser may no longer report parsing events.</p>\r
- *\r
- * @param e The error information encoded as an exception.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @see org.xml.sax.ErrorHandler#fatalError\r
- * @see org.xml.sax.SAXParseException\r
- */\r
- public void fatalError (SAXParseException e)\r
- throws SAXException\r
- {\r
- throw e;\r
- }\r
- \r
-}\r
-\r
-// end of DefaultHandler.java\r
+// DefaultHandler.java - default implementation of the core handlers.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: DefaultHandler.java,v 1.5.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.io.IOException;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+
+/**
+ * Default base class for SAX2 event handlers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class is available as a convenience base class for SAX2
+ * applications: it provides default implementations for all of the
+ * callbacks in the four core SAX2 handler classes:</p>
+ *
+ * <ul>
+ * <li>{@link org.xml.sax.EntityResolver EntityResolver}</li>
+ * <li>{@link org.xml.sax.DTDHandler DTDHandler}</li>
+ * <li>{@link org.xml.sax.ContentHandler ContentHandler}</li>
+ * <li>{@link org.xml.sax.ErrorHandler ErrorHandler}</li>
+ * </ul>
+ *
+ * <p>Application writers can extend this class when they need to
+ * implement only part of an interface; parser writers can
+ * instantiate this class to provide default handlers when the
+ * application has not supplied its own.</p>
+ *
+ * <p>This class replaces the deprecated SAX1
+ * {@link org.xml.sax.HandlerBase HandlerBase} class.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson,
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.EntityResolver
+ * @see org.xml.sax.DTDHandler
+ * @see org.xml.sax.ContentHandler
+ * @see org.xml.sax.ErrorHandler
+ */
+public class DefaultHandler
+ implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of the EntityResolver interface.
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Resolve an external entity.
+ *
+ * <p>Always return null, so that the parser will use the system
+ * identifier provided in the XML document. This method implements
+ * the SAX default behaviour: application writers can override it
+ * in a subclass to do special translations such as catalog lookups
+ * or URI redirection.</p>
+ *
+ * @param publicId The public identifer, or null if none is
+ * available.
+ * @param systemId The system identifier provided in the XML
+ * document.
+ * @return The new input source, or null to require the
+ * default behaviour.
+ * @exception java.io.IOException If there is an error setting
+ * up the new input source.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.EntityResolver#resolveEntity
+ */
+ public InputSource resolveEntity (String publicId, String systemId)
+ throws IOException, SAXException
+ {
+ return null;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of DTDHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive notification of a notation declaration.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass if they wish to keep track of the notations
+ * declared in a document.</p>
+ *
+ * @param name The notation name.
+ * @param publicId The notation public identifier, or null if not
+ * available.
+ * @param systemId The notation system identifier.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DTDHandler#notationDecl
+ */
+ public void notationDecl (String name, String publicId, String systemId)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of an unparsed entity declaration.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to keep track of the unparsed entities
+ * declared in a document.</p>
+ *
+ * @param name The entity name.
+ * @param publicId The entity public identifier, or null if not
+ * available.
+ * @param systemId The entity system identifier.
+ * @param notationName The name of the associated notation.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+ */
+ public void unparsedEntityDecl (String name, String publicId,
+ String systemId, String notationName)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of ContentHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive a Locator object for document events.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass if they wish to store the locator for use
+ * with other document events.</p>
+ *
+ * @param locator A locator for all SAX document events.
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
+ * @see org.xml.sax.Locator
+ */
+ public void setDocumentLocator (Locator locator)
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the beginning of the document.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the beginning
+ * of a document (such as allocating the root node of a tree or
+ * creating an output file).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#startDocument
+ */
+ public void startDocument ()
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the end of the document.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the end
+ * of a document (such as finalising a tree or closing an output
+ * file).</p>
+ *
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#endDocument
+ */
+ public void endDocument ()
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the start of a Namespace mapping.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the start of
+ * each Namespace prefix scope (such as storing the prefix mapping).</p>
+ *
+ * @param prefix The Namespace prefix being declared.
+ * @param uri The Namespace URI mapped to the prefix.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#startPrefixMapping
+ */
+ public void startPrefixMapping (String prefix, String uri)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the end of a Namespace mapping.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the end of
+ * each prefix mapping.</p>
+ *
+ * @param prefix The Namespace prefix being declared.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#endPrefixMapping
+ */
+ public void endPrefixMapping (String prefix)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the start of an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the start of
+ * each element (such as allocating a new tree node or writing
+ * output to a file).</p>
+ *
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
+ * @param atts The attributes attached to the element. If
+ * there are no attributes, it shall be an empty
+ * Attributes object.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#startElement
+ */
+ public void startElement (String uri, String localName,
+ String qName, Attributes attributes)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of the end of an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions at the end of
+ * each element (such as finalising a tree node or writing
+ * output to a file).</p>
+ *
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#endElement
+ */
+ public void endElement (String uri, String localName, String qName)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of character data inside an element.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method to take specific actions for each chunk of character data
+ * (such as adding the data to a node or buffer, or printing it to
+ * a file).</p>
+ *
+ * @param ch The characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#characters
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method to take specific actions for each chunk of ignorable
+ * whitespace (such as adding data to a node or buffer, or printing
+ * it to a file).</p>
+ *
+ * @param ch The whitespace characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#ignorableWhitespace
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of a processing instruction.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions for each
+ * processing instruction, such as setting status variables or
+ * invoking other methods.</p>
+ *
+ * @param target The processing instruction target.
+ * @param data The processing instruction data, or null if
+ * none is supplied.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#processingInstruction
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of a skipped entity.
+ *
+ * <p>By default, do nothing. Application writers may override this
+ * method in a subclass to take specific actions for each
+ * processing instruction, such as setting status variables or
+ * invoking other methods.</p>
+ *
+ * @param name The name of the skipped entity.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ContentHandler#processingInstruction
+ */
+ public void skippedEntity (String name)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Default implementation of the ErrorHandler interface.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Receive notification of a parser warning.
+ *
+ * <p>The default implementation does nothing. Application writers
+ * may override this method in a subclass to take specific actions
+ * for each warning, such as inserting the message in a log file or
+ * printing it to the console.</p>
+ *
+ * @param e The warning information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#warning
+ * @see org.xml.sax.SAXParseException
+ */
+ public void warning (SAXParseException e)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Receive notification of a recoverable parser error.
+ *
+ * <p>The default implementation does nothing. Application writers
+ * may override this method in a subclass to take specific actions
+ * for each error, such as inserting the message in a log file or
+ * printing it to the console.</p>
+ *
+ * @param e The warning information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#warning
+ * @see org.xml.sax.SAXParseException
+ */
+ public void error (SAXParseException e)
+ throws SAXException
+ {
+ // no op
+ }
+
+
+ /**
+ * Report a fatal XML parsing error.
+ *
+ * <p>The default implementation throws a SAXParseException.
+ * Application writers may override this method in a subclass if
+ * they need to take specific actions for each fatal error (such as
+ * collecting all of the errors into a single report): in any case,
+ * the application must stop all regular processing when this
+ * method is invoked, since the document is no longer reliable, and
+ * the parser may no longer report parsing events.</p>
+ *
+ * @param e The error information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.ErrorHandler#fatalError
+ * @see org.xml.sax.SAXParseException
+ */
+ public void fatalError (SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+}
+
+// end of DefaultHandler.java
-// SAX default implementation for Locator.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: LocatorImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import org.xml.sax.Locator;\r
-\r
-\r
-/**\r
- * Provide an optional convenience implementation of Locator.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class is available mainly for application writers, who\r
- * can use it to make a persistent snapshot of a locator at any\r
- * point during a document parse:</p>\r
- *\r
- * <pre>\r
- * Locator locator;\r
- * Locator startloc;\r
- *\r
- * public void setLocator (Locator locator)\r
- * {\r
- * // note the locator\r
- * this.locator = locator;\r
- * }\r
- *\r
- * public void startDocument ()\r
- * {\r
- * // save the location of the start of the document\r
- * // for future use.\r
- * Locator startloc = new LocatorImpl(locator);\r
- * }\r
- *</pre>\r
- *\r
- * <p>Normally, parser writers will not use this class, since it\r
- * is more efficient to provide location information only when\r
- * requested, rather than constantly updating a Locator object.</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Locator Locator\r
- */\r
-public class LocatorImpl implements Locator\r
-{\r
- \r
- \r
- /**\r
- * Zero-argument constructor.\r
- *\r
- * <p>This will not normally be useful, since the main purpose\r
- * of this class is to make a snapshot of an existing Locator.</p>\r
- */\r
- public LocatorImpl ()\r
- {\r
- }\r
- \r
- \r
- /**\r
- * Copy constructor.\r
- *\r
- * <p>Create a persistent copy of the current state of a locator.\r
- * When the original locator changes, this copy will still keep\r
- * the original values (and it can be used outside the scope of\r
- * DocumentHandler methods).</p>\r
- *\r
- * @param locator The locator to copy.\r
- */\r
- public LocatorImpl (Locator locator)\r
- {\r
- setPublicId(locator.getPublicId());\r
- setSystemId(locator.getSystemId());\r
- setLineNumber(locator.getLineNumber());\r
- setColumnNumber(locator.getColumnNumber());\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.Locator\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Return the saved public identifier.\r
- *\r
- * @return The public identifier as a string, or null if none\r
- * is available.\r
- * @see org.xml.sax.Locator#getPublicId\r
- * @see #setPublicId\r
- */\r
- public String getPublicId ()\r
- {\r
- return publicId;\r
- }\r
- \r
- \r
- /**\r
- * Return the saved system identifier.\r
- *\r
- * @return The system identifier as a string, or null if none\r
- * is available.\r
- * @see org.xml.sax.Locator#getSystemId\r
- * @see #setSystemId\r
- */\r
- public String getSystemId ()\r
- {\r
- return systemId;\r
- }\r
- \r
- \r
- /**\r
- * Return the saved line number (1-based).\r
- *\r
- * @return The line number as an integer, or -1 if none is available.\r
- * @see org.xml.sax.Locator#getLineNumber\r
- * @see #setLineNumber\r
- */\r
- public int getLineNumber ()\r
- {\r
- return lineNumber;\r
- }\r
- \r
- \r
- /**\r
- * Return the saved column number (1-based).\r
- *\r
- * @return The column number as an integer, or -1 if none is available.\r
- * @see org.xml.sax.Locator#getColumnNumber\r
- * @see #setColumnNumber\r
- */\r
- public int getColumnNumber ()\r
- {\r
- return columnNumber;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Setters for the properties (not in org.xml.sax.Locator)\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- \r
- /**\r
- * Set the public identifier for this locator.\r
- *\r
- * @param publicId The new public identifier, or null \r
- * if none is available.\r
- * @see #getPublicId\r
- */\r
- public void setPublicId (String publicId)\r
- {\r
- this.publicId = publicId;\r
- }\r
- \r
- \r
- /**\r
- * Set the system identifier for this locator.\r
- *\r
- * @param systemId The new system identifier, or null \r
- * if none is available.\r
- * @see #getSystemId\r
- */\r
- public void setSystemId (String systemId)\r
- {\r
- this.systemId = systemId;\r
- }\r
- \r
- \r
- /**\r
- * Set the line number for this locator (1-based).\r
- *\r
- * @param lineNumber The line number, or -1 if none is available.\r
- * @see #getLineNumber\r
- */\r
- public void setLineNumber (int lineNumber)\r
- {\r
- this.lineNumber = lineNumber;\r
- }\r
- \r
- \r
- /**\r
- * Set the column number for this locator (1-based).\r
- *\r
- * @param columnNumber The column number, or -1 if none is available.\r
- * @see #getColumnNumber\r
- */\r
- public void setColumnNumber (int columnNumber)\r
- {\r
- this.columnNumber = columnNumber;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- private String publicId;\r
- private String systemId;\r
- private int lineNumber;\r
- private int columnNumber;\r
- \r
-}\r
-\r
-// end of LocatorImpl.java\r
+// SAX default implementation for Locator.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: LocatorImpl.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import org.xml.sax.Locator;
+
+
+/**
+ * Provide an optional convenience implementation of Locator.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class is available mainly for application writers, who
+ * can use it to make a persistent snapshot of a locator at any
+ * point during a document parse:</p>
+ *
+ * <pre>
+ * Locator locator;
+ * Locator startloc;
+ *
+ * public void setLocator (Locator locator)
+ * {
+ * // note the locator
+ * this.locator = locator;
+ * }
+ *
+ * public void startDocument ()
+ * {
+ * // save the location of the start of the document
+ * // for future use.
+ * Locator startloc = new LocatorImpl(locator);
+ * }
+ *</pre>
+ *
+ * <p>Normally, parser writers will not use this class, since it
+ * is more efficient to provide location information only when
+ * requested, rather than constantly updating a Locator object.</p>
+ *
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.Locator Locator
+ */
+public class LocatorImpl implements Locator
+{
+
+
+ /**
+ * Zero-argument constructor.
+ *
+ * <p>This will not normally be useful, since the main purpose
+ * of this class is to make a snapshot of an existing Locator.</p>
+ */
+ public LocatorImpl ()
+ {
+ }
+
+
+ /**
+ * Copy constructor.
+ *
+ * <p>Create a persistent copy of the current state of a locator.
+ * When the original locator changes, this copy will still keep
+ * the original values (and it can be used outside the scope of
+ * DocumentHandler methods).</p>
+ *
+ * @param locator The locator to copy.
+ */
+ public LocatorImpl (Locator locator)
+ {
+ setPublicId(locator.getPublicId());
+ setSystemId(locator.getSystemId());
+ setLineNumber(locator.getLineNumber());
+ setColumnNumber(locator.getColumnNumber());
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.Locator
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Return the saved public identifier.
+ *
+ * @return The public identifier as a string, or null if none
+ * is available.
+ * @see org.xml.sax.Locator#getPublicId
+ * @see #setPublicId
+ */
+ public String getPublicId ()
+ {
+ return publicId;
+ }
+
+
+ /**
+ * Return the saved system identifier.
+ *
+ * @return The system identifier as a string, or null if none
+ * is available.
+ * @see org.xml.sax.Locator#getSystemId
+ * @see #setSystemId
+ */
+ public String getSystemId ()
+ {
+ return systemId;
+ }
+
+
+ /**
+ * Return the saved line number (1-based).
+ *
+ * @return The line number as an integer, or -1 if none is available.
+ * @see org.xml.sax.Locator#getLineNumber
+ * @see #setLineNumber
+ */
+ public int getLineNumber ()
+ {
+ return lineNumber;
+ }
+
+
+ /**
+ * Return the saved column number (1-based).
+ *
+ * @return The column number as an integer, or -1 if none is available.
+ * @see org.xml.sax.Locator#getColumnNumber
+ * @see #setColumnNumber
+ */
+ public int getColumnNumber ()
+ {
+ return columnNumber;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Setters for the properties (not in org.xml.sax.Locator)
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set the public identifier for this locator.
+ *
+ * @param publicId The new public identifier, or null
+ * if none is available.
+ * @see #getPublicId
+ */
+ public void setPublicId (String publicId)
+ {
+ this.publicId = publicId;
+ }
+
+
+ /**
+ * Set the system identifier for this locator.
+ *
+ * @param systemId The new system identifier, or null
+ * if none is available.
+ * @see #getSystemId
+ */
+ public void setSystemId (String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+
+ /**
+ * Set the line number for this locator (1-based).
+ *
+ * @param lineNumber The line number, or -1 if none is available.
+ * @see #getLineNumber
+ */
+ public void setLineNumber (int lineNumber)
+ {
+ this.lineNumber = lineNumber;
+ }
+
+
+ /**
+ * Set the column number for this locator (1-based).
+ *
+ * @param columnNumber The column number, or -1 if none is available.
+ * @see #getColumnNumber
+ */
+ public void setColumnNumber (int columnNumber)
+ {
+ this.columnNumber = columnNumber;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ private String publicId;
+ private String systemId;
+ private int lineNumber;
+ private int columnNumber;
+
+}
+
+// end of LocatorImpl.java
-// NamespaceSupport.java - generic Namespace support for SAX.\r
-// Written by David Megginson, sax@megginson.com\r
-// This class is in the Public Domain. NO WARRANTY!\r
-\r
-// $Id: NamespaceSupport.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import java.util.EmptyStackException;\r
-import java.util.Enumeration;\r
-import java.util.Hashtable;\r
-import java.util.Vector;\r
-\r
-\r
-/**\r
- * Encapsulate Namespace logic for use by SAX drivers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class encapsulates the logic of Namespace processing:\r
- * it tracks the declarations currently in force for each context\r
- * and automatically processes qualified XML 1.0 names into their\r
- * Namespace parts; it can also be used in reverse for generating\r
- * XML 1.0 from Namespaces.</p>\r
- *\r
- * <p>Namespace support objects are reusable, but the reset method\r
- * must be invoked between each session.</p>\r
- *\r
- * <p>Here is a simple session:</p>\r
- *\r
- * <pre>\r
- * String parts[] = new String[3];\r
- * NamespaceSupport support = new NamespaceSupport();\r
- *\r
- * support.pushContext();\r
- * support.declarePrefix("", "http://www.w3.org/1999/xhtml");\r
- * support.declarePrefix("dc", "http://www.purl.org/dc#");\r
- *\r
- * String parts[] = support.processName("p", parts, false);\r
- * System.out.println("Namespace URI: " + parts[0]);\r
- * System.out.println("Local name: " + parts[1]);\r
- * System.out.println("Raw name: " + parts[2]);\r
-\r
- * String parts[] = support.processName("dc:title", parts, false);\r
- * System.out.println("Namespace URI: " + parts[0]);\r
- * System.out.println("Local name: " + parts[1]);\r
- * System.out.println("Raw name: " + parts[2]);\r
-\r
- * support.popContext();\r
- * </pre>\r
- *\r
- * <p>Note that this class is optimized for the use case where most\r
- * elements do not contain Namespace declarations: if the same\r
- * prefix/URI mapping is repeated for each context (for example), this\r
- * class will be somewhat less efficient.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- */\r
-public class NamespaceSupport\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constants.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * The XML Namespace as a constant.\r
- *\r
- * <p>This is the Namespace URI that is automatically mapped\r
- * to the "xml" prefix.</p>\r
- */\r
- public final static String XMLNS =\r
- "http://www.w3.org/XML/1998/namespace";\r
-\r
-\r
- /**\r
- * An empty enumeration.\r
- */\r
- private final static Enumeration EMPTY_ENUMERATION =\r
- new Vector().elements();\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constructor.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Create a new Namespace support object.\r
- */\r
- public NamespaceSupport ()\r
- {\r
- reset();\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Context management.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Reset this Namespace support object for reuse.\r
- *\r
- * <p>It is necessary to invoke this method before reusing the\r
- * Namespace support object for a new session.</p>\r
- */\r
- public void reset ()\r
- {\r
- contexts = new Context[32];\r
- contextPos = 0;\r
- contexts[contextPos] = currentContext = new Context();\r
- currentContext.declarePrefix("xml", XMLNS);\r
- }\r
-\r
-\r
- /**\r
- * Start a new Namespace context.\r
- *\r
- * <p>Normally, you should push a new context at the beginning\r
- * of each XML element: the new context will automatically inherit\r
- * the declarations of its parent context, but it will also keep\r
- * track of which declarations were made within this context.</p>\r
- *\r
- * <p>The Namespace support object always starts with a base context\r
- * already in force: in this context, only the "xml" prefix is\r
- * declared.</p>\r
- *\r
- * @see #popContext\r
- */\r
- public void pushContext ()\r
- {\r
- int max = contexts.length;\r
- contextPos++;\r
-\r
- // Extend the array if necessary\r
- if (contextPos >= max) {\r
- Context newContexts[] = new Context[max*2];\r
- System.arraycopy(contexts, 0, newContexts, 0, max);\r
- max *= 2;\r
- contexts = newContexts;\r
- }\r
-\r
- // Allocate the context if necessary.\r
- currentContext = contexts[contextPos];\r
- if (currentContext == null) {\r
- contexts[contextPos] = currentContext = new Context();\r
- }\r
-\r
- // Set the parent, if any.\r
- if (contextPos > 0) {\r
- currentContext.setParent(contexts[contextPos - 1]);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Revert to the previous Namespace context.\r
- *\r
- * <p>Normally, you should pop the context at the end of each\r
- * XML element. After popping the context, all Namespace prefix\r
- * mappings that were previously in force are restored.</p>\r
- *\r
- * <p>You must not attempt to declare additional Namespace\r
- * prefixes after popping a context, unless you push another\r
- * context first.</p>\r
- *\r
- * @see #pushContext\r
- */\r
- public void popContext ()\r
- {\r
- contextPos--;\r
- if (contextPos < 0) {\r
- throw new EmptyStackException();\r
- }\r
- currentContext = contexts[contextPos];\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Operations within a context.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Declare a Namespace prefix.\r
- *\r
- * <p>This method declares a prefix in the current Namespace\r
- * context; the prefix will remain in force until this context\r
- * is popped, unless it is shadowed in a descendant context.</p>\r
- *\r
- * <p>To declare a default Namespace, use the empty string. The\r
- * prefix must not be "xml" or "xmlns".</p>\r
- *\r
- * <p>Note that you must <em>not</em> declare a prefix after\r
- * you've pushed and popped another Namespace.</p>\r
- *\r
- * <p>Note that there is an asymmetry in this library: while {@link\r
- * #getPrefix getPrefix} will not return the default "" prefix,\r
- * even if you have declared one; to check for a default prefix,\r
- * you have to look it up explicitly using {@link #getURI getURI}.\r
- * This asymmetry exists to make it easier to look up prefixes\r
- * for attribute names, where the default prefix is not allowed.</p>\r
- *\r
- * @param prefix The prefix to declare, or null for the empty\r
- * string.\r
- * @param uri The Namespace URI to associate with the prefix.\r
- * @return true if the prefix was legal, false otherwise\r
- * @see #processName\r
- * @see #getURI\r
- * @see #getPrefix\r
- */\r
- public boolean declarePrefix (String prefix, String uri)\r
- {\r
- if (prefix.equals("xml") || prefix.equals("xmlns")) {\r
- return false;\r
- } else {\r
- currentContext.declarePrefix(prefix, uri);\r
- return true;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Process a raw XML 1.0 name.\r
- *\r
- * <p>This method processes a raw XML 1.0 name in the current\r
- * context by removing the prefix and looking it up among the\r
- * prefixes currently declared. The return value will be the\r
- * array supplied by the caller, filled in as follows:</p>\r
- *\r
- * <dl>\r
- * <dt>parts[0]</dt>\r
- * <dd>The Namespace URI, or an empty string if none is\r
- * in use.</dd>\r
- * <dt>parts[1]</dt>\r
- * <dd>The local name (without prefix).</dd>\r
- * <dt>parts[2]</dt>\r
- * <dd>The original raw name.</dd>\r
- * </dl>\r
- *\r
- * <p>All of the strings in the array will be internalized. If\r
- * the raw name has a prefix that has not been declared, then\r
- * the return value will be null.</p>\r
- *\r
- * <p>Note that attribute names are processed differently than\r
- * element names: an unprefixed element name will received the\r
- * default Namespace (if any), while an unprefixed element name\r
- * will not.</p>\r
- *\r
- * @param qName The raw XML 1.0 name to be processed.\r
- * @param parts An array supplied by the caller, capable of\r
- * holding at least three members.\r
- * @param isAttribute A flag indicating whether this is an\r
- * attribute name (true) or an element name (false).\r
- * @return The supplied array holding three internalized strings \r
- * representing the Namespace URI (or empty string), the\r
- * local name, and the raw XML 1.0 name; or null if there\r
- * is an undeclared prefix.\r
- * @see #declarePrefix\r
- * @see java.lang.String#intern */\r
- public String [] processName (String qName, String parts[],\r
- boolean isAttribute)\r
- {\r
- String myParts[] = currentContext.processName(qName, isAttribute);\r
- if (myParts == null) {\r
- return null;\r
- } else {\r
- parts[0] = myParts[0];\r
- parts[1] = myParts[1];\r
- parts[2] = myParts[2];\r
- return parts;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Look up a prefix and get the currently-mapped Namespace URI.\r
- *\r
- * <p>This method looks up the prefix in the current context.\r
- * Use the empty string ("") for the default Namespace.</p>\r
- *\r
- * @param prefix The prefix to look up.\r
- * @return The associated Namespace URI, or null if the prefix\r
- * is undeclared in this context.\r
- * @see #getPrefix\r
- * @see #getPrefixes\r
- */\r
- public String getURI (String prefix)\r
- {\r
- return currentContext.getURI(prefix);\r
- }\r
-\r
-\r
- /**\r
- * Return an enumeration of all prefixes currently declared.\r
- *\r
- * <p><strong>Note:</strong> if there is a default prefix, it will not be\r
- * returned in this enumeration; check for the default prefix\r
- * using the {@link #getURI getURI} with an argument of "".</p>\r
- *\r
- * @return An enumeration of all prefixes declared in the\r
- * current context except for the empty (default)\r
- * prefix.\r
- * @see #getDeclaredPrefixes\r
- * @see #getURI\r
- */\r
- public Enumeration getPrefixes ()\r
- {\r
- return currentContext.getPrefixes();\r
- }\r
-\r
-\r
- /**\r
- * Return one of the prefixes mapped to a Namespace URI.\r
- *\r
- * <p>If more than one prefix is currently mapped to the same\r
- * URI, this method will make an arbitrary selection; if you\r
- * want all of the prefixes, use the {@link #getPrefixes}\r
- * method instead.</p>\r
- *\r
- * <p><strong>Note:</strong> this will never return the empty (default) prefix;\r
- * to check for a default prefix, use the {@link #getURI getURI}\r
- * method with an argument of "".</p>\r
- *\r
- * @param uri The Namespace URI.\r
- * @param isAttribute true if this prefix is for an attribute\r
- * (and the default Namespace is not allowed).\r
- * @return One of the prefixes currently mapped to the URI supplied,\r
- * or null if none is mapped or if the URI is assigned to\r
- * the default Namespace.\r
- * @see #getPrefixes(java.lang.String)\r
- * @see #getURI\r
- */\r
- public String getPrefix (String uri)\r
- {\r
- return currentContext.getPrefix(uri);\r
- }\r
-\r
-\r
- /**\r
- * Return an enumeration of all prefixes currently declared for a URI.\r
- *\r
- * <p>This method returns prefixes mapped to a specific Namespace\r
- * URI. The xml: prefix will be included. If you want only one\r
- * prefix that's mapped to the Namespace URI, and you don't care \r
- * which one you get, use the {@link #getPrefix getPrefix}\r
- * method instead.</p>\r
- *\r
- * <p><strong>Note:</strong> the empty (default) prefix is <em>never</em> included\r
- * in this enumeration; to check for the presence of a default\r
- * Namespace, use the {@link #getURI getURI} method with an\r
- * argument of "".</p>\r
- *\r
- * @param uri The Namespace URI.\r
- * @return An enumeration of all prefixes declared in the\r
- * current context.\r
- * @see #getPrefix\r
- * @see #getDeclaredPrefixes\r
- * @see #getURI\r
- */\r
- public Enumeration getPrefixes (String uri)\r
- {\r
- Vector prefixes = new Vector();\r
- Enumeration allPrefixes = getPrefixes();\r
- while (allPrefixes.hasMoreElements()) {\r
- String prefix = (String)allPrefixes.nextElement();\r
- if (uri.equals(getURI(prefix))) {\r
- prefixes.addElement(prefix);\r
- }\r
- }\r
- return prefixes.elements();\r
- }\r
-\r
-\r
- /**\r
- * Return an enumeration of all prefixes declared in this context.\r
- *\r
- * <p>The empty (default) prefix will be included in this \r
- * enumeration; note that this behaviour differs from that of\r
- * {@link #getPrefix} and {@link #getPrefixes}.</p>\r
- *\r
- * @return An enumeration of all prefixes declared in this\r
- * context.\r
- * @see #getPrefixes\r
- * @see #getURI\r
- */\r
- public Enumeration getDeclaredPrefixes ()\r
- {\r
- return currentContext.getDeclaredPrefixes();\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- private Context contexts[];\r
- private Context currentContext;\r
- private int contextPos;\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal classes.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- /**\r
- * Internal class for a single Namespace context.\r
- *\r
- * <p>This module caches and reuses Namespace contexts, so the number allocated\r
- * will be equal to the element depth of the document, not to the total\r
- * number of elements (i.e. 5-10 rather than tens of thousands).</p>\r
- */\r
- final class Context {\r
-\r
- /**\r
- * Create the root-level Namespace context.\r
- */\r
- Context ()\r
- {\r
- copyTables();\r
- }\r
- \r
- \r
- /**\r
- * (Re)set the parent of this Namespace context.\r
- *\r
- * @param context The parent Namespace context object.\r
- */\r
- void setParent (Context parent)\r
- {\r
- this.parent = parent;\r
- declarations = null;\r
- prefixTable = parent.prefixTable;\r
- uriTable = parent.uriTable;\r
- elementNameTable = parent.elementNameTable;\r
- attributeNameTable = parent.attributeNameTable;\r
- defaultNS = parent.defaultNS;\r
- tablesDirty = false;\r
- }\r
- \r
- \r
- /**\r
- * Declare a Namespace prefix for this context.\r
- *\r
- * @param prefix The prefix to declare.\r
- * @param uri The associated Namespace URI.\r
- * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix\r
- */\r
- void declarePrefix (String prefix, String uri)\r
- {\r
- // Lazy processing...\r
- if (!tablesDirty) {\r
- copyTables();\r
- }\r
- if (declarations == null) {\r
- declarations = new Vector();\r
- }\r
- \r
- prefix = prefix.intern();\r
- uri = uri.intern();\r
- if ("".equals(prefix)) {\r
- if ("".equals(uri)) {\r
- defaultNS = null;\r
- } else {\r
- defaultNS = uri;\r
- }\r
- } else {\r
- prefixTable.put(prefix, uri);\r
- uriTable.put(uri, prefix); // may wipe out another prefix\r
- }\r
- declarations.addElement(prefix);\r
- }\r
-\r
-\r
- /**\r
- * Process a raw XML 1.0 name in this context.\r
- *\r
- * @param qName The raw XML 1.0 name.\r
- * @param isAttribute true if this is an attribute name.\r
- * @return An array of three strings containing the\r
- * URI part (or empty string), the local part,\r
- * and the raw name, all internalized, or null\r
- * if there is an undeclared prefix.\r
- * @see org.xml.sax.helpers.NamespaceSupport#processName\r
- */\r
- String [] processName (String qName, boolean isAttribute)\r
- {\r
- String name[];\r
- Hashtable table;\r
- \r
- // Select the appropriate table.\r
- if (isAttribute) {\r
- table = elementNameTable;\r
- } else {\r
- table = attributeNameTable;\r
- }\r
- \r
- // Start by looking in the cache, and\r
- // return immediately if the name\r
- // is already known in this content\r
- name = (String[])table.get(qName);\r
- if (name != null) {\r
- return name;\r
- }\r
- \r
- // We haven't seen this name in this\r
- // context before.\r
- name = new String[3];\r
- int index = qName.indexOf(':');\r
- \r
- \r
- // No prefix.\r
- if (index == -1) {\r
- if (isAttribute || defaultNS == null) {\r
- name[0] = "";\r
- } else {\r
- name[0] = defaultNS;\r
- }\r
- name[1] = qName.intern();\r
- name[2] = name[1];\r
- }\r
- \r
- // Prefix\r
- else {\r
- String prefix = qName.substring(0, index);\r
- String local = qName.substring(index+1);\r
- String uri;\r
- if ("".equals(prefix)) {\r
- uri = defaultNS;\r
- } else {\r
- uri = (String)prefixTable.get(prefix);\r
- }\r
- if (uri == null) {\r
- return null;\r
- }\r
- name[0] = uri;\r
- name[1] = local.intern();\r
- name[2] = qName.intern();\r
- }\r
- \r
- // Save in the cache for future use.\r
- table.put(name[2], name);\r
- tablesDirty = true;\r
- return name;\r
- }\r
- \r
-\r
- /**\r
- * Look up the URI associated with a prefix in this context.\r
- *\r
- * @param prefix The prefix to look up.\r
- * @return The associated Namespace URI, or null if none is\r
- * declared. \r
- * @see org.xml.sax.helpers.NamespaceSupport#getURI\r
- */\r
- String getURI (String prefix)\r
- {\r
- if ("".equals(prefix)) {\r
- return defaultNS;\r
- } else if (prefixTable == null) {\r
- return null;\r
- } else {\r
- return (String)prefixTable.get(prefix);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Look up one of the prefixes associated with a URI in this context.\r
- *\r
- * <p>Since many prefixes may be mapped to the same URI,\r
- * the return value may be unreliable.</p>\r
- *\r
- * @param uri The URI to look up.\r
- * @return The associated prefix, or null if none is declared.\r
- * @see org.xml.sax.helpers.NamespaceSupport#getPrefix\r
- */\r
- String getPrefix (String uri)\r
- {\r
- if (uriTable == null) {\r
- return null;\r
- } else {\r
- return (String)uriTable.get(uri);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Return an enumeration of prefixes declared in this context.\r
- *\r
- * @return An enumeration of prefixes (possibly empty).\r
- * @see org.xml.sax.helpers.NamespaceSupport#getDeclaredPrefixes\r
- */\r
- Enumeration getDeclaredPrefixes ()\r
- {\r
- if (declarations == null) {\r
- return EMPTY_ENUMERATION;\r
- } else {\r
- return declarations.elements();\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Return an enumeration of all prefixes currently in force.\r
- *\r
- * <p>The default prefix, if in force, is <em>not</em>\r
- * returned, and will have to be checked for separately.</p>\r
- *\r
- * @return An enumeration of prefixes (never empty).\r
- * @see org.xml.sax.helpers.NamespaceSupport#getPrefixes\r
- */\r
- Enumeration getPrefixes ()\r
- {\r
- if (prefixTable == null) {\r
- return EMPTY_ENUMERATION;\r
- } else {\r
- return prefixTable.keys();\r
- }\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////\r
- // Internal methods.\r
- ////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Copy on write for the internal tables in this context.\r
- *\r
- * <p>This class is optimized for the normal case where most\r
- * elements do not contain Namespace declarations.</p>\r
- */ \r
- private void copyTables ()\r
- {\r
- if (prefixTable != null) {\r
- prefixTable = (Hashtable)prefixTable.clone();\r
- } else {\r
- prefixTable = new Hashtable();\r
- }\r
- if (uriTable != null) {\r
- uriTable = (Hashtable)uriTable.clone();\r
- } else {\r
- uriTable = new Hashtable();\r
- }\r
- elementNameTable = new Hashtable();\r
- attributeNameTable = new Hashtable();\r
- tablesDirty = true;\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////\r
- // Protected state.\r
- ////////////////////////////////////////////////////////////////\r
- \r
- Hashtable prefixTable;\r
- Hashtable uriTable;\r
- Hashtable elementNameTable;\r
- Hashtable attributeNameTable;\r
- String defaultNS = null;\r
- \r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////\r
- \r
- private Vector declarations = null;\r
- private boolean tablesDirty = false;\r
- private Context parent = null;\r
- }\r
-}\r
-\r
-// end of NamespaceSupport.java\r
+// NamespaceSupport.java - generic Namespace support for SAX.
+// http://www.saxproject.org
+// Written by David Megginson
+// This class is in the Public Domain. NO WARRANTY!
+
+// $Id: NamespaceSupport.java,v 1.6.2.5 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.util.EmptyStackException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+
+/**
+ * Encapsulate Namespace logic for use by applications using SAX,
+ * or internally by SAX drivers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class encapsulates the logic of Namespace processing:
+ * it tracks the declarations currently in force for each context
+ * and automatically processes qualified XML 1.0 names into their
+ * Namespace parts; it can also be used in reverse for generating
+ * XML 1.0 from Namespaces.</p>
+ *
+ * <p>Namespace support objects are reusable, but the reset method
+ * must be invoked between each session.</p>
+ *
+ * <p>Here is a simple session:</p>
+ *
+ * <pre>
+ * String parts[] = new String[3];
+ * NamespaceSupport support = new NamespaceSupport();
+ *
+ * support.pushContext();
+ * support.declarePrefix("", "http://www.w3.org/1999/xhtml");
+ * support.declarePrefix("dc", "http://www.purl.org/dc#");
+ *
+ * parts = support.processName("p", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * parts = support.processName("dc:title", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * support.popContext();
+ * </pre>
+ *
+ * <p>Note that this class is optimized for the use case where most
+ * elements do not contain Namespace declarations: if the same
+ * prefix/URI mapping is repeated for each context (for example), this
+ * class will be somewhat less efficient.</p>
+ *
+ * <p>Although SAX drivers (parsers) may choose to use this class to
+ * implement namespace handling, they are not required to do so.
+ * Applications must track namespace information themselves if they
+ * want to use namespace information.
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ */
+public class NamespaceSupport
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constants.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * The XML Namespace URI as a constant.
+ * The value is <code>http://www.w3.org/XML/1998/namespace</code>
+ * as defined in the XML Namespaces specification.
+ *
+ * <p>This is the Namespace URI that is automatically mapped
+ * to the "xml" prefix.</p>
+ */
+ public final static String XMLNS =
+ "http://www.w3.org/XML/1998/namespace";
+
+
+ /**
+ * An empty enumeration.
+ */
+ private final static Enumeration EMPTY_ENUMERATION =
+ new Vector().elements();
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constructor.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Create a new Namespace support object.
+ */
+ public NamespaceSupport ()
+ {
+ reset();
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Context management.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Reset this Namespace support object for reuse.
+ *
+ * <p>It is necessary to invoke this method before reusing the
+ * Namespace support object for a new session.</p>
+ */
+ public void reset ()
+ {
+ contexts = new Context[32];
+ contextPos = 0;
+ contexts[contextPos] = currentContext = new Context();
+ currentContext.declarePrefix("xml", XMLNS);
+ }
+
+
+ /**
+ * Start a new Namespace context.
+ * The new context will automatically inherit
+ * the declarations of its parent context, but it will also keep
+ * track of which declarations were made within this context.
+ *
+ * <p>Event callback code should start a new context once per element.
+ * This means being ready to call this in either of two places.
+ * For elements that don't include namespace declarations, the
+ * <em>ContentHandler.startElement()</em> callback is the right place.
+ * For elements with such a declaration, it'd done in the first
+ * <em>ContentHandler.startPrefixMapping()</em> callback.
+ * A boolean flag can be used to
+ * track whether a context has been started yet. When either of
+ * those methods is called, it checks the flag to see if a new context
+ * needs to be started. If so, it starts the context and sets the
+ * flag. After <em>ContentHandler.startElement()</em>
+ * does that, it always clears the flag.
+ *
+ * <p>Normally, SAX drivers would push a new context at the beginning
+ * of each XML element. Then they perform a first pass over the
+ * attributes to process all namespace declarations, making
+ * <em>ContentHandler.startPrefixMapping()</em> callbacks.
+ * Then a second pass is made, to determine the namespace-qualified
+ * names for all attributes and for the element name.
+ * Finally all the information for the
+ * <em>ContentHandler.startElement()</em> callback is available,
+ * so it can then be made.
+ *
+ * <p>The Namespace support object always starts with a base context
+ * already in force: in this context, only the "xml" prefix is
+ * declared.</p>
+ *
+ * @see org.xml.sax.ContentHandler
+ * @see #popContext
+ */
+ public void pushContext ()
+ {
+ int max = contexts.length;
+
+ contexts [contextPos].declsOK = false;
+ contextPos++;
+
+ // Extend the array if necessary
+ if (contextPos >= max) {
+ Context newContexts[] = new Context[max*2];
+ System.arraycopy(contexts, 0, newContexts, 0, max);
+ max *= 2;
+ contexts = newContexts;
+ }
+
+ // Allocate the context if necessary.
+ currentContext = contexts[contextPos];
+ if (currentContext == null) {
+ contexts[contextPos] = currentContext = new Context();
+ }
+
+ // Set the parent, if any.
+ if (contextPos > 0) {
+ currentContext.setParent(contexts[contextPos - 1]);
+ }
+ }
+
+
+ /**
+ * Revert to the previous Namespace context.
+ *
+ * <p>Normally, you should pop the context at the end of each
+ * XML element. After popping the context, all Namespace prefix
+ * mappings that were previously in force are restored.</p>
+ *
+ * <p>You must not attempt to declare additional Namespace
+ * prefixes after popping a context, unless you push another
+ * context first.</p>
+ *
+ * @see #pushContext
+ */
+ public void popContext ()
+ {
+ contexts[contextPos].clear();
+ contextPos--;
+ if (contextPos < 0) {
+ throw new EmptyStackException();
+ }
+ currentContext = contexts[contextPos];
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Operations within a context.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Declare a Namespace prefix. All prefixes must be declared
+ * before they are referenced. For example, a SAX driver (parser)
+ * would scan an element's attributes
+ * in two passes: first for namespace declarations,
+ * then a second pass using {@link #processName processName()} to
+ * interpret prefixes against (potentially redefined) prefixes.
+ *
+ * <p>This method declares a prefix in the current Namespace
+ * context; the prefix will remain in force until this context
+ * is popped, unless it is shadowed in a descendant context.</p>
+ *
+ * <p>To declare the default element Namespace, use the empty string as
+ * the prefix.</p>
+ *
+ * <p>Note that you must <em>not</em> declare a prefix after
+ * you've pushed and popped another Namespace context, or
+ * treated the declarations phase as complete by processing
+ * a prefixed name.</p>
+ *
+ * <p>Note that there is an asymmetry in this library: {@link
+ * #getPrefix getPrefix} will not return the "" prefix,
+ * even if you have declared a default element namespace.
+ * To check for a default namespace,
+ * you have to look it up explicitly using {@link #getURI getURI}.
+ * This asymmetry exists to make it easier to look up prefixes
+ * for attribute names, where the default prefix is not allowed.</p>
+ *
+ * @param prefix The prefix to declare, or the empty string to
+ * indicate the default element namespace. This may never have
+ * the value "xml" or "xmlns".
+ * @param uri The Namespace URI to associate with the prefix.
+ * @return true if the prefix was legal, false otherwise
+ * @exception IllegalStateException when a prefix is declared
+ * after looking up a name in the context, or after pushing
+ * another context on top of it.
+ *
+ * @see #processName
+ * @see #getURI
+ * @see #getPrefix
+ */
+ public boolean declarePrefix (String prefix, String uri)
+ {
+ if (prefix.equals("xml") || prefix.equals("xmlns")) {
+ return false;
+ } else {
+ currentContext.declarePrefix(prefix, uri);
+ return true;
+ }
+ }
+
+
+ /**
+ * Process a raw XML 1.0 name, after all declarations in the current
+ * context have been handled by {@link #declarePrefix declarePrefix()}.
+ *
+ * <p>This method processes a raw XML 1.0 name in the current
+ * context by removing the prefix and looking it up among the
+ * prefixes currently declared. The return value will be the
+ * array supplied by the caller, filled in as follows:</p>
+ *
+ * <dl>
+ * <dt>parts[0]</dt>
+ * <dd>The Namespace URI, or an empty string if none is
+ * in use.</dd>
+ * <dt>parts[1]</dt>
+ * <dd>The local name (without prefix).</dd>
+ * <dt>parts[2]</dt>
+ * <dd>The original raw name.</dd>
+ * </dl>
+ *
+ * <p>All of the strings in the array will be internalized. If
+ * the raw name has a prefix that has not been declared, then
+ * the return value will be null.</p>
+ *
+ * <p>Note that attribute names are processed differently than
+ * element names: an unprefixed element name will received the
+ * default Namespace (if any), while an unprefixed attribute name
+ * will not.</p>
+ *
+ * @param qName The raw XML 1.0 name to be processed.
+ * @param parts An array supplied by the caller, capable of
+ * holding at least three members.
+ * @param isAttribute A flag indicating whether this is an
+ * attribute name (true) or an element name (false).
+ * @return The supplied array holding three internalized strings
+ * representing the Namespace URI (or empty string), the
+ * local name, and the raw XML 1.0 name; or null if there
+ * is an undeclared prefix.
+ * @see #declarePrefix
+ * @see java.lang.String#intern */
+ public String [] processName (String qName, String parts[],
+ boolean isAttribute)
+ {
+ String myParts[] = currentContext.processName(qName, isAttribute);
+ if (myParts == null) {
+ return null;
+ } else {
+ parts[0] = myParts[0];
+ parts[1] = myParts[1];
+ parts[2] = myParts[2];
+ return parts;
+ }
+ }
+
+
+ /**
+ * Look up a prefix and get the currently-mapped Namespace URI.
+ *
+ * <p>This method looks up the prefix in the current context.
+ * Use the empty string ("") for the default Namespace.</p>
+ *
+ * @param prefix The prefix to look up.
+ * @return The associated Namespace URI, or null if the prefix
+ * is undeclared in this context.
+ * @see #getPrefix
+ * @see #getPrefixes
+ */
+ public String getURI (String prefix)
+ {
+ return currentContext.getURI(prefix);
+ }
+
+
+ /**
+ * Return an enumeration of all prefixes currently declared.
+ *
+ * <p><strong>Note:</strong> if there is a default prefix, it will not be
+ * returned in this enumeration; check for the default prefix
+ * using the {@link #getURI getURI} with an argument of "".</p>
+ *
+ * @return An enumeration of all prefixes declared in the
+ * current context except for the empty (default)
+ * prefix.
+ * @see #getDeclaredPrefixes
+ * @see #getURI
+ */
+ public Enumeration getPrefixes ()
+ {
+ return currentContext.getPrefixes();
+ }
+
+
+ /**
+ * Return one of the prefixes mapped to a Namespace URI.
+ *
+ * <p>If more than one prefix is currently mapped to the same
+ * URI, this method will make an arbitrary selection; if you
+ * want all of the prefixes, use the {@link #getPrefixes}
+ * method instead.</p>
+ *
+ * <p><strong>Note:</strong> this will never return the empty (default) prefix;
+ * to check for a default prefix, use the {@link #getURI getURI}
+ * method with an argument of "".</p>
+ *
+ * @param uri The Namespace URI.
+ * @param isAttribute true if this prefix is for an attribute
+ * (and the default Namespace is not allowed).
+ * @return One of the prefixes currently mapped to the URI supplied,
+ * or null if none is mapped or if the URI is assigned to
+ * the default Namespace.
+ * @see #getPrefixes(java.lang.String)
+ * @see #getURI
+ */
+ public String getPrefix (String uri)
+ {
+ return currentContext.getPrefix(uri);
+ }
+
+
+ /**
+ * Return an enumeration of all prefixes currently declared for a URI.
+ *
+ * <p>This method returns prefixes mapped to a specific Namespace
+ * URI. The xml: prefix will be included. If you want only one
+ * prefix that's mapped to the Namespace URI, and you don't care
+ * which one you get, use the {@link #getPrefix getPrefix}
+ * method instead.</p>
+ *
+ * <p><strong>Note:</strong> the empty (default) prefix is <em>never</em> included
+ * in this enumeration; to check for the presence of a default
+ * Namespace, use the {@link #getURI getURI} method with an
+ * argument of "".</p>
+ *
+ * @param uri The Namespace URI.
+ * @return An enumeration of all prefixes declared in the
+ * current context.
+ * @see #getPrefix
+ * @see #getDeclaredPrefixes
+ * @see #getURI
+ */
+ public Enumeration getPrefixes (String uri)
+ {
+ Vector prefixes = new Vector();
+ Enumeration allPrefixes = getPrefixes();
+ while (allPrefixes.hasMoreElements()) {
+ String prefix = (String)allPrefixes.nextElement();
+ if (uri.equals(getURI(prefix))) {
+ prefixes.addElement(prefix);
+ }
+ }
+ return prefixes.elements();
+ }
+
+
+ /**
+ * Return an enumeration of all prefixes declared in this context.
+ *
+ * <p>The empty (default) prefix will be included in this
+ * enumeration; note that this behaviour differs from that of
+ * {@link #getPrefix} and {@link #getPrefixes}.</p>
+ *
+ * @return An enumeration of all prefixes declared in this
+ * context.
+ * @see #getPrefixes
+ * @see #getURI
+ */
+ public Enumeration getDeclaredPrefixes ()
+ {
+ return currentContext.getDeclaredPrefixes();
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ private Context contexts[];
+ private Context currentContext;
+ private int contextPos;
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal classes.
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Internal class for a single Namespace context.
+ *
+ * <p>This module caches and reuses Namespace contexts,
+ * so the number allocated
+ * will be equal to the element depth of the document, not to the total
+ * number of elements (i.e. 5-10 rather than tens of thousands).
+ * Also, data structures used to represent contexts are shared when
+ * possible (child contexts without declarations) to further reduce
+ * the amount of memory that's consumed.
+ * </p>
+ */
+ final class Context {
+
+ /**
+ * Create the root-level Namespace context.
+ */
+ Context ()
+ {
+ copyTables();
+ }
+
+
+ /**
+ * (Re)set the parent of this Namespace context.
+ * The context must either have been freshly constructed,
+ * or must have been cleared.
+ *
+ * @param context The parent Namespace context object.
+ */
+ void setParent (Context parent)
+ {
+ this.parent = parent;
+ declarations = null;
+ prefixTable = parent.prefixTable;
+ uriTable = parent.uriTable;
+ elementNameTable = parent.elementNameTable;
+ attributeNameTable = parent.attributeNameTable;
+ defaultNS = parent.defaultNS;
+ declSeen = false;
+ declsOK = true;
+ }
+
+ /**
+ * Makes associated state become collectible,
+ * invalidating this context.
+ * {@link #setParent} must be called before
+ * this context may be used again.
+ */
+ void clear ()
+ {
+ parent = null;
+ prefixTable = null;
+ uriTable = null;
+ elementNameTable = null;
+ attributeNameTable = null;
+ defaultNS = null;
+ }
+
+
+ /**
+ * Declare a Namespace prefix for this context.
+ *
+ * @param prefix The prefix to declare.
+ * @param uri The associated Namespace URI.
+ * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix
+ */
+ void declarePrefix (String prefix, String uri)
+ {
+ // Lazy processing...
+ if (!declsOK)
+ throw new IllegalStateException (
+ "can't declare any more prefixes in this context");
+ if (!declSeen) {
+ copyTables();
+ }
+ if (declarations == null) {
+ declarations = new Vector();
+ }
+
+ prefix = prefix.intern();
+ uri = uri.intern();
+ if ("".equals(prefix)) {
+ if ("".equals(uri)) {
+ defaultNS = null;
+ } else {
+ defaultNS = uri;
+ }
+ } else {
+ prefixTable.put(prefix, uri);
+ uriTable.put(uri, prefix); // may wipe out another prefix
+ }
+ declarations.addElement(prefix);
+ }
+
+
+ /**
+ * Process a raw XML 1.0 name in this context.
+ *
+ * @param qName The raw XML 1.0 name.
+ * @param isAttribute true if this is an attribute name.
+ * @return An array of three strings containing the
+ * URI part (or empty string), the local part,
+ * and the raw name, all internalized, or null
+ * if there is an undeclared prefix.
+ * @see org.xml.sax.helpers.NamespaceSupport#processName
+ */
+ String [] processName (String qName, boolean isAttribute)
+ {
+ String name[];
+ Hashtable table;
+
+ // detect errors in call sequence
+ declsOK = false;
+
+ // Select the appropriate table.
+ if (isAttribute) {
+ table = attributeNameTable;
+ } else {
+ table = elementNameTable;
+ }
+
+ // Start by looking in the cache, and
+ // return immediately if the name
+ // is already known in this content
+ name = (String[])table.get(qName);
+ if (name != null) {
+ return name;
+ }
+
+ // We haven't seen this name in this
+ // context before. Maybe in the parent
+ // context, but we can't assume prefix
+ // bindings are the same.
+ name = new String[3];
+ name[2] = qName.intern();
+ int index = qName.indexOf(':');
+
+
+ // No prefix.
+ if (index == -1) {
+ if (isAttribute || defaultNS == null) {
+ name[0] = "";
+ } else {
+ name[0] = defaultNS;
+ }
+ name[1] = name[2];
+ }
+
+ // Prefix
+ else {
+ String prefix = qName.substring(0, index);
+ String local = qName.substring(index+1);
+ String uri;
+ if ("".equals(prefix)) {
+ uri = defaultNS;
+ } else {
+ uri = (String)prefixTable.get(prefix);
+ }
+ if (uri == null) {
+ return null;
+ }
+ name[0] = uri;
+ name[1] = local.intern();
+ }
+
+ // Save in the cache for future use.
+ // (Could be shared with parent context...)
+ table.put(name[2], name);
+ return name;
+ }
+
+
+ /**
+ * Look up the URI associated with a prefix in this context.
+ *
+ * @param prefix The prefix to look up.
+ * @return The associated Namespace URI, or null if none is
+ * declared.
+ * @see org.xml.sax.helpers.NamespaceSupport#getURI
+ */
+ String getURI (String prefix)
+ {
+ if ("".equals(prefix)) {
+ return defaultNS;
+ } else if (prefixTable == null) {
+ return null;
+ } else {
+ return (String)prefixTable.get(prefix);
+ }
+ }
+
+
+ /**
+ * Look up one of the prefixes associated with a URI in this context.
+ *
+ * <p>Since many prefixes may be mapped to the same URI,
+ * the return value may be unreliable.</p>
+ *
+ * @param uri The URI to look up.
+ * @return The associated prefix, or null if none is declared.
+ * @see org.xml.sax.helpers.NamespaceSupport#getPrefix
+ */
+ String getPrefix (String uri)
+ {
+ if (uriTable == null) {
+ return null;
+ } else {
+ return (String)uriTable.get(uri);
+ }
+ }
+
+
+ /**
+ * Return an enumeration of prefixes declared in this context.
+ *
+ * @return An enumeration of prefixes (possibly empty).
+ * @see org.xml.sax.helpers.NamespaceSupport#getDeclaredPrefixes
+ */
+ Enumeration getDeclaredPrefixes ()
+ {
+ if (declarations == null) {
+ return EMPTY_ENUMERATION;
+ } else {
+ return declarations.elements();
+ }
+ }
+
+
+ /**
+ * Return an enumeration of all prefixes currently in force.
+ *
+ * <p>The default prefix, if in force, is <em>not</em>
+ * returned, and will have to be checked for separately.</p>
+ *
+ * @return An enumeration of prefixes (never empty).
+ * @see org.xml.sax.helpers.NamespaceSupport#getPrefixes
+ */
+ Enumeration getPrefixes ()
+ {
+ if (prefixTable == null) {
+ return EMPTY_ENUMERATION;
+ } else {
+ return prefixTable.keys();
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////
+ // Internal methods.
+ ////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Copy on write for the internal tables in this context.
+ *
+ * <p>This class is optimized for the normal case where most
+ * elements do not contain Namespace declarations.</p>
+ */
+ private void copyTables ()
+ {
+ if (prefixTable != null) {
+ prefixTable = (Hashtable)prefixTable.clone();
+ } else {
+ prefixTable = new Hashtable();
+ }
+ if (uriTable != null) {
+ uriTable = (Hashtable)uriTable.clone();
+ } else {
+ uriTable = new Hashtable();
+ }
+ elementNameTable = new Hashtable();
+ attributeNameTable = new Hashtable();
+ declSeen = true;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////
+ // Protected state.
+ ////////////////////////////////////////////////////////////////
+
+ Hashtable prefixTable;
+ Hashtable uriTable;
+ Hashtable elementNameTable;
+ Hashtable attributeNameTable;
+ String defaultNS = null;
+ boolean declsOK = true;
+
+
+\f
+ ////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////
+
+ private Vector declarations = null;
+ private boolean declSeen = false;
+ private Context parent = null;
+ }
+}
+
+// end of NamespaceSupport.java
--- /dev/null
+// NewInstance.java - create a new instance of a class by name.
+// http://www.saxproject.org
+// Written by Edwin Goei, edwingo@apache.org
+// and by David Brownell, dbrownell@users.sourceforge.net
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: NewInstance.java,v 1.1.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Create a new instance of a class by name.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class contains a static method for creating an instance of a
+ * class from an explicit class name. It tries to use the thread's context
+ * ClassLoader if possible and falls back to using
+ * Class.forName(String).</p>
+ *
+ * <p>This code is designed to compile and run on JDK version 1.1 and later
+ * including versions of Java 2.</p>
+ *
+ * @author Edwin Goei, David Brownell
+ * @version 2.0.1 (sax2r2)
+ */
+class NewInstance {
+
+ /**
+ * Creates a new instance of the specified class name
+ *
+ * Package private so this code is not exposed at the API level.
+ */
+ static Object newInstance (ClassLoader classLoader, String className)
+ throws ClassNotFoundException, IllegalAccessException,
+ InstantiationException
+ {
+ Class driverClass;
+ if (classLoader == null) {
+ driverClass = Class.forName(className);
+ } else {
+ driverClass = classLoader.loadClass(className);
+ }
+ return driverClass.newInstance();
+ }
+
+ /**
+ * Figure out which ClassLoader to use. For JDK 1.2 and later use
+ * the context ClassLoader.
+ */
+ static ClassLoader getClassLoader ()
+ {
+ Method m = null;
+
+ try {
+ m = Thread.class.getMethod("getContextClassLoader", null);
+ } catch (NoSuchMethodException e) {
+ // Assume that we are running JDK 1.1, use the current ClassLoader
+ return NewInstance.class.getClassLoader();
+ }
+
+ try {
+ return (ClassLoader) m.invoke(Thread.currentThread(), null);
+ } catch (IllegalAccessException e) {
+ // assert(false)
+ throw new UnknownError(e.getMessage());
+ } catch (InvocationTargetException e) {
+ // assert(e.getTargetException() instanceof SecurityException)
+ throw new UnknownError(e.getMessage());
+ }
+ }
+}
-// ParserAdapter.java - adapt a SAX1 Parser to a SAX2 XMLReader.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: ParserAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import java.io.IOException;\r
-import java.util.Enumeration;\r
-\r
-import org.xml.sax.Parser; // deprecated\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.Locator;\r
-import org.xml.sax.AttributeList; // deprecated\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.DTDHandler;\r
-import org.xml.sax.DocumentHandler; // deprecated\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.ContentHandler;\r
-import org.xml.sax.SAXNotRecognizedException;\r
-import org.xml.sax.SAXNotSupportedException;\r
-\r
-\r
-/**\r
- * Adapt a SAX1 Parser as a SAX2 XMLReader.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class wraps a SAX1 {@link org.xml.sax.Parser Parser}\r
- * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader},\r
- * with feature, property, and Namespace support. Note\r
- * that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity\r
- * skippedEntity} events, since SAX1 does not make that information available.</p>\r
- *\r
- * <p>This adapter does not test for duplicate Namespace-qualified\r
- * attribute names.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.helpers.XMLReaderAdapter\r
- * @see org.xml.sax.XMLReader\r
- * @see org.xml.sax.Parser\r
- */\r
-public class ParserAdapter implements XMLReader, DocumentHandler\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constructors.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Construct a new parser adapter.\r
- *\r
- * <p>Use the "org.xml.sax.parser" property to locate the\r
- * embedded SAX1 driver.</p>\r
- *\r
- * @exception org.xml.sax.SAXException If the embedded driver\r
- * cannot be instantiated or if the\r
- * org.xml.sax.parser property is not specified.\r
- */\r
- public ParserAdapter ()\r
- throws SAXException\r
- {\r
- super();\r
-\r
- String driver = System.getProperty("org.xml.sax.parser");\r
-\r
- try {\r
- setup(ParserFactory.makeParser());\r
- } catch (ClassNotFoundException e1) {\r
- throw new\r
- SAXException("Cannot find SAX1 driver class " +\r
- driver, e1);\r
- } catch (IllegalAccessException e2) {\r
- throw new\r
- SAXException("SAX1 driver class " +\r
- driver +\r
- " found but cannot be loaded", e2);\r
- } catch (InstantiationException e3) {\r
- throw new\r
- SAXException("SAX1 driver class " +\r
- driver +\r
- " loaded but cannot be instantiated", e3);\r
- } catch (ClassCastException e4) {\r
- throw new\r
- SAXException("SAX1 driver class " +\r
- driver +\r
- " does not implement org.xml.sax.Parser");\r
- } catch (NullPointerException e5) {\r
- throw new \r
- SAXException("System property org.xml.sax.parser not specified");\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Construct a new parser adapter.\r
- *\r
- * <p>Note that the embedded parser cannot be changed once the\r
- * adapter is created; to embed a different parser, allocate\r
- * a new ParserAdapter.</p>\r
- *\r
- * @param parser The SAX1 parser to embed.\r
- * @exception java.lang.NullPointerException If the parser parameter\r
- * is null.\r
- */\r
- public ParserAdapter (Parser parser)\r
- {\r
- super();\r
- setup(parser);\r
- }\r
-\r
-\r
- /**\r
- * Internal setup method.\r
- *\r
- * @param parser The embedded parser.\r
- * @exception java.lang.NullPointerException If the parser parameter\r
- * is null.\r
- */\r
- private void setup (Parser parser)\r
- {\r
- if (parser == null) {\r
- throw new\r
- NullPointerException("Parser argument must not be null");\r
- }\r
- this.parser = parser;\r
- atts = new AttributesImpl();\r
- nsSupport = new NamespaceSupport();\r
- attAdapter = new AttributeListAdapter();\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.XMLReader.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- //\r
- // Internal constants for the sake of convenience.\r
- //\r
- private final static String FEATURES = "http://xml.org/sax/features/";\r
- private final static String NAMESPACES = FEATURES + "namespaces";\r
- private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes";\r
- private final static String VALIDATION = FEATURES + "validation";\r
- private final static String EXTERNAL_GENERAL =\r
- FEATURES + "external-general-entities";\r
- private final static String EXTERNAL_PARAMETER =\r
- FEATURES + "external-parameter-entities";\r
-\r
-\r
- /**\r
- * Set a feature for the parser.\r
- *\r
- * <p>The only features supported are namespaces and \r
- * namespace-prefixes.</p>\r
- *\r
- * @param name The feature name, as a complete URI.\r
- * @param state The requested feature state.\r
- * @exception org.xml.sax.SAXNotRecognizedException If the feature\r
- * name is not known.\r
- * @exception org.xml.sax.SAXNotSupportedException If the feature\r
- * state is not supported.\r
- * @see org.xml.sax.XMLReader#setFeature\r
- */\r
- public void setFeature (String name, boolean state)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (name.equals(NAMESPACES)) {\r
- checkNotParsing("feature", name);\r
- namespaces = state;\r
- if (!namespaces && !prefixes) {\r
- prefixes = true;\r
- }\r
- } else if (name.equals(NAMESPACE_PREFIXES)) {\r
- checkNotParsing("feature", name);\r
- prefixes = state;\r
- if (!prefixes && !namespaces) {\r
- namespaces = true;\r
- }\r
- } else if (name.equals(VALIDATION) ||\r
- name.equals(EXTERNAL_GENERAL) ||\r
- name.equals(EXTERNAL_PARAMETER)) {\r
- throw new SAXNotSupportedException("Feature: " + name);\r
- } else {\r
- throw new SAXNotRecognizedException("Feature: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Check a parser feature.\r
- *\r
- * <p>The only features supported are namespaces and \r
- * namespace-prefixes.</p>\r
- *\r
- * @param name The feature name, as a complete URI.\r
- * @return The current feature state.\r
- * @exception org.xml.sax.SAXNotRecognizedException If the feature\r
- * name is not known.\r
- * @exception org.xml.sax.SAXNotSupportedException If querying the\r
- * feature state is not supported.\r
- * @see org.xml.sax.XMLReader#setFeature\r
- */\r
- public boolean getFeature (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (name.equals(NAMESPACES)) {\r
- return namespaces;\r
- } else if (name.equals(NAMESPACE_PREFIXES)) {\r
- return prefixes;\r
- } else if (name.equals(VALIDATION) ||\r
- name.equals(EXTERNAL_GENERAL) ||\r
- name.equals(EXTERNAL_PARAMETER)) {\r
- throw new SAXNotSupportedException("Feature: " + name);\r
- } else {\r
- throw new SAXNotRecognizedException("Feature: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set a parser property.\r
- *\r
- * <p>No special properties are currently supported.</p>\r
- *\r
- * @param name The property name.\r
- * @param value The property value.\r
- * @exception org.xml.sax.SAXNotRecognizedException If the feature\r
- * name is not known.\r
- * @exception org.xml.sax.SAXNotSupportedException If the feature\r
- * state is not supported.\r
- * @see org.xml.sax.XMLReader#setProperty\r
- */\r
- public void setProperty (String name, Object value)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- throw new SAXNotRecognizedException("Property: " + name);\r
- }\r
-\r
-\r
- /**\r
- * Get a parser property.\r
- *\r
- * <p>No special properties are currently supported.</p>\r
- *\r
- * @param name The property name.\r
- * @return The property value.\r
- * @exception org.xml.sax.SAXNotRecognizedException If the feature\r
- * name is not known.\r
- * @exception org.xml.sax.SAXNotSupportedException If the feature\r
- * state is not supported.\r
- * @see org.xml.sax.XMLReader#getProperty\r
- */\r
- public Object getProperty (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- throw new SAXNotRecognizedException("Property: " + name);\r
- }\r
-\r
-\r
- /**\r
- * Set the entity resolver.\r
- *\r
- * @param resolver The new entity resolver.\r
- * @exception java.lang.NullPointerException If the entity resolver\r
- * parameter is null.\r
- * @see org.xml.sax.XMLReader#setEntityResolver\r
- */\r
- public void setEntityResolver (EntityResolver resolver)\r
- {\r
- if (resolver == null) {\r
- throw new NullPointerException("Null entity resolver");\r
- }\r
- entityResolver = resolver;\r
- }\r
-\r
-\r
- /**\r
- * Return the current entity resolver.\r
- *\r
- * @return The current entity resolver, or null if none was supplied.\r
- * @see org.xml.sax.XMLReader#getEntityResolver\r
- */\r
- public EntityResolver getEntityResolver ()\r
- {\r
- return entityResolver;\r
- }\r
-\r
-\r
- /**\r
- * Set the DTD handler.\r
- *\r
- * @param resolver The new DTD handler.\r
- * @exception java.lang.NullPointerException If the DTD handler\r
- * parameter is null.\r
- * @see org.xml.sax.XMLReader#setEntityResolver\r
- */\r
- public void setDTDHandler (DTDHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null DTD handler");\r
- }\r
- dtdHandler = handler;\r
- }\r
-\r
-\r
- /**\r
- * Return the current DTD handler.\r
- *\r
- * @return The current DTD handler, or null if none was supplied.\r
- * @see org.xml.sax.XMLReader#getEntityResolver\r
- */\r
- public DTDHandler getDTDHandler ()\r
- {\r
- return dtdHandler;\r
- }\r
-\r
-\r
- /**\r
- * Set the content handler.\r
- *\r
- * @param resolver The new content handler.\r
- * @exception java.lang.NullPointerException If the content handler\r
- * parameter is null.\r
- * @see org.xml.sax.XMLReader#setEntityResolver\r
- */\r
- public void setContentHandler (ContentHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null content handler");\r
- }\r
- contentHandler = handler;\r
- }\r
-\r
-\r
- /**\r
- * Return the current content handler.\r
- *\r
- * @return The current content handler, or null if none was supplied.\r
- * @see org.xml.sax.XMLReader#getEntityResolver\r
- */\r
- public ContentHandler getContentHandler ()\r
- {\r
- return contentHandler;\r
- }\r
-\r
-\r
- /**\r
- * Set the error handler.\r
- *\r
- * @param resolver The new error handler.\r
- * @exception java.lang.NullPointerException If the error handler\r
- * parameter is null.\r
- * @see org.xml.sax.XMLReader#setEntityResolver\r
- */\r
- public void setErrorHandler (ErrorHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null error handler");\r
- }\r
- errorHandler = handler;\r
- }\r
-\r
-\r
- /**\r
- * Return the current error handler.\r
- *\r
- * @return The current error handler, or null if none was supplied.\r
- * @see org.xml.sax.XMLReader#getEntityResolver\r
- */\r
- public ErrorHandler getErrorHandler ()\r
- {\r
- return errorHandler;\r
- }\r
-\r
-\r
- /**\r
- * Parse an XML document.\r
- *\r
- * @param systemId The absolute URL of the document.\r
- * @exception java.io.IOException If there is a problem reading\r
- * the raw content of the document.\r
- * @exception org.xml.sax.SAXException If there is a problem\r
- * processing the document.\r
- * @see #parse(org.xml.sax.InputSource)\r
- * @see org.xml.sax.Parser#parse(java.lang.String)\r
- */\r
- public void parse (String systemId)\r
- throws IOException, SAXException\r
- {\r
- parse(new InputSource(systemId));\r
- }\r
-\r
-\r
- /**\r
- * Parse an XML document.\r
- *\r
- * @param input An input source for the document.\r
- * @exception java.io.IOException If there is a problem reading\r
- * the raw content of the document.\r
- * @exception org.xml.sax.SAXException If there is a problem\r
- * processing the document.\r
- * @see #parse(java.lang.String)\r
- * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)\r
- */\r
- public void parse (InputSource input)\r
- throws IOException, SAXException\r
- {\r
- if (parsing) {\r
- throw new SAXException("Parser is already in use");\r
- }\r
- setupParser();\r
- parsing = true;\r
- try {\r
- parser.parse(input);\r
- } finally {\r
- parsing = false;\r
- }\r
- parsing = false;\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.DocumentHandler.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Adapt a SAX1 document locator event.\r
- *\r
- * @param locator A document locator.\r
- * @see org.xml.sax.ContentHandler#setDocumentLocator\r
- */\r
- public void setDocumentLocator (Locator locator)\r
- {\r
- this.locator = locator;\r
- if (contentHandler != null) {\r
- contentHandler.setDocumentLocator(locator);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 start document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#startDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.startDocument();\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 end document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#endDocument\r
- */\r
- public void endDocument ()\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.endDocument();\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 startElement event.\r
- *\r
- * <p>If necessary, perform Namespace processing.</p>\r
- *\r
- * @param qName The qualified (prefixed) name.\r
- * @param qAtts The XML 1.0 attribute list (with qnames).\r
- */\r
- public void startElement (String qName, AttributeList qAtts)\r
- throws SAXException\r
- {\r
- // If we're not doing Namespace\r
- // processing, dispatch this quickly.\r
- if (!namespaces) {\r
- if (contentHandler != null) {\r
- attAdapter.setAttributeList(qAtts);\r
- contentHandler.startElement("", "", qName.intern(),\r
- attAdapter);\r
- }\r
- return;\r
- }\r
-\r
-\r
- // OK, we're doing Namespace processing.\r
- nsSupport.pushContext();\r
- boolean seenDecl = false;\r
- atts.clear();\r
- \r
- // Take a first pass and copy all\r
- // attributes into the SAX2 attribute\r
- // list, noting any Namespace \r
- // declarations.\r
- int length = qAtts.getLength();\r
- for (int i = 0; i < length; i++) {\r
- String attQName = qAtts.getName(i);\r
- String type = qAtts.getType(i);\r
- String value = qAtts.getValue(i);\r
-\r
- // Found a declaration...\r
- if (attQName.startsWith("xmlns")) {\r
- String prefix;\r
- int n = attQName.indexOf(':');\r
- if (n == -1) {\r
- prefix = "";\r
- } else {\r
- prefix = attQName.substring(n+1);\r
- }\r
- if (!nsSupport.declarePrefix(prefix, value)) {\r
- reportError("Illegal Namespace prefix: " + prefix);\r
- }\r
- if (contentHandler != null) {\r
- contentHandler.startPrefixMapping(prefix, value);\r
- }\r
- // We may still have to add this to\r
- // the list.\r
- if (prefixes) {\r
- atts.addAttribute("", "", attQName.intern(),\r
- type, value);\r
- }\r
- seenDecl = true;\r
-\r
- // This isn't a declaration.\r
- } else {\r
- String attName[] = processName(attQName, true);\r
- atts.addAttribute(attName[0], attName[1], attName[2],\r
- type, value);\r
- }\r
- }\r
- \r
- // If there was a Namespace declaration,\r
- // we have to make a second pass just\r
- // to be safe -- this will happen very\r
- // rarely, possibly only once for each\r
- // document.\r
- if (seenDecl) {\r
- length = atts.getLength();\r
- for (int i = 0; i < length; i++) {\r
- String attQName = atts.getQName(i);\r
- if (!attQName.startsWith("xmlns")) {\r
- String attName[] = processName(attQName, true);\r
- atts.setURI(i, attName[0]);\r
- atts.setLocalName(i, attName[1]);\r
- }\r
- }\r
- }\r
-\r
- // OK, finally report the event.\r
- if (contentHandler != null) {\r
- String name[] = processName(qName, false);\r
- contentHandler.startElement(name[0], name[1], name[2], atts);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 end element event.\r
- *\r
- * @param qName The qualified (prefixed) name.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#endElement\r
- */\r
- public void endElement (String qName)\r
- throws SAXException\r
- {\r
- // If we're not doing Namespace\r
- // processing, dispatch this quickly.\r
- if (!namespaces) {\r
- if (contentHandler != null) {\r
- contentHandler.endElement("", "", qName.intern());\r
- }\r
- return;\r
- }\r
-\r
- // Split the name.\r
- String names[] = processName(qName, false);\r
- if (contentHandler != null) {\r
- contentHandler.endElement(names[0], names[1], names[2]);\r
- Enumeration prefixes = nsSupport.getDeclaredPrefixes();\r
- while (prefixes.hasMoreElements()) {\r
- String prefix = (String)prefixes.nextElement();\r
- contentHandler.endPrefixMapping(prefix);\r
- }\r
- }\r
- nsSupport.popContext();\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 characters event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#characters\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.characters(ch, start, length);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 ignorable whitespace event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#ignorableWhitespace\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.ignorableWhitespace(ch, start, length);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX1 processing instruction event.\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The remainder of the processing instruction\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.DocumentHandler#processingInstruction\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.processingInstruction(target, data);\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal utility methods.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Initialize the parser before each run.\r
- */\r
- private void setupParser ()\r
- {\r
- nsSupport.reset();\r
-\r
- if (entityResolver != null) {\r
- parser.setEntityResolver(entityResolver);\r
- }\r
- if (dtdHandler != null) {\r
- parser.setDTDHandler(dtdHandler);\r
- }\r
- if (errorHandler != null) {\r
- parser.setErrorHandler(errorHandler);\r
- }\r
- parser.setDocumentHandler(this);\r
- locator = null;\r
- }\r
-\r
-\r
- /**\r
- * Process a qualified (prefixed) name.\r
- *\r
- * <p>If the name has an undeclared prefix, use only the qname\r
- * and make an ErrorHandler.error callback in case the app is\r
- * interested.</p>\r
- *\r
- * @param qName The qualified (prefixed) name.\r
- * @param isAttribute true if this is an attribute name.\r
- * @return The name split into three parts.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception if there is an error callback.\r
- */\r
- private String [] processName (String qName, boolean isAttribute)\r
- throws SAXException\r
- {\r
- String parts[] = nsSupport.processName(qName, nameParts,\r
- isAttribute);\r
- if (parts == null) {\r
- parts = new String[3];\r
- parts[2] = qName.intern();\r
- reportError("Undeclared prefix: " + qName);\r
- }\r
- return parts;\r
- }\r
-\r
-\r
- /**\r
- * Report a non-fatal error.\r
- *\r
- * @param message The error message.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception.\r
- */\r
- void reportError (String message)\r
- throws SAXException\r
- {\r
- if (errorHandler == null) {\r
- return;\r
- }\r
-\r
- SAXParseException e;\r
- if (locator != null) {\r
- e = new SAXParseException(message, locator);\r
- } else {\r
- e = new SAXParseException(message, null, null, -1, -1);\r
- }\r
- errorHandler.error(e);\r
- }\r
-\r
-\r
- /**\r
- * Throw an exception if we are parsing.\r
- *\r
- * <p>Use this method to detect illegal feature or\r
- * property changes.</p>\r
- *\r
- * @param type The type of thing (feature or property).\r
- * @param name The feature or property name.\r
- * @exception org.xml.sax.SAXNotSupportedException If a\r
- * document is currently being parsed.\r
- */\r
- private void checkNotParsing (String type, String name)\r
- throws SAXNotSupportedException\r
- {\r
- if (parsing) {\r
- throw new SAXNotSupportedException("Cannot change " +\r
- type + ' ' +\r
- name + " while parsing");\r
- \r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- private NamespaceSupport nsSupport;\r
- private AttributeListAdapter attAdapter;\r
-\r
- private boolean parsing = false;\r
- private String nameParts[] = new String[3];\r
-\r
- private Parser parser = null;\r
-\r
- private AttributesImpl atts = null;\r
-\r
- // Features\r
- private boolean namespaces = true;\r
- private boolean prefixes = false;\r
-\r
- // Properties\r
-\r
- // Handlers\r
- Locator locator;\r
-\r
- EntityResolver entityResolver = null;\r
- DTDHandler dtdHandler = null;\r
- ContentHandler contentHandler = null;\r
- ErrorHandler errorHandler = null;\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Inner class to wrap an AttributeList when not doing NS proc.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Adapt a SAX1 AttributeList as a SAX2 Attributes object.\r
- *\r
- * <p>This class is in the Public Domain, and comes with NO\r
- * WARRANTY of any kind.</p>\r
- *\r
- * <p>This wrapper class is used only when Namespace support\r
- * is disabled -- it provides pretty much a direct mapping\r
- * from SAX1 to SAX2, except that names and types are \r
- * interned whenever requested.</p>\r
- */\r
- final class AttributeListAdapter implements Attributes\r
- {\r
-\r
- /**\r
- * Construct a new adapter.\r
- */\r
- AttributeListAdapter ()\r
- {\r
- }\r
-\r
-\r
- /**\r
- * Set the embedded AttributeList.\r
- *\r
- * <p>This method must be invoked before any of the others\r
- * can be used.</p>\r
- *\r
- * @param The SAX1 attribute list (with qnames).\r
- */\r
- void setAttributeList (AttributeList qAtts)\r
- {\r
- this.qAtts = qAtts;\r
- }\r
-\r
-\r
- /**\r
- * Return the length of the attribute list.\r
- *\r
- * @return The number of attributes in the list.\r
- * @see org.xml.sax.Attributes#getLength\r
- */\r
- public int getLength ()\r
- {\r
- return qAtts.getLength();\r
- }\r
-\r
-\r
- /**\r
- * Return the Namespace URI of the specified attribute.\r
- *\r
- * @param The attribute's index.\r
- * @return Always the empty string.\r
- * @see org.xml.sax.Attributes#getURI\r
- */\r
- public String getURI (int i)\r
- {\r
- return "";\r
- }\r
-\r
-\r
- /**\r
- * Return the local name of the specified attribute.\r
- *\r
- * @param The attribute's index.\r
- * @return Always the empty string.\r
- * @see org.xml.sax.Attributes#getLocalName\r
- */\r
- public String getLocalName (int i)\r
- {\r
- return "";\r
- }\r
-\r
-\r
- /**\r
- * Return the qualified (prefixed) name of the specified attribute.\r
- *\r
- * @param The attribute's index.\r
- * @return The attribute's qualified name, internalized.\r
- */\r
- public String getQName (int i)\r
- {\r
- return qAtts.getName(i).intern();\r
- }\r
-\r
-\r
- /**\r
- * Return the type of the specified attribute.\r
- *\r
- * @param The attribute's index.\r
- * @return The attribute's type as an internalized string.\r
- */\r
- public String getType (int i)\r
- {\r
- return qAtts.getType(i).intern();\r
- }\r
-\r
-\r
- /**\r
- * Return the value of the specified attribute.\r
- *\r
- * @param The attribute's index.\r
- * @return The attribute's value.\r
- */\r
- public String getValue (int i)\r
- {\r
- return qAtts.getValue(i);\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute index by Namespace name.\r
- *\r
- * @param uri The Namespace URI or the empty string.\r
- * @param localName The local name.\r
- * @return The attributes index, or -1 if none was found.\r
- * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)\r
- */\r
- public int getIndex (String uri, String localName)\r
- {\r
- return -1;\r
- }\r
-\r
-\r
- /**\r
- * Look up an attribute index by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attributes index, or -1 if none was found.\r
- * @see org.xml.sax.Attributes#getIndex(java.lang.String)\r
- */\r
- public int getIndex (String qName)\r
- {\r
- int max = atts.getLength();\r
- for (int i = 0; i < max; i++) {\r
- if (qAtts.getName(i).equals(qName)) {\r
- return i;\r
- }\r
- }\r
- return -1;\r
- }\r
-\r
-\r
- /**\r
- * Look up the type of an attribute by Namespace name.\r
- *\r
- * @param uri The Namespace URI\r
- * @param localName The local name.\r
- * @return The attribute's type as an internalized string.\r
- */\r
- public String getType (String uri, String localName)\r
- {\r
- return null;\r
- }\r
-\r
-\r
- /**\r
- * Look up the type of an attribute by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attribute's type as an internalized string.\r
- */\r
- public String getType (String qName)\r
- {\r
- return qAtts.getType(qName).intern();\r
- }\r
-\r
-\r
- /**\r
- * Look up the value of an attribute by Namespace name.\r
- *\r
- * @param uri The Namespace URI\r
- * @param localName The local name.\r
- * @return The attribute's value.\r
- */\r
- public String getValue (String uri, String localName)\r
- {\r
- return null;\r
- }\r
-\r
-\r
- /**\r
- * Look up the value of an attribute by qualified (prefixed) name.\r
- *\r
- * @param qName The qualified name.\r
- * @return The attribute's value.\r
- */\r
- public String getValue (String qName)\r
- {\r
- return qAtts.getValue(qName);\r
- }\r
-\r
- private AttributeList qAtts;\r
- }\r
-}\r
-\r
-// end of ParserAdapter.java\r
+// ParserAdapter.java - adapt a SAX1 Parser to a SAX2 XMLReader.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: ParserAdapter.java,v 1.8.2.4 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.xml.sax.Parser; // deprecated
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.AttributeList; // deprecated
+import org.xml.sax.EntityResolver;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.DocumentHandler; // deprecated
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+
+/**
+ * Adapt a SAX1 Parser as a SAX2 XMLReader.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class wraps a SAX1 {@link org.xml.sax.Parser Parser}
+ * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader},
+ * with feature, property, and Namespace support. Note
+ * that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity
+ * skippedEntity} events, since SAX1 does not make that information available.</p>
+ *
+ * <p>This adapter does not test for duplicate Namespace-qualified
+ * attribute names.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.helpers.XMLReaderAdapter
+ * @see org.xml.sax.XMLReader
+ * @see org.xml.sax.Parser
+ */
+public class ParserAdapter implements XMLReader, DocumentHandler
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constructors.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Construct a new parser adapter.
+ *
+ * <p>Use the "org.xml.sax.parser" property to locate the
+ * embedded SAX1 driver.</p>
+ *
+ * @exception SAXException If the embedded driver
+ * cannot be instantiated or if the
+ * org.xml.sax.parser property is not specified.
+ */
+ public ParserAdapter ()
+ throws SAXException
+ {
+ super();
+
+ String driver = System.getProperty("org.xml.sax.parser");
+
+ try {
+ setup(ParserFactory.makeParser());
+ } catch (ClassNotFoundException e1) {
+ throw new
+ SAXException("Cannot find SAX1 driver class " +
+ driver, e1);
+ } catch (IllegalAccessException e2) {
+ throw new
+ SAXException("SAX1 driver class " +
+ driver +
+ " found but cannot be loaded", e2);
+ } catch (InstantiationException e3) {
+ throw new
+ SAXException("SAX1 driver class " +
+ driver +
+ " loaded but cannot be instantiated", e3);
+ } catch (ClassCastException e4) {
+ throw new
+ SAXException("SAX1 driver class " +
+ driver +
+ " does not implement org.xml.sax.Parser");
+ } catch (NullPointerException e5) {
+ throw new
+ SAXException("System property org.xml.sax.parser not specified");
+ }
+ }
+
+
+ /**
+ * Construct a new parser adapter.
+ *
+ * <p>Note that the embedded parser cannot be changed once the
+ * adapter is created; to embed a different parser, allocate
+ * a new ParserAdapter.</p>
+ *
+ * @param parser The SAX1 parser to embed.
+ * @exception java.lang.NullPointerException If the parser parameter
+ * is null.
+ */
+ public ParserAdapter (Parser parser)
+ {
+ super();
+ setup(parser);
+ }
+
+
+ /**
+ * Internal setup method.
+ *
+ * @param parser The embedded parser.
+ * @exception java.lang.NullPointerException If the parser parameter
+ * is null.
+ */
+ private void setup (Parser parser)
+ {
+ if (parser == null) {
+ throw new
+ NullPointerException("Parser argument must not be null");
+ }
+ this.parser = parser;
+ atts = new AttributesImpl();
+ nsSupport = new NamespaceSupport();
+ attAdapter = new AttributeListAdapter();
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.XMLReader.
+ ////////////////////////////////////////////////////////////////////
+
+
+ //
+ // Internal constants for the sake of convenience.
+ //
+ private final static String FEATURES = "http://xml.org/sax/features/";
+ private final static String NAMESPACES = FEATURES + "namespaces";
+ private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes";
+
+
+ /**
+ * Set a feature flag for the parser.
+ *
+ * <p>The only features recognized are namespaces and
+ * namespace-prefixes.</p>
+ *
+ * @param name The feature name, as a complete URI.
+ * @param value The requested feature value.
+ * @exception SAXNotRecognizedException If the feature
+ * can't be assigned or retrieved.
+ * @exception SAXNotSupportedException If the feature
+ * can't be assigned that value.
+ * @see org.xml.sax.XMLReader#setFeature
+ */
+ public void setFeature (String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (name.equals(NAMESPACES)) {
+ checkNotParsing("feature", name);
+ namespaces = value;
+ if (!namespaces && !prefixes) {
+ prefixes = true;
+ }
+ } else if (name.equals(NAMESPACE_PREFIXES)) {
+ checkNotParsing("feature", name);
+ prefixes = value;
+ if (!prefixes && !namespaces) {
+ namespaces = true;
+ }
+ } else {
+ throw new SAXNotRecognizedException("Feature: " + name);
+ }
+ }
+
+
+ /**
+ * Check a parser feature flag.
+ *
+ * <p>The only features recognized are namespaces and
+ * namespace-prefixes.</p>
+ *
+ * @param name The feature name, as a complete URI.
+ * @return The current feature value.
+ * @exception SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved.
+ * @exception SAXNotSupportedException If the
+ * feature is not currently readable.
+ * @see org.xml.sax.XMLReader#setFeature
+ */
+ public boolean getFeature (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (name.equals(NAMESPACES)) {
+ return namespaces;
+ } else if (name.equals(NAMESPACE_PREFIXES)) {
+ return prefixes;
+ } else {
+ throw new SAXNotRecognizedException("Feature: " + name);
+ }
+ }
+
+
+ /**
+ * Set a parser property.
+ *
+ * <p>No properties are currently recognized.</p>
+ *
+ * @param name The property name.
+ * @param value The property value.
+ * @exception SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception SAXNotSupportedException If the property
+ * can't be assigned that value.
+ * @see org.xml.sax.XMLReader#setProperty
+ */
+ public void setProperty (String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException("Property: " + name);
+ }
+
+
+ /**
+ * Get a parser property.
+ *
+ * <p>No properties are currently recognized.</p>
+ *
+ * @param name The property name.
+ * @return The property value.
+ * @exception SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved.
+ * @exception SAXNotSupportedException If the property
+ * value is not currently readable.
+ * @see org.xml.sax.XMLReader#getProperty
+ */
+ public Object getProperty (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException("Property: " + name);
+ }
+
+
+ /**
+ * Set the entity resolver.
+ *
+ * @param resolver The new entity resolver.
+ * @see org.xml.sax.XMLReader#setEntityResolver
+ */
+ public void setEntityResolver (EntityResolver resolver)
+ {
+ entityResolver = resolver;
+ }
+
+
+ /**
+ * Return the current entity resolver.
+ *
+ * @return The current entity resolver, or null if none was supplied.
+ * @see org.xml.sax.XMLReader#getEntityResolver
+ */
+ public EntityResolver getEntityResolver ()
+ {
+ return entityResolver;
+ }
+
+
+ /**
+ * Set the DTD handler.
+ *
+ * @param resolver The new DTD handler.
+ * @see org.xml.sax.XMLReader#setEntityResolver
+ */
+ public void setDTDHandler (DTDHandler handler)
+ {
+ dtdHandler = handler;
+ }
+
+
+ /**
+ * Return the current DTD handler.
+ *
+ * @return The current DTD handler, or null if none was supplied.
+ * @see org.xml.sax.XMLReader#getEntityResolver
+ */
+ public DTDHandler getDTDHandler ()
+ {
+ return dtdHandler;
+ }
+
+
+ /**
+ * Set the content handler.
+ *
+ * @param resolver The new content handler.
+ * @see org.xml.sax.XMLReader#setEntityResolver
+ */
+ public void setContentHandler (ContentHandler handler)
+ {
+ contentHandler = handler;
+ }
+
+
+ /**
+ * Return the current content handler.
+ *
+ * @return The current content handler, or null if none was supplied.
+ * @see org.xml.sax.XMLReader#getEntityResolver
+ */
+ public ContentHandler getContentHandler ()
+ {
+ return contentHandler;
+ }
+
+
+ /**
+ * Set the error handler.
+ *
+ * @param resolver The new error handler.
+ * @see org.xml.sax.XMLReader#setEntityResolver
+ */
+ public void setErrorHandler (ErrorHandler handler)
+ {
+ errorHandler = handler;
+ }
+
+
+ /**
+ * Return the current error handler.
+ *
+ * @return The current error handler, or null if none was supplied.
+ * @see org.xml.sax.XMLReader#getEntityResolver
+ */
+ public ErrorHandler getErrorHandler ()
+ {
+ return errorHandler;
+ }
+
+
+ /**
+ * Parse an XML document.
+ *
+ * @param systemId The absolute URL of the document.
+ * @exception java.io.IOException If there is a problem reading
+ * the raw content of the document.
+ * @exception SAXException If there is a problem
+ * processing the document.
+ * @see #parse(org.xml.sax.InputSource)
+ * @see org.xml.sax.Parser#parse(java.lang.String)
+ */
+ public void parse (String systemId)
+ throws IOException, SAXException
+ {
+ parse(new InputSource(systemId));
+ }
+
+
+ /**
+ * Parse an XML document.
+ *
+ * @param input An input source for the document.
+ * @exception java.io.IOException If there is a problem reading
+ * the raw content of the document.
+ * @exception SAXException If there is a problem
+ * processing the document.
+ * @see #parse(java.lang.String)
+ * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
+ */
+ public void parse (InputSource input)
+ throws IOException, SAXException
+ {
+ if (parsing) {
+ throw new SAXException("Parser is already in use");
+ }
+ setupParser();
+ parsing = true;
+ try {
+ parser.parse(input);
+ } finally {
+ parsing = false;
+ }
+ parsing = false;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.DocumentHandler.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 document locator event.
+ *
+ * @param locator A document locator.
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
+ */
+ public void setDocumentLocator (Locator locator)
+ {
+ this.locator = locator;
+ if (contentHandler != null) {
+ contentHandler.setDocumentLocator(locator);
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 start document event.
+ *
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#startDocument
+ */
+ public void startDocument ()
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.startDocument();
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 end document event.
+ *
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#endDocument
+ */
+ public void endDocument ()
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.endDocument();
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 startElement event.
+ *
+ * <p>If necessary, perform Namespace processing.</p>
+ *
+ * @param qName The qualified (prefixed) name.
+ * @param qAtts The XML 1.0 attribute list (with qnames).
+ * @exception SAXException The client may raise a
+ * processing exception.
+ */
+ public void startElement (String qName, AttributeList qAtts)
+ throws SAXException
+ {
+ // These are exceptions from the
+ // first pass; they should be
+ // ignored if there's a second pass,
+ // but reported otherwise.
+ Vector exceptions = null;
+
+ // If we're not doing Namespace
+ // processing, dispatch this quickly.
+ if (!namespaces) {
+ if (contentHandler != null) {
+ attAdapter.setAttributeList(qAtts);
+ contentHandler.startElement("", "", qName.intern(),
+ attAdapter);
+ }
+ return;
+ }
+
+
+ // OK, we're doing Namespace processing.
+ nsSupport.pushContext();
+ int length = qAtts.getLength();
+
+ // First pass: handle NS decls
+ for (int i = 0; i < length; i++) {
+ String attQName = qAtts.getName(i);
+
+ if (!attQName.startsWith("xmlns"))
+ continue;
+ // Could be a declaration...
+ String prefix;
+ int n = attQName.indexOf(':');
+
+ // xmlns=...
+ if (n == -1 && attQName.length () == 5) {
+ prefix = "";
+ } else if (n != 5) {
+ // XML namespaces spec doesn't discuss "xmlnsf:oo"
+ // (and similarly named) attributes ... at most, warn
+ continue;
+ } else // xmlns:foo=...
+ prefix = attQName.substring(n+1);
+
+ String value = qAtts.getValue(i);
+ if (!nsSupport.declarePrefix(prefix, value)) {
+ reportError("Illegal Namespace prefix: " + prefix);
+ continue;
+ }
+ if (contentHandler != null)
+ contentHandler.startPrefixMapping(prefix, value);
+ }
+
+ // Second pass: copy all relevant
+ // attributes into the SAX2 AttributeList
+ // using updated prefix bindings
+ atts.clear();
+ for (int i = 0; i < length; i++) {
+ String attQName = qAtts.getName(i);
+ String type = qAtts.getType(i);
+ String value = qAtts.getValue(i);
+
+ // Declaration?
+ if (attQName.startsWith("xmlns")) {
+ String prefix;
+ int n = attQName.indexOf(':');
+
+ if (n == -1 && attQName.length () == 5) {
+ prefix = "";
+ } else if (n != 5) {
+ // XML namespaces spec doesn't discuss "xmlnsf:oo"
+ // (and similarly named) attributes ... ignore
+ prefix = null;
+ } else {
+ prefix = attQName.substring(n+1);
+ }
+ // Yes, decl: report or prune
+ if (prefix != null) {
+ if (prefixes)
+ atts.addAttribute("", "", attQName.intern(),
+ type, value);
+ continue;
+ }
+ }
+
+ // Not a declaration -- report
+ try {
+ String attName[] = processName(attQName, true, true);
+ atts.addAttribute(attName[0], attName[1], attName[2],
+ type, value);
+ } catch (SAXException e) {
+ if (exceptions == null)
+ exceptions = new Vector();
+ exceptions.addElement(e);
+ atts.addAttribute("", attQName, attQName, type, value);
+ }
+ }
+
+ // now handle the deferred exception reports
+ if (exceptions != null && errorHandler != null) {
+ for (int i = 0; i < exceptions.size(); i++)
+ errorHandler.error((SAXParseException)
+ (exceptions.elementAt(i)));
+ }
+
+ // OK, finally report the event.
+ if (contentHandler != null) {
+ String name[] = processName(qName, false, false);
+ contentHandler.startElement(name[0], name[1], name[2], atts);
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 end element event.
+ *
+ * @param qName The qualified (prefixed) name.
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#endElement
+ */
+ public void endElement (String qName)
+ throws SAXException
+ {
+ // If we're not doing Namespace
+ // processing, dispatch this quickly.
+ if (!namespaces) {
+ if (contentHandler != null) {
+ contentHandler.endElement("", "", qName.intern());
+ }
+ return;
+ }
+
+ // Split the name.
+ String names[] = processName(qName, false, false);
+ if (contentHandler != null) {
+ contentHandler.endElement(names[0], names[1], names[2]);
+ Enumeration prefixes = nsSupport.getDeclaredPrefixes();
+ while (prefixes.hasMoreElements()) {
+ String prefix = (String)prefixes.nextElement();
+ contentHandler.endPrefixMapping(prefix);
+ }
+ }
+ nsSupport.popContext();
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 characters event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use.
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#characters
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.characters(ch, start, length);
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 ignorable whitespace event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use.
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#ignorableWhitespace
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.ignorableWhitespace(ch, start, length);
+ }
+ }
+
+
+ /**
+ * Adapter implementation method; do not call.
+ * Adapt a SAX1 processing instruction event.
+ *
+ * @param target The processing instruction target.
+ * @param data The remainder of the processing instruction
+ * @exception SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.DocumentHandler#processingInstruction
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.processingInstruction(target, data);
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal utility methods.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Initialize the parser before each run.
+ */
+ private void setupParser ()
+ {
+ nsSupport.reset();
+
+ if (entityResolver != null) {
+ parser.setEntityResolver(entityResolver);
+ }
+ if (dtdHandler != null) {
+ parser.setDTDHandler(dtdHandler);
+ }
+ if (errorHandler != null) {
+ parser.setErrorHandler(errorHandler);
+ }
+ parser.setDocumentHandler(this);
+ locator = null;
+ }
+
+
+ /**
+ * Process a qualified (prefixed) name.
+ *
+ * <p>If the name has an undeclared prefix, use only the qname
+ * and make an ErrorHandler.error callback in case the app is
+ * interested.</p>
+ *
+ * @param qName The qualified (prefixed) name.
+ * @param isAttribute true if this is an attribute name.
+ * @return The name split into three parts.
+ * @exception SAXException The client may throw
+ * an exception if there is an error callback.
+ */
+ private String [] processName (String qName, boolean isAttribute,
+ boolean useException)
+ throws SAXException
+ {
+ String parts[] = nsSupport.processName(qName, nameParts,
+ isAttribute);
+ if (parts == null) {
+ if (useException)
+ throw makeException("Undeclared prefix: " + qName);
+ reportError("Undeclared prefix: " + qName);
+ parts = new String[3];
+ parts[0] = parts[1] = "";
+ parts[2] = qName.intern();
+ }
+ return parts;
+ }
+
+
+ /**
+ * Report a non-fatal error.
+ *
+ * @param message The error message.
+ * @exception SAXException The client may throw
+ * an exception.
+ */
+ void reportError (String message)
+ throws SAXException
+ {
+ if (errorHandler != null)
+ errorHandler.error(makeException(message));
+ }
+
+
+ /**
+ * Construct an exception for the current context.
+ *
+ * @param message The error message.
+ */
+ private SAXParseException makeException (String message)
+ {
+ if (locator != null) {
+ return new SAXParseException(message, locator);
+ } else {
+ return new SAXParseException(message, null, null, -1, -1);
+ }
+ }
+
+
+ /**
+ * Throw an exception if we are parsing.
+ *
+ * <p>Use this method to detect illegal feature or
+ * property changes.</p>
+ *
+ * @param type The type of thing (feature or property).
+ * @param name The feature or property name.
+ * @exception SAXNotSupportedException If a
+ * document is currently being parsed.
+ */
+ private void checkNotParsing (String type, String name)
+ throws SAXNotSupportedException
+ {
+ if (parsing) {
+ throw new SAXNotSupportedException("Cannot change " +
+ type + ' ' +
+ name + " while parsing");
+
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ private NamespaceSupport nsSupport;
+ private AttributeListAdapter attAdapter;
+
+ private boolean parsing = false;
+ private String nameParts[] = new String[3];
+
+ private Parser parser = null;
+
+ private AttributesImpl atts = null;
+
+ // Features
+ private boolean namespaces = true;
+ private boolean prefixes = false;
+
+ // Properties
+
+ // Handlers
+ Locator locator;
+
+ EntityResolver entityResolver = null;
+ DTDHandler dtdHandler = null;
+ ContentHandler contentHandler = null;
+ ErrorHandler errorHandler = null;
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Inner class to wrap an AttributeList when not doing NS proc.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Adapt a SAX1 AttributeList as a SAX2 Attributes object.
+ *
+ * <p>This class is in the Public Domain, and comes with NO
+ * WARRANTY of any kind.</p>
+ *
+ * <p>This wrapper class is used only when Namespace support
+ * is disabled -- it provides pretty much a direct mapping
+ * from SAX1 to SAX2, except that names and types are
+ * interned whenever requested.</p>
+ */
+ final class AttributeListAdapter implements Attributes
+ {
+
+ /**
+ * Construct a new adapter.
+ */
+ AttributeListAdapter ()
+ {
+ }
+
+
+ /**
+ * Set the embedded AttributeList.
+ *
+ * <p>This method must be invoked before any of the others
+ * can be used.</p>
+ *
+ * @param The SAX1 attribute list (with qnames).
+ */
+ void setAttributeList (AttributeList qAtts)
+ {
+ this.qAtts = qAtts;
+ }
+
+
+ /**
+ * Return the length of the attribute list.
+ *
+ * @return The number of attributes in the list.
+ * @see org.xml.sax.Attributes#getLength
+ */
+ public int getLength ()
+ {
+ return qAtts.getLength();
+ }
+
+
+ /**
+ * Return the Namespace URI of the specified attribute.
+ *
+ * @param The attribute's index.
+ * @return Always the empty string.
+ * @see org.xml.sax.Attributes#getURI
+ */
+ public String getURI (int i)
+ {
+ return "";
+ }
+
+
+ /**
+ * Return the local name of the specified attribute.
+ *
+ * @param The attribute's index.
+ * @return Always the empty string.
+ * @see org.xml.sax.Attributes#getLocalName
+ */
+ public String getLocalName (int i)
+ {
+ return "";
+ }
+
+
+ /**
+ * Return the qualified (prefixed) name of the specified attribute.
+ *
+ * @param The attribute's index.
+ * @return The attribute's qualified name, internalized.
+ */
+ public String getQName (int i)
+ {
+ return qAtts.getName(i).intern();
+ }
+
+
+ /**
+ * Return the type of the specified attribute.
+ *
+ * @param The attribute's index.
+ * @return The attribute's type as an internalized string.
+ */
+ public String getType (int i)
+ {
+ return qAtts.getType(i).intern();
+ }
+
+
+ /**
+ * Return the value of the specified attribute.
+ *
+ * @param The attribute's index.
+ * @return The attribute's value.
+ */
+ public String getValue (int i)
+ {
+ return qAtts.getValue(i);
+ }
+
+
+ /**
+ * Look up an attribute index by Namespace name.
+ *
+ * @param uri The Namespace URI or the empty string.
+ * @param localName The local name.
+ * @return The attributes index, or -1 if none was found.
+ * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
+ */
+ public int getIndex (String uri, String localName)
+ {
+ return -1;
+ }
+
+
+ /**
+ * Look up an attribute index by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attributes index, or -1 if none was found.
+ * @see org.xml.sax.Attributes#getIndex(java.lang.String)
+ */
+ public int getIndex (String qName)
+ {
+ int max = atts.getLength();
+ for (int i = 0; i < max; i++) {
+ if (qAtts.getName(i).equals(qName)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+ /**
+ * Look up the type of an attribute by Namespace name.
+ *
+ * @param uri The Namespace URI
+ * @param localName The local name.
+ * @return The attribute's type as an internalized string.
+ */
+ public String getType (String uri, String localName)
+ {
+ return null;
+ }
+
+
+ /**
+ * Look up the type of an attribute by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attribute's type as an internalized string.
+ */
+ public String getType (String qName)
+ {
+ return qAtts.getType(qName).intern();
+ }
+
+
+ /**
+ * Look up the value of an attribute by Namespace name.
+ *
+ * @param uri The Namespace URI
+ * @param localName The local name.
+ * @return The attribute's value.
+ */
+ public String getValue (String uri, String localName)
+ {
+ return null;
+ }
+
+
+ /**
+ * Look up the value of an attribute by qualified (prefixed) name.
+ *
+ * @param qName The qualified name.
+ * @return The attribute's value.
+ */
+ public String getValue (String qName)
+ {
+ return qAtts.getValue(qName);
+ }
+
+ private AttributeList qAtts;
+ }
+}
+
+// end of ParserAdapter.java
-// SAX parser factory.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: ParserFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import java.lang.ClassNotFoundException;\r
-import java.lang.IllegalAccessException;\r
-import java.lang.InstantiationException;\r
-import java.lang.SecurityException;\r
-import java.lang.ClassCastException;\r
-\r
-import org.xml.sax.Parser;\r
-\r
-\r
-/**\r
- * Java-specific class for dynamically loading SAX parsers.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p><strong>Note:</strong> This class is designed to work with the now-deprecated\r
- * SAX1 {@link org.xml.sax.Parser Parser} class. SAX2 applications should use\r
- * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.</p>\r
- *\r
- * <p>ParserFactory is not part of the platform-independent definition\r
- * of SAX; it is an additional convenience class designed\r
- * specifically for Java XML application writers. SAX applications\r
- * can use the static methods in this class to allocate a SAX parser\r
- * dynamically at run-time based either on the value of the\r
- * `org.xml.sax.parser' system property or on a string containing the class\r
- * name.</p>\r
- *\r
- * <p>Note that the application still requires an XML parser that\r
- * implements SAX1.</p>\r
- *\r
- * @deprecated This class works with the deprecated\r
- * {@link org.xml.sax.Parser Parser}\r
- * interface.\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser\r
- * @see java.lang.Class\r
- */\r
-public class ParserFactory {\r
- \r
- \r
- /**\r
- * Private null constructor.\r
- */\r
- private ParserFactory ()\r
- {\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAX parser using the `org.xml.sax.parser' system property.\r
- *\r
- * <p>The named class must exist and must implement the\r
- * {@link org.xml.sax.Parser Parser} interface.</p>\r
- *\r
- * @exception java.lang.NullPointerException There is no value\r
- * for the `org.xml.sax.parser' system property.\r
- * @exception java.lang.ClassNotFoundException The SAX parser\r
- * class was not found (check your CLASSPATH).\r
- * @exception IllegalAccessException The SAX parser class was\r
- * found, but you do not have permission to load\r
- * it.\r
- * @exception InstantiationException The SAX parser class was\r
- * found but could not be instantiated.\r
- * @exception java.lang.ClassCastException The SAX parser class\r
- * was found and instantiated, but does not implement\r
- * org.xml.sax.Parser.\r
- * @see #makeParser(java.lang.String)\r
- * @see org.xml.sax.Parser\r
- */\r
- public static Parser makeParser ()\r
- throws ClassNotFoundException,\r
- IllegalAccessException, \r
- InstantiationException,\r
- NullPointerException,\r
- ClassCastException\r
- {\r
- String className = System.getProperty("org.xml.sax.parser");\r
- if (className == null) {\r
- throw new NullPointerException("No value for sax.parser property");\r
- } else {\r
- return makeParser(className);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Create a new SAX parser object using the class name provided.\r
- *\r
- * <p>The named class must exist and must implement the\r
- * {@link org.xml.sax.Parser Parser} interface.</p>\r
- *\r
- * @param className A string containing the name of the\r
- * SAX parser class.\r
- * @exception java.lang.ClassNotFoundException The SAX parser\r
- * class was not found (check your CLASSPATH).\r
- * @exception IllegalAccessException The SAX parser class was\r
- * found, but you do not have permission to load\r
- * it.\r
- * @exception InstantiationException The SAX parser class was\r
- * found but could not be instantiated.\r
- * @exception java.lang.ClassCastException The SAX parser class\r
- * was found and instantiated, but does not implement\r
- * org.xml.sax.Parser.\r
- * @see #makeParser()\r
- * @see org.xml.sax.Parser\r
- */\r
- public static Parser makeParser (String className)\r
- throws ClassNotFoundException,\r
- IllegalAccessException, \r
- InstantiationException,\r
- ClassCastException\r
- {\r
- return (Parser)(Class.forName(className).newInstance());\r
- }\r
- \r
-}\r
-\r
-// end of ParserFactory.java\r
+// SAX parser factory.
+// http://www.saxproject.org
+// No warranty; no copyright -- use this as you will.
+// $Id: ParserFactory.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.lang.ClassNotFoundException;
+import java.lang.IllegalAccessException;
+import java.lang.InstantiationException;
+import java.lang.SecurityException;
+import java.lang.ClassCastException;
+
+import org.xml.sax.Parser;
+
+
+/**
+ * Java-specific class for dynamically loading SAX parsers.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p><strong>Note:</strong> This class is designed to work with the now-deprecated
+ * SAX1 {@link org.xml.sax.Parser Parser} class. SAX2 applications should use
+ * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.</p>
+ *
+ * <p>ParserFactory is not part of the platform-independent definition
+ * of SAX; it is an additional convenience class designed
+ * specifically for Java XML application writers. SAX applications
+ * can use the static methods in this class to allocate a SAX parser
+ * dynamically at run-time based either on the value of the
+ * `org.xml.sax.parser' system property or on a string containing the class
+ * name.</p>
+ *
+ * <p>Note that the application still requires an XML parser that
+ * implements SAX1.</p>
+ *
+ * @deprecated This class works with the deprecated
+ * {@link org.xml.sax.Parser Parser}
+ * interface.
+ * @since SAX 1.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ */
+public class ParserFactory {
+
+
+ /**
+ * Private null constructor.
+ */
+ private ParserFactory ()
+ {
+ }
+
+
+ /**
+ * Create a new SAX parser using the `org.xml.sax.parser' system property.
+ *
+ * <p>The named class must exist and must implement the
+ * {@link org.xml.sax.Parser Parser} interface.</p>
+ *
+ * @exception java.lang.NullPointerException There is no value
+ * for the `org.xml.sax.parser' system property.
+ * @exception java.lang.ClassNotFoundException The SAX parser
+ * class was not found (check your CLASSPATH).
+ * @exception IllegalAccessException The SAX parser class was
+ * found, but you do not have permission to load
+ * it.
+ * @exception InstantiationException The SAX parser class was
+ * found but could not be instantiated.
+ * @exception java.lang.ClassCastException The SAX parser class
+ * was found and instantiated, but does not implement
+ * org.xml.sax.Parser.
+ * @see #makeParser(java.lang.String)
+ * @see org.xml.sax.Parser
+ */
+ public static Parser makeParser ()
+ throws ClassNotFoundException,
+ IllegalAccessException,
+ InstantiationException,
+ NullPointerException,
+ ClassCastException
+ {
+ String className = System.getProperty("org.xml.sax.parser");
+ if (className == null) {
+ throw new NullPointerException("No value for sax.parser property");
+ } else {
+ return makeParser(className);
+ }
+ }
+
+
+ /**
+ * Create a new SAX parser object using the class name provided.
+ *
+ * <p>The named class must exist and must implement the
+ * {@link org.xml.sax.Parser Parser} interface.</p>
+ *
+ * @param className A string containing the name of the
+ * SAX parser class.
+ * @exception java.lang.ClassNotFoundException The SAX parser
+ * class was not found (check your CLASSPATH).
+ * @exception IllegalAccessException The SAX parser class was
+ * found, but you do not have permission to load
+ * it.
+ * @exception InstantiationException The SAX parser class was
+ * found but could not be instantiated.
+ * @exception java.lang.ClassCastException The SAX parser class
+ * was found and instantiated, but does not implement
+ * org.xml.sax.Parser.
+ * @see #makeParser()
+ * @see org.xml.sax.Parser
+ */
+ public static Parser makeParser (String className)
+ throws ClassNotFoundException,
+ IllegalAccessException,
+ InstantiationException,
+ ClassCastException
+ {
+ return (Parser) NewInstance.newInstance (
+ NewInstance.getClassLoader (), className);
+ }
+
+}
+
-// XMLFilterImpl.java - base SAX2 filter implementation.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: XMLFilterImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import java.io.IOException;\r
-\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.XMLFilter;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.Locator;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.DTDHandler;\r
-import org.xml.sax.ContentHandler;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-import org.xml.sax.SAXNotSupportedException;\r
-import org.xml.sax.SAXNotRecognizedException;\r
-\r
-\r
-/**\r
- * Base class for deriving an XML filter.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class is designed to sit between an {@link org.xml.sax.XMLReader\r
- * XMLReader} and the client application's event handlers. By default, it\r
- * does nothing but pass requests up to the reader and events\r
- * on to the handlers unmodified, but subclasses can override\r
- * specific methods to modify the event stream or the configuration\r
- * requests as they pass through.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.XMLFilter\r
- * @see org.xml.sax.XMLReader\r
- * @see org.xml.sax.EntityResolver\r
- * @see org.xml.sax.DTDHandler\r
- * @see org.xml.sax.ContentHandler\r
- * @see org.xml.sax.ErrorHandler\r
- */\r
-public class XMLFilterImpl\r
- implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constructors.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Construct an empty XML filter, with no parent.\r
- *\r
- * <p>This filter will have no parent: you must assign a parent\r
- * before you start a parse or do any configuration with\r
- * setFeature or setProperty.</p>\r
- *\r
- * @see org.xml.sax.XMLReader#setFeature\r
- * @see org.xml.sax.XMLReader#setProperty\r
- */\r
- public XMLFilterImpl ()\r
- {\r
- super();\r
- }\r
-\r
-\r
- /**\r
- * Construct an XML filter with the specified parent.\r
- *\r
- * @see #setParent\r
- * @see #getParent\r
- */\r
- public XMLFilterImpl (XMLReader parent)\r
- {\r
- super();\r
- setParent(parent);\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.XMLFilter.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Set the parent reader.\r
- *\r
- * <p>This is the {@link org.xml.sax.XMLReader XMLReader} from which \r
- * this filter will obtain its events and to which it will pass its \r
- * configuration requests. The parent may itself be another filter.</p>\r
- *\r
- * <p>If there is no parent reader set, any attempt to parse\r
- * or to set or get a feature or property will fail.</p>\r
- *\r
- * @param parent The parent XML reader.\r
- * @exception java.lang.NullPointerException If the parent is null.\r
- * @see #getParent\r
- */\r
- public void setParent (XMLReader parent)\r
- {\r
- if (parent == null) {\r
- throw new NullPointerException("Null parent");\r
- }\r
- this.parent = parent;\r
- }\r
-\r
-\r
- /**\r
- * Get the parent reader.\r
- *\r
- * @return The parent XML reader, or null if none is set.\r
- * @see #setParent\r
- */\r
- public XMLReader getParent ()\r
- {\r
- return parent;\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.XMLReader.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Set the state of a feature.\r
- *\r
- * <p>This will always fail if the parent is null.</p>\r
- *\r
- * @param name The feature name.\r
- * @param state The requested feature state.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the feature name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the feature name but \r
- * cannot set the requested value.\r
- * @see org.xml.sax.XMLReader#setFeature\r
- */\r
- public void setFeature (String name, boolean state)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (parent != null) {\r
- parent.setFeature(name, state);\r
- } else {\r
- throw new SAXNotRecognizedException("Feature: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Look up the state of a feature.\r
- *\r
- * <p>This will always fail if the parent is null.</p>\r
- *\r
- * @param name The feature name.\r
- * @return The current state of the feature.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the feature name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the feature name but \r
- * cannot determine its state at this time.\r
- * @see org.xml.sax.XMLReader#getFeature\r
- */\r
- public boolean getFeature (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (parent != null) {\r
- return parent.getFeature(name);\r
- } else {\r
- throw new SAXNotRecognizedException("Feature: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the value of a property.\r
- *\r
- * <p>This will always fail if the parent is null.</p>\r
- *\r
- * @param name The property name.\r
- * @param state The requested property value.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the property name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the property name but \r
- * cannot set the requested value.\r
- * @see org.xml.sax.XMLReader#setProperty\r
- */\r
- public void setProperty (String name, Object value)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (parent != null) {\r
- parent.setProperty(name, value);\r
- } else {\r
- throw new SAXNotRecognizedException("Property: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Look up the value of a property.\r
- *\r
- * @param name The property name.\r
- * @return The current value of the property.\r
- * @exception org.xml.sax.SAXNotRecognizedException When the\r
- * XMLReader does not recognize the feature name.\r
- * @exception org.xml.sax.SAXNotSupportedException When the\r
- * XMLReader recognizes the property name but \r
- * cannot determine its value at this time.\r
- * @see org.xml.sax.XMLReader#setFeature\r
- */\r
- public Object getProperty (String name)\r
- throws SAXNotRecognizedException, SAXNotSupportedException\r
- {\r
- if (parent != null) {\r
- return parent.getProperty(name);\r
- } else {\r
- throw new SAXNotRecognizedException("Property: " + name);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the entity resolver.\r
- *\r
- * @param resolver The new entity resolver.\r
- * @exception java.lang.NullPointerException If the resolver\r
- * is null.\r
- * @see org.xml.sax.XMLReader#setEntityResolver\r
- */\r
- public void setEntityResolver (EntityResolver resolver)\r
- {\r
- if (resolver == null) {\r
- throw new NullPointerException("Null entity resolver");\r
- } else {\r
- entityResolver = resolver;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Get the current entity resolver.\r
- *\r
- * @return The current entity resolver, or null if none was set.\r
- * @see org.xml.sax.XMLReader#getEntityResolver\r
- */\r
- public EntityResolver getEntityResolver ()\r
- {\r
- return entityResolver;\r
- }\r
-\r
-\r
- /**\r
- * Set the DTD event handler.\r
- *\r
- * @param resolver The new DTD handler.\r
- * @exception java.lang.NullPointerException If the handler\r
- * is null.\r
- * @see org.xml.sax.XMLReader#setDTDHandler\r
- */\r
- public void setDTDHandler (DTDHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null DTD handler");\r
- } else {\r
- dtdHandler = handler;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Get the current DTD event handler.\r
- *\r
- * @return The current DTD handler, or null if none was set.\r
- * @see org.xml.sax.XMLReader#getDTDHandler\r
- */\r
- public DTDHandler getDTDHandler ()\r
- {\r
- return dtdHandler;\r
- }\r
-\r
-\r
- /**\r
- * Set the content event handler.\r
- *\r
- * @param resolver The new content handler.\r
- * @exception java.lang.NullPointerException If the handler\r
- * is null.\r
- * @see org.xml.sax.XMLReader#setContentHandler\r
- */\r
- public void setContentHandler (ContentHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null content handler");\r
- } else {\r
- contentHandler = handler;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Get the content event handler.\r
- *\r
- * @return The current content handler, or null if none was set.\r
- * @see org.xml.sax.XMLReader#getContentHandler\r
- */\r
- public ContentHandler getContentHandler ()\r
- {\r
- return contentHandler;\r
- }\r
-\r
-\r
- /**\r
- * Set the error event handler.\r
- *\r
- * @param handle The new error handler.\r
- * @exception java.lang.NullPointerException If the handler\r
- * is null.\r
- * @see org.xml.sax.XMLReader#setErrorHandler\r
- */\r
- public void setErrorHandler (ErrorHandler handler)\r
- {\r
- if (handler == null) {\r
- throw new NullPointerException("Null error handler");\r
- } else {\r
- errorHandler = handler;\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Get the current error event handler.\r
- *\r
- * @return The current error handler, or null if none was set.\r
- * @see org.xml.sax.XMLReader#getErrorHandler\r
- */\r
- public ErrorHandler getErrorHandler ()\r
- {\r
- return errorHandler;\r
- }\r
-\r
-\r
- /**\r
- * Parse a document.\r
- *\r
- * @param input The input source for the document entity.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)\r
- */\r
- public void parse (InputSource input)\r
- throws SAXException, IOException\r
- {\r
- setupParse();\r
- parent.parse(input);\r
- }\r
-\r
-\r
- /**\r
- * Parse a document.\r
- *\r
- * @param systemId The system identifier as a fully-qualified URI.\r
- * @exception org.xml.sax.SAXException Any SAX exception, possibly\r
- * wrapping another exception.\r
- * @exception java.io.IOException An IO exception from the parser,\r
- * possibly from a byte stream or character stream\r
- * supplied by the application.\r
- * @see org.xml.sax.XMLReader#parse(java.lang.String)\r
- */\r
- public void parse (String systemId)\r
- throws SAXException, IOException\r
- {\r
- parse(new InputSource(systemId));\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.EntityResolver.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Filter an external entity resolution.\r
- *\r
- * @param publicId The entity's public identifier, or null.\r
- * @param systemId The entity's system identifier.\r
- * @return A new InputSource or null for the default.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @exception java.io.IOException The client may throw an\r
- * I/O-related exception while obtaining the\r
- * new InputSource.\r
- * @see org.xml.sax.EntityResolver#resolveEntity\r
- */\r
- public InputSource resolveEntity (String publicId, String systemId)\r
- throws SAXException, IOException\r
- {\r
- if (entityResolver != null) {\r
- return entityResolver.resolveEntity(publicId, systemId);\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.DTDHandler.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- \r
- /**\r
- * Filter a notation declaration event.\r
- *\r
- * @param name The notation name.\r
- * @param publicId The notation's public identifier, or null.\r
- * @param systemId The notation's system identifier, or null.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.DTDHandler#notationDecl\r
- */\r
- public void notationDecl (String name, String publicId, String systemId)\r
- throws SAXException\r
- {\r
- if (dtdHandler != null) {\r
- dtdHandler.notationDecl(name, publicId, systemId);\r
- }\r
- }\r
-\r
- \r
- /**\r
- * Filter an unparsed entity declaration event.\r
- *\r
- * @param name The entity name.\r
- * @param publicId The entity's public identifier, or null.\r
- * @param systemId The entity's system identifier, or null.\r
- * @param notationName The name of the associated notation.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl\r
- */\r
- public void unparsedEntityDecl (String name, String publicId,\r
- String systemId, String notationName)\r
- throws SAXException\r
- {\r
- if (dtdHandler != null) {\r
- dtdHandler.unparsedEntityDecl(name, publicId, systemId,\r
- notationName);\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.ContentHandler.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Filter a new document locator event.\r
- *\r
- * @param locator The document locator.\r
- * @see org.xml.sax.ContentHandler#setDocumentLocator\r
- */\r
- public void setDocumentLocator (Locator locator)\r
- {\r
- this.locator = locator;\r
- if (contentHandler != null) {\r
- contentHandler.setDocumentLocator(locator);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a start document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#startDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.startDocument();\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter an end document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#endDocument\r
- */\r
- public void endDocument ()\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.endDocument();\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a start Namespace prefix mapping event.\r
- *\r
- * @param prefix The Namespace prefix.\r
- * @param uri The Namespace URI.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#startPrefixMapping\r
- */\r
- public void startPrefixMapping (String prefix, String uri)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.startPrefixMapping(prefix, uri);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter an end Namespace prefix mapping event.\r
- *\r
- * @param prefix The Namespace prefix.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#endPrefixMapping\r
- */\r
- public void endPrefixMapping (String prefix)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.endPrefixMapping(prefix);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a start element event.\r
- *\r
- * @param uri The element's Namespace URI, or the empty string.\r
- * @param localName The element's local name, or the empty string.\r
- * @param qName The element's qualified (prefixed) name, or the empty\r
- * string.\r
- * @param atts The element's attributes.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#startElement\r
- */\r
- public void startElement (String uri, String localName, String qName,\r
- Attributes atts)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.startElement(uri, localName, qName, atts);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter an end element event.\r
- *\r
- * @param uri The element's Namespace URI, or the empty string.\r
- * @param localName The element's local name, or the empty string.\r
- * @param qName The element's qualified (prefixed) name, or the empty\r
- * string.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#endElement\r
- */\r
- public void endElement (String uri, String localName, String qName)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.endElement(uri, localName, qName);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a character data event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use from the array.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#characters\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.characters(ch, start, length);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter an ignorable whitespace event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use from the array.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#ignorableWhitespace\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.ignorableWhitespace(ch, start, length);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a processing instruction event.\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The text following the target.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#processingInstruction\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.processingInstruction(target, data);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a skipped entity event.\r
- *\r
- * @param name The name of the skipped entity.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ContentHandler#skippedEntity\r
- */\r
- public void skippedEntity (String name)\r
- throws SAXException\r
- {\r
- if (contentHandler != null) {\r
- contentHandler.skippedEntity(name);\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.ErrorHandler.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Filter a warning event.\r
- *\r
- * @param e The nwarning as an exception.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ErrorHandler#warning\r
- */\r
- public void warning (SAXParseException e)\r
- throws SAXException\r
- {\r
- if (errorHandler != null) {\r
- errorHandler.warning(e);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter an error event.\r
- *\r
- * @param e The error as an exception.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ErrorHandler#error\r
- */\r
- public void error (SAXParseException e)\r
- throws SAXException\r
- {\r
- if (errorHandler != null) {\r
- errorHandler.error(e);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Filter a fatal error event.\r
- *\r
- * @param e The error as an exception.\r
- * @exception org.xml.sax.SAXException The client may throw\r
- * an exception during processing.\r
- * @see org.xml.sax.ErrorHandler#fatalError\r
- */\r
- public void fatalError (SAXParseException e)\r
- throws SAXException\r
- {\r
- if (errorHandler != null) {\r
- errorHandler.fatalError(e);\r
- }\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal methods.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Set up before a parse.\r
- *\r
- * <p>Before every parse, check whether the parent is\r
- * non-null, and re-register the filter for all of the \r
- * events.</p>\r
- */\r
- private void setupParse ()\r
- {\r
- if (parent == null) {\r
- throw new NullPointerException("No parent for filter");\r
- }\r
- parent.setEntityResolver(this);\r
- parent.setDTDHandler(this);\r
- parent.setContentHandler(this);\r
- parent.setErrorHandler(this);\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- private XMLReader parent = null;\r
- private Locator locator = null;\r
- private EntityResolver entityResolver = null;\r
- private DTDHandler dtdHandler = null;\r
- private ContentHandler contentHandler = null;\r
- private ErrorHandler errorHandler = null;\r
-\r
-}\r
-\r
-// end of XMLFilterImpl.java\r
+// XMLFilterImpl.java - base SAX2 filter implementation.
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: XMLFilterImpl.java,v 1.3.2.7 2002/01/29 21:34:14 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.io.IOException;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.XMLFilter;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXNotRecognizedException;
+
+
+/**
+ * Base class for deriving an XML filter.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class is designed to sit between an {@link org.xml.sax.XMLReader
+ * XMLReader} and the client application's event handlers. By default, it
+ * does nothing but pass requests up to the reader and events
+ * on to the handlers unmodified, but subclasses can override
+ * specific methods to modify the event stream or the configuration
+ * requests as they pass through.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.XMLFilter
+ * @see org.xml.sax.XMLReader
+ * @see org.xml.sax.EntityResolver
+ * @see org.xml.sax.DTDHandler
+ * @see org.xml.sax.ContentHandler
+ * @see org.xml.sax.ErrorHandler
+ */
+public class XMLFilterImpl
+ implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constructors.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Construct an empty XML filter, with no parent.
+ *
+ * <p>This filter will have no parent: you must assign a parent
+ * before you start a parse or do any configuration with
+ * setFeature or setProperty, unless you use this as a pure event
+ * consumer rather than as an {@link XMLReader}.</p>
+ *
+ * @see org.xml.sax.XMLReader#setFeature
+ * @see org.xml.sax.XMLReader#setProperty
+ * @see #setParent
+ */
+ public XMLFilterImpl ()
+ {
+ super();
+ }
+
+
+ /**
+ * Construct an XML filter with the specified parent.
+ *
+ * @see #setParent
+ * @see #getParent
+ */
+ public XMLFilterImpl (XMLReader parent)
+ {
+ super();
+ setParent(parent);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.XMLFilter.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set the parent reader.
+ *
+ * <p>This is the {@link org.xml.sax.XMLReader XMLReader} from which
+ * this filter will obtain its events and to which it will pass its
+ * configuration requests. The parent may itself be another filter.</p>
+ *
+ * <p>If there is no parent reader set, any attempt to parse
+ * or to set or get a feature or property will fail.</p>
+ *
+ * @param parent The parent XML reader.
+ * @see #getParent
+ */
+ public void setParent (XMLReader parent)
+ {
+ this.parent = parent;
+ }
+
+
+ /**
+ * Get the parent reader.
+ *
+ * @return The parent XML reader, or null if none is set.
+ * @see #setParent
+ */
+ public XMLReader getParent ()
+ {
+ return parent;
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.XMLReader.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set the value of a feature.
+ *
+ * <p>This will always fail if the parent is null.</p>
+ *
+ * @param name The feature name.
+ * @param value The requested feature value.
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved from the parent.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * parent recognizes the feature name but
+ * cannot set the requested value.
+ */
+ public void setFeature (String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (parent != null) {
+ parent.setFeature(name, value);
+ } else {
+ throw new SAXNotRecognizedException("Feature: " + name);
+ }
+ }
+
+
+ /**
+ * Look up the value of a feature.
+ *
+ * <p>This will always fail if the parent is null.</p>
+ *
+ * @param name The feature name.
+ * @return The current value of the feature.
+ * @exception org.xml.sax.SAXNotRecognizedException If the feature
+ * value can't be assigned or retrieved from the parent.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * parent recognizes the feature name but
+ * cannot determine its value at this time.
+ */
+ public boolean getFeature (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (parent != null) {
+ return parent.getFeature(name);
+ } else {
+ throw new SAXNotRecognizedException("Feature: " + name);
+ }
+ }
+
+
+ /**
+ * Set the value of a property.
+ *
+ * <p>This will always fail if the parent is null.</p>
+ *
+ * @param name The property name.
+ * @param value The requested property value.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved from the parent.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * parent recognizes the property name but
+ * cannot set the requested value.
+ */
+ public void setProperty (String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (parent != null) {
+ parent.setProperty(name, value);
+ } else {
+ throw new SAXNotRecognizedException("Property: " + name);
+ }
+ }
+
+
+ /**
+ * Look up the value of a property.
+ *
+ * @param name The property name.
+ * @return The current value of the property.
+ * @exception org.xml.sax.SAXNotRecognizedException If the property
+ * value can't be assigned or retrieved from the parent.
+ * @exception org.xml.sax.SAXNotSupportedException When the
+ * parent recognizes the property name but
+ * cannot determine its value at this time.
+ */
+ public Object getProperty (String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (parent != null) {
+ return parent.getProperty(name);
+ } else {
+ throw new SAXNotRecognizedException("Property: " + name);
+ }
+ }
+
+
+ /**
+ * Set the entity resolver.
+ *
+ * @param resolver The new entity resolver.
+ */
+ public void setEntityResolver (EntityResolver resolver)
+ {
+ entityResolver = resolver;
+ }
+
+
+ /**
+ * Get the current entity resolver.
+ *
+ * @return The current entity resolver, or null if none was set.
+ */
+ public EntityResolver getEntityResolver ()
+ {
+ return entityResolver;
+ }
+
+
+ /**
+ * Set the DTD event handler.
+ *
+ * @param resolver The new DTD handler.
+ */
+ public void setDTDHandler (DTDHandler handler)
+ {
+ dtdHandler = handler;
+ }
+
+
+ /**
+ * Get the current DTD event handler.
+ *
+ * @return The current DTD handler, or null if none was set.
+ */
+ public DTDHandler getDTDHandler ()
+ {
+ return dtdHandler;
+ }
+
+
+ /**
+ * Set the content event handler.
+ *
+ * @param resolver The new content handler.
+ */
+ public void setContentHandler (ContentHandler handler)
+ {
+ contentHandler = handler;
+ }
+
+
+ /**
+ * Get the content event handler.
+ *
+ * @return The current content handler, or null if none was set.
+ */
+ public ContentHandler getContentHandler ()
+ {
+ return contentHandler;
+ }
+
+
+ /**
+ * Set the error event handler.
+ *
+ * @param handle The new error handler.
+ */
+ public void setErrorHandler (ErrorHandler handler)
+ {
+ errorHandler = handler;
+ }
+
+
+ /**
+ * Get the current error event handler.
+ *
+ * @return The current error handler, or null if none was set.
+ */
+ public ErrorHandler getErrorHandler ()
+ {
+ return errorHandler;
+ }
+
+
+ /**
+ * Parse a document.
+ *
+ * @param input The input source for the document entity.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ */
+ public void parse (InputSource input)
+ throws SAXException, IOException
+ {
+ setupParse();
+ parent.parse(input);
+ }
+
+
+ /**
+ * Parse a document.
+ *
+ * @param systemId The system identifier as a fully-qualified URI.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @exception java.io.IOException An IO exception from the parser,
+ * possibly from a byte stream or character stream
+ * supplied by the application.
+ */
+ public void parse (String systemId)
+ throws SAXException, IOException
+ {
+ parse(new InputSource(systemId));
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.EntityResolver.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Filter an external entity resolution.
+ *
+ * @param publicId The entity's public identifier, or null.
+ * @param systemId The entity's system identifier.
+ * @return A new InputSource or null for the default.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ * @exception java.io.IOException The client may throw an
+ * I/O-related exception while obtaining the
+ * new InputSource.
+ */
+ public InputSource resolveEntity (String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (entityResolver != null) {
+ return entityResolver.resolveEntity(publicId, systemId);
+ } else {
+ return null;
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.DTDHandler.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Filter a notation declaration event.
+ *
+ * @param name The notation name.
+ * @param publicId The notation's public identifier, or null.
+ * @param systemId The notation's system identifier, or null.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void notationDecl (String name, String publicId, String systemId)
+ throws SAXException
+ {
+ if (dtdHandler != null) {
+ dtdHandler.notationDecl(name, publicId, systemId);
+ }
+ }
+
+
+ /**
+ * Filter an unparsed entity declaration event.
+ *
+ * @param name The entity name.
+ * @param publicId The entity's public identifier, or null.
+ * @param systemId The entity's system identifier, or null.
+ * @param notationName The name of the associated notation.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void unparsedEntityDecl (String name, String publicId,
+ String systemId, String notationName)
+ throws SAXException
+ {
+ if (dtdHandler != null) {
+ dtdHandler.unparsedEntityDecl(name, publicId, systemId,
+ notationName);
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.ContentHandler.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Filter a new document locator event.
+ *
+ * @param locator The document locator.
+ */
+ public void setDocumentLocator (Locator locator)
+ {
+ this.locator = locator;
+ if (contentHandler != null) {
+ contentHandler.setDocumentLocator(locator);
+ }
+ }
+
+
+ /**
+ * Filter a start document event.
+ *
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void startDocument ()
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.startDocument();
+ }
+ }
+
+
+ /**
+ * Filter an end document event.
+ *
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void endDocument ()
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.endDocument();
+ }
+ }
+
+
+ /**
+ * Filter a start Namespace prefix mapping event.
+ *
+ * @param prefix The Namespace prefix.
+ * @param uri The Namespace URI.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void startPrefixMapping (String prefix, String uri)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.startPrefixMapping(prefix, uri);
+ }
+ }
+
+
+ /**
+ * Filter an end Namespace prefix mapping event.
+ *
+ * @param prefix The Namespace prefix.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void endPrefixMapping (String prefix)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.endPrefixMapping(prefix);
+ }
+ }
+
+
+ /**
+ * Filter a start element event.
+ *
+ * @param uri The element's Namespace URI, or the empty string.
+ * @param localName The element's local name, or the empty string.
+ * @param qName The element's qualified (prefixed) name, or the empty
+ * string.
+ * @param atts The element's attributes.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void startElement (String uri, String localName, String qName,
+ Attributes atts)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.startElement(uri, localName, qName, atts);
+ }
+ }
+
+
+ /**
+ * Filter an end element event.
+ *
+ * @param uri The element's Namespace URI, or the empty string.
+ * @param localName The element's local name, or the empty string.
+ * @param qName The element's qualified (prefixed) name, or the empty
+ * string.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void endElement (String uri, String localName, String qName)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.endElement(uri, localName, qName);
+ }
+ }
+
+
+ /**
+ * Filter a character data event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use from the array.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.characters(ch, start, length);
+ }
+ }
+
+
+ /**
+ * Filter an ignorable whitespace event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use from the array.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.ignorableWhitespace(ch, start, length);
+ }
+ }
+
+
+ /**
+ * Filter a processing instruction event.
+ *
+ * @param target The processing instruction target.
+ * @param data The text following the target.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.processingInstruction(target, data);
+ }
+ }
+
+
+ /**
+ * Filter a skipped entity event.
+ *
+ * @param name The name of the skipped entity.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void skippedEntity (String name)
+ throws SAXException
+ {
+ if (contentHandler != null) {
+ contentHandler.skippedEntity(name);
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.ErrorHandler.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Filter a warning event.
+ *
+ * @param e The warning as an exception.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void warning (SAXParseException e)
+ throws SAXException
+ {
+ if (errorHandler != null) {
+ errorHandler.warning(e);
+ }
+ }
+
+
+ /**
+ * Filter an error event.
+ *
+ * @param e The error as an exception.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void error (SAXParseException e)
+ throws SAXException
+ {
+ if (errorHandler != null) {
+ errorHandler.error(e);
+ }
+ }
+
+
+ /**
+ * Filter a fatal error event.
+ *
+ * @param e The error as an exception.
+ * @exception org.xml.sax.SAXException The client may throw
+ * an exception during processing.
+ */
+ public void fatalError (SAXParseException e)
+ throws SAXException
+ {
+ if (errorHandler != null) {
+ errorHandler.fatalError(e);
+ }
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal methods.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set up before a parse.
+ *
+ * <p>Before every parse, check whether the parent is
+ * non-null, and re-register the filter for all of the
+ * events.</p>
+ */
+ private void setupParse ()
+ {
+ if (parent == null) {
+ throw new NullPointerException("No parent for filter");
+ }
+ parent.setEntityResolver(this);
+ parent.setDTDHandler(this);
+ parent.setContentHandler(this);
+ parent.setErrorHandler(this);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ private XMLReader parent = null;
+ private Locator locator = null;
+ private EntityResolver entityResolver = null;
+ private DTDHandler dtdHandler = null;
+ private ContentHandler contentHandler = null;
+ private ErrorHandler errorHandler = null;
+
+}
+
+// end of XMLFilterImpl.java
-// XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the public domain.\r
-\r
-// $Id: XMLReaderAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-\r
-import java.io.IOException;\r
-import java.util.Locale;\r
-\r
-import org.xml.sax.Parser; // deprecated\r
-import org.xml.sax.Locator;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.AttributeList; // deprecated\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.DTDHandler;\r
-import org.xml.sax.DocumentHandler; // deprecated\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.SAXException;\r
-\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.ContentHandler;\r
-import org.xml.sax.SAXNotSupportedException;\r
-\r
-\r
-/**\r
- * Adapt a SAX2 XMLReader as a SAX1 Parser.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}\r
- * and makes it act as a SAX1 {@link org.xml.sax.Parser Parser}. The XMLReader \r
- * must support a true value for the \r
- * http://xml.org/sax/features/namespace-prefixes property or parsing will fail\r
- * with a {@link org.xml.sax.SAXException SAXException}; if the XMLReader \r
- * supports a false value for the http://xml.org/sax/features/namespaces \r
- * property, that will also be used to improve efficiency.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser\r
- * @see org.xml.sax.XMLReader\r
- */\r
-public class XMLReaderAdapter implements Parser, ContentHandler\r
-{\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Constructor.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Create a new adapter.\r
- *\r
- * <p>Use the "org.xml.sax.driver" property to locate the SAX2\r
- * driver to embed.</p>\r
- *\r
- * @exception org.xml.sax.SAXException If the embedded driver\r
- * cannot be instantiated or if the\r
- * org.xml.sax.driver property is not specified.\r
- */\r
- public XMLReaderAdapter ()\r
- throws SAXException\r
- {\r
- setup(XMLReaderFactory.createXMLReader());\r
- }\r
-\r
-\r
- /**\r
- * Create a new adapter.\r
- *\r
- * <p>Create a new adapter, wrapped around a SAX2 XMLReader.\r
- * The adapter will make the XMLReader act like a SAX1\r
- * Parser.</p>\r
- *\r
- * @param xmlReader The SAX2 XMLReader to wrap.\r
- * @exception java.lang.NullPointerException If the argument is null.\r
- */\r
- public XMLReaderAdapter (XMLReader xmlReader)\r
- {\r
- setup(xmlReader);\r
- }\r
-\r
-\r
-\r
- /**\r
- * Internal setup.\r
- *\r
- * @param xmlReader The embedded XMLReader.\r
- */\r
- private void setup (XMLReader xmlReader)\r
- {\r
- if (xmlReader == null) {\r
- throw new NullPointerException("XMLReader must not be null");\r
- }\r
- this.xmlReader = xmlReader;\r
- qAtts = new AttributesAdapter();\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.Parser.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Set the locale for error reporting.\r
- *\r
- * <p>This is not supported in SAX2, and will always throw\r
- * an exception.</p>\r
- *\r
- * @param The locale for error reporting.\r
- * @see org.xml.sax.Parser#setLocale\r
- */\r
- public void setLocale (Locale locale)\r
- throws SAXException\r
- {\r
- throw new SAXNotSupportedException("setLocale not supported");\r
- }\r
-\r
-\r
- /**\r
- * Register the entity resolver.\r
- *\r
- * @param resolver The new resolver.\r
- * @see org.xml.sax.Parser#setEntityResolver\r
- */\r
- public void setEntityResolver (EntityResolver resolver)\r
- {\r
- xmlReader.setEntityResolver(resolver);\r
- }\r
-\r
-\r
- /**\r
- * Register the DTD event handler.\r
- *\r
- * @param handler The new DTD event handler.\r
- * @see org.xml.sax.Parser#setDTDHandler\r
- */\r
- public void setDTDHandler (DTDHandler handler)\r
- {\r
- xmlReader.setDTDHandler(handler);\r
- }\r
-\r
-\r
- /**\r
- * Register the SAX1 document event handler.\r
- *\r
- * <p>Note that the SAX1 document handler has no Namespace\r
- * support.</p>\r
- *\r
- * @param handler The new SAX1 document event handler.\r
- * @see org.xml.sax.Parser#setDocumentHandler\r
- */\r
- public void setDocumentHandler (DocumentHandler handler)\r
- {\r
- documentHandler = handler;\r
- }\r
-\r
-\r
- /**\r
- * Register the error event handler.\r
- *\r
- * @param handler The new error event handler.\r
- * @see org.xml.sax.Parser#setErrorHandler\r
- */\r
- public void setErrorHandler (ErrorHandler handler)\r
- {\r
- xmlReader.setErrorHandler(handler);\r
- }\r
-\r
-\r
- /**\r
- * Parse the document.\r
- *\r
- * <p>This method will throw an exception if the embedded\r
- * XMLReader does not support the \r
- * http://xml.org/sax/features/namespace-prefixes property.</p>\r
- *\r
- * @param systemId The absolute URL of the document.\r
- * @exception java.io.IOException If there is a problem reading\r
- * the raw content of the document.\r
- * @exception org.xml.sax.SAXException If there is a problem\r
- * processing the document.\r
- * @see #parse(org.xml.sax.InputSource)\r
- * @see org.xml.sax.Parser#parse(java.lang.String)\r
- */\r
- public void parse (String systemId)\r
- throws IOException, SAXException\r
- {\r
- parse(new InputSource(systemId));\r
- }\r
-\r
-\r
- /**\r
- * Parse the document.\r
- *\r
- * <p>This method will throw an exception if the embedded\r
- * XMLReader does not support the \r
- * http://xml.org/sax/features/namespace-prefixes property.</p>\r
- *\r
- * @param input An input source for the document.\r
- * @exception java.io.IOException If there is a problem reading\r
- * the raw content of the document.\r
- * @exception org.xml.sax.SAXException If there is a problem\r
- * processing the document.\r
- * @see #parse(java.lang.String)\r
- * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)\r
- */\r
- public void parse (InputSource input)\r
- throws IOException, SAXException\r
- {\r
- setupXMLReader();\r
- xmlReader.parse(input);\r
- }\r
-\r
-\r
- /**\r
- * Set up the XML reader.\r
- */\r
- private void setupXMLReader ()\r
- throws SAXException\r
- {\r
- xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);\r
- try {\r
- xmlReader.setFeature("http://xml.org/sax/features/namespaces",\r
- false);\r
- } catch (SAXException e) {\r
- // NO OP: it's just extra information, and we can ignore it\r
- }\r
- xmlReader.setContentHandler(this);\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Implementation of org.xml.sax.ContentHandler.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Set a document locator.\r
- *\r
- * @param locator The document locator.\r
- * @see org.xml.sax.ContentHandler#setDocumentLocator\r
- */\r
- public void setDocumentLocator (Locator locator)\r
- {\r
- documentHandler.setDocumentLocator(locator);\r
- }\r
-\r
-\r
- /**\r
- * Start document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#startDocument\r
- */\r
- public void startDocument ()\r
- throws SAXException\r
- {\r
- documentHandler.startDocument();\r
- }\r
-\r
-\r
- /**\r
- * End document event.\r
- *\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#endDocument\r
- */\r
- public void endDocument ()\r
- throws SAXException\r
- {\r
- documentHandler.endDocument();\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 start prefix mapping event.\r
- *\r
- * @param prefix The prefix being mapped.\r
- * @param uri The Namespace URI being mapped to.\r
- * @see org.xml.sax.ContentHandler#startPrefixMapping\r
- */\r
- public void startPrefixMapping (String prefix, String uri)\r
- {\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 end prefix mapping event.\r
- *\r
- * @param prefix The prefix being mapped.\r
- * @see org.xml.sax.ContentHandler#endPrefixMapping\r
- */\r
- public void endPrefixMapping (String prefix)\r
- {\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 start element event.\r
- *\r
- * @param uri The Namespace URI.\r
- * @param localName The Namespace local name.\r
- * @param qName The qualified (prefixed) name.\r
- * @param atts The SAX2 attributes.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#endDocument\r
- */\r
- public void startElement (String uri, String localName,\r
- String qName, Attributes atts)\r
- throws SAXException\r
- {\r
- qAtts.setAttributes(atts);\r
- documentHandler.startElement(qName, qAtts);\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 end element event.\r
- *\r
- * @param uri The Namespace URI.\r
- * @param localName The Namespace local name.\r
- * @param qName The qualified (prefixed) name.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#endElement\r
- */\r
- public void endElement (String uri, String localName,\r
- String qName)\r
- throws SAXException\r
- {\r
- documentHandler.endElement(qName);\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 characters event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#characters\r
- */\r
- public void characters (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- documentHandler.characters(ch, start, length);\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 ignorable whitespace event.\r
- *\r
- * @param ch An array of characters.\r
- * @param start The starting position in the array.\r
- * @param length The number of characters to use.\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#ignorableWhitespace\r
- */\r
- public void ignorableWhitespace (char ch[], int start, int length)\r
- throws SAXException\r
- {\r
- documentHandler.ignorableWhitespace(ch, start, length);\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 processing instruction event.\r
- *\r
- * @param target The processing instruction target.\r
- * @param data The remainder of the processing instruction\r
- * @exception org.xml.sax.SAXException The client may raise a\r
- * processing exception.\r
- * @see org.xml.sax.ContentHandler#processingInstruction\r
- */\r
- public void processingInstruction (String target, String data)\r
- throws SAXException\r
- {\r
- documentHandler.processingInstruction(target, data);\r
- }\r
-\r
-\r
- /**\r
- * Adapt a SAX2 skipped entity event.\r
- *\r
- * @param name The name of the skipped entity.\r
- * @see org.xml.sax.ContentHandler#skippedEntity\r
- */\r
- public void skippedEntity (String name)\r
- throws SAXException\r
- {\r
- }\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
- XMLReader xmlReader;\r
- DocumentHandler documentHandler;\r
- AttributesAdapter qAtts;\r
-\r
-\r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal class.\r
- ////////////////////////////////////////////////////////////////////\r
-\r
-\r
- /**\r
- * Internal class to wrap a SAX2 Attributes object for SAX1.\r
- */\r
- final class AttributesAdapter implements AttributeList\r
- {\r
- AttributesAdapter ()\r
- {\r
- }\r
-\r
-\r
- /**\r
- * Set the embedded Attributes object.\r
- *\r
- * @param The embedded SAX2 Attributes.\r
- */ \r
- void setAttributes (Attributes attributes)\r
- {\r
- this.attributes = attributes;\r
- }\r
-\r
-\r
- /**\r
- * Return the number of attributes.\r
- *\r
- * @return The length of the attribute list.\r
- * @see org.xml.sax.AttributeList#getLength\r
- */\r
- public int getLength ()\r
- {\r
- return attributes.getLength();\r
- }\r
-\r
-\r
- /**\r
- * Return the qualified (prefixed) name of an attribute by position.\r
- *\r
- * @return The qualified name.\r
- * @see org.xml.sax.AttributeList#getName\r
- */\r
- public String getName (int i)\r
- {\r
- return attributes.getQName(i);\r
- }\r
-\r
-\r
- /**\r
- * Return the type of an attribute by position.\r
- *\r
- * @return The type.\r
- * @see org.xml.sax.AttributeList#getType(int)\r
- */\r
- public String getType (int i)\r
- {\r
- return attributes.getType(i);\r
- }\r
-\r
-\r
- /**\r
- * Return the value of an attribute by position.\r
- *\r
- * @return The value.\r
- * @see org.xml.sax.AttributeList#getValue(int)\r
- */\r
- public String getValue (int i)\r
- {\r
- return attributes.getValue(i);\r
- }\r
-\r
-\r
- /**\r
- * Return the type of an attribute by qualified (prefixed) name.\r
- *\r
- * @return The type.\r
- * @see org.xml.sax.AttributeList#getType(java.lang.String)\r
- */\r
- public String getType (String qName)\r
- {\r
- return attributes.getType(qName);\r
- }\r
-\r
-\r
- /**\r
- * Return the value of an attribute by qualified (prefixed) name.\r
- *\r
- * @return The value.\r
- * @see org.xml.sax.AttributeList#getValue(java.lang.String)\r
- */\r
- public String getValue (String qName)\r
- {\r
- return attributes.getValue(qName);\r
- }\r
-\r
- private Attributes attributes;\r
- }\r
-\r
-}\r
-\r
-// end of XMLReaderAdapter.java\r
+// XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser
+// http://www.saxproject.org
+// Written by David Megginson
+// NO WARRANTY! This class is in the public domain.
+
+// $Id: XMLReaderAdapter.java,v 1.5.2.3 2002/01/29 21:34:15 dbrownell Exp $
+
+package org.xml.sax.helpers;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import org.xml.sax.Parser; // deprecated
+import org.xml.sax.Locator;
+import org.xml.sax.InputSource;
+import org.xml.sax.AttributeList; // deprecated
+import org.xml.sax.EntityResolver;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.DocumentHandler; // deprecated
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXNotSupportedException;
+
+
+/**
+ * Adapt a SAX2 XMLReader as a SAX1 Parser.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}
+ * and makes it act as a SAX1 {@link org.xml.sax.Parser Parser}. The XMLReader
+ * must support a true value for the
+ * http://xml.org/sax/features/namespace-prefixes property or parsing will fail
+ * with a {@link org.xml.sax.SAXException SAXException}; if the XMLReader
+ * supports a false value for the http://xml.org/sax/features/namespaces
+ * property, that will also be used to improve efficiency.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson
+ * @version 2.0.1 (sax2r2)
+ * @see org.xml.sax.Parser
+ * @see org.xml.sax.XMLReader
+ */
+public class XMLReaderAdapter implements Parser, ContentHandler
+{
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Constructor.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Create a new adapter.
+ *
+ * <p>Use the "org.xml.sax.driver" property to locate the SAX2
+ * driver to embed.</p>
+ *
+ * @exception org.xml.sax.SAXException If the embedded driver
+ * cannot be instantiated or if the
+ * org.xml.sax.driver property is not specified.
+ */
+ public XMLReaderAdapter ()
+ throws SAXException
+ {
+ setup(XMLReaderFactory.createXMLReader());
+ }
+
+
+ /**
+ * Create a new adapter.
+ *
+ * <p>Create a new adapter, wrapped around a SAX2 XMLReader.
+ * The adapter will make the XMLReader act like a SAX1
+ * Parser.</p>
+ *
+ * @param xmlReader The SAX2 XMLReader to wrap.
+ * @exception java.lang.NullPointerException If the argument is null.
+ */
+ public XMLReaderAdapter (XMLReader xmlReader)
+ {
+ setup(xmlReader);
+ }
+
+
+
+ /**
+ * Internal setup.
+ *
+ * @param xmlReader The embedded XMLReader.
+ */
+ private void setup (XMLReader xmlReader)
+ {
+ if (xmlReader == null) {
+ throw new NullPointerException("XMLReader must not be null");
+ }
+ this.xmlReader = xmlReader;
+ qAtts = new AttributesAdapter();
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.Parser.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set the locale for error reporting.
+ *
+ * <p>This is not supported in SAX2, and will always throw
+ * an exception.</p>
+ *
+ * @param The locale for error reporting.
+ * @see org.xml.sax.Parser#setLocale
+ * @exception org.xml.sax.SAXException Thrown unless overridden.
+ */
+ public void setLocale (Locale locale)
+ throws SAXException
+ {
+ throw new SAXNotSupportedException("setLocale not supported");
+ }
+
+
+ /**
+ * Register the entity resolver.
+ *
+ * @param resolver The new resolver.
+ * @see org.xml.sax.Parser#setEntityResolver
+ */
+ public void setEntityResolver (EntityResolver resolver)
+ {
+ xmlReader.setEntityResolver(resolver);
+ }
+
+
+ /**
+ * Register the DTD event handler.
+ *
+ * @param handler The new DTD event handler.
+ * @see org.xml.sax.Parser#setDTDHandler
+ */
+ public void setDTDHandler (DTDHandler handler)
+ {
+ xmlReader.setDTDHandler(handler);
+ }
+
+
+ /**
+ * Register the SAX1 document event handler.
+ *
+ * <p>Note that the SAX1 document handler has no Namespace
+ * support.</p>
+ *
+ * @param handler The new SAX1 document event handler.
+ * @see org.xml.sax.Parser#setDocumentHandler
+ */
+ public void setDocumentHandler (DocumentHandler handler)
+ {
+ documentHandler = handler;
+ }
+
+
+ /**
+ * Register the error event handler.
+ *
+ * @param handler The new error event handler.
+ * @see org.xml.sax.Parser#setErrorHandler
+ */
+ public void setErrorHandler (ErrorHandler handler)
+ {
+ xmlReader.setErrorHandler(handler);
+ }
+
+
+ /**
+ * Parse the document.
+ *
+ * <p>This method will throw an exception if the embedded
+ * XMLReader does not support the
+ * http://xml.org/sax/features/namespace-prefixes property.</p>
+ *
+ * @param systemId The absolute URL of the document.
+ * @exception java.io.IOException If there is a problem reading
+ * the raw content of the document.
+ * @exception org.xml.sax.SAXException If there is a problem
+ * processing the document.
+ * @see #parse(org.xml.sax.InputSource)
+ * @see org.xml.sax.Parser#parse(java.lang.String)
+ */
+ public void parse (String systemId)
+ throws IOException, SAXException
+ {
+ parse(new InputSource(systemId));
+ }
+
+
+ /**
+ * Parse the document.
+ *
+ * <p>This method will throw an exception if the embedded
+ * XMLReader does not support the
+ * http://xml.org/sax/features/namespace-prefixes property.</p>
+ *
+ * @param input An input source for the document.
+ * @exception java.io.IOException If there is a problem reading
+ * the raw content of the document.
+ * @exception org.xml.sax.SAXException If there is a problem
+ * processing the document.
+ * @see #parse(java.lang.String)
+ * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
+ */
+ public void parse (InputSource input)
+ throws IOException, SAXException
+ {
+ setupXMLReader();
+ xmlReader.parse(input);
+ }
+
+
+ /**
+ * Set up the XML reader.
+ */
+ private void setupXMLReader ()
+ throws SAXException
+ {
+ xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+ try {
+ xmlReader.setFeature("http://xml.org/sax/features/namespaces",
+ false);
+ } catch (SAXException e) {
+ // NO OP: it's just extra information, and we can ignore it
+ }
+ xmlReader.setContentHandler(this);
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Implementation of org.xml.sax.ContentHandler.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Set a document locator.
+ *
+ * @param locator The document locator.
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
+ */
+ public void setDocumentLocator (Locator locator)
+ {
+ if (documentHandler != null)
+ documentHandler.setDocumentLocator(locator);
+ }
+
+
+ /**
+ * Start document event.
+ *
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#startDocument
+ */
+ public void startDocument ()
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.startDocument();
+ }
+
+
+ /**
+ * End document event.
+ *
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#endDocument
+ */
+ public void endDocument ()
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.endDocument();
+ }
+
+
+ /**
+ * Adapt a SAX2 start prefix mapping event.
+ *
+ * @param prefix The prefix being mapped.
+ * @param uri The Namespace URI being mapped to.
+ * @see org.xml.sax.ContentHandler#startPrefixMapping
+ */
+ public void startPrefixMapping (String prefix, String uri)
+ {
+ }
+
+
+ /**
+ * Adapt a SAX2 end prefix mapping event.
+ *
+ * @param prefix The prefix being mapped.
+ * @see org.xml.sax.ContentHandler#endPrefixMapping
+ */
+ public void endPrefixMapping (String prefix)
+ {
+ }
+
+
+ /**
+ * Adapt a SAX2 start element event.
+ *
+ * @param uri The Namespace URI.
+ * @param localName The Namespace local name.
+ * @param qName The qualified (prefixed) name.
+ * @param atts The SAX2 attributes.
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#endDocument
+ */
+ public void startElement (String uri, String localName,
+ String qName, Attributes atts)
+ throws SAXException
+ {
+ if (documentHandler != null) {
+ qAtts.setAttributes(atts);
+ documentHandler.startElement(qName, qAtts);
+ }
+ }
+
+
+ /**
+ * Adapt a SAX2 end element event.
+ *
+ * @param uri The Namespace URI.
+ * @param localName The Namespace local name.
+ * @param qName The qualified (prefixed) name.
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#endElement
+ */
+ public void endElement (String uri, String localName,
+ String qName)
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.endElement(qName);
+ }
+
+
+ /**
+ * Adapt a SAX2 characters event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use.
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#characters
+ */
+ public void characters (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.characters(ch, start, length);
+ }
+
+
+ /**
+ * Adapt a SAX2 ignorable whitespace event.
+ *
+ * @param ch An array of characters.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use.
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#ignorableWhitespace
+ */
+ public void ignorableWhitespace (char ch[], int start, int length)
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.ignorableWhitespace(ch, start, length);
+ }
+
+
+ /**
+ * Adapt a SAX2 processing instruction event.
+ *
+ * @param target The processing instruction target.
+ * @param data The remainder of the processing instruction
+ * @exception org.xml.sax.SAXException The client may raise a
+ * processing exception.
+ * @see org.xml.sax.ContentHandler#processingInstruction
+ */
+ public void processingInstruction (String target, String data)
+ throws SAXException
+ {
+ if (documentHandler != null)
+ documentHandler.processingInstruction(target, data);
+ }
+
+
+ /**
+ * Adapt a SAX2 skipped entity event.
+ *
+ * @param name The name of the skipped entity.
+ * @see org.xml.sax.ContentHandler#skippedEntity
+ * @exception org.xml.sax.SAXException Throwable by subclasses.
+ */
+ public void skippedEntity (String name)
+ throws SAXException
+ {
+ }
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal state.
+ ////////////////////////////////////////////////////////////////////
+
+ XMLReader xmlReader;
+ DocumentHandler documentHandler;
+ AttributesAdapter qAtts;
+
+
+\f
+ ////////////////////////////////////////////////////////////////////
+ // Internal class.
+ ////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Internal class to wrap a SAX2 Attributes object for SAX1.
+ */
+ final class AttributesAdapter implements AttributeList
+ {
+ AttributesAdapter ()
+ {
+ }
+
+
+ /**
+ * Set the embedded Attributes object.
+ *
+ * @param The embedded SAX2 Attributes.
+ */
+ void setAttributes (Attributes attributes)
+ {
+ this.attributes = attributes;
+ }
+
+
+ /**
+ * Return the number of attributes.
+ *
+ * @return The length of the attribute list.
+ * @see org.xml.sax.AttributeList#getLength
+ */
+ public int getLength ()
+ {
+ return attributes.getLength();
+ }
+
+
+ /**
+ * Return the qualified (prefixed) name of an attribute by position.
+ *
+ * @return The qualified name.
+ * @see org.xml.sax.AttributeList#getName
+ */
+ public String getName (int i)
+ {
+ return attributes.getQName(i);
+ }
+
+
+ /**
+ * Return the type of an attribute by position.
+ *
+ * @return The type.
+ * @see org.xml.sax.AttributeList#getType(int)
+ */
+ public String getType (int i)
+ {
+ return attributes.getType(i);
+ }
+
+
+ /**
+ * Return the value of an attribute by position.
+ *
+ * @return The value.
+ * @see org.xml.sax.AttributeList#getValue(int)
+ */
+ public String getValue (int i)
+ {
+ return attributes.getValue(i);
+ }
+
+
+ /**
+ * Return the type of an attribute by qualified (prefixed) name.
+ *
+ * @return The type.
+ * @see org.xml.sax.AttributeList#getType(java.lang.String)
+ */
+ public String getType (String qName)
+ {
+ return attributes.getType(qName);
+ }
+
+
+ /**
+ * Return the value of an attribute by qualified (prefixed) name.
+ *
+ * @return The value.
+ * @see org.xml.sax.AttributeList#getValue(java.lang.String)
+ */
+ public String getValue (String qName)
+ {
+ return attributes.getValue(qName);
+ }
+
+ private Attributes attributes;
+ }
+
+}
+
+// end of XMLReaderAdapter.java
-// XMLReaderFactory.java - factory for creating a new reader.\r
-// Written by David Megginson, sax@megginson.com\r
-// NO WARRANTY! This class is in the Public Domain.\r
-\r
-// $Id: XMLReaderFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $\r
-\r
-package org.xml.sax.helpers;\r
-import org.xml.sax.Parser;\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.SAXException;\r
-\r
-\r
-/**\r
- * Factory for creating an XML reader.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class contains static methods for creating an XML reader\r
- * from an explicit class name, or for creating an XML reader based\r
- * on the value of the <code>org.xml.sax.driver</code> system \r
- * property:</p>\r
- *\r
- * <pre>\r
- * try {\r
- * XMLReader myReader = XMLReaderFactory.createXMLReader();\r
- * } catch (SAXException e) {\r
- * System.err.println(e.getMessage());\r
- * }\r
- * </pre>\r
- *\r
- * <p>Note that these methods will not be usable in environments where\r
- * system properties are not accessible or where the application or\r
- * applet is not permitted to load classes dynamically.</p>\r
- *\r
- * <p><strong>Note to implementors:</strong> SAX implementations in specialized\r
- * environments may replace this class with a different one optimized for the\r
- * environment, as long as its method signatures remain the same.</p>\r
- *\r
- * @since SAX 2.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.XMLReader\r
- */\r
-final public class XMLReaderFactory\r
-{\r
-\r
- /**\r
- * Private constructor.\r
- *\r
- * <p>This constructor prevents the class from being instantiated.</p>\r
- */\r
- private XMLReaderFactory ()\r
- {\r
- }\r
-\r
-\r
- /**\r
- * Attempt to create an XML reader from a system property.\r
- *\r
- * <p>This method uses the value of the system property\r
- * "org.xml.sax.driver" as the full name of a Java class\r
- * and tries to instantiate that class as a SAX2 \r
- * XMLReader.</p>\r
- *\r
- * <p>Note that many Java interpreters allow system properties\r
- * to be specified on the command line.</p>\r
- *\r
- * @return A new XMLReader.\r
- * @exception org.xml.sax.SAXException If the value of the\r
- * "org.xml.sax.driver" system property is null,\r
- * or if the class cannot be loaded and instantiated.\r
- * @see #createXMLReader(java.lang.String)\r
- */\r
- public static XMLReader createXMLReader ()\r
- throws SAXException\r
- {\r
- String className = System.getProperty("org.xml.sax.driver");\r
- if (className == null) {\r
- Parser parser;\r
- try {\r
- parser = ParserFactory.makeParser();\r
- } catch (Exception e) {\r
- parser = null;\r
- }\r
- if (parser == null) {\r
- throw new\r
- SAXException("System property org.xml.sax.driver not specified");\r
- } else {\r
- return new ParserAdapter(parser);\r
- }\r
- } else {\r
- return createXMLReader(className);\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Attempt to create an XML reader from a class name.\r
- *\r
- * <p>Given a class name, this method attempts to load\r
- * and instantiate the class as an XML reader.</p>\r
- *\r
- * @return A new XML reader.\r
- * @exception org.xml.sax.SAXException If the class cannot be\r
- * loaded, instantiated, and cast to XMLReader.\r
- * @see #createXMLReader()\r
- */\r
- public static XMLReader createXMLReader (String className)\r
- throws SAXException\r
- {\r
- try {\r
- return (XMLReader)(Class.forName(className).newInstance());\r
- } catch (ClassNotFoundException e1) {\r
- throw new SAXException("SAX2 driver class " + className +\r
- " not found", e1);\r
- } catch (IllegalAccessException e2) {\r
- throw new SAXException("SAX2 driver class " + className +\r
- " found but cannot be loaded", e2);\r
- } catch (InstantiationException e3) {\r
- throw new SAXException("SAX2 driver class " + className +\r
- " loaded but cannot be instantiated (no empty public constructor?)",\r
- e3);\r
- } catch (ClassCastException e4) {\r
- throw new SAXException("SAX2 driver class " + className +\r
- " does not implement XMLReader", e4);\r
- }\r
- \r
- }\r
-\r
-}\r
-\r
-// end of XMLReaderFactory.java\r
+// XMLReaderFactory.java - factory for creating a new reader.
+// http://www.saxproject.org
+// Written by David Megginson
+// and by David Brownell
+// NO WARRANTY! This class is in the Public Domain.
+
+// $Id: XMLReaderFactory.java,v 1.5.2.4 2002/01/29 21:34:15 dbrownell Exp $
+
+package org.xml.sax.helpers;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Factory for creating an XML reader.
+ *
+ * <blockquote>
+ * <em>This module, both source code and documentation, is in the
+ * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
+ * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+ * for further information.
+ * </blockquote>
+ *
+ * <p>This class contains static methods for creating an XML reader
+ * from an explicit class name, or based on runtime defaults:</p>
+ *
+ * <pre>
+ * try {
+ * XMLReader myReader = XMLReaderFactory.createXMLReader();
+ * } catch (SAXException e) {
+ * System.err.println(e.getMessage());
+ * }
+ * </pre>
+ *
+ * <p><strong>Note to Distributions bundled with parsers:</strong>
+ * You should modify the implementation of the no-arguments
+ * <em>createXMLReader</em> to handle cases where the external
+ * configuration mechanisms aren't set up. That method should do its
+ * best to return a parser when one is in the class path, even when
+ * nothing bound its class name to <code>org.xml.sax.driver</code> so
+ * those configuration mechanisms would see it.</p>
+ *
+ * @since SAX 2.0
+ * @author David Megginson, David Brownell
+ * @version 2.0.1 (sax2r2)
+ */
+final public class XMLReaderFactory
+{
+ /**
+ * Private constructor.
+ *
+ * <p>This constructor prevents the class from being instantiated.</p>
+ */
+ private XMLReaderFactory ()
+ {
+ }
+
+ private static final String property = "org.xml.sax.driver";
+
+ /**
+ * Attempt to create an XMLReader from system defaults.
+ * In environments which can support it, the name of the XMLReader
+ * class is determined by trying each these options in order, and
+ * using the first one which succeeds:</p> <ul>
+ *
+ * <li>If the system property <code>org.xml.sax.driver</code>
+ * has a value, that is used as an XMLReader class name. </li>
+ *
+ * <li>The JAR "Services API" is used to look for a class name
+ * in the <em>META-INF/services/org.xml.sax.driver</em> file in
+ * jarfiles available to the runtime.</li>
+ *
+ * <li> SAX parser distributions are strongly encouraged to provide
+ * a default XMLReader class name that will take effect only when
+ * previous options (on this list) are not successful.</li>
+ *
+ * <li>Finally, if {@link ParserFactory#makeParser()} can
+ * return a system default SAX1 parser, that parser is wrapped in
+ * a {@link ParserAdapter}. (This is a migration aid for SAX1
+ * environments, where the <code>org.xml.sax.parser</code> system
+ * property will often be usable.) </li>
+ *
+ * </ul>
+ *
+ * <p> In environments such as small embedded systems, which can not
+ * support that flexibility, other mechanisms to determine the default
+ * may be used. </p>
+ *
+ * <p>Note that many Java environments allow system properties to be
+ * initialized on a command line. This means that <em>in most cases</em>
+ * setting a good value for that property ensures that calls to this
+ * method will succeed, except when security policies intervene.
+ * This will also maximize application portability to older SAX
+ * environments, with less robust implementations of this method.
+ * </p>
+ *
+ * @return A new XMLReader.
+ * @exception org.xml.sax.SAXException If no default XMLReader class
+ * can be identified and instantiated.
+ * @see #createXMLReader(java.lang.String)
+ */
+ public static XMLReader createXMLReader ()
+ throws SAXException
+ {
+ String className = null;
+ ClassLoader loader = NewInstance.getClassLoader ();
+
+ // 1. try the JVM-instance-wide system property
+ try { className = System.getProperty (property); }
+ catch (Exception e) { /* normally fails for applets */ }
+
+ // 2. if that fails, try META-INF/services/
+ if (className == null) {
+ try {
+ String service = "META-INF/services/" + property;
+ InputStream in;
+ BufferedReader reader;
+
+ if (loader == null)
+ in = ClassLoader.getSystemResourceAsStream (service);
+ else
+ in = loader.getResourceAsStream (service);
+
+ if (in != null) {
+ reader = new BufferedReader (
+ new InputStreamReader (in, "UTF8"));
+ className = reader.readLine ();
+ in.close ();
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ // 3. Distro-specific fallback
+ if (className == null) {
+// BEGIN DISTRIBUTION-SPECIFIC
+
+ // EXAMPLE:
+ // className = "com.example.sax.XmlReader";
+ // or a $JAVA_HOME/jre/lib/*properties setting...
+
+// END DISTRIBUTION-SPECIFIC
+ }
+
+ // do we know the XMLReader implementation class yet?
+ if (className != null)
+ return loadClass (loader, className);
+
+ // 4. panic -- adapt any SAX1 parser
+ try {
+ return new ParserAdapter (ParserFactory.makeParser ());
+ } catch (Exception e) {
+ throw new SAXException ("Can't create default XMLReader; "
+ + "is system property org.xml.sax.driver set?");
+ }
+ }
+
+
+ /**
+ * Attempt to create an XML reader from a class name.
+ *
+ * <p>Given a class name, this method attempts to load
+ * and instantiate the class as an XML reader.</p>
+ *
+ * <p>Note that this method will not be usable in environments where
+ * the caller (perhaps an applet) is not permitted to load classes
+ * dynamically.</p>
+ *
+ * @return A new XML reader.
+ * @exception org.xml.sax.SAXException If the class cannot be
+ * loaded, instantiated, and cast to XMLReader.
+ * @see #createXMLReader()
+ */
+ public static XMLReader createXMLReader (String className)
+ throws SAXException
+ {
+ return loadClass (NewInstance.getClassLoader (), className);
+ }
+
+ private static XMLReader loadClass (ClassLoader loader, String className)
+ throws SAXException
+ {
+ try {
+ return (XMLReader) NewInstance.newInstance (loader, className);
+ } catch (ClassNotFoundException e1) {
+ throw new SAXException("SAX2 driver class " + className +
+ " not found", e1);
+ } catch (IllegalAccessException e2) {
+ throw new SAXException("SAX2 driver class " + className +
+ " found but cannot be loaded", e2);
+ } catch (InstantiationException e3) {
+ throw new SAXException("SAX2 driver class " + className +
+ " loaded but cannot be instantiated (no empty public constructor?)",
+ e3);
+ } catch (ClassCastException e4) {
+ throw new SAXException("SAX2 driver class " + className +
+ " does not implement XMLReader", e4);
+ }
+ }
+}
--- /dev/null
+<HTML><HEAD>
+
+<!-- $Id: package.html,v 1.3.2.1 2001/11/09 20:32:58 dbrownell Exp $ -->
+
+</HEAD><BODY>
+
+<p>This package contains "helper" classes, including
+support for bootstrapping SAX-based applications.
+
+<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+for more information about SAX.</p>
+
+</BODY></HTML>
--- /dev/null
+<html><head>
+
+<!-- $Id: package.html,v 1.2.2.2 2002/01/12 21:42:21 dbrownell Exp $ -->
+
+</head><body>
+
+<p> This package provides the core SAX APIs.
+Some SAX1 APIs are deprecated to encourage integration of
+namespace-awareness into designs of new applications
+and into maintainance of existing infrastructure. </p>
+
+<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
+for more information about SAX.</p>
+
+
+<h2> SAX2 Standard Feature Flags </h2>
+
+<p> One of the essential characteristics of SAX2 is that it added
+feature flags which can be used to examine and perhaps modify
+parser modes, in particular modes such as validation.
+Since features are identified by (absolute) URIs, anyone
+can define such features.
+Currently defined standard feature URIs have the prefix
+<code>http://xml.org/sax/features/</code> before an identifier such as
+<code>validation</code>. Turn features on or off using
+<em>setFeature</em>. Those standard identifiers are: </p>
+
+
+<table border="1" cellpadding="3" cellspacing="0" width="100%">
+ <tr align="center" bgcolor="#ccccff">
+ <th>Feature ID</th>
+ <th>Default</th>
+ <th>Description</th>
+ </tr>
+
+ <tr>
+ <td>external-general-entities</td>
+ <td><em>unspecified</em></td>
+ <td> Reports whether this parser processes external
+ general entities; always true if validating</td>
+ </tr>
+
+ <tr>
+ <td>external-parameter-entities</td>
+ <td><em>unspecified</em></td>
+ <td> Reports whether this parser processes external
+ parameter entities; always true if validating</td>
+ </tr>
+
+ <tr>
+ <td>lexical-handler/parameter-entities</td>
+ <td><em>unspecified</em></td>
+ <td> true indicates that the LexicalHandler will report the
+ beginning and end of parameter entities
+ </td>
+ </tr>
+
+ <tr>
+ <td>namespaces</td>
+ <td>true</td>
+ <td> true indicates namespace URIs and unprefixed local names
+ for element and attribute names will be available </td>
+ </tr>
+
+ <tr>
+ <td>namespace-prefixes</td>
+ <td>false</td>
+ <td> true indicates XML 1.0 names (with prefixes) and attributes
+ (including <em>xmlns*</em> attributes) will be available </td>
+ </tr>
+
+ <tr>
+ <td>string-interning</td>
+ <td><em>unspecified</em></td>
+ <td> true if all XML names (for elements, prefixes, attributes,
+ entities, notations, and local names),
+ as well as Namespace URIs, will have been interned
+ using <em>java.lang.String.intern</em>. This supports fast
+ testing of equality/inequality against string constants.</td>
+ </tr>
+
+ <tr>
+ <td>validation</td>
+ <td><em>unspecified</em></td>
+ <td> controls whether the parser is reporting all validity
+ errors; if true, all external entities will be read. </td>
+ </tr>
+
+</table>
+
+<p> Support for the default values of the
+<em>namespaces</em> and <em>namespace-prefixes</em>
+properties is required.
+</p>
+
+<p> For default values not specified by SAX2,
+each XMLReader implementation specifies its default,
+or may choose not to expose the feature flag.
+Unless otherwise specified here,
+implementations may support changing current values
+of these standard feature flags, but not while parsing.
+</p>
+
+<h2> SAX2 Standard Handler and Property IDs </h2>
+
+<p> For parser interface characteristics that are described
+as objects, a separate namespace is defined. The
+objects in this namespace are again identified by URI, and
+the standard property URIs have the prefix
+<code>http://xml.org/sax/properties/</code> before an identifier such as
+<code>lexical-handler</code> or
+<code>dom-node</code>. Manage those properties using
+<em>setProperty()</em>. Those identifiers are: </p>
+
+<table border="1" cellpadding="3" cellspacing="0" width="100%">
+ <tr align="center" bgcolor="#ccccff">
+ <th>Property ID</th>
+ <th>Description</th>
+ </tr>
+
+ <tr>
+ <td>declaration-handler</td>
+ <td> Used to see most DTD declarations except those treated
+ as lexical ("document element name is ...") or which are
+ mandatory for all SAX parsers (<em>DTDHandler</em>).
+ The Object must implement <a href="ext/DeclHandler.html"
+ ><em>org.xml.sax.ext.DeclHandler</em></a>.
+ </td>
+ </tr>
+
+ <tr>
+ <td>dom-node</td>
+ <td> For "DOM Walker" style parsers, which ignore their
+ <em>parser.parse()</em> parameters, this is used to
+ specify the DOM (sub)tree being walked by the parser.
+ The Object must implement the
+ <em>org.w3c.dom.Node</em> interface.
+ </td>
+ </tr>
+
+ <tr>
+ <td>lexical-handler</td>
+ <td> Used to see some syntax events that are essential in some
+ applications: comments, CDATA delimeters, selected general
+ entity inclusions, and the start and end of the DTD
+ (and declaration of document element name).
+ The Object must implement <a href="ext/LexicalHandler.html"
+ ><em>org.xml.sax.ext.LexicalHandler</em></a>.
+ </td>
+ </tr>
+
+ <tr>
+ <td>xml-string</td>
+ <td> Readable only during a parser callback, this exposes a <b>TBS</b>
+ chunk of characters responsible for the current event. </td>
+ </tr>
+
+</table>
+
+<p> All of these standard properties are optional;
+XMLReader implementations need not support them.
+</p>
+
+</body></html>