Commit 9556f887 by Anthony Green Committed by Anthony Green

Add some org packages.

From-SVN: r43922
parent 608fe35b
2001-07-10 Anthony Green <green@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am: Add new files.
* org/w3c/dom/Attr.java, org/w3c/dom/CDATASection.java,
org/w3c/dom/CharacterData.java, org/w3c/dom/Comment.java,
org/w3c/dom/DOMException.java, org/w3c/dom/DOMImplementation.java,
org/w3c/dom/Document.java, org/w3c/dom/DocumentFragment.java,
org/w3c/dom/DocumentType.java, org/w3c/dom/Element.java,
org/w3c/dom/Entity.java, org/w3c/dom/EntityReference.java,
org/w3c/dom/NamedNodeMap.java, org/w3c/dom/Node.java,
org/w3c/dom/NodeList.java, org/w3c/dom/Notation.java,
org/w3c/dom/ProcessingInstruction.java, org/w3c/dom/Text.java,
org/w3c/dom/ranges/DocumentRange.java,
org/w3c/dom/ranges/Range.java,
org/w3c/dom/ranges/RangeException.java,
org/w3c/dom/traversal/DocumentTraversal.java,
org/w3c/dom/traversal/NodeFilter.java,
org/w3c/dom/traversal/NodeIterator.java,
org/w3c/dom/traversal/TreeWalker.java,
org/xml/sax/ext/DeclHandler.java,
org/xml/sax/ext/LexicalHandler.java,
org/xml/sax/helpers/AttributeListImpl.java,
org/xml/sax/helpers/AttributesImpl.java,
org/xml/sax/helpers/DefaultHandler.java,
org/xml/sax/helpers/LocatorImpl.java,
org/xml/sax/helpers/NamespaceSupport.java,
org/xml/sax/helpers/ParserAdapter.java,
org/xml/sax/helpers/ParserFactory.java,
org/xml/sax/helpers/XMLFilterImpl.java,
org/xml/sax/helpers/XMLReaderAdapter.java,
org/xml/sax/helpers/XMLReaderFactory.java,
org/xml/sax/AttributeList.java, org/xml/sax/Attributes.java,
org/xml/sax/ContentHandler.java, org/xml/sax/DTDHandler.java,
org/xml/sax/DocumentHandler.java, org/xml/sax/EntityResolver.java,
org/xml/sax/ErrorHandler.java, org/xml/sax/HandlerBase.java,
org/xml/sax/InputSource.java, org/xml/sax/Locator.java,
org/xml/sax/Parser.java, org/xml/sax/SAXException.java,
org/xml/sax/SAXNotRecognizedException.java,
org/xml/sax/SAXNotSupportedException.java,
org/xml/sax/SAXParseException.java, org/xml/sax/XMLFilter.java,
org/xml/sax/XMLReader.java: New files.
2001-07-10 Alexandre Petit-Bianco <apbianco@redhat.com>
* Makefile.am: Added `java/lang/ThreadLocal.java'.
......
......@@ -188,7 +188,7 @@ libgcj.jar: $(built_java_source_files) $(java_source_files) $(x_java_source_file
test "$$fail" = no
-@rm -f tmp-list libgcj.jar
## Note that we explicitly want to include directory information.
find java gnu -type d -o -type f -name '*.class' | \
find java gnu org -type d -o -type f -name '*.class' | \
sed -e '/\/\./d' -e '/\/xlib/d' | \
$(ZIP) cfM0E@ $@
......@@ -977,7 +977,6 @@ java/util/TooManyListenersException.java \
java/util/Vector.java \
java/util/WeakHashMap.java
## List of all .java files to be compiled. Please keep this list
## alphabetical. Please put files from java/lang, java/io, and java/util
## into core_java_source_files. Please put files from gnu/gcj/convert
......@@ -1252,6 +1251,60 @@ java/util/zip/ZipException.java \
java/util/zip/ZipFile.java \
java/util/zip/ZipInputStream.java \
java/util/zip/ZipOutputStream.java \
org/w3c/dom/Attr.java \
org/w3c/dom/CDATASection.java \
org/w3c/dom/CharacterData.java \
org/w3c/dom/Comment.java \
org/w3c/dom/DOMException.java \
org/w3c/dom/DOMImplementation.java \
org/w3c/dom/Document.java \
org/w3c/dom/DocumentFragment.java \
org/w3c/dom/DocumentType.java \
org/w3c/dom/Element.java \
org/w3c/dom/Entity.java \
org/w3c/dom/EntityReference.java \
org/w3c/dom/NamedNodeMap.java \
org/w3c/dom/Node.java \
org/w3c/dom/NodeList.java \
org/w3c/dom/Notation.java \
org/w3c/dom/ProcessingInstruction.java \
org/w3c/dom/Text.java \
org/w3c/dom/ranges/DocumentRange.java \
org/w3c/dom/ranges/Range.java \
org/w3c/dom/ranges/RangeException.java \
org/w3c/dom/traversal/DocumentTraversal.java \
org/w3c/dom/traversal/NodeFilter.java \
org/w3c/dom/traversal/NodeIterator.java \
org/w3c/dom/traversal/TreeWalker.java \
org/xml/sax/ext/DeclHandler.java \
org/xml/sax/ext/LexicalHandler.java \
org/xml/sax/helpers/AttributeListImpl.java \
org/xml/sax/helpers/AttributesImpl.java \
org/xml/sax/helpers/DefaultHandler.java \
org/xml/sax/helpers/LocatorImpl.java \
org/xml/sax/helpers/NamespaceSupport.java \
org/xml/sax/helpers/ParserAdapter.java \
org/xml/sax/helpers/ParserFactory.java \
org/xml/sax/helpers/XMLFilterImpl.java \
org/xml/sax/helpers/XMLReaderAdapter.java \
org/xml/sax/helpers/XMLReaderFactory.java \
org/xml/sax/AttributeList.java \
org/xml/sax/Attributes.java \
org/xml/sax/ContentHandler.java \
org/xml/sax/DTDHandler.java \
org/xml/sax/DocumentHandler.java \
org/xml/sax/EntityResolver.java \
org/xml/sax/ErrorHandler.java \
org/xml/sax/HandlerBase.java \
org/xml/sax/InputSource.java \
org/xml/sax/Locator.java \
org/xml/sax/Parser.java \
org/xml/sax/SAXException.java \
org/xml/sax/SAXNotRecognizedException.java \
org/xml/sax/SAXNotSupportedException.java \
org/xml/sax/SAXParseException.java \
org/xml/sax/XMLFilter.java \
org/xml/sax/XMLReader.java \
$(awt_java_source_files) \
$(convert_source_files)
......
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>Attr</code> interface represents an attribute in an
* <code>Element</code> object. Typically the allowable values for the
* attribute are defined in a document type definition.
* <p><code>Attr</code> objects inherit the <code>Node</code> interface, but
* since they are not actually child nodes of the element they describe, the
* DOM does not consider them part of the document tree. Thus, the
* <code>Node</code> attributes <code>parentNode</code>,
* <code>previousSibling</code>, and <code>nextSibling</code> have a
* <code>null</code> value for <code>Attr</code> objects. The DOM takes the
* view that attributes are properties of elements rather than having a
* separate identity from the elements they are associated with; this should
* make it more efficient to implement such features as default attributes
* associated with all elements of a given type. Furthermore,
* <code>Attr</code> nodes may not be immediate children of a
* <code>DocumentFragment</code>. However, they can be associated with
* <code>Element</code> nodes contained within a
* <code>DocumentFragment</code>. In short, users and implementors of the
* DOM need to be aware that <code>Attr</code> nodes have some things in
* common with other objects inheriting the <code>Node</code> interface, but
* they also are quite distinct.
* <p> The attribute's effective value is determined as follows: if this
* attribute has been explicitly assigned any value, that value is the
* attribute's effective value; otherwise, if there is a declaration for
* this attribute, and that declaration includes a default value, then that
* default value is the attribute's effective value; otherwise, the
* attribute does not exist on this element in the structure model until it
* has been explicitly added. Note that the <code>nodeValue</code> attribute
* on the <code>Attr</code> instance can also be used to retrieve the string
* version of the attribute's value(s).
* <p>In XML, where the value of an attribute can contain entity references,
* the child nodes of the <code>Attr</code> node may be either
* <code>Text</code> or <code>EntityReference</code> nodes (when these are
* in use; see the description of <code>EntityReference</code> for
* discussion). Because the DOM Core is not aware of attribute types, it
* treats all attribute values as simple strings, even if the DTD or schema
* declares them as having tokenized types.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface Attr extends Node {
/**
* Returns the name of this attribute.
*/
public String getName();
/**
* If this attribute was explicitly given a value in the original
* document, this is <code>true</code>; otherwise, it is
* <code>false</code>. Note that the implementation is in charge of this
* attribute, not the user. If the user changes the value of the
* attribute (even if it ends up having the same value as the default
* value) then the <code>specified</code> flag is automatically flipped
* to <code>true</code>. To re-specify the attribute as the default
* value from the DTD, the user must delete the attribute. The
* implementation will then make a new attribute available with
* <code>specified</code> set to <code>false</code> and the default
* value (if one exists).
* <br>In summary: If the attribute has an assigned value in the document
* then <code>specified</code> is <code>true</code>, and the value is
* the assigned value. If the attribute has no assigned value in the
* document and has a default value in the DTD, then
* <code>specified</code> is <code>false</code>, and the value is the
* default value in the DTD. If the attribute has no assigned value in
* the document and has a value of #IMPLIED in the DTD, then the
* attribute does not appear in the structure model of the document. If
* the <code>ownerElement</code> attribute is <code>null</code> (i.e.
* because it was just created or was set to <code>null</code> by the
* various removal and cloning operations) <code>specified</code> is
* <code>true</code>.
*/
public boolean getSpecified();
/**
* On retrieval, the value of the attribute is returned as a string.
* Character and general entity references are replaced with their
* values. See also the method <code>getAttribute</code> on the
* <code>Element</code> interface.
* <br>On setting, this creates a <code>Text</code> node with the unparsed
* contents of the string. I.e. any characters that an XML processor
* would recognize as markup are instead treated as literal text. See
* also the method <code>setAttribute</code> on the <code>Element</code>
* interface.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
*/
public String getValue();
public void setValue(String value)
throws DOMException;
/**
* The <code>Element</code> node this attribute is attached to or
* <code>null</code> if this attribute is not in use.
* @since DOM Level 2
*/
public Element getOwnerElement();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* CDATA sections are used to escape blocks of text containing characters that
* would otherwise be regarded as markup. The only delimiter that is
* recognized in a CDATA section is the "]]&gt;" string that ends the CDATA
* section. CDATA sections cannot be nested. Their primary purpose is for
* including material such as XML fragments, without needing to escape all
* the delimiters.
* <p>The <code>DOMString</code> attribute of the <code>Text</code> node holds
* the text that is contained by the CDATA section. Note that this may
* contain characters that need to be escaped outside of CDATA sections and
* that, depending on the character encoding ("charset") chosen for
* serialization, it may be impossible to write out some characters as part
* of a CDATA section.
* <p> The <code>CDATASection</code> interface inherits from the
* <code>CharacterData</code> interface through the <code>Text</code>
* interface. Adjacent <code>CDATASection</code> nodes are not merged by use
* of the <code>normalize</code> method of the <code>Node</code> interface.
* Because no markup is recognized within a <code>CDATASection</code>,
* character numeric references cannot be used as an escape mechanism when
* serializing. Therefore, action needs to be taken when serializing a
* <code>CDATASection</code> with a character encoding where some of the
* contained characters cannot be represented. Failure to do so would not
* produce well-formed XML.One potential solution in the serialization
* process is to end the CDATA section before the character, output the
* character using a character reference or entity reference, and open a new
* CDATA section for any further characters in the text node. Note, however,
* that some code conversion libraries at the time of writing do not return
* an error or exception when a character is missing from the encoding,
* making the task of ensuring that data is not corrupted on serialization
* more difficult.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface CDATASection extends Text {
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>CharacterData</code> interface extends Node with a set of
* attributes and methods for accessing character data in the DOM. For
* clarity this set is defined here rather than on each object that uses
* these attributes and methods. No DOM objects correspond directly to
* <code>CharacterData</code>, though <code>Text</code> and others do
* inherit the interface from it. All <code>offsets</code> in this interface
* start from <code>0</code>.
* <p>As explained in the <code>DOMString</code> interface, text strings in
* the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In
* the following, the term 16-bit units is used whenever necessary to
* indicate that indexing on CharacterData is done in 16-bit units.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface CharacterData extends Node {
/**
* The character data of the node that implements this interface. The DOM
* implementation may not put arbitrary limits on the amount of data
* that may be stored in a <code>CharacterData</code> node. However,
* implementation limits may mean that the entirety of a node's data may
* not fit into a single <code>DOMString</code>. In such cases, the user
* may call <code>substringData</code> to retrieve the data in
* appropriately sized pieces.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
*/
public String getData()
throws DOMException;
public void setData(String data)
throws DOMException;
/**
* The number of 16-bit units that are available through <code>data</code>
* and the <code>substringData</code> method below. This may have the
* value zero, i.e., <code>CharacterData</code> nodes may be empty.
*/
public int getLength();
/**
* Extracts a range of data from the node.
* @param offsetStart offset of substring to extract.
* @param countThe number of 16-bit units to extract.
* @return The specified substring. If the sum of <code>offset</code> and
* <code>count</code> exceeds the <code>length</code>, then all 16-bit
* units to the end of the data are returned.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
* negative or greater than the number of 16-bit units in
* <code>data</code>, or if the specified <code>count</code> is
* negative.
* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
* not fit into a <code>DOMString</code>.
*/
public String substringData(int offset,
int count)
throws DOMException;
/**
* Append the string to the end of the character data of the node. Upon
* success, <code>data</code> provides access to the concatenation of
* <code>data</code> and the <code>DOMString</code> specified.
* @param argThe <code>DOMString</code> to append.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public void appendData(String arg)
throws DOMException;
/**
* Insert a string at the specified 16-bit unit offset.
* @param offsetThe character offset at which to insert.
* @param argThe <code>DOMString</code> to insert.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
* negative or greater than the number of 16-bit units in
* <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public void insertData(int offset,
String arg)
throws DOMException;
/**
* Remove a range of 16-bit units from the node. Upon success,
* <code>data</code> and <code>length</code> reflect the change.
* @param offsetThe offset from which to start removing.
* @param countThe number of 16-bit units to delete. If the sum of
* <code>offset</code> and <code>count</code> exceeds
* <code>length</code> then all 16-bit units from <code>offset</code>
* to the end of the data are deleted.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
* negative or greater than the number of 16-bit units in
* <code>data</code>, or if the specified <code>count</code> is
* negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public void deleteData(int offset,
int count)
throws DOMException;
/**
* Replace the characters starting at the specified 16-bit unit offset
* with the specified string.
* @param offsetThe offset from which to start replacing.
* @param countThe number of 16-bit units to replace. If the sum of
* <code>offset</code> and <code>count</code> exceeds
* <code>length</code>, then all 16-bit units to the end of the data
* are replaced; (i.e., the effect is the same as a <code>remove</code>
* method call with the same range, followed by an <code>append</code>
* method invocation).
* @param argThe <code>DOMString</code> with which the range must be
* replaced.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
* negative or greater than the number of 16-bit units in
* <code>data</code>, or if the specified <code>count</code> is
* negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public void replaceData(int offset,
int count,
String arg)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* This interface inherits from <code>CharacterData</code> and represents the
* content of a comment, i.e., all the characters between the starting '
* <code>&lt;!--</code>' and ending '<code>--&gt;</code>'. Note that this is
* the definition of a comment in XML, and, in practice, HTML, although some
* HTML tools may implement the full SGML comment structure.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface Comment extends CharacterData {
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* DOM operations only raise exceptions in "exceptional" circumstances, i.e.,
* when an operation is impossible to perform (either for logical reasons,
* because data is lost, or because the implementation has become unstable).
* In general, DOM methods return specific error values in ordinary
* processing situations, such as out-of-bound errors when using
* <code>NodeList</code>.
* <p>Implementations should raise other exceptions under other circumstances.
* For example, implementations should raise an implementation-dependent
* exception if a <code>null</code> argument is passed.
* <p>Some languages and object systems do not support the concept of
* exceptions. For such systems, error conditions may be indicated using
* native error reporting mechanisms. For some bindings, for example,
* methods may return error codes similar to those listed in the
* corresponding method descriptions.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public class DOMException extends RuntimeException {
public DOMException(short code, String message) {
super(message);
this.code = code;
}
/** @serial */
public short code;
// ExceptionCode
/**
* If index or size is negative, or greater than the allowed value
*/
public static final short INDEX_SIZE_ERR = 1;
/**
* If the specified range of text does not fit into a DOMString
*/
public static final short DOMSTRING_SIZE_ERR = 2;
/**
* If any node is inserted somewhere it doesn't belong
*/
public static final short HIERARCHY_REQUEST_ERR = 3;
/**
* If a node is used in a different document than the one that created it
* (that doesn't support it)
*/
public static final short WRONG_DOCUMENT_ERR = 4;
/**
* If an invalid or illegal character is specified, such as in a name. See
* production 2 in the XML specification for the definition of a legal
* character, and production 5 for the definition of a legal name
* character.
*/
public static final short INVALID_CHARACTER_ERR = 5;
/**
* If data is specified for a node which does not support data
*/
public static final short NO_DATA_ALLOWED_ERR = 6;
/**
* If an attempt is made to modify an object where modifications are not
* allowed
*/
public static final short NO_MODIFICATION_ALLOWED_ERR = 7;
/**
* If an attempt is made to reference a node in a context where it does
* not exist
*/
public static final short NOT_FOUND_ERR = 8;
/**
* If the implementation does not support the requested type of object or
* operation.
*/
public static final short NOT_SUPPORTED_ERR = 9;
/**
* If an attempt is made to add an attribute that is already in use
* elsewhere
*/
public static final short INUSE_ATTRIBUTE_ERR = 10;
/**
* If an attempt is made to use an object that is not, or is no longer,
* usable.
* @since DOM Level 2
*/
public static final short INVALID_STATE_ERR = 11;
/**
* If an invalid or illegal string is specified.
* @since DOM Level 2
*/
public static final short SYNTAX_ERR = 12;
/**
* If an attempt is made to modify the type of the underlying object.
* @since DOM Level 2
*/
public static final short INVALID_MODIFICATION_ERR = 13;
/**
* If an attempt is made to create or change an object in a way which is
* incorrect with regard to namespaces.
* @since DOM Level 2
*/
public static final short NAMESPACE_ERR = 14;
/**
* If a parameter or an operation is not supported by the underlying
* object.
* @since DOM Level 2
*/
public static final short INVALID_ACCESS_ERR = 15;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>DOMImplementation</code> interface provides a number of methods
* for performing operations that are independent of any particular instance
* of the document object model.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface DOMImplementation {
/**
* Test if the DOM implementation implements a specific feature.
* @param featureThe name of the feature to test (case-insensitive). The
* values used by DOM features are defined throughout the DOM Level 2
* specifications and listed in the section. The name must be an XML
* name. To avoid possible conflicts, as a convention, names referring
* to features defined outside the DOM specification should be made
* unique by reversing the name of the Internet domain name of the
* person (or the organization that the person belongs to) who defines
* the feature, component by component, and using this as a prefix.
* For instance, the W3C SVG Working Group defines the feature
* "org.w3c.dom.svg".
* @param versionThis is the version number of the feature to test. In
* Level 2, the string can be either "2.0" or "1.0". If the version is
* not specified, supporting any version of the feature causes the
* method to return <code>true</code>.
* @return <code>true</code> if the feature is implemented in the
* specified version, <code>false</code> otherwise.
*/
public boolean hasFeature(String feature,
String version);
/**
* Creates an empty <code>DocumentType</code> node. Entity declarations
* and notations are not made available. Entity reference expansions and
* default attribute additions do not occur. It is expected that a
* future version of the DOM will provide a way for populating a
* <code>DocumentType</code>.
* <br>HTML-only DOM implementations do not need to implement this method.
* @param qualifiedNameThe qualified name of the document type to be
* created.
* @param publicIdThe external subset public identifier.
* @param systemIdThe external subset system identifier.
* @return A new <code>DocumentType</code> node with
* <code>Node.ownerDocument</code> set to <code>null</code>.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified qualified name
* contains an illegal character.
* <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
* malformed.
* @since DOM Level 2
*/
public DocumentType createDocumentType(String qualifiedName,
String publicId,
String systemId)
throws DOMException;
/**
* Creates an XML <code>Document</code> object of the specified type with
* its document element. HTML-only DOM implementations do not need to
* implement this method.
* @param namespaceURIThe namespace URI of the document element to create.
* @param qualifiedNameThe qualified name of the document element to be
* created.
* @param doctypeThe type of document to be created or <code>null</code>.
* When <code>doctype</code> is not <code>null</code>, its
* <code>Node.ownerDocument</code> attribute is set to the document
* being created.
* @return A new <code>Document</code> object.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified qualified name
* contains an illegal character.
* <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
* malformed, if the <code>qualifiedName</code> has a prefix and the
* <code>namespaceURI</code> is <code>null</code>, or if the
* <code>qualifiedName</code> has a prefix that is "xml" and the
* <code>namespaceURI</code> is different from "
* http://www.w3.org/XML/1998/namespace" .
* <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
* been used with a different document or was created from a different
* implementation.
* @since DOM Level 2
*/
public Document createDocument(String namespaceURI,
String qualifiedName,
DocumentType doctype)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* <code>DocumentFragment</code> is a "lightweight" or "minimal"
* <code>Document</code> object. It is very common to want to be able to
* extract a portion of a document's tree or to create a new fragment of a
* document. Imagine implementing a user command like cut or rearranging a
* document by moving fragments around. It is desirable to have an object
* which can hold such fragments and it is quite natural to use a Node for
* this purpose. While it is true that a <code>Document</code> object could
* fulfill this role, a <code>Document</code> object can potentially be a
* heavyweight object, depending on the underlying implementation. What is
* really needed for this is a very lightweight object.
* <code>DocumentFragment</code> is such an object.
* <p>Furthermore, various operations -- such as inserting nodes as children
* of another <code>Node</code> -- may take <code>DocumentFragment</code>
* objects as arguments; this results in all the child nodes of the
* <code>DocumentFragment</code> being moved to the child list of this node.
* <p>The children of a <code>DocumentFragment</code> node are zero or more
* nodes representing the tops of any sub-trees defining the structure of
* the document. <code>DocumentFragment</code> nodes do not need to be
* well-formed XML documents (although they do need to follow the rules
* imposed upon well-formed XML parsed entities, which can have multiple top
* nodes). For example, a <code>DocumentFragment</code> might have only one
* child and that child node could be a <code>Text</code> node. Such a
* structure model represents neither an HTML document nor a well-formed XML
* document.
* <p>When a <code>DocumentFragment</code> is inserted into a
* <code>Document</code> (or indeed any other <code>Node</code> that may
* take children) the children of the <code>DocumentFragment</code> and not
* the <code>DocumentFragment</code> itself are inserted into the
* <code>Node</code>. This makes the <code>DocumentFragment</code> very
* useful when the user wishes to create nodes that are siblings; the
* <code>DocumentFragment</code> acts as the parent of these nodes so that
* the user can use the standard methods from the <code>Node</code>
* interface, such as <code>insertBefore</code> and <code>appendChild</code>.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface DocumentFragment extends Node {
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* Each <code>Document</code> has a <code>doctype</code> attribute whose value
* is either <code>null</code> or a <code>DocumentType</code> object. The
* <code>DocumentType</code> interface in the DOM Core provides an interface
* to the list of entities that are defined for the document, and little
* else because the effect of namespaces and the various XML schema efforts
* on DTD representation are not clearly understood as of this writing.
* <p>The DOM Level 2 doesn't support editing <code>DocumentType</code> nodes.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface DocumentType extends Node {
/**
* The name of DTD; i.e., the name immediately following the
* <code>DOCTYPE</code> keyword.
*/
public String getName();
/**
* A <code>NamedNodeMap</code> containing the general entities, both
* external and internal, declared in the DTD. Parameter entities are
* not contained. Duplicates are discarded. For example in:
* <pre>&lt;!DOCTYPE
* ex SYSTEM "ex.dtd" [ &lt;!ENTITY foo "foo"&gt; &lt;!ENTITY bar
* "bar"&gt; &lt;!ENTITY bar "bar2"&gt; &lt;!ENTITY % baz "baz"&gt;
* ]&gt; &lt;ex/&gt;</pre>
* the interface provides access to <code>foo</code>
* and the first declaration of <code>bar</code> but not the second
* declaration of <code>bar</code> or <code>baz</code>. Every node in
* this map also implements the <code>Entity</code> interface.
* <br>The DOM Level 2 does not support editing entities, therefore
* <code>entities</code> cannot be altered in any way.
*/
public NamedNodeMap getEntities();
/**
* A <code>NamedNodeMap</code> containing the notations declared in the
* DTD. Duplicates are discarded. Every node in this map also implements
* the <code>Notation</code> interface.
* <br>The DOM Level 2 does not support editing notations, therefore
* <code>notations</code> cannot be altered in any way.
*/
public NamedNodeMap getNotations();
/**
* The public identifier of the external subset.
* @since DOM Level 2
*/
public String getPublicId();
/**
* The system identifier of the external subset.
* @since DOM Level 2
*/
public String getSystemId();
/**
* The internal subset as a string.The actual content returned depends on
* how much information is available to the implementation. This may
* vary depending on various parameters, including the XML processor
* used to build the document.
* @since DOM Level 2
*/
public String getInternalSubset();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* This interface represents an entity, either parsed or unparsed, in an XML
* document. Note that this models the entity itself not the entity
* declaration. <code>Entity</code> declaration modeling has been left for a
* later Level of the DOM specification.
* <p>The <code>nodeName</code> attribute that is inherited from
* <code>Node</code> contains the name of the entity.
* <p>An XML processor may choose to completely expand entities before the
* structure model is passed to the DOM; in this case there will be no
* <code>EntityReference</code> nodes in the document tree.
* <p>XML does not mandate that a non-validating XML processor read and
* process entity declarations made in the external subset or declared in
* external parameter entities. This means that parsed entities declared in
* the external subset need not be expanded by some classes of applications,
* and that the replacement value of the entity may not be available. When
* the replacement value is available, the corresponding <code>Entity</code>
* node's child list represents the structure of that replacement text.
* Otherwise, the child list is empty.
* <p>The DOM Level 2 does not support editing <code>Entity</code> nodes; if a
* user wants to make changes to the contents of an <code>Entity</code>,
* every related <code>EntityReference</code> node has to be replaced in the
* structure model by a clone of the <code>Entity</code>'s contents, and
* then the desired changes must be made to each of those clones instead.
* <code>Entity</code> nodes and all their descendants are readonly.
* <p>An <code>Entity</code> node does not have any parent.If the entity
* contains an unbound namespace prefix, the <code>namespaceURI</code> of
* the corresponding node in the <code>Entity</code> node subtree is
* <code>null</code>. The same is true for <code>EntityReference</code>
* nodes that refer to this entity, when they are created using the
* <code>createEntityReference</code> method of the <code>Document</code>
* interface. The DOM Level 2 does not support any mechanism to resolve
* namespace prefixes.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface Entity extends Node {
/**
* The public identifier associated with the entity, if specified. If the
* public identifier was not specified, this is <code>null</code>.
*/
public String getPublicId();
/**
* The system identifier associated with the entity, if specified. If the
* system identifier was not specified, this is <code>null</code>.
*/
public String getSystemId();
/**
* For unparsed entities, the name of the notation for the entity. For
* parsed entities, this is <code>null</code>.
*/
public String getNotationName();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* <code>EntityReference</code> objects may be inserted into the structure
* model when an entity reference is in the source document, or when the
* user wishes to insert an entity reference. Note that character references
* and references to predefined entities are considered to be expanded by
* the HTML or XML processor so that characters are represented by their
* Unicode equivalent rather than by an entity reference. Moreover, the XML
* processor may completely expand references to entities while building the
* structure model, instead of providing <code>EntityReference</code>
* objects. If it does provide such objects, then for a given
* <code>EntityReference</code> node, it may be that there is no
* <code>Entity</code> node representing the referenced entity. If such an
* <code>Entity</code> exists, then the subtree of the
* <code>EntityReference</code> node is in general a copy of the
* <code>Entity</code> node subtree. However, this may not be true when an
* entity contains an unbound namespace prefix. In such a case, because the
* namespace prefix resolution depends on where the entity reference is, the
* descendants of the <code>EntityReference</code> node may be bound to
* different namespace URIs.
* <p>As for <code>Entity</code> nodes, <code>EntityReference</code> nodes and
* all their descendants are readonly.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface EntityReference extends Node {
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* Objects implementing the <code>NamedNodeMap</code> interface are used to
* represent collections of nodes that can be accessed by name. Note that
* <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>;
* <code>NamedNodeMaps</code> are not maintained in any particular order.
* Objects contained in an object implementing <code>NamedNodeMap</code> may
* also be accessed by an ordinal index, but this is simply to allow
* convenient enumeration of the contents of a <code>NamedNodeMap</code>,
* and does not imply that the DOM specifies an order to these Nodes.
* <p><code>NamedNodeMap</code> objects in the DOM are live.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface NamedNodeMap {
/**
* Retrieves a node specified by name.
* @param nameThe <code>nodeName</code> of a node to retrieve.
* @return A <code>Node</code> (of any type) with the specified
* <code>nodeName</code>, or <code>null</code> if it does not identify
* any node in this map.
*/
public Node getNamedItem(String name);
/**
* Adds a node using its <code>nodeName</code> attribute. If a node with
* that name is already present in this map, it is replaced by the new
* one.
* <br>As the <code>nodeName</code> attribute is used to derive the name
* which the node must be stored under, multiple nodes of certain types
* (those that have a "special" string value) cannot be stored as the
* names would clash. This is seen as preferable to allowing nodes to be
* aliased.
* @param argA node to store in this map. The node will later be
* accessible using the value of its <code>nodeName</code> attribute.
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned, otherwise <code>null</code>
* is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
*/
public Node setNamedItem(Node arg)
throws DOMException;
/**
* Removes a node specified by name. When this map contains the attributes
* attached to an element, if the removed attribute is known to have a
* default value, an attribute immediately appears containing the
* default value as well as the corresponding namespace URI, local name,
* and prefix when applicable.
* @param nameThe <code>nodeName</code> of the node to remove.
* @return The node removed from this map if a node with such a name
* exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
* this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
*/
public Node removeNamedItem(String name)
throws DOMException;
/**
* Returns the <code>index</code>th item in the map. If <code>index</code>
* is greater than or equal to the number of nodes in this map, this
* returns <code>null</code>.
* @param indexIndex into this map.
* @return The node at the <code>index</code>th position in the map, or
* <code>null</code> if that is not a valid index.
*/
public Node item(int index);
/**
* The number of nodes in this map. The range of valid child node indices
* is <code>0</code> to <code>length-1</code> inclusive.
*/
public int getLength();
/**
* Retrieves a node specified by local name and namespace URI. HTML-only
* DOM implementations do not need to implement this method.
* @param namespaceURIThe namespace URI of the node to retrieve.
* @param localNameThe local name of the node to retrieve.
* @return A <code>Node</code> (of any type) with the specified local
* name and namespace URI, or <code>null</code> if they do not
* identify any node in this map.
* @since DOM Level 2
*/
public Node getNamedItemNS(String namespaceURI,
String localName);
/**
* Adds a node using its <code>namespaceURI</code> and
* <code>localName</code>. If a node with that namespace URI and that
* local name is already present in this map, it is replaced by the new
* one.
* <br>HTML-only DOM implementations do not need to implement this method.
* @param argA node to store in this map. The node will later be
* accessible using the value of its <code>namespaceURI</code> and
* <code>localName</code> attributes.
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned, otherwise <code>null</code>
* is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
* @since DOM Level 2
*/
public Node setNamedItemNS(Node arg)
throws DOMException;
/**
* Removes a node specified by local name and namespace URI. A removed
* attribute may be known to have a default value when this map contains
* the attributes attached to an element, as returned by the attributes
* attribute of the <code>Node</code> interface. If so, an attribute
* immediately appears containing the default value as well as the
* corresponding namespace URI, local name, and prefix when applicable.
* <br>HTML-only DOM implementations do not need to implement this method.
* @param namespaceURIThe namespace URI of the node to remove.
* @param localNameThe local name of the node to remove.
* @return The node removed from this map if a node with such a local
* name and namespace URI exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node with the specified
* <code>namespaceURI</code> and <code>localName</code> in this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* @since DOM Level 2
*/
public Node removeNamedItemNS(String namespaceURI,
String localName)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>NodeList</code> interface provides the abstraction of an ordered
* collection of nodes, without defining or constraining how this collection
* is implemented. <code>NodeList</code> objects in the DOM are live.
* <p>The items in the <code>NodeList</code> are accessible via an integral
* index, starting from 0.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface NodeList {
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
* @param indexIndex into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public Node item(int index);
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive.
*/
public int getLength();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* This interface represents a notation declared in the DTD. A notation either
* declares, by name, the format of an unparsed entity (see section 4.7 of
* the XML 1.0 specification ), or is used for formal declaration of
* processing instruction targets (see section 2.6 of the XML 1.0
* specification ). The <code>nodeName</code> attribute inherited from
* <code>Node</code> is set to the declared name of the notation.
* <p>The DOM Level 1 does not support editing <code>Notation</code> nodes;
* they are therefore readonly.
* <p>A <code>Notation</code> node does not have any parent.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface Notation extends Node {
/**
* The public identifier of this notation. If the public identifier was
* not specified, this is <code>null</code>.
*/
public String getPublicId();
/**
* The system identifier of this notation. If the system identifier was
* not specified, this is <code>null</code>.
*/
public String getSystemId();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>ProcessingInstruction</code> interface represents a "processing
* instruction", used in XML as a way to keep processor-specific information
* in the text of the document.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface ProcessingInstruction extends Node {
/**
* The target of this processing instruction. XML defines this as being
* the first token following the markup that begins the processing
* instruction.
*/
public String getTarget();
/**
* The content of this processing instruction. This is from the first non
* white space character after the target to the character immediately
* preceding the <code>?&gt;</code>.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
*/
public String getData();
public void setData(String data)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom;
/**
* The <code>Text</code> interface inherits from <code>CharacterData</code>
* and represents the textual content (termed character data in XML) of an
* <code>Element</code> or <code>Attr</code>. If there is no markup inside
* an element's content, the text is contained in a single object
* implementing the <code>Text</code> interface that is the only child of
* the element. If there is markup, it is parsed into the information items
* (elements, comments, etc.) and <code>Text</code> nodes that form the list
* of children of the element.
* <p>When a document is first made available via the DOM, there is only one
* <code>Text</code> node for each block of text. Users may create adjacent
* <code>Text</code> nodes that represent the contents of a given element
* without any intervening markup, but should be aware that there is no way
* to represent the separations between these nodes in XML or HTML, so they
* will not (in general) persist between DOM editing sessions. The
* <code>normalize()</code> method on <code>Node</code> merges any such
* adjacent <code>Text</code> objects into a single node for each block of
* text.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
*/
public interface Text extends CharacterData {
/**
* Breaks this node into two nodes at the specified <code>offset</code>,
* keeping both in the tree as siblings. After being split, this node
* will contain all the content up to the <code>offset</code> point. A
* new node of the same type, which contains all the content at and
* after the <code>offset</code> point, is returned. If the original
* node had a parent node, the new node is inserted as the next sibling
* of the original node. When the <code>offset</code> is equal to the
* length of this node, the new node has no data.
* @param offsetThe 16-bit unit offset at which to split, starting from
* <code>0</code>.
* @return The new node, of the same type as this node.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of 16-bit units in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
public Text splitText(int offset)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.ranges;
/**
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface DocumentRange {
/**
* This interface can be obtained from the object implementing the
* <code>Document</code> interface using binding-specific casting
* methods.
* @return The initial state of the Range returned from this method is
* such that both of its boundary-points are positioned at the
* beginning of the corresponding Document, before any content. The
* Range returned can only be used to select content associated with
* this Document, or with DocumentFragments and Attrs for which this
* Document is the <code>ownerDocument</code>.
*/
public Range createRange();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.ranges;
/**
* Range operations may throw a <code>RangeException</code> as specified in
* their method descriptions.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public class RangeException extends RuntimeException {
public RangeException(short code, String message) {
super(message);
this.code = code;
}
public short code;
// RangeExceptionCode
/**
* If the boundary-points of a Range do not meet specific requirements.
*/
public static final short BAD_BOUNDARYPOINTS_ERR = 1;
/**
* If the container of an boundary-point of a Range is being set to either
* a node of an invalid type or a node with an ancestor of an invalid
* type.
*/
public static final short INVALID_NODE_TYPE_ERR = 2;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.traversal;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
/**
* <code>DocumentTraversal</code> contains methods that create iterators and
* tree-walkers to traverse a node and its children in document order (depth
* first, pre-order traversal, which is equivalent to the order in which the
* start tags occur in the text representation of the document). In DOMs
* which support the Traversal feature, <code>DocumentTraversal</code> will
* be implemented by the same objects that implement the Document interface.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface DocumentTraversal {
/**
* Create a new <code>NodeIterator</code> over the subtree rooted at the
* specified node.
* @param rootThe node which will be iterated together with its children.
* The iterator is initially positioned just before this node. The
* <code>whatToShow</code> flags and the filter, if any, are not
* considered when setting this position. The root must not be
* <code>null</code>.
* @param whatToShowThis flag specifies which node types may appear in
* the logical view of the tree presented by the iterator. See the
* description of <code>NodeFilter</code> for the set of possible
* <code>SHOW_</code> values.These flags can be combined using
* <code>OR</code>.
* @param filterThe <code>NodeFilter</code> to be used with this
* <code>TreeWalker</code>, or <code>null</code> to indicate no filter.
* @param entityReferenceExpansionThe value of this flag determines
* whether entity reference nodes are expanded.
* @return The newly created <code>NodeIterator</code>.
* @exception DOMException
* NOT_SUPPORTED_ERR: Raised if the specified <code>root</code> is
* <code>null</code>.
*/
public NodeIterator createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
throws DOMException;
/**
* Create a new <code>TreeWalker</code> over the subtree rooted at the
* specified node.
* @param rootThe node which will serve as the <code>root</code> for the
* <code>TreeWalker</code>. The <code>whatToShow</code> flags and the
* <code>NodeFilter</code> are not considered when setting this value;
* any node type will be accepted as the <code>root</code>. The
* <code>currentNode</code> of the <code>TreeWalker</code> is
* initialized to this node, whether or not it is visible. The
* <code>root</code> functions as a stopping point for traversal
* methods that look upward in the document structure, such as
* <code>parentNode</code> and nextNode. The <code>root</code> must
* not be <code>null</code>.
* @param whatToShowThis flag specifies which node types may appear in
* the logical view of the tree presented by the tree-walker. See the
* description of <code>NodeFilter</code> for the set of possible
* SHOW_ values.These flags can be combined using <code>OR</code>.
* @param filterThe <code>NodeFilter</code> to be used with this
* <code>TreeWalker</code>, or <code>null</code> to indicate no filter.
* @param entityReferenceExpansionIf this flag is false, the contents of
* <code>EntityReference</code> nodes are not presented in the logical
* view.
* @return The newly created <code>TreeWalker</code>.
* @exception DOMException
* NOT_SUPPORTED_ERR: Raised if the specified <code>root</code> is
* <code>null</code>.
*/
public TreeWalker createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
throws DOMException;
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.traversal;
import org.w3c.dom.Node;
/**
* Filters are objects that know how to "filter out" nodes. If a
* <code>NodeIterator</code> or <code>TreeWalker</code> is given a
* <code>NodeFilter</code>, it applies the filter before it returns the next
* node. If the filter says to accept the node, the traversal logic returns
* it; otherwise, traversal looks for the next node and pretends that the
* node that was rejected was not there.
* <p>The DOM does not provide any filters. <code>NodeFilter</code> is just an
* interface that users can implement to provide their own filters.
* <p><code>NodeFilters</code> do not need to know how to traverse from node
* to node, nor do they need to know anything about the data structure that
* is being traversed. This makes it very easy to write filters, since the
* only thing they have to know how to do is evaluate a single node. One
* filter may be used with a number of different kinds of traversals,
* encouraging code reuse.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface NodeFilter {
// Constants returned by acceptNode
/**
* Accept the node. Navigation methods defined for
* <code>NodeIterator</code> or <code>TreeWalker</code> will return this
* node.
*/
public static final short FILTER_ACCEPT = 1;
/**
* Reject the node. Navigation methods defined for
* <code>NodeIterator</code> or <code>TreeWalker</code> will not return
* this node. For <code>TreeWalker</code>, the children of this node
* will also be rejected. <code>NodeIterators</code> treat this as a
* synonym for <code>FILTER_SKIP</code>.
*/
public static final short FILTER_REJECT = 2;
/**
* Skip this single node. Navigation methods defined for
* <code>NodeIterator</code> or <code>TreeWalker</code> will not return
* this node. For both <code>NodeIterator</code> and
* <code>TreeWalker</code>, the children of this node will still be
* considered.
*/
public static final short FILTER_SKIP = 3;
// Constants for whatToShow
/**
* Show all <code>Nodes</code>.
*/
public static final int SHOW_ALL = 0xFFFFFFFF;
/**
* Show <code>Element</code> nodes.
*/
public static final int SHOW_ELEMENT = 0x00000001;
/**
* Show <code>Attr</code> nodes. This is meaningful only when creating an
* iterator or tree-walker with an attribute node as its
* <code>root</code>; in this case, it means that the attribute node
* will appear in the first position of the iteration or traversal.
* Since attributes are never children of other nodes, they do not
* appear when traversing over the document tree.
*/
public static final int SHOW_ATTRIBUTE = 0x00000002;
/**
* Show <code>Text</code> nodes.
*/
public static final int SHOW_TEXT = 0x00000004;
/**
* Show <code>CDATASection</code> nodes.
*/
public static final int SHOW_CDATA_SECTION = 0x00000008;
/**
* Show <code>EntityReference</code> nodes.
*/
public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
/**
* Show <code>Entity</code> nodes. This is meaningful only when creating
* an iterator or tree-walker with an<code> Entity</code> node as its
* <code>root</code>; in this case, it means that the <code>Entity</code>
* node will appear in the first position of the traversal. Since
* entities are not part of the document tree, they do not appear when
* traversing over the document tree.
*/
public static final int SHOW_ENTITY = 0x00000020;
/**
* Show <code>ProcessingInstruction</code> nodes.
*/
public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
/**
* Show <code>Comment</code> nodes.
*/
public static final int SHOW_COMMENT = 0x00000080;
/**
* Show <code>Document</code> nodes.
*/
public static final int SHOW_DOCUMENT = 0x00000100;
/**
* Show <code>DocumentType</code> nodes.
*/
public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
/**
* Show <code>DocumentFragment</code> nodes.
*/
public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
/**
* Show <code>Notation</code> nodes. This is meaningful only when creating
* an iterator or tree-walker with a <code>Notation</code> node as its
* <code>root</code>; in this case, it means that the
* <code>Notation</code> node will appear in the first position of the
* traversal. Since notations are not part of the document tree, they do
* not appear when traversing over the document tree.
*/
public static final int SHOW_NOTATION = 0x00000800;
/**
* Test whether a specified node is visible in the logical view of a
* <code>TreeWalker</code> or <code>NodeIterator</code>. This function
* will be called by the implementation of <code>TreeWalker</code> and
* <code>NodeIterator</code>; it is not normally called directly from
* user code. (Though you could do so if you wanted to use the same
* filter to guide your own application logic.)
* @param nThe node to check to see if it passes the filter or not.
* @return a constant to determine whether the node is accepted,
* rejected, or skipped, as defined above.
*/
public short acceptNode(Node n);
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.traversal;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
/**
* <code>Iterators</code> are used to step through a set of nodes, e.g. the
* set of nodes in a <code>NodeList</code>, the document subtree governed by
* a particular <code>Node</code>, the results of a query, or any other set
* of nodes. The set of nodes to be iterated is determined by the
* implementation of the <code>NodeIterator</code>. DOM Level 2 specifies a
* single <code>NodeIterator</code> implementation for document-order
* traversal of a document subtree. Instances of these iterators are created
* by calling <code>DocumentTraversal</code>
* <code>.createNodeIterator()</code>.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface NodeIterator {
/**
* The root node of the <code>NodeIterator</code>, as specified when it
* was created.
*/
public Node getRoot();
/**
* This attribute determines which node types are presented via the
* iterator. The available set of constants is defined in the
* <code>NodeFilter</code> interface. Nodes not accepted by
* <code>whatToShow</code> will be skipped, but their children may still
* be considered. Note that this skip takes precedence over the filter,
* if any.
*/
public int getWhatToShow();
/**
* The <code>NodeFilter</code> used to screen nodes.
*/
public NodeFilter getFilter();
/**
* The value of this flag determines whether the children of entity
* reference nodes are visible to the iterator. If false, they and
* their descendants will be rejected. Note that this rejection takes
* precedence over <code>whatToShow</code> and the filter. Also note
* that this is currently the only situation where
* <code>NodeIterators</code> may reject a complete subtree rather than
* skipping individual nodes.
* <br>
* <br> To produce a view of the document that has entity references
* expanded and does not expose the entity reference node itself, use
* the <code>whatToShow</code> flags to hide the entity reference node
* and set <code>expandEntityReferences</code> to true when creating the
* iterator. To produce a view of the document that has entity reference
* nodes but no entity expansion, use the <code>whatToShow</code> flags
* to show the entity reference node and set
* <code>expandEntityReferences</code> to false.
*/
public boolean getExpandEntityReferences();
/**
* Returns the next node in the set and advances the position of the
* iterator in the set. After a <code>NodeIterator</code> is created,
* the first call to <code>nextNode()</code> returns the first node in
* the set.
* @return The next <code>Node</code> in the set being iterated over, or
* <code>null</code> if there are no more members in that set.
* @exception DOMException
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
public Node nextNode()
throws DOMException;
/**
* Returns the previous node in the set and moves the position of the
* <code>NodeIterator</code> backwards in the set.
* @return The previous <code>Node</code> in the set being iterated over,
* or <code>null</code> if there are no more members in that set.
* @exception DOMException
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
public Node previousNode()
throws DOMException;
/**
* Detaches the <code>NodeIterator</code> from the set which it iterated
* over, releasing any computational resources and placing the iterator
* in the INVALID state. After <code>detach</code> has been invoked,
* calls to <code>nextNode</code> or <code>previousNode</code> will
* raise the exception INVALID_STATE_ERR.
*/
public void detach();
}
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.traversal;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
/**
* <code>TreeWalker</code> objects are used to navigate a document tree or
* subtree using the view of the document defined by their
* <code>whatToShow</code> flags and filter (if any). Any function which
* performs navigation using a <code>TreeWalker</code> will automatically
* support any view defined by a <code>TreeWalker</code>.
* <p>Omitting nodes from the logical view of a subtree can result in a
* structure that is substantially different from the same subtree in the
* complete, unfiltered document. Nodes that are siblings in the
* <code>TreeWalker</code> view may be children of different, widely
* separated nodes in the original view. For instance, consider a
* <code>NodeFilter</code> that skips all nodes except for Text nodes and
* the root node of a document. In the logical view that results, all text
* nodes will be siblings and appear as direct children of the root node, no
* matter how deeply nested the structure of the original document.
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface TreeWalker {
/**
* The <code>root</code> node of the <code>TreeWalker</code>, as specified
* when it was created.
*/
public Node getRoot();
/**
* This attribute determines which node types are presented via the
* <code>TreeWalker</code>. The available set of constants is defined in
* the <code>NodeFilter</code> interface. Nodes not accepted by
* <code>whatToShow</code> will be skipped, but their children may still
* be considered. Note that this skip takes precedence over the filter,
* if any.
*/
public int getWhatToShow();
/**
* The filter used to screen nodes.
*/
public NodeFilter getFilter();
/**
* The value of this flag determines whether the children of entity
* reference nodes are visible to the <code>TreeWalker</code>. If false,
* they and their descendants will be rejected. Note that this
* rejection takes precedence over <code>whatToShow</code> and the
* filter, if any.
* <br> To produce a view of the document that has entity references
* expanded and does not expose the entity reference node itself, use
* the <code>whatToShow</code> flags to hide the entity reference node
* and set <code>expandEntityReferences</code> to true when creating the
* <code>TreeWalker</code>. To produce a view of the document that has
* entity reference nodes but no entity expansion, use the
* <code>whatToShow</code> flags to show the entity reference node and
* set <code>expandEntityReferences</code> to false.
*/
public boolean getExpandEntityReferences();
/**
* The node at which the <code>TreeWalker</code> is currently positioned.
* <br>Alterations to the DOM tree may cause the current node to no longer
* be accepted by the <code>TreeWalker</code>'s associated filter.
* <code>currentNode</code> may also be explicitly set to any node,
* whether or not it is within the subtree specified by the
* <code>root</code> node or would be accepted by the filter and
* <code>whatToShow</code> flags. Further traversal occurs relative to
* <code>currentNode</code> even if it is not part of the current view,
* by applying the filters in the requested direction; if no traversal
* is possible, <code>currentNode</code> is not changed.
* @exception DOMException
* NOT_SUPPORTED_ERR: Raised if an attempt is made to set
* <code>currentNode</code> to <code>null</code>.
*/
public Node getCurrentNode();
public void setCurrentNode(Node currentNode)
throws DOMException;
/**
* Moves to and returns the closest visible ancestor node of the current
* node. If the search for <code>parentNode</code> attempts to step
* upward from the <code>TreeWalker</code>'s <code>root</code> node, or
* if it fails to find a visible ancestor node, this method retains the
* current position and returns <code>null</code>.
* @return The new parent node, or <code>null</code> if the current node
* has no parent in the <code>TreeWalker</code>'s logical view.
*/
public Node parentNode();
/**
* Moves the <code>TreeWalker</code> to the first visible child of the
* current node, and returns the new node. If the current node has no
* visible children, returns <code>null</code>, and retains the current
* node.
* @return The new node, or <code>null</code> if the current node has no
* visible children in the <code>TreeWalker</code>'s logical view.
*/
public Node firstChild();
/**
* Moves the <code>TreeWalker</code> to the last visible child of the
* current node, and returns the new node. If the current node has no
* visible children, returns <code>null</code>, and retains the current
* node.
* @return The new node, or <code>null</code> if the current node has no
* children in the <code>TreeWalker</code>'s logical view.
*/
public Node lastChild();
/**
* Moves the <code>TreeWalker</code> to the previous sibling of the
* current node, and returns the new node. If the current node has no
* visible previous sibling, returns <code>null</code>, and retains the
* current node.
* @return The new node, or <code>null</code> if the current node has no
* previous sibling. in the <code>TreeWalker</code>'s logical view.
*/
public Node previousSibling();
/**
* Moves the <code>TreeWalker</code> to the next sibling of the current
* node, and returns the new node. If the current node has no visible
* next sibling, returns <code>null</code>, and retains the current node.
* @return The new node, or <code>null</code> if the current node has no
* next sibling. in the <code>TreeWalker</code>'s logical view.
*/
public Node nextSibling();
/**
* Moves the <code>TreeWalker</code> to the previous visible node in
* document order relative to the current node, and returns the new
* node. If the current node has no previous node, or if the search for
* <code>previousNode</code> attempts to step upward from the
* <code>TreeWalker</code>'s <code>root</code> node, returns
* <code>null</code>, and retains the current node.
* @return The new node, or <code>null</code> if the current node has no
* previous node in the <code>TreeWalker</code>'s logical view.
*/
public Node previousNode();
/**
* Moves the <code>TreeWalker</code> to the next visible node in document
* order relative to the current node, and returns the new node. If the
* current node has no next node, or if the search for nextNode attempts
* to step upward from the <code>TreeWalker</code>'s <code>root</code>
* node, returns <code>null</code>, and retains the current node.
* @return The new node, or <code>null</code> if the current node has no
* next node in the <code>TreeWalker</code>'s logical view.
*/
public Node nextNode();
}
// SAX Attribute List Interface.
// No warranty; no copyright -- use this as you will.
// $Id: AttributeList.java,v 1.1 2000/10/02 02:43:16 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.DocumentHandler#startElement startElement
* @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
*/
public interface AttributeList {
////////////////////////////////////////////////////////////////////
// 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);
////////////////////////////////////////////////////////////////////
// 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
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
// $Id: Attributes.java,v 1.1 2000/10/02 02:43:16 sboag 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>
* </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).</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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.helpers.AttributeListImpl
*/
public interface Attributes
{
////////////////////////////////////////////////////////////////////
// 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);
////////////////////////////////////////////////////////////////////
// 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 localPart);
/**
* 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
// SAX DTD handler.
// No warranty; no copyright -- use this as you will.
// $Id: DTDHandler.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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.</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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.Parser#setDTDHandler
* @see org.xml.sax.HandlerBase
*/
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.</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.AttributeList
*/
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.</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 notation name The name of the associated notation.
* @see #notationDecl
* @see org.xml.sax.AttributeList
*/
public abstract void unparsedEntityDecl (String name,
String publicId,
String systemId,
String notationName)
throws SAXException;
}
// end of DTDHandler.java
// SAX document handler.
// No warranty; no copyright -- use this as you will.
// $Id: DocumentHandler.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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.
// No warranty; no copyright -- use this as you will.
// $Id: EntityResolver.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.Parser#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 (including the
* external DTD subset, external entities referenced within the
* DTD, and external entities referenced within the document
* element): the application may request that the parser resolve
* the entity itself, that it use an alternative URI, or that it
* use an entirely different input source.</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).</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.
// No warranty; no copyright -- use this as you will.
// $Id: ErrorHandler.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.Parser#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 input source.
// No warranty; no copyright -- use this as you will.
// $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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 will deliver this
* 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; if not, the parser will use
* a byte stream, if available; 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).</p>
*
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.Parser#parse
* @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 full resolved.</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 may use setSystemId to provide a base
* for resolving relative URIs, setPublicId to include a
* public identifier, and/or 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 may use setSystemId() to provide a base
* for resolving relative URIs, and 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 ID is a URL, it must be fully resolved.</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.
* @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.
*
* @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;
}
////////////////////////////////////////////////////////////////////
// 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.
// No warranty; no copyright -- use this as you will.
// $Id: Locator.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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 content handler 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 content handler method: the application
* will receive unpredictable results if it attempts to use the
* locator at any other time.</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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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.</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.
*
* <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error
* reporting; it is not intended to provide sufficient information
* to edit the character content of the original XML document.</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 in the document 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.
*
* <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error
* reporting; it is not intended to provide sufficient information
* to edit the character content of the original XML document.</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.</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.
// No warranty; no copyright -- use this as you will.
// $Id: Parser.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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.
// No warranty; no copyright -- use this as you will.
// $Id: SAXException.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.SAXParseException
*/
public class SAXException extends Exception {
/**
* Create a new SAXException.
*
* @param message The error or warning message.
* @see org.xml.sax.Parser#setLocale
*/
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.
* @see org.xml.sax.Parser#setLocale
*/
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.
* @see org.xml.sax.Parser#setLocale
*/
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();
}
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
/**
* @serial The embedded exception if tunnelling, or null.
*/
private Exception exception;
}
// end of SAXException.java
// SAXNotRecognizedException.java - unrecognized feature or value.
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
// $Id: SAXNotRecognizedException.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.SAXNotSupportedException
*/
public class SAXNotRecognizedException extends SAXException
{
/**
* 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.
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
// $Id: SAXNotSupportedException.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.SAXNotRecognizedException
*/
public class SAXNotSupportedException extends SAXException
{
/**
* 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.
// No warranty; no copyright -- use this as you will.
// $Id: SAXParseException.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </blockquote>
*
* <p>This exception will include information for locating the error
* in the original XML document. 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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.SAXException
* @see org.xml.sax.Locator
* @see org.xml.sax.ErrorHandler
*/
public class SAXParseException extends SAXException {
//////////////////////////////////////////////////////////////////////
// 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
* @see org.xml.sax.Parser#setLocale
*/
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
* @see org.xml.sax.Parser#setLocale
*/
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>If the system identifier is a URL, the parser 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.
* @see org.xml.sax.Parser#setLocale
*/
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>If the system identifier is a URL, the parser 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.
* @see org.xml.sax.Parser#setLocale
*/
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 be 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.
*
* @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;
}
//////////////////////////////////////////////////////////////////////
// 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.
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
// $Id: XMLFilter.java,v 1.1 2000/10/02 02:43:17 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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
// DeclHandler.java - Optional handler for DTD declaration events.
// Public Domain: no warranty.
// $Id: DeclHandler.java,v 1.1 2000/10/02 02:43:19 sboag 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>
* </blockquote>
*
* <p>This is an optional extension handler for SAX2 to provide
* information about DTD declarations in an XML document. XML
* readers are not required to support this handler.</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 propertyId "http://xml.org/sax/handlers/DeclHandler".
* If the reader does not support declaration events, it will throw a
* {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0beta
* @see org.xml.sax.XMLReader
*/
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 whitespace is removed,and will include the enclosing
* parentheses.</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", or "NOTATION", or a parenthesized token group with
* the separator "|" and all whitespace removed.</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 valueDefault A string representing the attribute default
* ("#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 valueDefault,
String value)
throws SAXException;
/**
* Report an internal 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 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.
// Public Domain: no warranty.
// $Id: LexicalHandler.java,v 1.1 2000/10/02 02:43:20 sboag 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>
* </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
* support this handler.</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 propertyId "http://xml.org/sax/handlers/LexicalHandler".
* If the reader does not support lexical events, it will throw a
* {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0beta
* @see org.xml.sax.XMLReader#setProperty
* @see org.xml.sax.SAXNotRecognizedException
* @see org.xml.sax.SAXNotSupportedException
*/
public interface LexicalHandler
{
/**
* Report the start of DTD declarations, if any.
*
* <p>Any declarations are assumed to be in the internal subset
* unless otherwise indicated by a {@link #startEntity startEntity}
* event.</p>
*
* <p>Note that the start/endDTD events will appear within
* the start/endDocument events from ContentHandler and
* before the first 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.
* @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.
*
* @exception SAXException The application may raise an exception.
* @see #startDTD
*/
public abstract void endDTD ()
throws SAXException;
/**
* Report the beginning of an entity in content.
*
* <p><strong>NOTE:</entity> entity references in attribute
* values -- and the start and end of the document entity --
* are never reported.</p>
*
* <p>The start and end of the external DTD subset are reported
* using the pseudo-name "[dtd]". All other events must be
* properly nested within start/end entity events.</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>
*
* @param name The name of the entity. If it is a parameter
* entity, the name will begin with '%'.
* @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.</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).</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
// SAX default implementation for AttributeList.
// No warranty; no copyright -- use this as you will.
// $Id: AttributeListImpl.java,v 1.1 2000/10/02 02:43:20 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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);
}
////////////////////////////////////////////////////////////////////
// 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();
}
////////////////////////////////////////////////////////////////////
// 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));
}
////////////////////////////////////////////////////////////////////
// Internal state.
////////////////////////////////////////////////////////////////////
Vector names = new Vector();
Vector types = new Vector();
Vector values = new Vector();
}
// end of AttributeListImpl.java
// SAX default implementation for Locator.
// No warranty; no copyright -- use this as you will.
// $Id: LocatorImpl.java,v 1.1 2000/10/02 02:43:20 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @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());
}
////////////////////////////////////////////////////////////////////
// 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;
}
////////////////////////////////////////////////////////////////////
// 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;
}
////////////////////////////////////////////////////////////////////
// Internal state.
////////////////////////////////////////////////////////////////////
private String publicId;
private String systemId;
private int lineNumber;
private int columnNumber;
}
// end of LocatorImpl.java
// SAX parser factory.
// No warranty; no copyright -- use this as you will.
// $Id: ParserFactory.java,v 1.1 2000/10/02 02:43:20 sboag 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>
* </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,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
* @see org.xml.sax.Parser
* @see java.lang.Class
*/
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)(Class.forName(className).newInstance());
}
}
// end of ParserFactory.java
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment