diff options
author | Andrew Haley <aph@redhat.com> | 2016-09-30 16:24:48 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2016-09-30 16:24:48 +0000 |
commit | 07b78716af6a9d7c9fd1e94d9baf94a52c873947 (patch) | |
tree | 3f22b3241c513ad168c8353805614ae1249410f4 /libjava/classpath/gnu/xml/dom | |
parent | eae993948bae8b788c53772bcb9217c063716f93 (diff) | |
download | gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.zip gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.gz gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.bz2 |
Makefile.def: Remove libjava.
2016-09-30 Andrew Haley <aph@redhat.com>
* Makefile.def: Remove libjava.
* Makefile.tpl: Likewise.
* Makefile.in: Regenerate.
* configure.ac: Likewise.
* configure: Likewise.
* gcc/java: Remove.
* libjava: Likewise.
From-SVN: r240662
Diffstat (limited to 'libjava/classpath/gnu/xml/dom')
103 files changed, 0 insertions, 21580 deletions
diff --git a/libjava/classpath/gnu/xml/dom/Consumer.java b/libjava/classpath/gnu/xml/dom/Consumer.java deleted file mode 100644 index 836c8d2..0000000 --- a/libjava/classpath/gnu/xml/dom/Consumer.java +++ /dev/null @@ -1,352 +0,0 @@ -/* Consumer.java -- - Copyright (C) 2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.xml.dom; - -import org.w3c.dom.DocumentType; -import org.w3c.dom.Node; -import org.w3c.dom.Text; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.ext.Attributes2; - -import gnu.xml.pipeline.DomConsumer; -import gnu.xml.pipeline.EventConsumer; - - -/** - * Event consumer which constructs DOM documents using the implementation - * in this package, using SAX2 events. This packages various backdoors - * into this DOM implementation, as needed to address DOM requirements - * that can't be met by strictly conforming implementations of DOM. - * - * <p> These requirements all relate to {@link DocumentType} nodes and - * features of that node type. These features are normally not used, - * because that interface only exposes a subset of the information found - * in DTDs. More, that subset does not include the most important typing - * information. For example, it excludes element content models and - * attribute typing. It does expose some entity management issues, - * although entity management doesn't relate to document typing. - * - * <p> Note that SAX2 does not expose the literal text of the DTD's - * internal subset, so it will not be present in DOM trees constructed - * using this API. (Though with a good SAX2 implementation, it could - * be partially recreated...) - * - * @author David Brownell - */ -public class Consumer extends DomConsumer -{ - /** - * Constructs an unconfigured event consumer, - * as a terminus in a SAX event pipeline. - */ - // used by PipelineFactory [terminus] - public Consumer () - throws SAXException - { - super (DomDocument.class); - setHandler (new Backdoor (this)); - } - - /** - * Constructs an unconfigured event consumer, - * as a stage in a SAX event pipeline. - */ - // used by PipelineFactory [filter] - public Consumer (EventConsumer next) - throws SAXException - { - super (DomDocument.class, next); - setHandler (new Backdoor (this)); - } - - /** - * Implements the backdoors needed by DOM. - * All methods in this class use implementation-specific APIs that are - * implied by the DOM specification (needed to implement testable - * behavior) but which are excluded from the DOM specification. - */ - public static class Backdoor extends DomConsumer.Handler - { - /** - * Constructor. - * @param consumer must have been initialized to use the - * {@link DomDocument} class (or a subclass) for - * constructing DOM trees - */ - protected Backdoor (DomConsumer consumer) - throws SAXException - { super (consumer); } - - // helper routine - private DomDoctype getDoctype () - throws SAXException - { - DomDocument doc = (DomDocument) getDocument (); - DocumentType dt = doc.getDoctype (); - - if (dt == null) - throw new SAXException ("doctype missing!"); - return (DomDoctype) dt; - } - - // SAX2 "lexical" event - public void startDTD (String name, String publicId, String systemId) - throws SAXException - { - DomDocument doc = (DomDocument) getDocument (); - - super.startDTD (name, publicId, systemId); - // DOM L2 doctype creation model is bizarre - DomDoctype dt = new DomDoctype (doc, name, publicId, systemId); - doc.appendChild (dt); - } - - // SAX2 "lexical" event - public void endDTD () - throws SAXException - { - super.endDTD (); - // DOM L2 has no way to make things readonly - getDoctype ().makeReadonly (); - } - - // SAX1 DTD event - public void notationDecl ( - String name, - String publicId, String systemId - ) throws SAXException - { - // DOM L2 can't create/save notation nodes - getDoctype ().declareNotation (name, publicId, systemId); - } - - // SAX1 DTD event - public void unparsedEntityDecl ( - String name, - String publicId, String systemId, - String notationName - ) throws SAXException - { - // DOM L2 can't create/save entity nodes - getDoctype ().declareEntity (name, publicId, systemId, - notationName); - } - - // SAX2 declaration event - public void internalEntityDecl (String name, String value) - throws SAXException - { - // DOM L2 can't create/save entity nodes - // NOTE: this doesn't save the value as a child of this - // node, though it could realistically do so. - getDoctype ().declareEntity (name, null, null, null); - } - - // SAX2 declaration event - public void externalEntityDecl ( - String name, - String publicId, - String systemId - ) throws SAXException - { - // DOM L2 can't create/save entity nodes - // NOTE: DOM allows for these to have children, if - // they don't have unbound namespace references. - getDoctype ().declareEntity (name, publicId, systemId, null); - } - - // SAX2 element - public void startElement ( - String uri, - String localName, - String qName, - Attributes atts - ) throws SAXException - { - Node top; - - super.startElement (uri, localName, qName, atts); - - // might there be more work? - top = getTop (); - if (!top.hasAttributes () || !(atts instanceof Attributes2)) - return; - - // remember any attributes that got defaulted - DomNamedNodeMap map = (DomNamedNodeMap) top.getAttributes (); - Attributes2 attrs = (Attributes2) atts; - int length = atts.getLength (); - - //map.compact (); - for (int i = 0; i < length; i++) { - if (attrs.isSpecified (i)) - continue; - - // value was defaulted. - String temp = attrs.getQName (i); - DomAttr attr; - - if ("".equals (temp)) - attr = (DomAttr) map.getNamedItemNS (attrs.getURI (i), - atts.getLocalName (i)); - else - attr = (DomAttr) map.getNamedItem (temp); - - // DOM L2 can't write this flag, only read it - attr.setSpecified (false); - } - } - - public void endElement ( - String uri, - String localName, - String qName - ) throws SAXException - { - DomNode top = (DomNode) getTop (); - top.compact (); - super.endElement (uri, localName, qName); - } - - protected Text createText ( - boolean isCDATA, - char buf [], - int off, - int len - ) { - DomDocument doc = (DomDocument) getDocument (); - - if (isCDATA) - return doc.createCDATASection (buf, off, len); - else - return doc.createTextNode (buf, off, len); - } - - public void elementDecl(String name, String model) - throws SAXException - { - getDoctype().elementDecl(name, model); - } - - public void attributeDecl ( - String ename, - String aname, - String type, - String mode, - String value - ) throws SAXException - { - getDoctype().attributeDecl(ename, aname, type, mode, value); - /* - if (value == null && !"ID".equals (type)) - return; - - DomDoctype.ElementInfo info; - - info = getDoctype ().getElementInfo (ename); - if (value != null) - info.setAttrDefault (aname, value); - if ("ID".equals (type)) - info.setIdAttr (aname); - */ - - } - - // force duplicate name checking off while we're - // using parser output (don't duplicate the work) - public void startDocument () throws SAXException - { - super.startDocument (); - - DomDocument doc = (DomDocument) getDocument (); - doc.setStrictErrorChecking(false); - doc.setBuilding(true); - } - - public void endDocument () - throws SAXException - { - DomDocument doc = (DomDocument) getDocument (); - doc.setStrictErrorChecking(true); - doc.setBuilding(false); - doc.compact (); - DomDoctype doctype = (DomDoctype) doc.getDoctype(); - if (doctype != null) - { - doctype.makeReadonly(); - } - super.endDocument (); - } - - // these three methods collaborate to populate entity - // refs, marking contents readonly on end-of-entity - - public boolean canPopulateEntityRefs () - { return true; } - - public void startEntity (String name) - throws SAXException - { - if (name.charAt (0) == '%' || "[dtd]".equals (name)) - return; - super.startEntity (name); - - DomNode top = (DomNode) getTop (); - - if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE) - top.readonly = false; - } - - public void endEntity (String name) - throws SAXException - { - if (name.charAt (0) == '%' || "[dtd]".equals (name)) - return; - DomNode top = (DomNode) getTop (); - - if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE) { - top.compact (); - top.makeReadonly (); - } - super.endEntity (name); - } - } -} diff --git a/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java b/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java deleted file mode 100644 index d6e2552..0000000 --- a/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/* DTDAttributeTypeInfo.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.TypeInfo; - -/** - * Attribute type information supplied by a DTD attribute declaration. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DTDAttributeTypeInfo - implements TypeInfo -{ - - final String elementName; - final String name; - final String type; - final String mode; - final String value; - - DTDAttributeTypeInfo(String elementName, String name, String type, - String mode, String value) - { - this.elementName = elementName; - this.name = name; - this.type = type; - this.mode = mode; - this.value = value; - } - - public final String getTypeName() - { - return type; - } - - public final String getTypeNamespace() - { - return "http://www.w3.org/TR/REC-xml"; - } - - public final boolean isDerivedFrom(String typeNamespace, String typeName, - int derivationMethod) - { - return false; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java b/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java deleted file mode 100644 index 9063d4c..0000000 --- a/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java +++ /dev/null @@ -1,111 +0,0 @@ -/* DTDElementTypeInfo.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.HashMap; -import java.util.Iterator; -import org.w3c.dom.TypeInfo; - -/** - * Element type information provided by a DTD element declaration. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DTDElementTypeInfo - implements TypeInfo -{ - - final String name; - String model; - HashMap attributes; - String idAttrName; - - DTDElementTypeInfo(String name, String model) - { - this.name = name; - this.model = model; - } - - public final String getTypeName() - { - return null; - } - - public final String getTypeNamespace() - { - return "http://www.w3.org/TR/REC-xml"; - } - - public final boolean isDerivedFrom(String typeNamespace, String typeName, - int derivationMethod) - { - return false; - } - - DTDAttributeTypeInfo getAttributeTypeInfo(String name) - { - if (attributes == null) - { - return null; - } - return (DTDAttributeTypeInfo) attributes.get(name); - } - - void setAttributeTypeInfo(String name, DTDAttributeTypeInfo info) - { - if (attributes == null) - { - attributes = new HashMap(); - } - attributes.put(name, info); - if ("ID".equals(info.type)) - { - idAttrName = name; - } - } - - Iterator attributes() - { - if (attributes == null) - { - return null; - } - return attributes.values().iterator(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomAttr.java b/libjava/classpath/gnu/xml/dom/DomAttr.java deleted file mode 100644 index 421baf7..0000000 --- a/libjava/classpath/gnu/xml/dom/DomAttr.java +++ /dev/null @@ -1,411 +0,0 @@ -/* DomAttr.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import gnu.java.lang.CPStringBuilder; - -import org.w3c.dom.Attr; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.TypeInfo; -import org.w3c.dom.events.MutationEvent; - - -/** - * <p> "Attr" implementation. In DOM, attributes cost quite a lot of - * memory because their values are complex structures rather than just - * simple strings. To reduce your costs, avoid having more than one - * child of an attribute; stick to a single Text node child, and ignore - * even that by using the attribute's "nodeValue" property.</p> - * - * <p> As a bit of general advice, only look at attribute modification - * events through the DOMAttrModified event (sent to the associated - * element). Implementations are not guaranteed to report other events - * in the same order, so you're very likely to write nonportable code if - * you monitor events at the "children of Attr" level.</p> - * - * <p> At this writing, not all attribute modifications will cause the - * DOMAttrModified event to be triggered ... only the ones using the string - * methods (setNodeValue, setValue, and Element.setAttribute) to modify - * those values. That is, if you manipulate those children directly, - * elements won't get notified that attribute values have changed. - * The natural fix for that will report other modifications, but won't - * be able to expose "previous" attribute value; it'll need to be cached - * or something (at which point why bother using child nodes). </p> - * - * <p><em>You are strongly advised not to use "children" of any attribute - * nodes you work with.</em> </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomAttr - extends DomNsNode - implements Attr -{ - - private boolean specified; - private String value; // string value cache - - /** - * Constructs an Attr node associated with the specified document. - * The "specified" flag is initialized to true, since this DOM has - * no current "back door" mechanisms to manage default values so - * that every value must effectively be "specified". - * - * <p>This constructor should only be invoked by a Document as part of - * its createAttribute functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * - * @param owner The document with which this node is associated - * @param namespaceURI Combined with the local part of the name, - * this is used to uniquely identify a type of attribute - * @param name Name of this attribute, which may include a prefix - */ - protected DomAttr(DomDocument owner, String namespaceURI, String name) - { - super(ATTRIBUTE_NODE, owner, namespaceURI, name); - specified = true; - length = 1; - - // XXX register self to get insertion/removal events - // and character data change events and when they happen, - // report self-mutation - } - - /** - * Constructs an Attr node associated with the specified document. - * The "specified" flag is initialized to true, since this DOM has - * no current "back door" mechanisms to manage default values so - * that every value must effectively be "specified". - * - * <p>This constructor should only be invoked by a Document as part of - * its createAttribute functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * <p> - * With this constructor, the prefix and local part are given explicitly - * rather than being computed. This allows them to be explicitly set to - * {@code null} as required by {@link Document#createAttribute(String)}. - * </p> - * - * @param owner The document with which this node is associated - * @param namespaceURI Combined with the local part of the name, - * this is used to uniquely identify a type of attribute - * @param name Name of this attribute, which may include a prefix - * @param prefix the namespace prefix of the name. May be {@code null}. - * @param localName the local part of the name. May be {@code null}. - */ - protected DomAttr(DomDocument owner, String namespaceURI, String name, - String prefix, String localName) - { - super(ATTRIBUTE_NODE, owner, namespaceURI, name, prefix, localName); - specified = true; - length = 1; - } - - /** - * <b>DOM L1</b> - * Returns the attribute name (same as getNodeName) - */ - public final String getName() - { - return getNodeName(); - } - - /** - * <b>DOM L1</b> - * Returns true if a parser reported this was in the source text. - */ - public final boolean getSpecified() - { - return specified; - } - - /** - * Records whether this attribute was in the source text. - */ - public final void setSpecified(boolean value) - { - specified = value; - } - - /** - * <b>DOM L1</b> - * Returns the attribute value, with character and entity - * references substituted. - * <em>NOTE: entity refs as children aren't currently handled.</em> - */ - public String getNodeValue() - { - // If we have a simple node-value, use that - if (first == null) - { - return (value == null) ? "" : value; - } - // Otherwise collect child node-values - CPStringBuilder buf = new CPStringBuilder(); - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - switch (ctx.nodeType) - { - case Node.TEXT_NODE: - buf.append(ctx.getNodeValue()); - break; - case Node.ENTITY_REFERENCE_NODE: - // TODO - break; - } - } - return buf.toString(); - } - - /** - * <b>DOM L1</b> - * Assigns the value of the attribute; it will have one child, - * which is a text node with the specified value (same as - * setNodeValue). - */ - public final void setValue(String value) - { - setNodeValue(value); - } - - /** - * <b>DOM L1</b> - * Returns the value of the attribute as a non-null string; same - * as getNodeValue. - * <em>NOTE: entity refs as children aren't currently handled.</em> - */ - public final String getValue() - { - return getNodeValue(); - } - - /** - * <b>DOM L1</b> - * Assigns the attribute value; using this API, no entity or - * character references will exist. - * Causes a DOMAttrModified mutation event to be sent. - */ - public void setNodeValue(String value) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - if (value == null) - { - value = ""; - } - String oldValue = getNodeValue(); - while (last != null) - { - removeChild(last); - } - // don't create a new node just for this... - /* - Node text = owner.createTextNode(value); - appendChild(text); - */ - this.value = value; - length = 1; - specified = true; - - mutating(oldValue, value, MutationEvent.MODIFICATION); - } - - public final Node getFirstChild() - { - // Create a child text node if necessary - if (first == null) - { - length = 0; - Node text = owner.createTextNode((value == null) ? "" : value); - appendChild(text); - } - return first; - } - - public final Node getLastChild() - { - // Create a child text node if necessary - if (last == null) - { - length = 0; - Node text = owner.createTextNode((value == null) ? "" : value); - appendChild(text); - } - return last; - } - - public Node item(int index) - { - // Create a child text node if necessary - if (first == null) - { - length = 0; - Node text = owner.createTextNode((value == null) ? "" : value); - appendChild(text); - } - return super.item(index); - } - - /** - * <b>DOM L2</b> - * Returns the element with which this attribute is associated. - */ - public final Element getOwnerElement() - { - return (Element) parent; - } - - public final Node getNextSibling() - { - return null; - } - - public final Node getPreviousSibling() - { - return null; - } - - public Node getParentNode() - { - return null; - } - - /** - * Records the element with which this attribute is associated. - */ - public final void setOwnerElement(Element e) - { - if (parent != null) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR); - } - if (!(e instanceof DomElement)) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR); - } - parent = (DomElement) e; - depth = parent.depth + 1; - } - - /** - * The base URI of an Attr is always <code>null</code>. - */ - public final String getBaseURI() - { - return null; - } - - /** - * Shallow clone of the attribute, breaking all ties with any - * elements. - */ - public Object clone() - { - DomAttr retval = (DomAttr) super.clone(); - retval.specified = true; - return retval; - } - - private void mutating(String oldValue, String newValue, short why) - { - if (!reportMutations || parent == null || equal(newValue, oldValue)) - { - return; - } - - // EVENT: DOMAttrModified, target = parent, - // prev/new values provided, also attr name - MutationEvent event; - - event = (MutationEvent) createEvent ("MutationEvents"); - event.initMutationEvent ("DOMAttrModified", - true /* bubbles */, false /* nocancel */, - null, oldValue, newValue, getNodeName (), why); - parent.dispatchEvent (event); - } - - // DOM Level 3 methods - - public TypeInfo getSchemaTypeInfo() - { - if (parent != null) - { - // DTD implementation - DomDoctype doctype = (DomDoctype) parent.owner.getDoctype(); - if (doctype != null) - { - return doctype.getAttributeTypeInfo(parent.getNodeName(), - getNodeName()); - } - // TODO XML Schema implementation - } - return null; - } - - public boolean isId() - { - if (parent != null) - { - DomDoctype doctype = (DomDoctype) parent.owner.getDoctype(); - if (doctype != null) - { - DTDAttributeTypeInfo info = - doctype.getAttributeTypeInfo(parent.getNodeName(), - getNodeName()); - if (info != null && "ID".equals(info.type)) - { - return true; - } - } - DomElement element = (DomElement) parent; - if (element.userIdAttrs != null && - element.userIdAttrs.contains(this)) - { - return true; - } - // TODO XML Schema implementation - } - return false; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomCDATASection.java b/libjava/classpath/gnu/xml/dom/DomCDATASection.java deleted file mode 100644 index 770f7d5..0000000 --- a/libjava/classpath/gnu/xml/dom/DomCDATASection.java +++ /dev/null @@ -1,90 +0,0 @@ -/* DomCDATASection.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.CDATASection; - -/** - * <p> "CDATASection" implementation. - * This is a non-core DOM class, supporting the "XML" feature. - * CDATA sections are just ways to represent text using different - * delimeters. </p> - * - * <p> <em>You are strongly advised not to use CDATASection nodes.</em> - * The advantage of having slightly prettier ways to print text that may - * have lots of embedded XML delimiters, such as "&" and "<", - * can be dwarfed by the cost of dealing with multiple kinds of text - * nodes in all your algorithms. </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomCDATASection - extends DomText - implements CDATASection -{ - - /** - * Constructs a CDATA section node associated with the specified - * document and holding the specified data. - * - * <p>This constructor should only be invoked by a Document as part of - * its createCDATASection functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * - */ - protected DomCDATASection(DomDocument owner, String value) - { - super(CDATA_SECTION_NODE, owner, value); - } - - protected DomCDATASection(DomDocument owner, char buf [], int off, int len) - { - super(CDATA_SECTION_NODE, owner, buf, off, len); - } - - /** - * <b>DOM L1</b> - * Returns the string "#cdata-section". - */ - final public String getNodeName() - { - return "#cdata-section"; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomCharacterData.java b/libjava/classpath/gnu/xml/dom/DomCharacterData.java deleted file mode 100644 index 396c5f7..0000000 --- a/libjava/classpath/gnu/xml/dom/DomCharacterData.java +++ /dev/null @@ -1,344 +0,0 @@ -/* DomCharacterData.java -- - Copyright (C) 1999,2000,2001,2004,2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.CharacterData; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.events.MutationEvent; - - -/** - * <p> Abstract "CharacterData" implementation. This - * facilitates reusing code in classes implementing subtypes of that DOM - * interface (Text, Comment, CDATASection). </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public abstract class DomCharacterData - extends DomNode - implements CharacterData -{ - - /** - * Empty node list representing the children of character data nodes. - */ - static class EmptyNodeList - implements NodeList - { - - public int getLength() - { - return 0; - } - - public Node item(int index) - { - return null; - } - - } - - /** - * Singleton empty node list for character data nodes. - */ - static final NodeList CHILD_NODES = new EmptyNodeList(); - - private String text; - - // package private - DomCharacterData(short nodeType, DomDocument doc, String value) - { - super(nodeType, doc); - text = (value == null) ? "" : value; - } - - // package private - DomCharacterData(short nodeType, DomDocument doc, - char[] buf, int offset, int length) - { - super(nodeType, doc); - text = (buf == null) ? "" : new String(buf, offset, length); - } - - /** - * <b>DOM L1</b> - * Appends the specified data to the value of this node. - * Causes a DOMCharacterDataModified mutation event to be reported. - */ - public void appendData(String arg) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - String value = text + arg; - mutating(value); - text = value; - } - - /** - * <b>DOM L1</b> - * Modifies the value of this node. - * Causes a DOMCharacterDataModified mutation event to be reported. - */ - public void deleteData(int offset, int count) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - char[] raw = text.toCharArray(); - if (offset < 0 || count < 0 || offset > raw.length) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - if ((offset + count) > raw.length) - { - count = raw.length - offset; - } - if (count == 0) - { - return; - } - try - { - char[] buf = new char[raw.length - count]; - System.arraycopy(raw, 0, buf, 0, offset); - System.arraycopy(raw, offset + count, buf, offset, - raw.length - (offset + count)); - String value = new String(buf); - mutating(value); - text = value; - } - catch (IndexOutOfBoundsException x) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - } - - /** - * <b>DOM L1</b> - * Returns the value of this node. - */ - public String getNodeValue() - { - return text; - } - - /** - * <b>DOM L1</b> - * Returns the value of this node; same as getNodeValue. - */ - public final String getData() - { - return text; - } - - /** - * <b>DOM L1</b> - * Returns the length of the data. - */ - public int getLength() - { - return text.length(); - } - - /** - * <b>DOM L1</b> - * Modifies the value of this node. - */ - public void insertData(int offset, String arg) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - char[] raw = text.toCharArray(); - char[] tmp = arg.toCharArray (); - char[] buf = new char[raw.length + tmp.length]; - - try - { - System.arraycopy(raw, 0, buf, 0, offset); - System.arraycopy(tmp, 0, buf, offset, tmp.length); - System.arraycopy(raw, offset, buf, offset + tmp.length, - raw.length - offset); - String value = new String(buf); - mutating(value); - text = value; - } - catch (IndexOutOfBoundsException x) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - } - - /** - * <b>DOM L1</b> - * Modifies the value of this node. Causes DOMCharacterDataModified - * mutation events to be reported (at least one). - */ - public void replaceData(int offset, int count, String arg) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - char[] raw = text.toCharArray(); - - // deleteData - if (offset < 0 || count < 0 || offset > raw.length) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - if ((offset + count) > raw.length) - { - count = raw.length - offset; - } - try - { - char[] buf = new char[raw.length - count]; - System.arraycopy(raw, 0, buf, 0, offset); - System.arraycopy(raw, offset + count, buf, offset, - raw.length - (offset + count)); - - // insertData - char[] tmp = arg.toCharArray (); - char[] buf2 = new char[buf.length + tmp.length]; - System.arraycopy(raw, 0, buf, 0, offset); - System.arraycopy(tmp, 0, buf, offset, tmp.length); - System.arraycopy(raw, offset, buf, offset + tmp.length, - raw.length - offset); - String value = new String(buf); - mutating(value); - text = value; - } - catch (IndexOutOfBoundsException x) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - } - - /** - * <b>DOM L1</b> - * Assigns the value of this node. - * Causes a DOMCharacterDataModified mutation event to be reported. - */ - public void setNodeValue(String value) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - if (value == null) - { - value = ""; - } - mutating(value); - text = value; - } - - /** - * <b>DOM L1</b> - * Assigns the value of this node; same as setNodeValue. - */ - final public void setData(String data) - { - setNodeValue(data); - } - - /** - * <b>DOM L1</b> - * Returns the specified substring. - */ - public String substringData(int offset, int count) - { - try - { - return text.substring(offset, count); - } - catch (StringIndexOutOfBoundsException e) - { - if (offset >= 0 && count >= 0 && offset < text.length()) - { - return text.substring(offset); - } - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - } - - /** - * Returns an empty node list. - * Character data nodes do not have children. - */ - public NodeList getChildNodes() - { - return CHILD_NODES; - } - - /** - * The base URI for character data is <code>null</code>. - * @since DOM Level 3 Core - */ - public final String getBaseURI() - { - return null; - } - - private void mutating(String newValue) - { - if (!reportMutations) - { - return; - } - - // EVENT: DOMCharacterDataModified, target = this, - // prev/new values provided - MutationEvent event; - - event = (MutationEvent) createEvent("MutationEvents"); - event.initMutationEvent("DOMCharacterDataModified", - true /* bubbles */, false /* nocancel */, - null, text, newValue, null, (short) 0); - dispatchEvent(event); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomComment.java b/libjava/classpath/gnu/xml/dom/DomComment.java deleted file mode 100644 index 5be6bd5..0000000 --- a/libjava/classpath/gnu/xml/dom/DomComment.java +++ /dev/null @@ -1,80 +0,0 @@ -/* DomComment.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.Comment; - -/** - * <p> "Comment" implementation. - * Comments hold data intended for direct consumption by people; - * programs should only use ProcessingInstruction nodes. Note that - * since SAX makes comment reporting optional, XML systems that - * rely on comments (such as by using this class) will often lose - * those comments at some point in the processing pipeline. </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomComment - extends DomCharacterData - implements Comment -{ - - /** - * Constructs a comment node associated with the specified - * document and holding the specified data. - * - * <p>This constructor should only be invoked by a Document as part of - * its createComment functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - */ - protected DomComment(DomDocument owner, String value) - { - super(COMMENT_NODE, owner, value); - } - - /** - * <b>DOM L1</b> - * Returns the string "#comment". - */ - final public String getNodeName() - { - return "#comment"; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDOMException.java b/libjava/classpath/gnu/xml/dom/DomDOMException.java deleted file mode 100644 index 4a3ba7a..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDOMException.java +++ /dev/null @@ -1,174 +0,0 @@ -/* DomDOMException.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; - -/** - * <p> DOMException implementation. The version that - * is provided by the W3C is abstract, so it can't be instantiated. - * - * <p> This also provides a bit more information about the error - * that is being reported, in terms of the relevant DOM structures - * and data. - * - * @author David Brownell - */ -public class DomDOMException - extends DOMException -{ - - /** @serial Data that caused an error to be reported */ - private String data; - - /** @serial Node associated with the error. */ - private Node node; - - /** @serial Data associated with the error. */ - private int value; - - /** - * Constructs an exception, with the diagnostic message - * corresponding to the specified code. - */ - public DomDOMException(short code) - { - super(code, diagnostic(code)); - } - - /** - * Constructs an exception, with the diagnostic message - * corresponding to the specified code and additional - * information as provided. - */ - public DomDOMException(short code, String data, Node node, int value) - { - super(code, diagnostic(code)); - this.data = data; - this.node = node; - this.value = value; - } - - /** Returns the node to which the diagnotic applies, or null. */ - final public Node getNode() - { - return node; - } - - /** Returns data to which the diagnotic applies, or null. */ - final public String getData() - { - return data; - } - - /** Returns data to which the diagnotic applies, or null. */ - final public int getValue() - { - return value; - } - - /** - * Returns a diagnostic message that may be slightly more useful - * than the generic one, where possible. - */ - public String getMessage() - { - String retval = super.getMessage(); - - if (data != null) - { - retval += "\nMore Information: " + data; - } - if (value != 0) - { - retval += "\nNumber: " + value; - } - if (node != null) - { - retval += "\nNode Name: " + node.getNodeName(); - } - return retval; - } - - // these strings should be localizable. - - private static String diagnostic(short code) - { - switch (code) - { - // DOM L1: - case INDEX_SIZE_ERR: - return "An index or size is out of range."; - case DOMSTRING_SIZE_ERR: - return "A string is too big."; - case HIERARCHY_REQUEST_ERR: - return "The node doesn't belong here."; - case WRONG_DOCUMENT_ERR: - return "The node belongs in another document."; - case INVALID_CHARACTER_ERR: - return "That character is not permitted."; - case NO_DATA_ALLOWED_ERR: - return "This node does not permit data."; - case NO_MODIFICATION_ALLOWED_ERR: - return "No changes are allowed."; - case NOT_FOUND_ERR: - return "The node was not found in that context."; - case NOT_SUPPORTED_ERR: - return "That object is not supported."; - case INUSE_ATTRIBUTE_ERR: - return "The attribute belongs to a different element."; - - // DOM L2: - case INVALID_STATE_ERR: - return "The object is not usable."; - case SYNTAX_ERR: - return "An illegal string was provided."; - case INVALID_MODIFICATION_ERR: - return "An object's type may not be changed."; - case NAMESPACE_ERR: - return "The operation violates XML Namespaces."; - case INVALID_ACCESS_ERR: - return "Parameter or operation isn't supported by this node."; - case TYPE_MISMATCH_ERR: - return "The type of the argument is incompatible with the expected type."; - } - return "Reserved exception number: " + code; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDoctype.java b/libjava/classpath/gnu/xml/dom/DomDoctype.java deleted file mode 100644 index ecf7a95..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDoctype.java +++ /dev/null @@ -1,455 +0,0 @@ -/* DomDoctype.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.HashMap; -import org.w3c.dom.DocumentType; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Entity; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.Notation; - -/** - * <p> "DocumentType" implementation (with no extensions for supporting - * any document typing information). This is a non-core DOM class, - * supporting the "XML" feature. </p> - * - * <p> <em>Few XML applications will actually care about this partial - * DTD support</em>, since it doesn't expose any (!) of the data typing - * facilities which can motivate applications to use DTDs. It does not - * expose element content models, or information about attribute typing - * rules. Plus the information it exposes isn't very useful; as one example, - * DOM exposes information about unparsed ENTITY objects, which is only used - * with certain element attributes, but does not expose the information about - * those attributes which is needed to apply that data! </p> - * - * <p> Also, note that there are no nonportable ways to associate even the - * notation and entity information exposed by DOM with a DocumentType. While - * there is a DOM L2 method to construct a DocumentType, it only gives access - * to the textual content of the <!DOCTYPE ...> declaration. </p> - * - * <p> In short, <em>you are strongly advised not to rely on this incomplete - * DTD functionality</em> in your application code.</p> - * - * @see DomEntity - * @see DomEntityReference - * @see DomNotation - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomDoctype - extends DomExtern - implements DocumentType -{ - - private DomNamedNodeMap notations; - private DomNamedNodeMap entities; - private final DOMImplementation implementation; - private String subset; - - private HashMap elements = new HashMap(); - private boolean ids; - - /** - * Constructs a DocumentType node associated with the specified - * implementation, with the specified name. - * - * <p>This constructor should only be invoked by a DOMImplementation as - * part of its createDocumentType functionality, or through a subclass - * which is similarly used in a "Sub-DOM" style layer. - * - * <p> Note that at this time there is no standard SAX API granting - * access to the internal subset text, so that relying on that value - * is not currently portable. - * - * @param impl The implementation with which this object is associated - * @param name Name of this root element - * @param publicId If non-null, provides the external subset's - * PUBLIC identifier - * @param systemId If non-null, provides the external subset's - * SYSTEM identifier - * @param internalSubset Provides the literal value (unparsed, no - * entities expanded) of the DTD's internal subset. - */ - protected DomDoctype(DOMImplementation impl, - String name, - String publicId, - String systemId, - String internalSubset) - { - super(DOCUMENT_TYPE_NODE, null, name, publicId, systemId); - implementation = impl; - subset = internalSubset; - } - - /** - * JAXP builder constructor. - * @param doc the document - * @param name the name of the document element - * @param publicId the public ID of the document type declaration - * @param systemId the system ID of the document type declaration - */ - public DomDoctype(DomDocument doc, - String name, - String publicId, - String systemId) - { - super(DOCUMENT_TYPE_NODE, doc, name, publicId, systemId); - implementation = doc.getImplementation(); - } - - /** - * <b>DOM L1</b> - * Returns the root element's name (just like getNodeName). - */ - final public String getName() - { - return getNodeName(); - } - - /** - * <b>DOM L1</b> - * Returns information about any general entities declared - * in the DTD. - * - * <p><em>Note: DOM L1 doesn't throw a DOMException here, but - * then it doesn't have the strange construction rules of L2.</em> - * - * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType - * is not associated with a document. - */ - public NamedNodeMap getEntities() - { - if (entities == null) - { - entities = new DomNamedNodeMap(this, Node.ENTITY_NODE); - } - return entities; - } - - /** - * Records the declaration of a general entity in this DocumentType. - * - * @param name Name of the entity - * @param publicId If non-null, provides the entity's PUBLIC identifier - * @param systemId Provides the entity's SYSTEM identifier - * @param notation If non-null, provides the entity's notation - * (indicating an unparsed entity) - * @return The Entity that was declared, or null if the entity wasn't - * recorded (because it's a parameter entity or because an entity with - * this name was already declared). - * - * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the - * DocumentType is no longer writable. - * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType - * is not associated with a document. - */ - public Entity declareEntity(String name, - String publicId, - String systemId, - String notation) - { - DomEntity entity; - - if (name.charAt(0) == '%' || "[dtd]".equals(name)) - { - return null; - } - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - getEntities(); - - DomDocument.checkName(name, (owner != null) ? - "1.1".equals(owner.getXmlVersion()) : false); - if (entities.getNamedItem(name) != null) - { - return null; - } - - entity = new DomEntity(owner, name, publicId, systemId, notation); - entities.setNamedItem(entity); - return entity; - } - - /** - * <b>DOM L1</b> - * Returns information about any notations declared in the DTD. - * - * <p><em>Note: DOM L1 doesn't throw a DOMException here, but - * then it doesn't have the strange construction rules of L2.</em> - * - * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType - * is not associated with a document. - */ - public NamedNodeMap getNotations() - { - if (notations == null) - { - notations = new DomNamedNodeMap(this, Node.NOTATION_NODE); - } - return notations; - } - - /** - * Records the declaration of a notation in this DocumentType. - * - * @param name Name of the notation - * @param publicId If non-null, provides the notation's PUBLIC identifier - * @param systemId If non-null, provides the notation's SYSTEM identifier - * @return The notation that was declared. - * - * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the - * DocumentType is no longer writable. - * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType - * is not associated with a document. - */ - public Notation declareNotation(String name, - String publicId, - String systemId) - { - DomNotation notation; - - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - getNotations(); - - DomDocument.checkName(name, (owner != null) ? - "1.1".equals(owner.getXmlVersion()) : false); - - notation = new DomNotation(owner, name, publicId, systemId); - notations.setNamedItem(notation); - return notation; - } - - /** - * <b>DOM L2</b> - * Returns the internal subset of the document, as a string of unparsed - * XML declarations (and comments, PIs, whitespace); or returns null if - * there is no such subset. There is no vendor-independent expectation - * that this attribute be set, or that declarations found in it be - * reflected in the <em>entities</em> or <em>notations</em> attributes - * of this Document "Type" object. - * - * <p> Some application-specific XML profiles require that documents - * only use specific PUBLIC identifiers, without an internal subset - * to modify the interperetation of the declarations associated with - * that PUBLIC identifier through some standard. - */ - public String getInternalSubset() - { - return subset; - } - - /** - * The base URI of a DocumentType is always <code>null</code>. - * See the Infoset Mapping, appendix C. - */ - public final String getBaseURI() - { - return null; - } - - /** - * Sets the internal "readonly" flag so the node and its associated - * data (only lists of entities and notations, no type information - * at the moment) can't be changed. - */ - public void makeReadonly() - { - super.makeReadonly(); - if (entities != null) - { - entities.makeReadonly(); - } - if (notations != null) - { - notations.makeReadonly(); - } - } - - void setOwner(DomDocument doc) - { - if (entities != null) - { - for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next) - { - ctx.setOwner(doc); - } - } - if (notations != null) - { - for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next) - { - ctx.setOwner(doc); - } - } - super.setOwner(doc); - } - - /** - * <b>DOM L2</b> - * Consults the DOM implementation to determine if the requested - * feature is supported. - */ - final public boolean supports(String feature, String version) - { - return implementation.hasFeature(feature, version); - } - - /** - * Returns the implementation associated with this document type. - */ - final public DOMImplementation getImplementation() - { - return implementation; - } - - public void elementDecl(String name, String model) - { - DTDElementTypeInfo info = getElementTypeInfo(name); - if (info == null) - { - info = new DTDElementTypeInfo(name, model); - elements.put(name, info); - } - else - { - info.model = model; - } - } - - DTDElementTypeInfo getElementTypeInfo(String name) - { - return (DTDElementTypeInfo) elements.get(name); - } - - public void attributeDecl(String eName, String aName, String type, - String mode, String value) - { - DTDAttributeTypeInfo info = new DTDAttributeTypeInfo(eName, aName, type, - mode, value); - DTDElementTypeInfo elementInfo = getElementTypeInfo(eName); - if (elementInfo == null) - { - elementInfo = new DTDElementTypeInfo(eName, null); - elements.put(eName, elementInfo); - } - elementInfo.setAttributeTypeInfo(aName, info); - if ("ID".equals(type)) - { - ids = true; - } - } - - DTDAttributeTypeInfo getAttributeTypeInfo(String elementName, String name) - { - DTDElementTypeInfo elementInfo = - (DTDElementTypeInfo) elements.get(elementName); - return (elementInfo == null) ? null : - elementInfo.getAttributeTypeInfo(name); - } - - boolean hasIds() - { - return ids; - } - - public boolean isSameNode(Node arg) - { - if (equals(arg)) - { - return true; - } - if (!(arg instanceof DocumentType)) - { - return false; - } - DocumentType doctype = (DocumentType) arg; - if (!equal(getPublicId(), doctype.getPublicId())) - { - return false; - } - if (!equal(getSystemId(), doctype.getSystemId())) - { - return false; - } - if (!equal(getInternalSubset(), doctype.getInternalSubset())) - { - return false; - } - // TODO entities - // TODO notations - return true; - } - - /** - * Shallow clone of the doctype, except that associated - * entities and notations are (deep) cloned. - */ - public Object clone() - { - DomDoctype node = (DomDoctype) super.clone(); - - if (entities != null) - { - node.entities = new DomNamedNodeMap(node, Node.ENTITY_NODE); - for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next) - { - node.entities.setNamedItem(ctx.cloneNode(true)); - } - } - if (notations != null) - { - node.notations = new DomNamedNodeMap(node, Node.NOTATION_NODE); - for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next) - { - node.notations.setNamedItem(ctx.cloneNode(true)); - } - } - return node; - } - - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDocument.java b/libjava/classpath/gnu/xml/dom/DomDocument.java deleted file mode 100644 index b1e99f4..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDocument.java +++ /dev/null @@ -1,1555 +0,0 @@ -/* DomDocument.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.Iterator; -import javax.xml.XMLConstants; - -import org.w3c.dom.Attr; -import org.w3c.dom.CDATASection; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentFragment; -import org.w3c.dom.DocumentType; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.Entity; -import org.w3c.dom.EntityReference; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.Notation; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; -import org.w3c.dom.UserDataHandler; -import org.w3c.dom.traversal.DocumentTraversal; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; -import org.w3c.dom.traversal.TreeWalker; -import org.w3c.dom.xpath.XPathEvaluator; -import org.w3c.dom.xpath.XPathException; -import org.w3c.dom.xpath.XPathExpression; -import org.w3c.dom.xpath.XPathNSResolver; - -/** - * <p> "Document" and "DocumentTraversal" implementation. - * - * <p> Note that when this checks names for legality, it uses an - * approximation of the XML rules, not the real ones. Specifically, - * it uses Unicode rules, with sufficient tweaks to pass a majority - * of basic XML conformance tests. (The huge XML character tables are - * hairy to implement.) - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomDocument - extends DomNode - implements Document, DocumentTraversal, XPathEvaluator -{ - - private final DOMImplementation implementation; - private boolean checkingCharacters = true; - boolean checkingWellformedness = true; - private boolean defaultAttributes = true; - - boolean building; // if true, skip mutation events in the tree - - DomDocumentConfiguration config; - - String inputEncoding; - String encoding; - String version = "1.0"; - boolean standalone; - String systemId; - - /** - * Constructs a Document node, associating it with an instance - * of the DomImpl class. - * - * <p> Note that this constructor disables character checking. - * It is normally used when connecting a DOM to an XML parser, - * and duplicating such checks is undesirable. When used for - * purposes other than connecting to a parser, you should - * re-enable that checking. - * - * @see #setCheckingCharacters - */ - public DomDocument() - { - this(new DomImpl()); - } - - /** - * Constructs a Document node, associating it with the specified - * implementation. This should only be used in conjunction with - * a specialized implementation; it will normally be called by - * that implementation. - * - * @see DomImpl - * @see #setCheckingCharacters - */ - protected DomDocument(DOMImplementation impl) - { - super(DOCUMENT_NODE, null); - implementation = impl; - } - - /** - * Sets the <code>building</code> flag. - * Mutation events in the document are not reported. - */ - public void setBuilding(boolean flag) - { - building = flag; - } - - /** - * Sets whether to check for document well-formedness. - * If true, an exception will be raised if a second doctype or root - * element node is added to the document. - */ - public void setCheckWellformedness(boolean flag) - { - checkingWellformedness = flag; - } - - /** - * Sets whether to check for document characters. - */ - public void setCheckingCharacters(boolean flag) - { - checkingCharacters = flag; - } - - /** - * Sets whether to default attributes for new elements. - */ - public void setDefaultAttributes(boolean flag) - { - defaultAttributes = flag; - } - - /** - * <b>DOM L1</b> - * Returns the constant "#document". - */ - final public String getNodeName() - { - return "#document"; - } - - /** - * <b>DOM L1</b> - * Returns the document's root element, or null. - */ - final public Element getDocumentElement() - { - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - if (ctx.nodeType == ELEMENT_NODE) - { - return (Element) ctx; - } - } - return null; - } - - /** - * <b>DOM L1</b> - * Returns the document's DocumentType, or null. - */ - final public DocumentType getDoctype() - { - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - if (ctx.nodeType == DOCUMENT_TYPE_NODE) - { - return (DocumentType) ctx; - } - } - return null; - } - - /** - * <b>DOM L1</b> - * Returns the document's DOMImplementation. - */ - final public DOMImplementation getImplementation() - { - return implementation; - } - - /** - * <b>DOM L1 (relocated in DOM L2)</b> - * Returns the element with the specified "ID" attribute, or null. - * - * <p>Returns null unless {@link Consumer} was used to populate internal - * DTD declaration information, using package-private APIs. If that - * internal DTD information is available, the document may be searched for - * the element with that ID. - */ - public Element getElementById(String id) - { - if (id == null || id.length() == 0) - { - return null; - } - DomDoctype doctype = (DomDoctype) getDoctype(); - if (doctype != null && !doctype.hasIds()) - { - doctype = null; - } - - // yes, this is linear in size of document. - // it'd be easy enough to maintain a hashtable. - Node current = getDocumentElement(); - Node temp; - - if (current == null) - { - return null; - } - while (current != this) - { - // done? - if (current.getNodeType() == ELEMENT_NODE) - { - DomElement element = (DomElement) current; - if (element.userIdAttrs != null) - { - for (Iterator i = element.userIdAttrs.iterator(); - i.hasNext(); ) - { - Node idAttr = (Node) i.next(); - if (id.equals(idAttr.getNodeValue())) - { - return element; - } - } - } - if (doctype != null) - { - DTDElementTypeInfo info = - doctype.getElementTypeInfo(current.getNodeName()); - if (info != null && - id.equals(element.getAttribute(info.idAttrName))) - { - return element; - } - } - // xml:id - String xmlId = element.getAttribute("xml:id"); - if (xmlId == null) - { - xmlId = element.getAttributeNS(XMLConstants.XML_NS_URI, - "id"); - } - if (id.equals(xmlId)) - { - return element; - } - } - - // descend? - if (current.hasChildNodes()) - { - current = current.getFirstChild(); - continue; - } - - // lateral? - temp = current.getNextSibling(); - if (temp != null) - { - current = temp; - continue; - } - - // back up ... - do - { - temp = current.getParentNode(); - if (temp == null) - { - return null; - } - current = temp; - temp = current.getNextSibling(); - } - while (temp == null); - current = temp; - } - return null; - } - - private void checkNewChild(Node newChild) - { - if (newChild.getNodeType() == ELEMENT_NODE - && getDocumentElement() != null) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, - "document element already present: " + - getDocumentElement(), newChild, 0); - } - if (newChild.getNodeType() == DOCUMENT_TYPE_NODE - && getDoctype() != null) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, - "document type already present: " + - getDoctype(), newChild, 0); - } - } - - /** - * <b>DOM L1</b> - * Appends the specified node to this node's list of children, - * enforcing the constraints that there be only one root element - * and one document type child. - */ - public Node appendChild(Node newChild) - { - if (checkingWellformedness) - { - checkNewChild(newChild); - } - return super.appendChild(newChild); - } - - /** - * <b>DOM L1</b> - * Inserts the specified node in this node's list of children, - * enforcing the constraints that there be only one root element - * and one document type child. - */ - public Node insertBefore(Node newChild, Node refChild) - { - if (checkingWellformedness) - { - checkNewChild(newChild); - } - return super.insertBefore(newChild, refChild); - } - - /** - * <b>DOM L1</b> - * Replaces the specified node in this node's list of children, - * enforcing the constraints that there be only one root element - * and one document type child. - */ - public Node replaceChild(Node newChild, Node refChild) - { - if (checkingWellformedness && - ((newChild.getNodeType() == ELEMENT_NODE && - refChild.getNodeType() != ELEMENT_NODE) || - (newChild.getNodeType() == DOCUMENT_TYPE_NODE && - refChild.getNodeType() != DOCUMENT_TYPE_NODE))) - { - checkNewChild(newChild); - } - return super.replaceChild(newChild, refChild); - } - - // NOTE: DOM can't really tell when the name of an entity, - // notation, or PI must follow the namespace rules (excluding - // colons) instead of the XML rules (which allow them without - // much restriction). That's an API issue. verifyXmlName - // aims to enforce the XML rules, not the namespace rules. - - /** - * Throws a DOM exception if the specified name is not a legal XML 1.0 - * Name. - * @deprecated This method is deprecated and may be removed in future - * versions of GNU JAXP - */ - public static void verifyXmlName(String name) - { - // XXX why is this public? - checkName(name, false); - } - - static void checkName(String name, boolean xml11) - { - if (name == null) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0); - } - int len = name.length(); - if (len == 0) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0); - } - - // dog: rewritten to use the rules for XML 1.0 and 1.1 - - // Name start character - char c = name.charAt(0); - if (xml11) - { - // XML 1.1 - if ((c < 0x0041 || c > 0x005a) && - (c < 0x0061 || c > 0x007a) && - c != ':' && c != '_' && - (c < 0x00c0 || c > 0x00d6) && - (c < 0x00d8 || c > 0x00f6) && - (c < 0x00f8 || c > 0x02ff) && - (c < 0x0370 || c > 0x037d) && - (c < 0x037f || c > 0x1fff) && - (c < 0x200c || c > 0x200d) && - (c < 0x2070 || c > 0x218f) && - (c < 0x2c00 || c > 0x2fef) && - (c < 0x3001 || c > 0xd7ff) && - (c < 0xf900 || c > 0xfdcf) && - (c < 0xfdf0 || c > 0xfffd) && - (c < 0x10000 || c > 0xeffff)) - { - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - name, null, c); - } - } - else - { - // XML 1.0 - int type = Character.getType(c); - switch (type) - { - case Character.LOWERCASE_LETTER: // Ll - case Character.UPPERCASE_LETTER: // Lu - case Character.OTHER_LETTER: // Lo - case Character.TITLECASE_LETTER: // Lt - case Character.LETTER_NUMBER: // Nl - if ((c > 0xf900 && c < 0xfffe) || - (c >= 0x20dd && c <= 0x20e0)) - { - // Compatibility area and Unicode 2.0 exclusions - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - name, null, c); - } - break; - default: - if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && - c != 0x0559 && c != 0x06e5 && c != 0x06e6) - { - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - name, null, c); - } - } - } - - // Subsequent characters - for (int i = 1; i < len; i++) - { - c = name.charAt(i); - if (xml11) - { - // XML 1.1 - if ((c < 0x0041 || c > 0x005a) && - (c < 0x0061 || c > 0x007a) && - (c < 0x0030 || c > 0x0039) && - c != ':' && c != '_' && c != '-' && c != '.' && - (c < 0x00c0 || c > 0x00d6) && - (c < 0x00d8 || c > 0x00f6) && - (c < 0x00f8 || c > 0x02ff) && - (c < 0x0370 || c > 0x037d) && - (c < 0x037f || c > 0x1fff) && - (c < 0x200c || c > 0x200d) && - (c < 0x2070 || c > 0x218f) && - (c < 0x2c00 || c > 0x2fef) && - (c < 0x3001 || c > 0xd7ff) && - (c < 0xf900 || c > 0xfdcf) && - (c < 0xfdf0 || c > 0xfffd) && - (c < 0x10000 || c > 0xeffff) && - c != 0x00b7 && - (c < 0x0300 || c > 0x036f) && - (c < 0x203f || c > 0x2040)) - { - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, name, - null, c); - } - } - else - { - // XML 1.0 - int type = Character.getType(c); - switch (type) - { - case Character.LOWERCASE_LETTER: // Ll - case Character.UPPERCASE_LETTER: // Lu - case Character.DECIMAL_DIGIT_NUMBER: // Nd - case Character.OTHER_LETTER: // Lo - case Character.TITLECASE_LETTER: // Lt - case Character.LETTER_NUMBER: // Nl - case Character.COMBINING_SPACING_MARK: // Mc - case Character.ENCLOSING_MARK: // Me - case Character.NON_SPACING_MARK: // Mn - case Character.MODIFIER_LETTER: // Lm - if ((c > 0xf900 && c < 0xfffe) || - (c >= 0x20dd && c <= 0x20e0)) - { - // Compatibility area and Unicode 2.0 exclusions - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - name, null, c); - } - break; - default: - if (c != '-' && c != '.' && c != ':' && c != '_' && - c != 0x0387 && (c < 0x02bb || c > 0x02c1) && - c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) - { - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - name, null, c); - } - } - } - } - - // FIXME characters with a font or compatibility decomposition (i.e. - // those with a "compatibility formatting tag" in field 5 of the - // database -- marked by field 5 beginning with a "<") are not allowed. - } - - // package private - static void checkNCName(String name, boolean xml11) - { - checkName(name, xml11); - int len = name.length(); - int index = name.indexOf(':'); - if (index != -1) - { - if (index == 0 || index == (len - 1) || name.lastIndexOf(':') != index) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0); - } - } - } - - // package private - static void checkChar(String value, boolean xml11) - { - char[] chars = value.toCharArray(); - checkChar(chars, 0, chars.length, xml11); - } - - static void checkChar(char[] buf, int off, int len, boolean xml11) - { - for (int i = 0; i < len; i++) - { - char c = buf[i]; - - // assume surrogate pairing checks out OK, for simplicity - if ((c >= 0x0020 && c <= 0xd7ff) || - (c == 0x000a || c == 0x000d || c == 0x0009) || - (c >= 0xe000 && c <= 0xfffd) || - (c >= 0x10000 && c <= 0x10ffff)) - { - continue; - } - if (xml11) - { - if ((c >= 0x0001 && c <= 0x001f) || - (c >= 0x007f && c <= 0x0084) || - (c >= 0x0086 && c <= 0x009f)) - { - continue; - } - } - throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, - new String(buf, off, len), null, c); - } - } - - /** - * <b>DOM L1</b> - * Returns a newly created element with the specified name. - * The node name of the created element will be equal to {@code name}. - * The namespace, prefix and local name will all be {@code null}. - */ - public Element createElement(String name) - { - Element element; - - if (checkingCharacters) - { - checkName(name, "1.1".equals(version)); - } - if (name.startsWith("xml:")) - { - element = createElementNS(null, name); - } - else - { - DomElement domElement = new DomElement(this, null, name, null, null); - element = domElement; - } - if (defaultAttributes) - setDefaultAttributes(element, name); - return element; - } - - /** - * <b>DOM L2</b> - * Returns a newly created element with the specified name - * and namespace information. - */ - public Element createElementNS(String namespaceURI, String name) - { - if (checkingCharacters) - { - checkNCName(name, "1.1".equals(version)); - } - - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - if (name.startsWith("xml:")) - { - if (namespaceURI != null - && !XMLConstants.XML_NS_URI.equals(namespaceURI)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xml namespace is always " + - XMLConstants.XML_NS_URI, this, 0); - } - namespaceURI = XMLConstants.XML_NS_URI; - } - else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || - name.startsWith("xmlns:")) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns is reserved", this, 0); - } - else if (namespaceURI == null && name.indexOf(':') != -1) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "prefixed name '" + name + - "' needs a URI", this, 0); - } - - Element element = new DomElement(this, namespaceURI, name); - if (defaultAttributes) - setDefaultAttributes(element, name); - return element; - } - - private void setDefaultAttributes(Element element, String name) - { - DomDoctype doctype = (DomDoctype) getDoctype(); - if (doctype == null) - { - return; - } - - // default any attributes that need it - DTDElementTypeInfo info = doctype.getElementTypeInfo(name); - if (info != null) - { - for (Iterator i = info.attributes(); i != null && i.hasNext(); ) - { - DTDAttributeTypeInfo attr = (DTDAttributeTypeInfo) i.next(); - String value = attr.value; - if ("#IMPLIED".equals(attr.mode) && value == null) - continue; - DomAttr node = (DomAttr) createAttribute(attr.name); - - if (value == null) - { - value = ""; - } - node.setValue(value); - node.setSpecified(false); - element.setAttributeNode(node); - } - } - } - - /** - * <b>DOM L1</b> - * Returns a newly created document fragment. - */ - public DocumentFragment createDocumentFragment() - { - return new DomDocumentFragment(this); - } - - /** - * <b>DOM L1</b> - * Returns a newly created text node with the specified value. - */ - public Text createTextNode(String value) - { - if (checkingCharacters) - { - checkChar(value, "1.1".equals(version)); - } - return new DomText(this, value); - } - - /** - * Returns a newly created text node with the specified value. - */ - public Text createTextNode(char[] buf, int off, int len) - { - if (checkingCharacters) - { - checkChar(buf, off, len, "1.1".equals(version)); - } - return new DomText(this, buf, off, len); - } - - /** - * <b>DOM L1</b> - * Returns a newly created comment node with the specified value. - */ - public Comment createComment(String value) - { - if (checkingCharacters) - { - checkChar(value, "1.1".equals(version)); - } - return new DomComment(this, value); - } - - /** - * <b>DOM L1</b> - * Returns a newly created CDATA section node with the specified value. - */ - public CDATASection createCDATASection(String value) - { - if (checkingCharacters) - { - checkChar(value, "1.1".equals(version)); - } - return new DomCDATASection(this, value); - } - - /** - * Returns a newly created CDATA section node with the specified value. - */ - public CDATASection createCDATASection(char[] buf, int off, int len) - { - if (checkingCharacters) - { - checkChar(buf, off, len, "1.1".equals(version)); - } - return new DomCDATASection(this, buf, off, len); - } - - /** - * <b>DOM L1</b> - * Returns a newly created processing instruction. - */ - public ProcessingInstruction createProcessingInstruction(String target, - String data) - { - if (checkingCharacters) - { - boolean xml11 = "1.1".equals(version); - checkName(target, xml11); - if ("xml".equalsIgnoreCase(target)) - { - throw new DomDOMException(DOMException.SYNTAX_ERR, - "illegal PI target name", - this, 0); - } - checkChar(data, xml11); - } - return new DomProcessingInstruction(this, target, data); - } - - /** - * <b>DOM L1</b> - * Returns a newly created attribute with the specified name. - */ - public Attr createAttribute(String name) - { - if (checkingCharacters) - { - checkName(name, "1.1".equals(version)); - } - if (name.startsWith("xml:")) - { - return createAttributeNS(XMLConstants.XML_NS_URI, name); - } - else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || - name.startsWith("xmlns:")) - { - return createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, name); - } - else - { - DomAttr ret = new DomAttr(this, null, name, null, null); - return ret; - } - } - - /** - * <b>DOM L2</b> - * Returns a newly created attribute with the specified name - * and namespace information. - */ - public Attr createAttributeNS(String namespaceURI, String name) - { - if (checkingCharacters) - { - checkNCName(name, "1.1".equals(version)); - } - - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - if (name.startsWith ("xml:")) - { - if (namespaceURI == null) - { - namespaceURI = XMLConstants.XML_NS_URI; - } - else if (!XMLConstants.XML_NS_URI.equals(namespaceURI)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xml namespace is always " + - XMLConstants.XML_NS_URI, - this, 0); - } - } - else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || - name.startsWith("xmlns:")) - { - if (namespaceURI == null) - { - namespaceURI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } - else if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns namespace must be " + - XMLConstants.XMLNS_ATTRIBUTE_NS_URI, - this, 0); - } - } - else if (namespaceURI == null && name.indexOf(':') != -1) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "prefixed name needs a URI: " + name, this, 0); - } - return new DomAttr(this, namespaceURI, name); - } - - /** - * <b>DOM L1</b> - * Returns a newly created reference to the specified entity. - * The caller should populate this with the appropriate children - * and then mark it as readonly. - * - * @see DomNode#makeReadonly - */ - public EntityReference createEntityReference(String name) - { - DomEntityReference ret = new DomEntityReference(this, name); - DocumentType doctype = getDoctype(); - if (doctype != null) - { - DomEntity ent = (DomEntity) doctype.getEntities().getNamedItem(name); - if (ent != null) - { - for (DomNode ctx = ent.first; ctx != null; ctx = ctx.next) - { - ret.appendChild(ctx.cloneNode(true)); - } - } - } - ret.makeReadonly(); - return ret; - } - - /** - * <b>DOM L2</b> - * Makes a copy of the specified node, with all nodes "owned" by - * this document and with children optionally copied. This type - * of standard utility has become, well, a standard utility. - * - * <p> Note that EntityReference nodes created through this method (either - * directly, or recursively) never have children, and that there is no - * portable way to associate them with such children. - * - * <p> Note also that there is no requirement that the specified node - * be associated with a different document. This differs from the - * <em>cloneNode</em> operation in that the node itself is not given - * an opportunity to participate, so that any information managed - * by node subclasses will be lost. - */ - public Node importNode(Node src, boolean deep) - { - Node dst = null; - switch (src.getNodeType()) - { - case TEXT_NODE: - dst = createTextNode(src.getNodeValue()); - break; - case CDATA_SECTION_NODE: - dst = createCDATASection(src.getNodeValue()); - break; - case COMMENT_NODE: - dst = createComment(src.getNodeValue()); - break; - case PROCESSING_INSTRUCTION_NODE: - dst = createProcessingInstruction(src.getNodeName(), - src.getNodeValue()); - break; - case NOTATION_NODE: - // NOTE: There's no standard way to create - // these, or add them to a doctype. Useless. - Notation notation = (Notation) src; - dst = new DomNotation(this, notation.getNodeName(), - notation.getPublicId(), - notation.getSystemId()); - break; - case ENTITY_NODE: - // NOTE: There's no standard way to create - // these, or add them to a doctype. Useless. - Entity entity = (Entity) src; - dst = new DomEntity(this, entity.getNodeName(), - entity.getPublicId(), - entity.getSystemId(), - entity.getNotationName()); - if (deep) - { - for (Node ctx = src.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - dst.appendChild(importNode(ctx, deep)); - } - } - break; - case ENTITY_REFERENCE_NODE: - dst = createEntityReference(src.getNodeName()); - break; - case DOCUMENT_FRAGMENT_NODE: - dst = new DomDocumentFragment(this); - if (deep) - { - for (Node ctx = src.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - dst.appendChild(importNode(ctx, deep)); - } - } - break; - case ATTRIBUTE_NODE: - String attr_nsuri = src.getNamespaceURI(); - if (attr_nsuri != null) - { - dst = createAttributeNS(attr_nsuri, src.getNodeName()); - } - else - { - dst = createAttribute(src.getNodeName()); - } - // this is _always_ done regardless of "deep" setting - for (Node ctx = src.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - dst.appendChild(importNode(ctx, false)); - } - break; - case ELEMENT_NODE: - String elem_nsuri = src.getNamespaceURI(); - if (elem_nsuri != null) - { - dst = createElementNS(elem_nsuri, src.getNodeName()); - } - else - { - dst = createElement(src.getNodeName()); - } - NamedNodeMap srcAttrs = src.getAttributes(); - NamedNodeMap dstAttrs = dst.getAttributes(); - int len = srcAttrs.getLength(); - for (int i = 0; i < len; i++) - { - Attr a = (Attr) srcAttrs.item(i); - Attr dflt; - - // maybe update defaulted attributes - dflt = (Attr) dstAttrs.getNamedItem(a.getNodeName()); - if (dflt != null) - { - String newval = a.getNodeValue(); - if (!dflt.getNodeValue().equals(newval) - || a.getSpecified () == true) - { - dflt.setNodeValue (newval); - } - continue; - } - - dstAttrs.setNamedItem((Attr) importNode(a, false)); - } - if (deep) - { - for (Node ctx = src.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - dst.appendChild(importNode(ctx, true)); - } - } - break; - // can't import document or doctype nodes - case DOCUMENT_NODE: - case DOCUMENT_TYPE_NODE: - // FALLTHROUGH - // can't import unrecognized or nonstandard nodes - default: - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, src, 0); - } - - // FIXME cleanup a bit -- for deep copies, copy those - // children in one place, here (code sharing is healthy) - - if (src instanceof DomNode) - { - ((DomNode) src).notifyUserDataHandlers(UserDataHandler.NODE_IMPORTED, - src, dst); - } - return dst; - } - - /** - * <b>DOM L2 (Traversal)</b> - * Returns a newly created node iterator. Don't forget to detach - * this iterator when you're done using it! - * - * @see DomIterator - */ - public NodeIterator createNodeIterator(Node root, - int whatToShow, - NodeFilter filter, - boolean expandEntities) - { - return new DomNodeIterator(root, whatToShow, filter, expandEntities, - false); - } - - public TreeWalker createTreeWalker(Node root, - int whatToShow, - NodeFilter filter, - boolean expandEntities) - { - return new DomNodeIterator(root, whatToShow, filter, expandEntities, - true); - } - - // DOM Level 3 methods - - /** - * DOM L3 - */ - public String getInputEncoding() - { - return inputEncoding; - } - - public void setInputEncoding(String inputEncoding) - { - this.inputEncoding = inputEncoding; - } - - /** - * DOM L3 - */ - public String getXmlEncoding() - { - return encoding; - } - - public void setXmlEncoding(String encoding) - { - this.encoding = encoding; - } - - public boolean getXmlStandalone() - { - return standalone; - } - - public void setXmlStandalone(boolean xmlStandalone) - { - standalone = xmlStandalone; - } - - public String getXmlVersion() - { - return version; - } - - public void setXmlVersion(String xmlVersion) - { - if (xmlVersion == null) - { - xmlVersion = "1.0"; - } - if ("1.0".equals(xmlVersion) || - "1.1".equals(xmlVersion)) - { - version = xmlVersion; - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - } - - public boolean getStrictErrorChecking() - { - return checkingCharacters; - } - - public void setStrictErrorChecking(boolean strictErrorChecking) - { - checkingCharacters = strictErrorChecking; - } - - public String lookupPrefix(String namespaceURI) - { - Node root = getDocumentElement(); - return (root == null) ? null : root.lookupPrefix(namespaceURI); - } - - public boolean isDefaultNamespace(String namespaceURI) - { - Node root = getDocumentElement(); - return (root == null) ? false : root.isDefaultNamespace(namespaceURI); - } - - public String lookupNamespaceURI(String prefix) - { - Node root = getDocumentElement(); - return (root == null) ? null : root.lookupNamespaceURI(prefix); - } - - public String getBaseURI() - { - return getDocumentURI(); - /* - Node root = getDocumentElement(); - if (root != null) - { - NamedNodeMap attrs = root.getAttributes(); - Node xmlBase = attrs.getNamedItemNS(XMLConstants.XML_NS_URI, "base"); - if (xmlBase != null) - { - return xmlBase.getNodeValue(); - } - } - return systemId; - */ - } - - public String getDocumentURI() - { - return systemId; - } - - public void setDocumentURI(String documentURI) - { - systemId = documentURI; - } - - public Node adoptNode(Node source) - { - int sourceNodeType = source.getNodeType(); - switch (sourceNodeType) - { - case DOCUMENT_NODE: - case DOCUMENT_TYPE_NODE: - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - case ENTITY_NODE: - case NOTATION_NODE: - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - if (source instanceof DomNode) - { - // GNU native - DomNode src = (DomNode) source; - DomNode dst = src; - if (dst.parent != null) - { - dst = (DomNode) dst.cloneNode(true); - } - dst.setOwner(this); - src.notifyUserDataHandlers(UserDataHandler.NODE_ADOPTED, src, dst); - return dst; - } - else - { - // Some other implementation - Node dst = null; - switch (sourceNodeType) - { - case Node.ATTRIBUTE_NODE: - { - Attr src = (Attr) source; - String nodeName = src.getNodeName(); - String localName = src.getLocalName(); - String namespaceUri = src.getNamespaceURI(); - dst = (localName == null) ? - createAttribute(nodeName) : - createAttributeNS(namespaceUri, nodeName); - adoptChildren(src, dst); - break; - } - case Node.CDATA_SECTION_NODE: - { - CDATASection src = (CDATASection) source; - dst = createCDATASection(src.getData()); - break; - } - case Node.COMMENT_NODE: - { - Comment src = (Comment) source; - dst = createComment(src.getData()); - break; - } - case Node.DOCUMENT_FRAGMENT_NODE: - { - DocumentFragment src = (DocumentFragment) source; - dst = createDocumentFragment(); - adoptChildren(src, dst); - break; - } - case Node.ELEMENT_NODE: - { - Element src = (Element) source; - String nodeName = src.getNodeName(); - String localName = src.getLocalName(); - String namespaceUri = src.getNamespaceURI(); - dst = (localName == null) ? - createElement(nodeName) : - createElementNS(namespaceUri, nodeName); - adoptAttributes(src, dst); - adoptChildren(src, dst); - break; - } - case Node.ENTITY_REFERENCE_NODE: - { - EntityReference src = (EntityReference) source; - dst = createEntityReference(src.getNodeName()); - adoptChildren(src, dst); - break; - } - case Node.PROCESSING_INSTRUCTION_NODE: - { - ProcessingInstruction src = (ProcessingInstruction) source; - dst = createProcessingInstruction(src.getTarget(), - src.getData()); - break; - } - case Node.TEXT_NODE: - { - Text src = (Text) source; - dst = createTextNode(src.getData()); - break; - } - } - return dst; - } - } - - void adoptChildren(Node src, Node dst) - { - Node node = src.getFirstChild(); - while (node != null) - { - Node next = node.getNextSibling(); - dst.appendChild(adoptNode(node)); - node = next; - } - } - - void adoptAttributes(Node src, Node dst) - { - NamedNodeMap srcAttrs = src.getAttributes(); - NamedNodeMap dstAttrs = dst.getAttributes(); - int len = srcAttrs.getLength(); - for (int i = 0; i < len; i++) - { - Node node = srcAttrs.item(i); - String localName = node.getLocalName(); - if (localName == null) - { - dstAttrs.setNamedItem(adoptNode(node)); - } - else - { - dstAttrs.setNamedItemNS(adoptNode(node)); - } - } - } - - public DOMConfiguration getDomConfig() - { - if (config == null) - { - config = new DomDocumentConfiguration(); - } - return config; - } - - public boolean isEqualNode(Node arg) - { - if (!super.isEqualNode(arg)) - return false; - Document d = (Document) arg; - String dversion = d.getXmlVersion(); - if (dversion == null || !dversion.equals(version)) - return false; - boolean dstandalone = d.getXmlStandalone(); - if (dstandalone != standalone) - return false; - String dencoding = d.getXmlEncoding(); - if (dencoding == null || dencoding.equalsIgnoreCase("UTF-8")) - { - if (encoding != null && !encoding.equalsIgnoreCase("UTF-8")) - return false; - } - else - { - if (!dencoding.equals(encoding)) - return false; - } - return true; - } - - public void normalizeDocument() - { - boolean save = building; - building = true; - normalizeNode(this); - building = save; - } - - void normalizeNode(DomNode node) - { - node.normalize(); - if (config != null) - { - switch (node.nodeType) - { - case CDATA_SECTION_NODE: - if (!config.cdataSections) - { - // replace CDATA section with text node - Text text = createTextNode(node.getNodeValue()); - node.parent.insertBefore(text, node); - node.parent.removeChild(node); - // merge adjacent text nodes - String data = text.getWholeText(); - node = (DomNode) text.replaceWholeText(data); - } - else if (config.splitCdataSections) - { - String value = node.getNodeValue(); - int i = value.indexOf("]]>"); - while (i != -1) - { - Node node2 = createCDATASection(value.substring(0, i)); - node.parent.insertBefore(node2, node); - value = value.substring(i + 3); - node.setNodeValue(value); - i = value.indexOf("]]>"); - } - } - break; - case COMMENT_NODE: - if (!config.comments) - { - node.parent.removeChild(node); - } - break; - case TEXT_NODE: - if (!config.elementContentWhitespace && - ((Text) node).isElementContentWhitespace()) - { - node.parent.removeChild(node); - } - break; - case ENTITY_REFERENCE_NODE: - if (!config.entities) - { - for (DomNode ctx = node.first; ctx != null; ) - { - DomNode ctxNext = ctx.next; - node.parent.insertBefore(ctx, node); - ctx = ctxNext; - } - node.parent.removeChild(node); - } - break; - case ELEMENT_NODE: - if (!config.namespaceDeclarations) - { - DomNamedNodeMap attrs = - (DomNamedNodeMap) node.getAttributes(); - boolean aro = attrs.readonly; - attrs.readonly = false; // Ensure we can delete if necessary - int len = attrs.getLength(); - for (int i = 0; i < len; i++) - { - Node attr = attrs.item(i); - String namespace = attr.getNamespaceURI(); - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace)) - { - attrs.removeNamedItemNS(namespace, - attr.getLocalName()); - i--; - len--; - } - } - attrs.readonly = aro; - } - break; - } - } - for (DomNode ctx = node.first; ctx != null; ) - { - DomNode ctxNext = ctx.next; - normalizeNode(ctx); - ctx = ctxNext; - } - } - - public Node renameNode(Node n, String namespaceURI, String qualifiedName) - throws DOMException - { - if (n instanceof DomNsNode) - { - DomNsNode src = (DomNsNode) n; - if (src == null) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR); - } - if (src.owner != this) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, src, 0); - } - boolean xml11 = "1.1".equals(version); - checkName(qualifiedName, xml11); - int ci = qualifiedName.indexOf(':'); - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - if (namespaceURI != null) - { - checkNCName(qualifiedName, xml11); - String prefix = (ci == -1) ? "" : - qualifiedName.substring(0, ci); - if (XMLConstants.XML_NS_PREFIX.equals(prefix) && - !XMLConstants.XML_NS_URI.equals(namespaceURI)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xml namespace must be " + - XMLConstants.XML_NS_URI, src, 0); - } - else if (src.nodeType == ATTRIBUTE_NODE && - (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) || - XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName)) && - !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns namespace must be " + - XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); - } - if (XMLConstants.XML_NS_URI.equals(namespaceURI) && - !XMLConstants.XML_NS_PREFIX.equals(prefix)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xml namespace must be " + - XMLConstants.XML_NS_URI, src, 0); - } - else if (src.nodeType == ATTRIBUTE_NODE && - XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI) && - !(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) || - XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName))) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns namespace must be " + - XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); - } - - } - src.setNodeName(qualifiedName); - src.setNamespaceURI(namespaceURI); - src.notifyUserDataHandlers(UserDataHandler.NODE_RENAMED, src, src); - // TODO MutationNameEvents - // DOMElementNameChanged or DOMAttributeNameChanged - return src; - } - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, n, 0); - } - - // -- XPathEvaluator -- - - public XPathExpression createExpression(String expression, - XPathNSResolver resolver) - throws XPathException, DOMException - { - return new DomXPathExpression(this, expression, resolver); - } - - public XPathNSResolver createNSResolver(Node nodeResolver) - { - return new DomXPathNSResolver(nodeResolver); - } - - public Object evaluate(String expression, - Node contextNode, - XPathNSResolver resolver, - short type, - Object result) - throws XPathException, DOMException - { - XPathExpression xpe = - new DomXPathExpression(this, expression, resolver); - return xpe.evaluate(contextNode, type, result); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java b/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java deleted file mode 100644 index 99c2544..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java +++ /dev/null @@ -1,227 +0,0 @@ -/* DomDocumentBuilder.java -- - Copyright (C) 2004,2006,2007 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.io.File; -import java.io.InputStream; -import java.io.IOException; -import java.io.Reader; -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import org.w3c.dom.Document; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSException; -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSParser; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * Document builder using the GNU DOM Load & Save implementation. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomDocumentBuilder - extends DocumentBuilder -{ - - final DOMImplementation impl; - final DOMImplementationLS ls; - final LSParser parser; - - DomDocumentBuilder(DOMImplementation impl, - DOMImplementationLS ls, - LSParser parser) - { - this.impl = impl; - this.ls = ls; - this.parser = parser; - } - - public boolean isNamespaceAware() - { - DOMConfiguration config = parser.getDomConfig(); - return ((Boolean) config.getParameter("namespaces")).booleanValue(); - } - - public boolean isValidating() - { - DOMConfiguration config = parser.getDomConfig(); - return ((Boolean) config.getParameter("validating")).booleanValue(); - } - - public boolean isXIncludeAware() - { - DOMConfiguration config = parser.getDomConfig(); - return ((Boolean) config.getParameter("xinclude-aware")).booleanValue(); - } - - public void setEntityResolver(EntityResolver resolver) - { - DOMConfiguration config = parser.getDomConfig(); - config.setParameter("entity-resolver", resolver); - } - - public void setErrorHandler(ErrorHandler handler) - { - DOMConfiguration config = parser.getDomConfig(); - config.setParameter("error-handler", handler); - } - - public DOMImplementation getDOMImplementation() - { - return impl; - } - - public Document newDocument() - { - return impl.createDocument(null, null, null); - } - - public Document parse(InputStream in) - throws SAXException, IOException - { - LSInput input = ls.createLSInput(); - input.setByteStream(in); - try - { - return parser.parse(input); - } - catch (LSException e) - { - Throwable e2 = e.getCause(); - if (e2 instanceof IOException) - throw (IOException) e2; - else - throw e; - } - } - - public Document parse(InputStream in, String systemId) - throws SAXException, IOException - { - LSInput input = ls.createLSInput(); - input.setByteStream(in); - input.setSystemId(systemId); - try - { - return parser.parse(input); - } - catch (LSException e) - { - Throwable e2 = e.getCause(); - if (e2 instanceof IOException) - throw (IOException) e2; - else - throw e; - } - } - - public Document parse(String systemId) - throws SAXException, IOException - { - try - { - return parser.parseURI(systemId); - } - catch (LSException e) - { - Throwable e2 = e.getCause(); - if (e2 instanceof IOException) - throw (IOException) e2; - else - throw e; - } - } - - public Document parse(InputSource is) - throws SAXException, IOException - { - LSInput input = ls.createLSInput(); - String systemId = is.getSystemId(); - InputStream in = is.getByteStream(); - if (in != null) - { - input.setByteStream(in); - } - else - { - Reader reader = is.getCharacterStream(); - if (reader != null) - { - input.setCharacterStream(reader); - } - else - { - try - { - URL url = new URL(systemId); - input.setByteStream(url.openStream()); - } - catch (MalformedURLException e) - { - // Maybe this is a relative file URL - File cwd = new File(System.getProperty("user.dir")); - URL url = new URL(cwd.toURL(), systemId); - input.setByteStream(url.openStream()); - } - } - } - input.setPublicId(is.getPublicId()); - input.setSystemId(systemId); - input.setEncoding(is.getEncoding()); - try - { - return parser.parse(input); - } - catch (LSException e) - { - Throwable e2 = e.getCause(); - if (e2 instanceof IOException) - throw (IOException) e2; - else - throw e; - } - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java b/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java deleted file mode 100644 index 1e3eaa5..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java +++ /dev/null @@ -1,181 +0,0 @@ -/* DomDocumentBuilderFactory.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.bootstrap.DOMImplementationRegistry; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSParser; - -/** - * Document builder factory that uses a DOM Level 3 Load & Save - * implementation. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomDocumentBuilderFactory - extends DocumentBuilderFactory -{ - - final DOMImplementation impl; - final DOMImplementationLS ls; - private boolean secureProcessing; - - public DomDocumentBuilderFactory() - { - try - { - DOMImplementationRegistry reg = - DOMImplementationRegistry.newInstance(); - impl = reg.getDOMImplementation("LS 3.0"); - if (impl == null) - { - throw new FactoryConfigurationError("no LS implementations found"); - } - ls = (DOMImplementationLS) impl; - } - catch (Exception e) - { - throw new FactoryConfigurationError(e); - } - } - - public DocumentBuilder newDocumentBuilder() - throws ParserConfigurationException - { - LSParser parser = null; - try - { - parser = ls.createLSParser(DOMImplementationLS.MODE_ASYNCHRONOUS, - "http://www.w3.org/TR/REC-xml"); - } - catch (DOMException e) - { - if (e.code == DOMException.NOT_SUPPORTED_ERR) - { - // Fall back to synchronous parser - try - { - parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, - "http://www.w3.org/TR/REC-xml"); - } - catch (DOMException e2) - { - ParserConfigurationException pce = - new ParserConfigurationException(); - pce.initCause(e2); - throw pce; - } - } - else - { - ParserConfigurationException pce = - new ParserConfigurationException(); - pce.initCause(e); - throw pce; - } - } - DOMConfiguration config = parser.getDomConfig(); - setParameter(config, "namespaces", - isNamespaceAware() ? Boolean.TRUE : Boolean.FALSE); - setParameter(config, "element-content-whitespace", - isIgnoringElementContentWhitespace() ? Boolean.FALSE : - Boolean.TRUE); - setParameter(config, "comments", - isIgnoringComments() ? Boolean.FALSE : Boolean.TRUE); - setParameter(config, "expand-entity-references", - isExpandEntityReferences() ? Boolean.TRUE : Boolean.FALSE); - setParameter(config, "coalescing", - isCoalescing() ? Boolean.TRUE : Boolean.FALSE); - setParameter(config, "validating", - isValidating() ? Boolean.TRUE : Boolean.FALSE); - setParameter(config, "xinclude-aware", - isXIncludeAware() ? Boolean.TRUE : Boolean.FALSE); - return new DomDocumentBuilder(impl, ls, parser); - } - - void setParameter(DOMConfiguration config, String name, Object value) - throws ParserConfigurationException - { - if (!config.canSetParameter(name, value)) - { - throw new ParserConfigurationException(name); - } - config.setParameter(name, value); - } - - public Object getAttribute(String name) - { - // TODO - return null; - } - - public void setAttribute(String name, Object value) - { - // TODO - } - - public void setFeature(String name, boolean value) - throws ParserConfigurationException - { - if (name == null) - throw new NullPointerException(); - if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) - { - secureProcessing = true; - return; - } - throw new ParserConfigurationException(name); - } - - public boolean getFeature(String name) - throws ParserConfigurationException - { - if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) - return secureProcessing; - throw new ParserConfigurationException(name); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java b/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java deleted file mode 100644 index 9aab445..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java +++ /dev/null @@ -1,260 +0,0 @@ -/* DomDocumentConfiguration.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.Arrays; -import java.util.List; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMErrorHandler; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMStringList; - -/** - * Document configuration, used to store normalization and other parameters. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomDocumentConfiguration - implements DOMConfiguration, DOMStringList -{ - - private static final List SUPPORTED_PARAMETERS = - Arrays.asList(new String[] { "cdata-sections", - "comments", - "element-content-whitespace", - "entities", - "error-handler", - "namespace-declarations", - "split-cdata-sections", - "infoset"}); - - boolean cdataSections = true; - boolean comments = true; - boolean elementContentWhitespace = true; - boolean entities = true; - DOMErrorHandler errorHandler; - boolean namespaceDeclarations = true; - boolean splitCdataSections = true; - - public void setParameter(String name, Object value) - throws DOMException - { - name = name.toLowerCase(); - if ("cdata-sections".equals(name)) - { - cdataSections = "true".equals(value.toString()); - } - else if ("comments".equals(name)) - { - comments = "true".equals(value.toString()); - } - else if ("element-content-whitespace".equals(name)) - { - elementContentWhitespace = "true".equals(value.toString()); - } - else if ("entities".equals(name)) - { - entities = "true".equals(value.toString()); - } - else if ("error-handler".equals(name)) - { - try - { - errorHandler = (DOMErrorHandler) value; - } - catch (ClassCastException e) - { - throw new DomDOMException(DOMException.TYPE_MISMATCH_ERR, - value.getClass().getName(), null, 0); - } - } - else if ("namespace-declarations".equals(name)) - { - namespaceDeclarations = "true".equals(value.toString()); - } - else if ("split-cdata-sections".equals(name)) - { - comments = "true".equals(value.toString()); - } - else if ("infoset".equals(name)) - { - if ("true".equals(value.toString())) - { - entities = false; - cdataSections = false; - namespaceDeclarations = true; - elementContentWhitespace = true; - comments = true; - } - } - else if (("canonical-form".equals(name) || - "check-character-normalization".equals(name) || - "datatype-normalization".equals(name) || - "normalize-characters".equals(name) || - "validate".equals(name) || - "validate-if-schema".equals(name)) && - "false".equals(value.toString())) - { - // NOOP - } - else if (("namespaces".equals(name) || - "well-formed".equals(name)) && - "true".equals(value.toString())) - { - // NOOP - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, - name, null, 0); - } - } - - public Object getParameter(String name) - throws DOMException - { - name = name.toLowerCase(); - if ("cdata-sections".equals(name)) - { - return cdataSections ? Boolean.TRUE : Boolean.FALSE; - } - else if ("comments".equals(name)) - { - return comments ? Boolean.TRUE : Boolean.FALSE; - } - else if ("element-content-whitespace".equals(name)) - { - return elementContentWhitespace ? Boolean.TRUE : Boolean.FALSE; - } - else if ("entities".equals(name)) - { - return entities ? Boolean.TRUE : Boolean.FALSE; - } - else if ("error-handler".equals(name)) - { - return errorHandler; - } - else if ("namespace-declarations".equals(name)) - { - return namespaceDeclarations ? Boolean.TRUE : Boolean.FALSE; - } - else if ("split-cdata-sections".equals(name)) - { - return comments ? Boolean.TRUE : Boolean.FALSE; - } - else if ("canonical-form".equals(name) || - "check-character-normalization".equals(name) || - "datatype-normalization".equals(name) || - "normalize-characters".equals(name) || - "validate".equals(name) || - "validate-if-schema".equals(name)) - { - return Boolean.FALSE; - } - else if ("namespaces".equals(name) || - "well-formed".equals(name)) - { - return Boolean.TRUE; - } - else if ("infoset".equals(name)) - { - return (entities == false && - cdataSections == false && - namespaceDeclarations == true && - comments == true) ? Boolean.TRUE : Boolean.FALSE; - } - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0); - } - - public boolean canSetParameter(String name, Object value) - { - name = name.toLowerCase(); - if ("error-handler".equals(name)) - { - return (value == null || value instanceof DOMErrorHandler); - } - else if (contains(name)) - { - return true; - } - else if ("canonical-form".equals(name) || - "check-character-normalization".equals(name) || - "datatype-normalization".equals(name) || - "normalize-characters".equals(name) || - "validate".equals(name) || - "validate-if-schema".equals(name)) - { - return "false".equals(value.toString()); - } - else if ("namespaces".equals(name) || - "well-formed".equals(name)) - { - return "true".equals(value.toString()); - } - return false; - } - - public DOMStringList getParameterNames() - { - return this; - } - - public String item(int i) - { - try - { - return (String) SUPPORTED_PARAMETERS.get(i); - } - catch (IndexOutOfBoundsException e) - { - return null; - } - } - - public int getLength() - { - return SUPPORTED_PARAMETERS.size(); - } - - public boolean contains(String str) - { - str = str.toLowerCase(); - return SUPPORTED_PARAMETERS.contains(str); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java b/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java deleted file mode 100644 index 8c4e0db..0000000 --- a/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java +++ /dev/null @@ -1,75 +0,0 @@ -/* DomDocumentFragment.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DocumentFragment; - -/** - * <p> "DocumentFragment" implementation. </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomDocumentFragment - extends DomNode - implements DocumentFragment -{ - - /** - * Constructs a DocumentFragment node associated with the - * specified document. - * - * <p>This constructor should only be invoked by a Document as part of - * its createDocumentFragment functionality, or through a subclass which - * is similarly used in a "Sub-DOM" style layer. - */ - protected DomDocumentFragment(DomDocument owner) - { - super(DOCUMENT_FRAGMENT_NODE, owner); - } - - /** - * <b>DOM L1</b> - * Returns the string "#document-fragment". - */ - final public String getNodeName() - { - return "#document-fragment"; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomElement.java b/libjava/classpath/gnu/xml/dom/DomElement.java deleted file mode 100644 index 4297499..0000000 --- a/libjava/classpath/gnu/xml/dom/DomElement.java +++ /dev/null @@ -1,582 +0,0 @@ -/* DomElement.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.HashSet; -import java.util.Set; -import javax.xml.XMLConstants; - -import org.w3c.dom.Attr; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.TypeInfo; - -/** - * <p> "Element" implementation. - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomElement - extends DomNsNode - implements Element -{ - - /** - * User-defined ID attributes. - * Used by DomAttr.isId and DomDocument.getElementById - */ - Set userIdAttrs; - - // Attributes are VERY expensive in DOM, and not just for - // this implementation. Avoid creating them. - private DomNamedNodeMap attributes; - - // xml:space cache - String xmlSpace = ""; - - /** - * Constructs an Element node associated with the specified document. - * - * <p>This constructor should only be invoked by a Document as part - * of its createElement functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * - * @param owner The document with which this node is associated - * @param namespaceURI Combined with the local part of the name, - * this is used to uniquely identify a type of element - * @param name Name of this element, which may include a prefix - */ - protected DomElement(DomDocument owner, String namespaceURI, String name) - { - super(ELEMENT_NODE, owner, namespaceURI, name); - } - - /** - * <p> - * Constructs an Element node associated with the specified document. - * This constructor should only be invoked by a Document as part - * of its createElement functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * </p> - * <p> - * With this constructor, the prefix and local part are given explicitly - * rather than being computed. This allows them to be explicitly set to - * {@code null} as required by {@link Document#createElement(String)}. - * </p> - * - * @param owner The document with which this node is associated - * @param namespaceURI Combined with the local part of the name, - * this is used to uniquely identify a type of element - * @param name Name of this element, which may include a prefix - * @param prefix the namespace prefix of the name. May be {@code null}. - * @param localName the local part of the name. May be {@code null}. - */ - protected DomElement(DomDocument owner, String namespaceURI, String name, - String prefix, String localName) - { - super(ELEMENT_NODE, owner, namespaceURI, name, prefix, localName); - } - - /** - * <b>DOM L1</b> - * Returns the element's attributes - */ - public NamedNodeMap getAttributes() - { - if (attributes == null) - { - attributes = new DomNamedNodeMap(this, Node.ATTRIBUTE_NODE); - } - return attributes; - } - - /** - * <b>DOM L2></b> - * Returns true iff this is an element node with attributes. - */ - public boolean hasAttributes() - { - return attributes != null && attributes.length != 0; - } - - /** - * Shallow clone of the element, except that associated - * attributes are (deep) cloned. - */ - public Object clone() - { - DomElement node = (DomElement) super.clone(); - - if (attributes != null) - { - node.attributes = new DomNamedNodeMap(node, Node.ATTRIBUTE_NODE); - for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next) - { - node.attributes.setNamedItem(ctx.cloneNode(true), true, true); - } - } - return node; - } - - void setOwner(DomDocument doc) - { - if (attributes != null) - { - for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next) - { - ctx.setOwner(doc); - } - } - super.setOwner(doc); - } - - /** - * Marks this element, its children, and its associated attributes as - * readonly. - */ - public void makeReadonly() - { - super.makeReadonly(); - if (attributes != null) - { - attributes.makeReadonly(); - } - } - - /** - * <b>DOM L1</b> - * Returns the element name (same as getNodeName). - */ - final public String getTagName() - { - return getNodeName(); - } - - /** - * <b>DOM L1</b> - * Returns the value of the specified attribute, or an - * empty string. - */ - public String getAttribute(String name) - { - if ("xml:space" == name) // NB only works on interned string - { - // Use cached value - return xmlSpace; - } - Attr attr = getAttributeNode(name); - return (attr == null) ? "" : attr.getValue(); - } - - /** - * <b>DOM L2</b> - * Returns true if the element has an attribute with the - * specified name (specified or DTD defaulted). - */ - public boolean hasAttribute(String name) - { - return getAttributeNode(name) != null; - } - - /** - * <b>DOM L2</b> - * Returns true if the element has an attribute with the - * specified name (specified or DTD defaulted). - */ - public boolean hasAttributeNS(String namespaceURI, String local) - { - return getAttributeNodeNS(namespaceURI, local) != null; - } - - /** - * <b>DOM L2</b> - * Returns the value of the specified attribute, or an - * empty string. - */ - public String getAttributeNS(String namespaceURI, String local) - { - Attr attr = getAttributeNodeNS(namespaceURI, local); - return (attr == null) ? "" : attr.getValue(); - } - - /** - * <b>DOM L1</b> - * Returns the appropriate attribute node; the name is the - * nodeName property of the attribute. - */ - public Attr getAttributeNode(String name) - { - return (attributes == null) ? null : - (Attr) attributes.getNamedItem(name); - } - - /** - * <b>DOM L2</b> - * Returns the appropriate attribute node; the name combines - * the namespace name and the local part. - */ - public Attr getAttributeNodeNS(String namespace, String localPart) - { - return (attributes == null) ? null : - (Attr) attributes.getNamedItemNS(namespace, localPart); - } - - /** - * <b>DOM L1</b> - * Modifies an existing attribute to have the specified value, - * or creates a new one with that value. The name used is the - * nodeName value. - */ - public void setAttribute(String name, String value) - { - Attr attr = getAttributeNode(name); - if (attr != null) - { - attr.setNodeValue(value); - ((DomAttr) attr).setSpecified(true); - return; - } - attr = owner.createAttribute(name); - attr.setNodeValue(value); - setAttributeNode(attr); - } - - /** - * <b>DOM L2</b> - * Modifies an existing attribute to have the specified value, - * or creates a new one with that value. - */ - public void setAttributeNS(String uri, String aname, String value) - { - if (("xmlns".equals (aname) || aname.startsWith ("xmlns:")) - && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (uri)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "setting xmlns attribute to illegal value", this, 0); - } - - Attr attr = getAttributeNodeNS(uri, aname); - if (attr != null) - { - attr.setNodeValue(value); - return; - } - attr = owner.createAttributeNS(uri, aname); - attr.setNodeValue(value); - setAttributeNodeNS(attr); - } - - /** - * <b>DOM L1</b> - * Stores the specified attribute, optionally overwriting any - * existing one with that name. - */ - public Attr setAttributeNode(Attr attr) - { - return (Attr) getAttributes().setNamedItem(attr); - } - - /** - * <b>DOM L2</b> - * Stores the specified attribute, optionally overwriting any - * existing one with that name. - */ - public Attr setAttributeNodeNS(Attr attr) - { - return (Attr) getAttributes().setNamedItemNS(attr); - } - - /** - * <b>DOM L1</b> - * Removes the appropriate attribute node. - * If there is no such node, this is (bizarrely enough) a NOP so you - * won't see exceptions if your code deletes non-existent attributes. - * - * <p>Note that since there is no portable way for DOM to record - * DTD information, default values for attributes will never be - * provided automatically. - */ - public void removeAttribute(String name) - { - if (attributes == null) - { - return; - } - - try - { - attributes.removeNamedItem(name); - } - catch (DomDOMException e) - { - if (e.code != DOMException.NOT_FOUND_ERR) - { - throw e; - } - } - } - - /** - * <b>DOM L1</b> - * Removes the appropriate attribute node; the name is the - * nodeName property of the attribute. - * - * <p>Note that since there is no portable way for DOM to record - * DTD information, default values for attributes will never be - * provided automatically. - */ - public Attr removeAttributeNode(Attr node) - { - if (attributes == null) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, null, node, 0); - } - return (Attr) attributes.removeNamedItem(node.getNodeName()); - } - - /** - * <b>DOM L2</b> - * Removes the appropriate attribute node; the name combines - * the namespace name and the local part. - * - * <p>Note that since there is no portable way for DOM to record - * DTD information, default values for attributes will never be - * provided automatically. - */ - public void removeAttributeNS(String namespace, String localPart) - { - if (attributes == null) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, localPart, null, 0); - } - attributes.removeNamedItemNS (namespace, localPart); - } - - // DOM Level 3 methods - - public String lookupPrefix(String namespaceURI) - { - if (namespaceURI == null) - { - return null; - } - String namespace = getNamespaceURI(); - if (namespace != null && namespace.equals(namespaceURI)) - { - return getPrefix(); - } - if (attributes != null) - { - for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next) - { - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI - .equals(ctx.getNamespaceURI())) - { - String value = ctx.getNodeValue(); - if (value.equals(namespaceURI)) - { - return ctx.getLocalName(); - } - } - } - } - return super.lookupPrefix(namespaceURI); - } - - public boolean isDefaultNamespace(String namespaceURI) - { - String namespace = getNamespaceURI(); - if (namespace != null && namespace.equals(namespaceURI)) - { - return getPrefix() == null; - } - if (attributes != null) - { - for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next) - { - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI - .equals(ctx.getNamespaceURI())) - { - String qName = ctx.getNodeName(); - return (XMLConstants.XMLNS_ATTRIBUTE.equals(qName)); - } - } - } - return super.isDefaultNamespace(namespaceURI); - } - - public String lookupNamespaceURI(String prefix) - { - String namespace = getNamespaceURI(); - if (namespace != null && equal(prefix, getPrefix())) - { - return namespace; - } - if (attributes != null) - { - for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next) - { - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI - .equals(ctx.getNamespaceURI())) - { - if (prefix == null) - { - if (XMLConstants.XMLNS_ATTRIBUTE.equals(ctx.getNodeName())) - { - return ctx.getNodeValue(); - } - } - else - { - if (prefix.equals(ctx.getLocalName())) - { - return ctx.getNodeValue(); - } - } - } - } - } - return super.lookupNamespaceURI(prefix); - } - - public String getBaseURI() - { - if (attributes != null) - { - Node xmlBase = - attributes.getNamedItemNS(XMLConstants.XML_NS_URI, "base"); - if (xmlBase != null) - { - return xmlBase.getNodeValue(); - } - } - return super.getBaseURI(); - } - - public TypeInfo getSchemaTypeInfo() - { - // DTD implementation - DomDoctype doctype = (DomDoctype) owner.getDoctype(); - if (doctype != null) - { - return doctype.getElementTypeInfo(getNodeName()); - } - // TODO XML Schema implementation - return null; - } - - public void setIdAttribute(String name, boolean isId) - { - NamedNodeMap attrs = getAttributes(); - Attr attr = (Attr) attrs.getNamedItem(name); - setIdAttributeNode(attr, isId); - } - - public void setIdAttributeNode(Attr attr, boolean isId) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - if (attr == null || attr.getOwnerElement() != this) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR); - } - if (isId) - { - if (userIdAttrs == null) - { - userIdAttrs = new HashSet(); - } - userIdAttrs.add(attr); - } - else if (userIdAttrs != null) - { - userIdAttrs.remove(attr); - if (userIdAttrs.isEmpty()) - { - userIdAttrs = null; - } - } - } - - public void setIdAttributeNS(String namespaceURI, String localName, - boolean isId) - { - NamedNodeMap attrs = getAttributes(); - Attr attr = (Attr) attrs.getNamedItemNS(namespaceURI, localName); - setIdAttributeNode(attr, isId); - } - - public boolean isEqualNode(Node arg) - { - if (!super.isEqualNode(arg)) - return false; - getAttributes(); - NamedNodeMap argAttrs = arg.getAttributes(); - int len = argAttrs.getLength(); - if (argAttrs == null || (len != attributes.length)) - return false; - for (int i = 0; i < len; i++) - { - Node argCtx = argAttrs.item(i); - // Don't compare namespace nodes - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI - .equals(argCtx.getNamespaceURI())) - continue; - // Find corresponding attribute node - DomNode ctx = attributes.first; - for (; ctx != null; ctx = ctx.next) - { - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI - .equals(ctx.getNamespaceURI())) - continue; - if (!ctx.isEqualNode(argCtx)) - continue; - break; - } - if (ctx == null) - return false; // not found - } - return true; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomEntity.java b/libjava/classpath/gnu/xml/dom/DomEntity.java deleted file mode 100644 index be44d73..0000000 --- a/libjava/classpath/gnu/xml/dom/DomEntity.java +++ /dev/null @@ -1,146 +0,0 @@ -/* DomEntity.java -- - Copyright (C) 1999,2000,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.Entity; - -/** - * <p> "Entity" implementation. This is a non-core DOM class, supporting the - * "XML" feature. There are two types of entities, neither of which works - * particularly well in this API:</p><dl> - * - * <dt><em>Unparsed Entities</em></dt> - * <dd>Since ENTITY/ENTITIES attributes, the only legal use of unparsed - * entities in XML, can't be detected with DOM, there isn't much point in - * trying to use unparsed entities in DOM applications. (XML Linking is - * working to provide a better version of this functionality.) </dd> - * - * <dt><em>Parsed Entities</em></dt> - * <dd> While the DOM specification permits nodes for parsed entities - * to have a readonly set of children, this is not required and there - * is no portable way to provide such children. <em>This implementation - * currently does not permit children to be added to Entities.</em> - * There are related issues with the use of EntityReference nodes. </dd> - * - * </dl> - * - * <p> In short, <em>avoid using this DOM functionality</em>. - * - * @see DomDoctype - * @see DomEntityReference - * @see DomNotation - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomEntity - extends DomExtern - implements Entity -{ - - private String notation; - - /** - * Constructs an Entity node associated with the specified document, - * with the specified descriptive data. - * - * <p>This constructor should only be invoked by a DomDoctype as part - * of its declareEntity functionality, or through a subclass which is - * similarly used in a "Sub-DOM" style layer. - * - * @param owner The document with which this entity is associated - * @param name Name of this entity - * @param publicId If non-null, provides the entity's PUBLIC identifier - * @param systemId Provides the entity's SYSTEM identifier (URI) - * @param notation If non-null, provides the unparsed entity's notation. - */ - protected DomEntity(DomDocument owner, - String name, - String publicId, - String systemId, - String notation) - { - super(ENTITY_NODE, owner, name, publicId, systemId); - this.notation = notation; - - // NOTE: if notation == null, this is a parsed entity - // which could reasonably be given child nodes ... - makeReadonly(); - } - - /** - * <b>DOM L1</b> - * Returns the NOTATION identifier associated with this entity, if any. - */ - final public String getNotationName() - { - return notation; - } - - // DOM Level 3 methods - - public String getInputEncoding() - { - // TODO - return null; - } - - public String getXmlEncoding() - { - // TODO - return null; - } - - public String getXmlVersion() - { - // TODO - return null; - } - - /** - * The base URI of an external entity is its system ID. - * The base URI of an internal entity is the parent document's base URI. - * @since DOM Level 3 Core - */ - public String getBaseURI() - { - String systemId = getSystemId(); - return (systemId == null) ? owner.getBaseURI() : systemId; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomEntityReference.java b/libjava/classpath/gnu/xml/dom/DomEntityReference.java deleted file mode 100644 index 1fa2ea6..0000000 --- a/libjava/classpath/gnu/xml/dom/DomEntityReference.java +++ /dev/null @@ -1,130 +0,0 @@ -/* DomEntityReference.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DocumentType; -import org.w3c.dom.Entity; -import org.w3c.dom.EntityReference; - -/** - * <p> "EntityReference" implementation (reference to parsed entity). - * This is a non-core DOM class, supporting the "XML" feature. - * It does not represent builtin entities (such as "&amp;") - * or character references, which are always directly expanded in - * DOM trees.</p> - * - * <p> Note that while the DOM specification permits these nodes to have - * a readonly set of children, this is not required. Similarly, it does - * not require a DOM to couple EntityReference nodes with any Entity nodes - * that have the same entity name (and equivalent children). It also - * effectively guarantees that references created directly or indirectly - * through the <em>Document.ImportNode</em> method will not have children. - * The level of functionality you may get is extremely variable. - * - * <p> Also significant is that even at their most functional level, the fact - * that EntityReference children must be readonly has caused significant - * problems when modifying work products held in DOM trees. Other problems - * include issues related to undeclared namespace prefixes (and references - * to the current default namespace) that may be found in the text of such - * parsed entities nodes. These must be contextually bound as part of DOM - * tree construction. When such nodes are moved, the namespace associated - * with a given prefix (or default) may change to be in conflict with the - * namespace bound to the node at creation time. - * - * <p> In short, <em>avoid using this DOM functionality</em>. - * - * @see DomDoctype - * @see DomEntity - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomEntityReference - extends DomNode - implements EntityReference -{ - - private String name; - - /** - * Constructs an EntityReference node associated with the specified - * document. The creator should populate this with whatever contents - * are appropriate, and then mark it as readonly. - * - * <p>This constructor should only be invoked by a Document as part of - * its createEntityReference functionality, or through a subclass which - * is similarly used in a "Sub-DOM" style layer. - * - * @see DomNode#makeReadonly - */ - protected DomEntityReference(DomDocument owner, String name) - { - super(ENTITY_REFERENCE_NODE, owner); - this.name = name; - } - - /** - * Returns the name of the referenced entity. - * @since DOM Level 1 Core - */ - public final String getNodeName() - { - return name; - } - - /** - * The base URI of an entity reference is the base URI where the entity - * declaration occurs. - * @since DOM Level 3 Core - */ - public final String getBaseURI() - { - DocumentType doctype = owner.getDoctype(); - if (doctype == null) - { - return null; - } - Entity entity = (Entity) doctype.getEntities().getNamedItem(name); - if (entity == null) - { - return null; - } - return entity.getBaseURI(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomEvent.java b/libjava/classpath/gnu/xml/dom/DomEvent.java deleted file mode 100644 index 3e9a655..0000000 --- a/libjava/classpath/gnu/xml/dom/DomEvent.java +++ /dev/null @@ -1,351 +0,0 @@ -/* DomEvent.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import gnu.java.lang.CPStringBuilder; - -import org.w3c.dom.Node; - -import org.w3c.dom.events.Event; -import org.w3c.dom.events.EventTarget; -import org.w3c.dom.events.MutationEvent; -import org.w3c.dom.events.UIEvent; - -import org.w3c.dom.views.AbstractView; // used by UIEvent - -/** - * "Event" implementation. Events are - * created (through DocumentEvent interface methods on the document object), - * and are sent to any target node in the document. - * - * <p> Applications may define application specific event subclasses, but - * should otherwise use the <em>DocumentTraversal</em> interface to acquire - * event objects. - * - * @author David Brownell - */ -public class DomEvent - implements Event -{ - - String type; // init - EventTarget target; - EventTarget currentNode; - short eventPhase; - boolean bubbles; // init - boolean cancelable; // init - long timeStamp; // ? - - /** Returns the event's type (name) as initialized */ - public final String getType() - { - return type; - } - - /** - * Returns event's target; delivery of an event is initiated - * by a <em>target.dispatchEvent(event)</em> invocation. - */ - public final EventTarget getTarget() - { - return target; - } - - /** - * Returns the target to which events are currently being - * delivered. When capturing or bubbling, this will not - * be what <em>getTarget</em> returns. - */ - public final EventTarget getCurrentTarget() - { - return currentNode; - } - - /** - * Returns CAPTURING_PHASE, AT_TARGET, or BUBBLING; - * only meaningful within EventListener.handleEvent - */ - public final short getEventPhase() - { - return eventPhase; - } - - /** - * Returns true if the news of the event bubbles to tree tops - * (as specified during initialization). - */ - public final boolean getBubbles() - { - return bubbles; - } - - /** - * Returns true if the default handling may be canceled - * (as specified during initialization). - */ - public final boolean getCancelable() - { - return cancelable; - } - - /** - * Returns the event's timestamp. - */ - public final long getTimeStamp() - { - return timeStamp; - } - - boolean stop; - boolean doDefault; - - /** - * Requests the event no longer be captured or bubbled; only - * listeners on the event target will see the event, if they - * haven't yet been notified. - * - * <p> <em> Avoid using this </em> except for application-specific - * events, for which you the protocol explicitly "blesses" the use - * of this with some event types. Otherwise, you are likely to break - * algorithms which depend on event notification either directly or - * through bubbling or capturing. </p> - * - * <p> Note that this method is not final, specifically to enable - * enforcing of policies about events always propagating. </p> - */ - public void stopPropagation() - { - stop = true; - } - - /** - * Requests that whoever dispatched the event not perform their - * default processing when event delivery completes. Initializes - * event timestamp. - */ - public final void preventDefault() - { - doDefault = false; - } - - /** Initializes basic event state. */ - public void initEvent(String typeArg, - boolean canBubbleArg, - boolean cancelableArg) - { - eventPhase = 0; - type = typeArg; - bubbles = canBubbleArg; - cancelable = cancelableArg; - timeStamp = System.currentTimeMillis(); - } - - /** Constructs, but does not initialize, an event. */ - public DomEvent(String type) - { - this.type = type; - } - - /** - * Returns a basic printable description of the event's type, - * state, and delivery conditions - */ - public String toString() - { - CPStringBuilder buf = new CPStringBuilder("[Event "); - buf.append(type); - switch (eventPhase) - { - case CAPTURING_PHASE: - buf.append(", CAPTURING"); - break; - case AT_TARGET: - buf.append(", AT TARGET"); - break; - case BUBBLING_PHASE: - buf.append(", BUBBLING"); - break; - default: - buf.append(", (inactive)"); - break; - } - if (bubbles && eventPhase != BUBBLING_PHASE) - { - buf.append(", bubbles"); - } - if (cancelable) - { - buf.append(", can cancel"); - } - // were we to provide subclass info, this's where it'd live - buf.append("]"); - return buf.toString(); - } - - /** - * "MutationEvent" implementation. - */ - public static final class DomMutationEvent - extends DomEvent - implements MutationEvent - { - - // package private - Node relatedNode; // init - - private String prevValue; // init - private String newValue; // init - - private String attrName; // init - private short attrChange; // init - - /** Returns any "related" node provided by this type of event */ - public final Node getRelatedNode() - { - return relatedNode; - } - - /** Returns any "previous value" provided by this type of event */ - public final String getPrevValue() - { - return prevValue; - } - - /** Returns any "new value" provided by this type of event */ - public final String getNewValue() - { - return newValue; - } - - /** For attribute change events, returns the attribute's name */ - public final String getAttrName() - { - return attrName; - } - - /** For attribute change events, returns how the attribuet changed */ - public final short getAttrChange() - { - return attrChange; - } - - /** Initializes a mutation event */ - public final void initMutationEvent(String typeArg, - boolean canBubbleArg, - boolean cancelableArg, - Node relatedNodeArg, - String prevValueArg, - String newValueArg, - String attrNameArg, - short attrChangeArg) - { - // super.initEvent is inlined here for speed - // (mutation events are issued on all DOM changes) - eventPhase = 0; - type = typeArg; - bubbles = canBubbleArg; - cancelable = cancelableArg; - timeStamp = System.currentTimeMillis(); - - relatedNode = relatedNodeArg; - prevValue = prevValueArg; - newValue = newValueArg; - attrName = attrNameArg; - attrChange = attrChangeArg; - } - - // clear everything that should be GC-able - void clear() - { - type = null; - target = null; - relatedNode = null; - currentNode = null; - prevValue = newValue = attrName = null; - } - - /** Constructs an uninitialized mutation event. */ - public DomMutationEvent(String type) - { - super(type); - } - - } - - /** - * "UIEvent" implementation. - */ - public static class DomUIEvent - extends DomEvent - implements UIEvent - { - - private AbstractView view; // init - private int detail; // init - - /** Constructs an uninitialized User Interface (UI) event */ - public DomUIEvent (String type) { super (type); } - - public final AbstractView getView () { return view; } - public final int getDetail () { return detail; } - - /** Initializes a UI event */ - public final void initUIEvent(String typeArg, - boolean canBubbleArg, - boolean cancelableArg, - AbstractView viewArg, - int detailArg) - { - super.initEvent(typeArg, canBubbleArg, cancelableArg); - view = viewArg; - detail = detailArg; - } - - } - - /* - - static final class DomMouseEvent extends DomUIEvent - implements MouseEvent - { - // another half dozen state variables/accessors - } - - */ - -} diff --git a/libjava/classpath/gnu/xml/dom/DomExtern.java b/libjava/classpath/gnu/xml/dom/DomExtern.java deleted file mode 100644 index 7f2e55a..0000000 --- a/libjava/classpath/gnu/xml/dom/DomExtern.java +++ /dev/null @@ -1,116 +0,0 @@ -/* DomExtern.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -/** - * <p> Abstract implemention of nodes describing external DTD-related - * objects. This facilitates reusing code for Entity, Notation, and - * DocumentType (really, external subset) nodes. Such support is not - * part of the core DOM; it's for the "XML" feature. </p> - * - * <p> Note that you are strongly advised to avoid using the DOM - * features that take advantage of this class, since (as of L2) none - * of them is defined fully enough to permit full use of the - * XML feature they partially expose. </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public abstract class DomExtern - extends DomNode -{ - - private final String name; - private final String publicId; - private final String systemId; - - /** - * Constructs a node associated with the specified document, - * with the specified descriptive data. - * - * @param owner The document with which this object is associated - * @param name Name of this object - * @param publicId If non-null, provides the entity's PUBLIC identifier - * @param systemId If non-null, provides the entity's SYSTEM identifier - */ - // package private - DomExtern(short nodeType, - DomDocument owner, - String name, - String publicId, - String systemId) - { - super(nodeType, owner); - this.name = name; - this.publicId = publicId; - this.systemId = systemId; - } - - /** - * <b>DOM L1</b> - * Returns the SYSTEM identifier associated with this object, if any. - */ - public final String getSystemId() - { - return systemId; - } - - /** - * <b>DOM L1</b> - * Returns the PUBLIC identifier associated with this object, if any. - */ - public final String getPublicId() - { - return publicId; - } - - /** - * <b>DOM L1</b> - * Returns the object's name. - */ - public final String getNodeName() - { - return name; - } - - public final String getLocalName() - { - return name; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomImpl.java b/libjava/classpath/gnu/xml/dom/DomImpl.java deleted file mode 100644 index 76a63ca..0000000 --- a/libjava/classpath/gnu/xml/dom/DomImpl.java +++ /dev/null @@ -1,277 +0,0 @@ -/* DomImpl.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Element; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSOutput; -import org.w3c.dom.ls.LSParser; -import org.w3c.dom.ls.LSSerializer; -import gnu.xml.dom.html2.DomHTMLImpl; -import gnu.xml.dom.ls.DomLSInput; -import gnu.xml.dom.ls.DomLSOutput; -import gnu.xml.dom.ls.DomLSParser; -import gnu.xml.dom.ls.DomLSSerializer; - -/** - * <p> "DOMImplementation" implementation. </p> - * - * <p> At this writing, the following features are supported: - * "XML" (L1, L2, L3), - * "Events" (L2), "MutationEvents" (L2), "USER-Events" (a conformant extension), - * "HTMLEvents" (L2), "UIEvents" (L2), "Traversal" (L2), "XPath" (L3), - * "LS" (L3) "LS-Async" (L3). - * It is possible to compile the package so it doesn't support some of these - * features (notably, Traversal). - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomImpl - implements DOMImplementation, DOMImplementationLS -{ - - /** - * Constructs a DOMImplementation object which supports - * "XML" and other DOM Level 2 features. - */ - public DomImpl() - { - } - - /** - * <b>DOM L1</b> - * Returns true if the specified feature and version are - * supported. Note that the case of the feature name is ignored. - */ - public boolean hasFeature(String name, String version) - { - if (name.length() == 0) - { - return false; - } - name = name.toLowerCase(); - if (name.charAt(0) == '+') - { - name = name.substring(1); - } - - if ("xml".equals(name) || "core".equals(name)) - { - return (version == null || - "".equals(version) || - "1.0".equals(version) || - "2.0".equals(version) || - "3.0".equals(version)); - - } - else if ("ls".equals(name) || "ls-async".equals(name)) - { - return (version == null || - "".equals(version) || - "3.0".equals(version)); - } - else if ("events".equals(name) - || "mutationevents".equals(name) - || "uievents".equals(name) - // || "mouseevents".equals(name) - || "htmlevents".equals(name)) - { - return (version == null || - "".equals(version) || - "2.0".equals(version)); - - // Extension: "USER-" prefix event types can - // be created and passed through the DOM. - - } - else if ("user-events".equals(name)) - { - return (version == null || - "".equals(version) || - "0.1".equals(version)); - - // NOTE: "hasFeature" for events is here interpreted to - // mean the DOM can manufacture those sorts of events, - // since actually choosing to report the events is more - // often part of the environment or application. It's - // only really an issue for mutation events. - - } - else if (DomNode.reportMutations - && "traversal".equals(name)) - { - return (version == null || - "".equals(version) || - "2.0".equals(version)); - } - else if ("xpath".equals(name)) - { - return (version == null || - "".equals(version) || - "3.0".equals(version)); - } - else if ("html".equals(name) || "xhtml".equals(name)) - { - return (version == null || - "".equals(version) || - "2.0".equals(version)); - } - - // views - // stylesheets - // css, css2 - // range - - return false; - } - - /** - * <b>DOM L2</b> - * Creates and returns a DocumentType, associated with this - * implementation. This DocumentType can have no associated - * objects(notations, entities) until the DocumentType is - * first associated with a document. - * - * <p> Note that there is no implication that this DTD will - * be parsed by the DOM, or ever have contents. Moreover, the - * DocumentType created here can only be added to a document by - * the createDocument method(below). <em>That means that the only - * portable way to create a Document object is to start parsing, - * queue comment and processing instruction (PI) nodes, and then only - * create a DOM Document after <b>(a)</b> it's known if a DocumentType - * object is needed, and <b>(b) the name and namespace of the root - * element is known. Queued comment and PI nodes would then be - * inserted appropriately in the document prologue, both before and - * after the DTD node, and additional attributes assigned to the - * root element.</em> - *(One hopes that the final DOM REC fixes this serious botch.) - */ - public DocumentType createDocumentType(String rootName, - String publicId, - String systemId) - // CR2 deleted internal subset, ensuring DocumentType - // is 100% useless instead of just 90% so. - { - DomDocument.checkNCName(rootName, false); - return new DomDoctype(this, rootName, publicId, systemId, null); - } - - /** - * <b>DOM L2</b> - * Creates and returns a Document, populated only with a root element and - * optionally a document type(if that was provided). - */ - public Document createDocument(String namespaceURI, - String rootName, - DocumentType doctype) - { - Document doc = createDocument(); - Element root = null; - - if (rootName != null) - { - root = doc.createElementNS(namespaceURI, rootName); - if (rootName.startsWith("xmlns:")) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns is reserved", null, 0); - } - } - // Bleech -- L2 seemingly _requires_ omission of xmlns attributes. - if (doctype != null) - { - doc.appendChild(doctype); // handles WRONG_DOCUMENT error - } - if (root != null) - { - doc.appendChild(root); - } - return doc; - } - - protected Document createDocument() - { - return new DomDocument(this); - } - - // DOM Level 3 - - public Object getFeature(String feature, String version) - { - if (hasFeature(feature, version)) - { - if ("html".equalsIgnoreCase(feature) || - "xhtml".equalsIgnoreCase(feature)) - { - return new DomHTMLImpl(); - } - return this; - } - return null; - } - - // -- DOMImplementationLS -- - - public LSParser createLSParser(short mode, String schemaType) - throws DOMException - { - return new DomLSParser(mode, schemaType); - } - - public LSSerializer createLSSerializer() - { - return new DomLSSerializer(); - } - - public LSInput createLSInput() - { - return new DomLSInput(); - } - - public LSOutput createLSOutput() - { - return new DomLSOutput(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomIterator.java b/libjava/classpath/gnu/xml/dom/DomIterator.java deleted file mode 100644 index d5f305c..0000000 --- a/libjava/classpath/gnu/xml/dom/DomIterator.java +++ /dev/null @@ -1,380 +0,0 @@ -/* DomIterator.java -- - Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.events.Event; -import org.w3c.dom.events.EventListener; -import org.w3c.dom.events.EventTarget; -import org.w3c.dom.events.MutationEvent; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; - -/** - * <p> "NodeIterator" implementation, usable with any L2 DOM which - * supports MutationEvents. </p> - * - * @author David Brownell - */ -public final class DomIterator - implements NodeIterator, EventListener -{ - - private Node reference; - private boolean right; - private boolean done; - - private final Node root; - private final int whatToShow; - private final NodeFilter filter; - private final boolean expandEntityReferences; - - /** - * Constructs and initializes an iterator. - */ - protected DomIterator(Node root, - int whatToShow, - NodeFilter filter, - boolean entityReferenceExpansion) - { - if (!root.isSupported("MutationEvents", "2.0")) - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, - "Iterator needs mutation events", root, 0); - } - - this.root = root; - this.whatToShow = whatToShow; - this.filter = filter; - this.expandEntityReferences = entityReferenceExpansion; - - // start condition: going right, seen nothing yet. - reference = null; - right = true; - - EventTarget target = (EventTarget) root; - target.addEventListener("DOMNodeRemoved", this, false); - } - - /** - * <b>DOM L2</b> - * Flags the iterator as done, unregistering its event listener so - * that the iterator can be garbage collected without relying on weak - * references (a "Java 2" feature) in the event subsystem. - */ - public void detach() - { - EventTarget target = (EventTarget) root; - target.removeEventListener("DOMNodeRemoved", this, false); - done = true; - } - - /** - * <b>DOM L2</b> - * Returns the flag controlling whether iteration descends - * through entity references. - */ - public boolean getExpandEntityReferences() - { - return expandEntityReferences; - } - - /** - * <b>DOM L2</b> - * Returns the filter provided during construction. - */ - public NodeFilter getFilter() - { - return filter; - } - - /** - * <b>DOM L2</b> - * Returns the root of the tree this is iterating through. - */ - public Node getRoot() - { - return root; - } - - /** - * <b>DOM L2</b> - * Returns the mask of flags provided during construction. - */ - public int getWhatToShow() - { - return whatToShow; - } - - /** - * <b>DOM L2</b> - * Returns the next node in a forward iteration, masked and filtered. - * Note that the node may be read-only due to entity expansions. - * A null return indicates the iteration is complete, but may still - * be processed backwards. - */ - public Node nextNode() - { - if (done) - { - throw new DomDOMException(DOMException.INVALID_STATE_ERR); - } - right = true; - return walk(true); - } - - /** - * <b>DOM L2</b> - * Returns the next node in a backward iteration, masked and filtered. - * Note that the node may be read-only due to entity expansions. - * A null return indicates the iteration is complete, but may still - * be processed forwards. - */ - public Node previousNode() - { - if (done) - { - throw new DomDOMException(DOMException.INVALID_STATE_ERR); - } - Node previous = reference; - right = false; - walk(false); - return previous; - } - - private boolean shouldShow(Node node) - // raises Runtime exceptions indirectly, via acceptNode() - { - if ((whatToShow & (1 << (node.getNodeType() - 1))) == 0) - { - return false; - } - if (filter == null) - { - return true; - } - return filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT; - } - - // - // scenario: root = 1, sequence = 1 2 ... 3 4 - // forward walk: 1 2 ... 3 4 null - // then backward: 4 3 ... 2 1 null - // - // At the leftmost end, "previous" == null - // At the rightmost end, "previous" == 4 - // - // The current draft spec really seem to make no sense re the - // role of the reference node, so what it says is ignored here. - // - private Node walk(boolean forward) - { - Node here = reference; - - while ((here = successor(here, forward)) != null - && !shouldShow(here)) - { - continue; - } - if (here != null || !forward) - { - reference = here; - } - return here; - } - - private boolean isLeaf(Node here) - { - boolean leaf = !here.hasChildNodes(); - if (!leaf && !expandEntityReferences) - { - leaf = (here.getNodeType() == Node.ENTITY_REFERENCE_NODE); - } - return leaf; - } - - // - // Returns the immediate successor in a forward (or backward) - // document order walk, sans filtering ... except that it knows - // how to stop, returning null when done. This is a depth first - // preorder traversal when run in the forward direction. - // - private Node successor(Node here, boolean forward) - { - Node next; - - // the "leftmost" end is funky - if (here == null) - { - return forward ? root : null; - } - - // - // Forward, this is preorder: children before siblings. - // Backward, it's postorder: we saw the children already. - // - if (forward && !isLeaf(here)) - { - return here.getFirstChild(); - } - - // There's no way up or sideways from the root, so if we - // couldn't move down to a child, there's nowhere to go. - // - if (here == root) - return null; - - // - // Siblings ... if forward, we visit them, if backwards - // we visit their children first. - // - if (forward) - { - if ((next = here.getNextSibling()) != null) - { - return next; - } - } - else if ((next = here.getPreviousSibling()) != null) - { - if (isLeaf(next)) - { - return next; - } - next = next.getLastChild(); - while (!isLeaf(next)) - { - next = next.getLastChild(); - } - return next; - } - - // - // We can't go down or lateral -- it's up, then. The logic is - // the converse of what's above: backwards is easy (the parent - // is next), forwards isn't. - // - next = here.getParentNode(); - if (!forward) - { - return next; - } - - Node temp = null; - while (next != null - && next != root - && (temp = next.getNextSibling()) == null) - { - next = next.getParentNode(); - } - - // If we have exceeded the root node then stop traversing. - if (next == root.getParentNode()) - { - return null; - } - return temp; - } - - /** - * Not for public use. This lets the iterator know when its - * reference node will be removed from the tree, so that a new - * one may be selected. - * - * <p> This version works by watching removal events as they - * bubble up. So, don't prevent them from bubbling. - */ - public void handleEvent(Event e) - { - MutationEvent event; - Node ancestor, removed; - - if (reference == null - || !"DOMNodeRemoved".equals(e.getType()) - || e.getEventPhase() != Event.BUBBLING_PHASE) - { - return; - } - - event = (MutationEvent) e; - removed = (Node) event.getTarget(); - - // See if the removal will cause trouble for this iterator - // by being the reference node or an ancestor of it. - for (ancestor = reference; - ancestor != null && ancestor != root; - ancestor = ancestor.getParentNode()) - { - if (ancestor == removed) - { - break; - } - } - if (ancestor != removed) - { - return; - } - - // OK, it'll cause trouble. We want to make the "next" - // node in our current traversal direction seem right. - // So we pick the nearest node that's not getting removed, - // but go in the _opposite_ direction from our current - // traversal ... so the "next" doesn't skip anything. - Node candidate; - -search: - while ((candidate = walk(!right)) != null) - { - for (ancestor = candidate; - ancestor != null && ancestor != root; - ancestor = ancestor.getParentNode()) - { - if (ancestor == removed) - { - continue search; - } - } - return; - } - - // The current DOM WD talks about a special case here; - // I've not yet seen it. - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java b/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java deleted file mode 100644 index 3dd9575..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java +++ /dev/null @@ -1,90 +0,0 @@ -/* DomNSResolverContext.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.Iterator; -import javax.xml.namespace.NamespaceContext; -import org.w3c.dom.xpath.XPathNSResolver; - -/** - * Namespace content wrapper for an XPathNSResolver. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomNSResolverContext - implements NamespaceContext, Iterator -{ - - final XPathNSResolver resolver; - - DomNSResolverContext(XPathNSResolver resolver) - { - this.resolver = resolver; - } - - public String getNamespaceURI(String prefix) - { - return resolver.lookupNamespaceURI(prefix); - } - - public String getPrefix(String namespaceURI) - { - return null; - } - - public Iterator getPrefixes(String namespaceURI) - { - return this; - } - - public boolean hasNext() - { - return false; - } - - public Object next() - { - return null; - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java b/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java deleted file mode 100644 index 7a76735..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java +++ /dev/null @@ -1,421 +0,0 @@ -/* DomNamedNodeMap.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DOMException; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** - * <p> "NamedNodeMap" implementation. </p> - * Used mostly to hold element attributes, but sometimes also - * to list notations or entities. - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomNamedNodeMap - implements NamedNodeMap -{ - - final DomNode owner; - final short type; - - DomNode first; - int length; - boolean readonly; - - // package private - DomNamedNodeMap(DomNode owner, short type) - { - this.owner = owner; - this.type = type; - } - - /** - * Exposes the internal "readonly" flag. In DOM, all NamedNodeMap - * objects found in a DocumentType object are read-only (after - * they are fully constructed), and those holding attributes of - * a readonly element will also be readonly. - */ - public final boolean isReadonly() - { - return readonly; - } - - /** - * Sets the internal "readonly" flag so the node and its - * children can't be changed. - */ - public void makeReadonly() - { - readonly = true; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - ctx.makeReadonly(); - } - } - - /** - * <b>DOM L1</b> - * Returns the named item from the map, or null; names are just - * the nodeName property. - */ - public Node getNamedItem(String name) - { - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - if (ctx.getNodeName().equals(name)) - { - return ctx; - } - } - return null; - } - - /** - * <b>DOM L2</b> - * Returns the named item from the map, or null; names are the - * localName and namespaceURI properties, ignoring any prefix. - */ - public Node getNamedItemNS(String namespaceURI, String localName) - { - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - String name = ctx.getLocalName(); - if ((localName == null && name == null) || - (localName != null && localName.equals(name))) - { - String uri = ctx.getNamespaceURI(); - if ("".equals(uri)) - { - uri = null; - } - if ((namespaceURI == null && uri == null) || - (namespaceURI != null && namespaceURI.equals(uri))) - { - return ctx; - } - } - } - return null; - } - - /** - * <b>DOM L1</b> - * Stores the named item into the map, optionally overwriting - * any existing node with that name. The name used is just - * the nodeName attribute. - */ - public Node setNamedItem(Node arg) - { - return setNamedItem(arg, false, false); - } - - /** - * <b>DOM L2</b> - * Stores the named item into the map, optionally overwriting - * any existing node with that fully qualified name. The name - * used incorporates the localName and namespaceURI properties, - * and ignores any prefix. - */ - public Node setNamedItemNS(Node arg) - { - return setNamedItem(arg, true, false); - } - - Node setNamedItem(Node arg, boolean ns, boolean cloning) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - - DomNode node = (DomNode) arg; - if (!cloning && node.owner != owner.owner) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR); - } - if (node.nodeType != type) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR); - } - if (node.nodeType == Node.ATTRIBUTE_NODE) - { - DomNode element = node.parent; - if (element != null && element != owner) - { - throw new DomDOMException(DOMException.INUSE_ATTRIBUTE_ERR); - } - node.parent = owner; - node.depth = owner.depth + 1; - } - - String nodeName = node.getNodeName(); - String localName = ns ? node.getLocalName() : null; - String namespaceURI = ns ? node.getNamespaceURI() : null; - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - - // maybe attribute ADDITION events (?) - DomNode last = null; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - boolean test = false; - if (ns) - { - String tln = ctx.getLocalName(); - if (tln == null) - { - tln = ctx.getNodeName(); - } - if (tln.equals(localName)) - { - String tu = ctx.getNamespaceURI(); - if ((tu == null && namespaceURI == null) || - (tu != null && tu.equals(namespaceURI))) - { - test = true; - } - } - } - else - { - test = ctx.getNodeName().equals(nodeName); - } - if (test) - { - // replace - node.previous = ctx.previous; - node.next = ctx.next; - if (ctx.previous != null) - { - ctx.previous.next = node; - } - if (ctx.next != null) - { - ctx.next.previous = node; - } - if (first == ctx) - { - first = node; - } - reparent(node, nodeName, ctx.index); - ctx.parent = null; - ctx.next = null; - ctx.previous = null; - ctx.setDepth(0); - ctx.index = 0; - return ctx; - } - last = ctx; - } - // append - if (last != null) - { - last.next = node; - node.previous = last; - } - else - { - first = node; - } - length++; - reparent(node, nodeName, 0); - return null; - } - - void reparent(DomNode node, String nodeName, int i) - { - node.parent = owner; - node.setDepth(owner.depth + 1); - // index renumbering - for (DomNode ctx = node; ctx != null; ctx = ctx.next) - { - ctx.index = i++; - } - // cache xml:space - boolean xmlSpace = "xml:space".equals(nodeName); - if (xmlSpace && owner instanceof DomElement) - { - ((DomElement) owner).xmlSpace = node.getNodeValue(); - } - } - - /** - * <b>DOM L1</b> - * Removes the named item from the map, or reports an exception; - * names are just the nodeName property. - */ - public Node removeNamedItem(String name) - { - return removeNamedItem(null, name, false); - } - - /** - * <b>DOM L2</b> - * Removes the named item from the map, or reports an exception; - * names are the localName and namespaceURI properties. - */ - public Node removeNamedItemNS(String namespaceURI, String localName) - { - return removeNamedItem(namespaceURI, localName, true); - } - - Node removeNamedItem(String uri, String name, boolean ns) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - - // report attribute REMOVAL event? - - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - boolean test = false; - String nodeName = ctx.getNodeName(); - if (ns) - { - String tln = ctx.getLocalName(); - if (name != null && name.equals(tln)) - { - String tu = ctx.getNamespaceURI(); - if ((tu == null && uri == null) || - (tu != null && tu.equals(uri))) - { - test = true; - } - } - } - else - { - test = nodeName.equals(name); - } - if (test) - { - // uncache xml:space - boolean xmlSpace = "xml:space".equals(nodeName); - if (xmlSpace && owner instanceof DomElement) - { - ((DomElement) owner).xmlSpace = ""; - } - // is this a default attribute? - if (ctx.nodeType == Node.ATTRIBUTE_NODE) - { - String def = getDefaultValue(ctx.getNodeName()); - if (def != null) - { - ctx.setNodeValue(def); - ((DomAttr) ctx).setSpecified(false); - return null; - } - } - // remove - if (ctx == first) - { - first = ctx.next; - } - if (ctx.previous != null) - { - ctx.previous.next = ctx.next; - } - if (ctx.next != null) - { - ctx.next.previous = ctx.previous; - } - length--; - ctx.previous = null; - ctx.next = null; - ctx.parent = null; - ctx.setDepth(0); - ctx.index = 0; - return ctx; - } - } - throw new DomDOMException(DOMException.NOT_FOUND_ERR); - } - - String getDefaultValue(String name) - { - DomDoctype doctype = (DomDoctype) owner.owner.getDoctype(); - if (doctype == null) - { - return null; - } - DTDAttributeTypeInfo info = - doctype.getAttributeTypeInfo(owner.getNodeName(), name); - if (info == null) - { - return null; - } - return info.value; - } - - /** - * <b>DOM L1</b> - * Returns the indexed item from the map, or null. - */ - public Node item(int index) - { - DomNode ctx = first; - int count = 0; - while (ctx != null && count < index) - { - ctx = ctx.next; - count++; - } - return ctx; - } - - /** - * <b>DOM L1</b> - * Returns the length of the map. - */ - public int getLength() - { - return length; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNode.java b/libjava/classpath/gnu/xml/dom/DomNode.java deleted file mode 100644 index 879baaa..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNode.java +++ /dev/null @@ -1,2222 +0,0 @@ -/* DomNode.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import gnu.java.lang.CPStringBuilder; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; - -import org.w3c.dom.Document; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.w3c.dom.UserDataHandler; -import org.w3c.dom.events.DocumentEvent; -import org.w3c.dom.events.Event; -import org.w3c.dom.events.EventException; -import org.w3c.dom.events.EventListener; -import org.w3c.dom.events.EventTarget; -import org.w3c.dom.events.MutationEvent; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; - -/** - * <p> "Node", "EventTarget", and "DocumentEvent" implementation. - * This provides most of the core DOM functionality; only more - * specialized features are provided by subclasses. Those subclasses may - * have some particular constraints they must implement, by overriding - * methods defined here. Such constraints are noted here in the method - * documentation. </p> - * - * <p> Note that you can create events with type names prefixed with "USER-", - * and pass them through this DOM. This lets you use the DOM event scheme - * for application specific purposes, although you must use a predefined event - * structure (such as MutationEvent) to pass data along with those events. - * Test for existence of this feature with the "USER-Events" DOM feature - * name.</p> - * - * <p> Other kinds of events you can send include the "html" events, - * like "load", "unload", "abort", "error", and "blur"; and the mutation - * events. If this DOM has been compiled with mutation event support - * enabled, it will send mutation events when you change parts of the - * tree; otherwise you may create and send such events yourself, but - * they won't be generated by the DOM itself. </p> - * - * <p> Note that there is a namespace-aware name comparison method, - * <em>nameAndTypeEquals</em>, which compares the names (and types) of - * two nodes in conformance with the "Namespaces in XML" specification. - * While mostly intended for use with elements and attributes, this should - * also be helpful for ProcessingInstruction nodes and some others which - * do not have namespace URIs. - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public abstract class DomNode - implements Node, NodeList, EventTarget, DocumentEvent, Cloneable, Comparable -{ - - // package private - //final static String xmlNamespace = "http://www.w3.org/XML/1998/namespace"; - //final static String xmlnsURI = "http://www.w3.org/2000/xmlns/"; - - // tunable - // NKIDS_* affects arrays of children (which grow) - // (currently) fixed size: - // ANCESTORS_* is for event capture/bubbling, # ancestors - // NOTIFICATIONS_* is for per-node event delivery, # events - private static final int NKIDS_DELTA = 8; - private static final int ANCESTORS_INIT = 20; - private static final int NOTIFICATIONS_INIT = 10; - - // tunable: enable mutation events or not? Enabling it costs about - // 10-15% in DOM construction time, last time it was measured. - - // package private !!! - static final boolean reportMutations = true; - - // locking protocol changeable only within this class - private static final Object lockNode = new Object(); - - // NON-FINAL class data - - // Optimize event dispatch by not allocating memory each time - private static boolean dispatchDataLock; - private static DomNode[] ancestors = new DomNode[ANCESTORS_INIT]; - private static ListenerRecord[] notificationSet - = new ListenerRecord[NOTIFICATIONS_INIT]; - - // Ditto for the (most common) event object itself! - private static boolean eventDataLock; - private static DomEvent.DomMutationEvent mutationEvent - = new DomEvent.DomMutationEvent(null); - - // - // PER-INSTANCE DATA - // - - DomDocument owner; - DomNode parent; // parent node; - DomNode previous; // previous sibling node - DomNode next; // next sibling node - DomNode first; // first child node - DomNode last; // last child node - int index; // index of this node in its parent's children - int depth; // depth of the node in the document - int length; // number of children - final short nodeType; - - // Bleech ... "package private" so a builder can populate entity refs. - // writable during construction. DOM spec is nasty. - boolean readonly; - - // event registrations - private HashSet listeners; - private int nListeners; - - // DOM Level 3 userData dictionary. - private HashMap userData; - private HashMap userDataHandlers; - - // - // Some of the methods here are declared 'final' because - // knowledge about their implementation is built into this - // class -- for both integrity and performance. - // - - /** - * Reduces space utilization for this node. - */ - public void compact() - { - } - - /** - * Constructs a node and associates it with its owner. Only - * Document and DocumentType nodes may be created with no owner, - * and DocumentType nodes get an owner as soon as they are - * associated with a document. - */ - protected DomNode(short nodeType, DomDocument owner) - { - this.nodeType = nodeType; - - if (owner == null) - { - // DOM calls never go down this path - if (nodeType != DOCUMENT_NODE && nodeType != DOCUMENT_TYPE_NODE) - { - throw new IllegalArgumentException ("no owner!"); - } - } - this.owner = owner; - this.listeners = new HashSet(); - } - - - /** - * <b>DOM L1</b> - * Returns null; Element subclasses must override this method. - */ - public NamedNodeMap getAttributes() - { - return null; - } - - /** - * <b>DOM L2></b> - * Returns true iff this is an element node with attributes. - */ - public boolean hasAttributes() - { - return false; - } - - /** - * <b>DOM L1</b> - * Returns a list, possibly empty, of the children of this node. - * In this implementation, to conserve memory, nodes are the same - * as their list of children. This can have ramifications for - * subclasses, which may need to provide their own getLength method - * for reasons unrelated to the NodeList method of the same name. - */ - public NodeList getChildNodes() - { - return this; - } - - /** - * <b>DOM L1</b> - * Returns the first child of this node, or null if there are none. - */ - public Node getFirstChild() - { - return first; - } - - /** - * <b>DOM L1</b> - * Returns the last child of this node, or null if there are none. - */ - public Node getLastChild() - { - return last; - } - - /** - * <b>DOM L1</b> - * Returns true if this node has children. - */ - public boolean hasChildNodes() - { - return length != 0; - } - - - /** - * Exposes the internal "readonly" flag. In DOM, children of - * entities and entity references are readonly, as are the - * objects associated with DocumentType objets. - */ - public final boolean isReadonly() - { - return readonly; - } - - /** - * Sets the internal "readonly" flag so this subtree can't be changed. - * Subclasses need to override this method for any associated content - * that's not a child node, such as an element's attributes or the - * (few) declarations associated with a DocumentType. - */ - public void makeReadonly() - { - readonly = true; - for (DomNode child = first; child != null; child = child.next) - { - child.makeReadonly(); - } - } - - /** - * Used to adopt a node to a new document. - */ - void setOwner(DomDocument doc) - { - this.owner = doc; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - ctx.setOwner(doc); - } - } - - // just checks the node for inclusion -- may be called many - // times (docfrag) before anything is allowed to change - private void checkMisc(DomNode child) - { - if (readonly && !owner.building) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, - null, this, 0); - } - for (DomNode ctx = this; ctx != null; ctx = ctx.parent) - { - if (child == ctx) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, - "can't make ancestor into a child", - this, 0); - } - } - - DomDocument owner = (nodeType == DOCUMENT_NODE) ? (DomDocument) this : - this.owner; - DomDocument childOwner = child.owner; - short childNodeType = child.nodeType; - - if (childOwner != owner) - { - // new in DOM L2, this case -- patch it up later, in reparent() - if (!(childNodeType == DOCUMENT_TYPE_NODE && childOwner == null)) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, child, 0); - } - } - - // enforce various structural constraints - switch (nodeType) - { - case DOCUMENT_NODE: - switch (childNodeType) - { - case ELEMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - case COMMENT_NODE: - case DOCUMENT_TYPE_NODE: - return; - } - break; - - case ATTRIBUTE_NODE: - switch (childNodeType) - { - case TEXT_NODE: - case ENTITY_REFERENCE_NODE: - return; - } - break; - - case DOCUMENT_FRAGMENT_NODE: - case ENTITY_REFERENCE_NODE: - case ELEMENT_NODE: - case ENTITY_NODE: - switch (childNodeType) - { - case ELEMENT_NODE: - case TEXT_NODE: - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - case CDATA_SECTION_NODE: - case ENTITY_REFERENCE_NODE: - return; - } - break; - case DOCUMENT_TYPE_NODE: - if (!owner.building) - break; - switch (childNodeType) - { - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - return; - } - break; - } - if (owner.checkingWellformedness) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, - "can't append " + - nodeTypeToString(childNodeType) + - " to node of type " + - nodeTypeToString(nodeType), - this, 0); - } - } - - // Here's hoping a good optimizer will detect the case when the - // next several methods are never called, and won't allocate - // object code space of any kind. (Case: not reporting any - // mutation events. We can also remove some static variables - // listed above.) - - private void insertionEvent(DomEvent.DomMutationEvent event, - DomNode target) - { - if (owner == null || owner.building) - { - return; - } - boolean doFree = false; - - if (event == null) - { - event = getMutationEvent(); - } - if (event != null) - { - doFree = true; - } - else - { - event = new DomEvent.DomMutationEvent(null); - } - event.initMutationEvent("DOMNodeInserted", - true /* bubbles */, false /* nocancel */, - this /* related */, null, null, null, (short) 0); - target.dispatchEvent(event); - - // XXX should really visit every descendant of 'target' - // and sent a DOMNodeInsertedIntoDocument event to it... - // bleech, there's no way to keep that acceptably fast. - - if (doFree) - { - event.target = null; - event.relatedNode = null; - event.currentNode = null; - eventDataLock = false; - } // else we created work for the GC - } - - private void removalEvent(DomEvent.DomMutationEvent event, - DomNode target) - { - if (owner == null || owner.building) - { - return; - } - boolean doFree = false; - - if (event == null) - { - event = getMutationEvent(); - } - if (event != null) - { - doFree = true; - } - else - { - event = new DomEvent.DomMutationEvent(null); - } - event.initMutationEvent("DOMNodeRemoved", - true /* bubbles */, false /* nocancel */, - this /* related */, null, null, null, (short) 0); - target.dispatchEvent(event); - - // XXX should really visit every descendant of 'target' - // and sent a DOMNodeRemovedFromDocument event to it... - // bleech, there's no way to keep that acceptably fast. - - event.target = null; - event.relatedNode = null; - event.currentNode = null; - if (doFree) - { - eventDataLock = false; - } - // else we created more work for the GC - } - - // - // Avoid creating lots of memory management work, by using a simple - // allocation strategy for the mutation event objects that get used - // at least once per tree modification. We can't use stack allocation, - // so we do the next simplest thing -- more or less, static allocation. - // Concurrent notifications should be rare, anyway. - // - // Returns the preallocated object, which needs to be carefully freed, - // or null to indicate the caller needs to allocate their own. - // - static private DomEvent.DomMutationEvent getMutationEvent() - { - synchronized (lockNode) - { - if (eventDataLock) - { - return null; - } - eventDataLock = true; - return mutationEvent; - } - } - - // NOTE: this is manually inlined in the insertion - // and removal event methods above; change in sync. - static private void freeMutationEvent() - { - // clear fields to enable GC - mutationEvent.clear(); - eventDataLock = false; - } - - void setDepth(int depth) - { - this.depth = depth; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - ctx.setDepth(depth + 1); - } - } - - /** - * <b>DOM L1</b> - * Appends the specified node to this node's list of children. - * Document subclasses must override this to enforce the restrictions - * that there be only one element and document type child. - * - * <p> Causes a DOMNodeInserted mutation event to be reported. - * Will first cause a DOMNodeRemoved event to be reported if the - * parameter already has a parent. If the new child is a document - * fragment node, both events will be reported for each child of - * the fragment; the order in which children are removed and - * inserted is implementation-specific. - * - * <p> If this DOM has been compiled without mutation event support, - * these events will not be reported. - */ - public Node appendChild(Node newChild) - { - try - { - DomNode child = (DomNode) newChild; - - if (child.nodeType == DOCUMENT_FRAGMENT_NODE) - { - // Append all nodes in the fragment to this node - for (DomNode ctx = child.first; ctx != null; ctx = ctx.next) - { - checkMisc(ctx); - } - for (DomNode ctx = child.first; ctx != null; ) - { - DomNode ctxNext = ctx.next; - appendChild(ctx); - ctx = ctxNext; - } - } - else - { - checkMisc(child); - if (child.parent != null) - { - child.parent.removeChild(child); - } - child.parent = this; - child.index = length++; - child.setDepth(depth + 1); - child.next = null; - if (last == null) - { - first = child; - child.previous = null; - } - else - { - last.next = child; - child.previous = last; - } - last = child; - - if (reportMutations) - { - insertionEvent(null, child); - } - } - - return child; - } - catch (ClassCastException e) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, newChild, 0); - } - } - - /** - * <b>DOM L1</b> - * Inserts the specified node in this node's list of children. - * Document subclasses must override this to enforce the restrictions - * that there be only one element and document type child. - * - * <p> Causes a DOMNodeInserted mutation event to be reported. Will - * first cause a DOMNodeRemoved event to be reported if the newChild - * parameter already has a parent. If the new child is a document - * fragment node, both events will be reported for each child of - * the fragment; the order in which children are removed and inserted - * is implementation-specific. - * - * <p> If this DOM has been compiled without mutation event support, - * these events will not be reported. - */ - public Node insertBefore(Node newChild, Node refChild) - { - if (refChild == null) - { - return appendChild(newChild); - } - - try - { - DomNode child = (DomNode) newChild; - DomNode ref = (DomNode) refChild; - - if (child.nodeType == DOCUMENT_FRAGMENT_NODE) - { - // Append all nodes in the fragment to this node - for (DomNode ctx = child.first; ctx != null; ctx = ctx.next) - { - checkMisc(ctx); - } - for (DomNode ctx = child.first; ctx != null; ) - { - DomNode ctxNext = ctx.next; - insertBefore(ctx, ref); - ctx = ctxNext; - } - } - else - { - checkMisc(child); - if (ref == null || ref.parent != this) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, - null, ref, 0); - } - if (ref == child) - { - throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, - "can't insert node before itself", - ref, 0); - } - - if (child.parent != null) - { - child.parent.removeChild(child); - } - child.parent = this; - int i = ref.index; - child.setDepth(depth + 1); - child.next = ref; - if (ref.previous != null) - { - ref.previous.next = child; - } - child.previous = ref.previous; - ref.previous = child; - if (first == ref) - { - first = child; - } - // index renumbering - for (DomNode ctx = child; ctx != null; ctx = ctx.next) - { - ctx.index = i++; - } - - if (reportMutations) - { - insertionEvent(null, child); - } - length++; - } - - return child; - } - catch (ClassCastException e) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, newChild, 0); - } - } - - /** - * <b>DOM L1</b> - * Replaces the specified node in this node's list of children. - * Document subclasses must override this to test the restrictions - * that there be only one element and document type child. - * - * <p> Causes DOMNodeRemoved and DOMNodeInserted mutation event to be - * reported. Will cause another DOMNodeRemoved event to be reported if - * the newChild parameter already has a parent. These events may be - * delivered in any order, except that the event reporting removal - * from such an existing parent will always be delivered before the - * event reporting its re-insertion as a child of some other node. - * The order in which children are removed and inserted is implementation - * specific. - * - * <p> If your application needs to depend on the in which those removal - * and insertion events are delivered, don't use this API. Instead, - * invoke the removeChild and insertBefore methods directly, to guarantee - * a specific delivery order. Similarly, don't use document fragments, - * Otherwise your application code may not work on a DOM which implements - * this method differently. - * - * <p> If this DOM has been compiled without mutation event support, - * these events will not be reported. - */ - public Node replaceChild(Node newChild, Node refChild) - { - try - { - DomNode child = (DomNode) newChild; - DomNode ref = (DomNode) refChild; - - DomEvent.DomMutationEvent event = getMutationEvent(); - boolean doFree = (event != null); - - if (child.nodeType == DOCUMENT_FRAGMENT_NODE) - { - // Append all nodes in the fragment to this node - for (DomNode ctx = child.first; ctx != null; ctx = ctx.next) - { - checkMisc(ctx); - } - if (ref == null || ref.parent != this) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, - null, ref, 0); - } - - if (reportMutations) - { - removalEvent(event, ref); - } - length--; - length += child.length; - - if (child.length == 0) - { - // Removal - if (ref.previous != null) - { - ref.previous.next = ref.next; - } - if (ref.next != null) - { - ref.next.previous = ref.previous; - } - if (first == ref) - { - first = ref.next; - } - if (last == ref) - { - last = ref.previous; - } - } - else - { - int i = ref.index; - for (DomNode ctx = child.first; ctx != null; ctx = ctx.next) - { - // Insertion - ctx.parent = this; - ctx.index = i++; - ctx.setDepth(ref.depth); - if (ctx == child.first) - { - ctx.previous = ref.previous; - } - if (ctx == child.last) - { - ctx.next = ref.next; - } - } - if (first == ref) - { - first = child.first; - } - if (last == ref) - { - last = child.last; - } - } - } - else - { - checkMisc(child); - if (ref == null || ref.parent != this) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, - null, ref, 0); - } - - if (reportMutations) - { - removalEvent(event, ref); - } - - if (child.parent != null) - { - child.parent.removeChild(child); - } - child.parent = this; - child.index = ref.index; - child.setDepth(ref.depth); - if (ref.previous != null) - { - ref.previous.next = child; - } - child.previous = ref.previous; - if (ref.next != null) - { - ref.next.previous = child; - } - child.next = ref.next; - if (first == ref) - { - first = child; - } - if (last == ref) - { - last = child; - } - - if (reportMutations) - { - insertionEvent(event, child); - } - if (doFree) - { - freeMutationEvent(); - } - } - ref.parent = null; - ref.index = 0; - ref.setDepth(0); - ref.previous = null; - ref.next = null; - - return ref; - } - catch (ClassCastException e) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, newChild, 0); - } - } - - /** - * <b>DOM L1</b> - * Removes the specified child from this node's list of children, - * or else reports an exception. - * - * <p> Causes a DOMNodeRemoved mutation event to be reported. - * - * <p> If this DOM has been compiled without mutation event support, - * these events will not be reported. - */ - public Node removeChild(Node refChild) - { - try - { - DomNode ref = (DomNode) refChild; - - if (ref == null || ref.parent != this) - { - throw new DomDOMException(DOMException.NOT_FOUND_ERR, - null, ref, 0); - } - if (readonly && !owner.building) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, - null, this, 0); - } - - for (DomNode child = first; child != null; child = child.next) - { - if (child == ref) - { - if (reportMutations) - { - removalEvent(null, child); - } - - length--; - if (ref.previous != null) - { - ref.previous.next = ref.next; - } - if (ref.next != null) - { - ref.next.previous = ref.previous; - } - if (first == ref) - { - first = ref.next; - } - if (last == ref) - { - last = ref.previous; - } - // renumber indices - int i = 0; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - ctx.index = i++; - } - ref.parent = null; - ref.setDepth(0); - ref.index = 0; - ref.previous = null; - ref.next = null; - - return ref; - } - } - throw new DomDOMException(DOMException.NOT_FOUND_ERR, - "that's no child of mine", refChild, 0); - } - catch (ClassCastException e) - { - throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, - null, refChild, 0); - } - } - - /** - * <b>DOM L1 (NodeList)</b> - * Returns the item with the specified index in this NodeList, - * else null. - */ - public Node item(int index) - { - DomNode child = first; - int count = 0; - while (child != null && count < index) - { - child = child.next; - count++; - } - return child; - } - - /** - * <b>DOM L1 (NodeList)</b> - * Returns the number of elements in this NodeList. - * (Note that many interfaces have a "Length" property, not just - * NodeList, and if a node subtype must implement one of those, - * it will also need to override getChildNodes.) - */ - public int getLength() - { - return length; - } - - /** - * Minimize extra space consumed by this node to hold children and event - * listeners. - */ - public void trimToSize() - { - } - - /** - * <b>DOM L1</b> - * Returns the previous sibling, if one is known. - */ - public Node getNextSibling() - { - return next; - } - - /** - * <b>DOM L1</b> - * Returns the previous sibling, if one is known. - */ - public Node getPreviousSibling() - { - return previous; - } - - /** - * <b>DOM L1</b> - * Returns the parent node, if one is known. - */ - public Node getParentNode() - { - return parent; - } - - /** - * <b>DOM L2</b> - * Consults the DOM implementation to determine if the requested - * feature is supported. DocumentType subclasses must override - * this method, and associate themselves directly with the - * DOMImplementation node used. (This method relies on being able - * to access the DOMImplementation from the owner document, but - * DocumentType nodes can be created without an owner.) - */ - public boolean isSupported(String feature, String version) - { - Document doc = owner; - DOMImplementation impl = null; - - if (doc == null && nodeType == DOCUMENT_NODE) - { - doc = (Document) this; - } - - if (doc == null) - { - // possible for DocumentType - throw new IllegalStateException ("unbound ownerDocument"); - } - - impl = doc.getImplementation(); - return impl.hasFeature(feature, version); - } - - /** - * <b>DOM L1 (modified in L2)</b> - * Returns the owner document. This is only null for Document nodes, - * and (new in L2) for DocumentType nodes which have not yet been - * associated with the rest of their document. - */ - final public Document getOwnerDocument() - { - return owner; - } - - /** - * <b>DOM L1</b> - * Does nothing; this must be overridden (along with the - * getNodeValue method) for nodes with a non-null defined value. - */ - public void setNodeValue(String value) - { - } - - /** - * <b>DOM L1</b> - * Returns null; this must be overridden for nodes types with - * a defined value, along with the setNodeValue method. - */ - public String getNodeValue() - { - return null; - } - - /** This forces GCJ compatibility. - * Without this method GCJ is unable to compile to byte code. - */ - public final short getNodeType() - { - return nodeType; - } - - /** This forces GCJ compatibility. - * Without this method GCJ seems unable to natively compile GNUJAXP. - */ - public abstract String getNodeName(); - - /** - * <b>DOM L2</b> - * Does nothing; this must be overridden (along with the - * getPrefix method) for element and attribute nodes. - */ - public void setPrefix(String prefix) - { - } - - /** - * <b>DOM L2</b> - * Returns null; this must be overridden for element and - * attribute nodes. - */ - public String getPrefix() - { - return null; - } - - /** - * <b>DOM L2</b> - * Returns null; this must be overridden for element and - * attribute nodes. - */ - public String getNamespaceURI() - { - return null; - } - - /** - * <b>DOM L2</b> - * Returns the node name; this must be overridden for element and - * attribute nodes. - */ - public String getLocalName() - { - return null; - } - - /** - * <b>DOM L1</b> - * Returns a clone of this node which optionally includes cloned - * versions of child nodes. Clones are always mutable, except for - * entity reference nodes. - */ - public Node cloneNode(boolean deep) - { - if (deep) - { - return cloneNodeDeepInternal(true, null); - } - - DomNode node = (DomNode) clone(); - if (nodeType == ENTITY_REFERENCE_NODE) - { - node.makeReadonly(); - } - notifyUserDataHandlers(UserDataHandler.NODE_CLONED, this, node); - return node; - } - - /** - * Returns a deep clone of this node. - */ - private DomNode cloneNodeDeepInternal(boolean root, DomDocument doc) - { - DomNode node = (DomNode) clone(); - boolean building = false; // Never used unless root is true - if (root) - { - doc = (nodeType == DOCUMENT_NODE) ? (DomDocument) node : node.owner; - building = doc.building; - doc.building = true; // Permit certain structural rules - } - node.owner = doc; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - DomNode newChild = ctx.cloneNodeDeepInternal(false, doc); - node.appendChild(newChild); - } - if (nodeType == ENTITY_REFERENCE_NODE) - { - node.makeReadonly(); - } - if (root) - { - doc.building = building; - } - notifyUserDataHandlers(UserDataHandler.NODE_CLONED, this, node); - return node; - } - - void notifyUserDataHandlers(short op, Node src, Node dst) - { - if (userDataHandlers != null) - { - for (Iterator i = userDataHandlers.entrySet().iterator(); i.hasNext(); ) - { - Map.Entry entry = (Map.Entry) i.next(); - String key = (String) entry.getKey(); - UserDataHandler handler = (UserDataHandler) entry.getValue(); - Object data = userData.get(key); - handler.handle(op, key, data, src, dst); - } - } - } - - /** - * Clones this node; roughly equivalent to cloneNode(false). - * Element subclasses must provide a new implementation which - * invokes this method to handle the basics, and then arranges - * to clone any element attributes directly. Attribute subclasses - * must make similar arrangements, ensuring that existing ties to - * elements are broken by cloning. - */ - public Object clone() - { - try - { - DomNode node = (DomNode) super.clone(); - - node.parent = null; - node.depth = 0; - node.index = 0; - node.length = 0; - node.first = null; - node.last = null; - node.previous = null; - node.next = null; - - node.readonly = false; - node.listeners = new HashSet(); - node.nListeners = 0; - return node; - - } - catch (CloneNotSupportedException x) - { - throw new Error("clone didn't work"); - } - } - - // the elements-by-tagname stuff is needed for both - // elements and documents ... this is in lieu of a - // common base class between Node and NodeNS. - - /** - * <b>DOM L1</b> - * Creates a NodeList giving array-style access to elements with - * the specified name. Access is fastest if indices change by - * small values, and the DOM is not modified. - */ - public NodeList getElementsByTagName(String tag) - { - return new ShadowList(null, tag); - } - - /** - * <b>DOM L2</b> - * Creates a NodeList giving array-style access to elements with - * the specified namespace and local name. Access is fastest if - * indices change by small values, and the DOM is not modified. - */ - public NodeList getElementsByTagNameNS(String namespace, String local) - { - return new ShadowList(namespace, local); - } - - - // - // This shadow class is GC-able even when the live list it shadows - // can't be, because of event registration hookups. Its finalizer - // makes that live list become GC-able. - // - final class ShadowList - implements NodeList - { - - private LiveNodeList liveList; - - ShadowList(String ns, String local) - { - liveList = new LiveNodeList(ns, local); - } - - public void finalize() - { - liveList.detach(); - liveList = null; - } - - public Node item(int index) - { - return liveList.item(index); - } - - public int getLength() - { - return liveList.getLength(); - } - } - - final class LiveNodeList - implements NodeList, EventListener, NodeFilter - { - - private final boolean matchAnyURI; - private final boolean matchAnyName; - private final String elementURI; - private final String elementName; - - private DomIterator current; - private int lastIndex; - - LiveNodeList(String uri, String name) - { - elementURI = uri; - elementName = name; - matchAnyURI = "*".equals(uri); - matchAnyName = "*".equals(name); - - DomNode.this.addEventListener("DOMNodeInserted", this, true); - DomNode.this.addEventListener("DOMNodeRemoved", this, true); - } - - void detach() - { - if (current != null) - current.detach(); - current = null; - - DomNode.this.removeEventListener("DOMNodeInserted", this, true); - DomNode.this.removeEventListener("DOMNodeRemoved", this, true); - } - - public short acceptNode(Node element) - { - if (element == DomNode.this) - { - return FILTER_SKIP; - } - - // use namespace-aware matching ... - if (elementURI != null) - { - if (!(matchAnyURI - || elementURI.equals(element.getNamespaceURI()))) - { - return FILTER_SKIP; - } - if (!(matchAnyName - || elementName.equals(element.getLocalName()))) - { - return FILTER_SKIP; - } - - // ... or qName-based kind. - } - else - { - if (!(matchAnyName - || elementName.equals(element.getNodeName()))) - { - return FILTER_SKIP; - } - } - return FILTER_ACCEPT; - } - - private DomIterator createIterator() - { - return new DomIterator(DomNode.this, - NodeFilter.SHOW_ELEMENT, - this, /* filter */ - true /* expand entity refs */ - ); - } - - public void handleEvent(Event e) - { - MutationEvent mutation = (MutationEvent) e; - Node related = mutation.getRelatedNode(); - - // XXX if it's got children ... check all kids too, they - // will invalidate our saved index - - if (related.getNodeType() != Node.ELEMENT_NODE || - related.getNodeName() != elementName || - related.getNamespaceURI() != elementURI) - { - return; - } - - if (current != null) - current.detach(); - current = null; - } - - public Node item(int index) - { - if (current == null) - { - current = createIterator(); - lastIndex = -1; - } - - // last node or before? go backwards - if (index <= lastIndex) { - while (index != lastIndex) { - current.previousNode (); - lastIndex--; - } - Node ret = current.previousNode (); - current.detach(); - current = null; - return ret; - } - - // somewhere after last node - while (++lastIndex != index) - current.nextNode (); - - Node ret = current.nextNode (); - current.detach(); - current = null; - return ret; - } - - public int getLength() - { - int retval = 0; - NodeIterator iter = createIterator(); - - while (iter.nextNode() != null) - { - retval++; - } - iter.detach(); - return retval; - } - - } - - // - // EventTarget support - // - static final class ListenerRecord - { - - String type; - EventListener listener; - boolean useCapture; - - // XXX use JDK 1.2 java.lang.ref.WeakReference to listener, - // and we can both get rid of "shadow" classes and remove - // the need for applications to apply similar trix ... but - // JDK 1.2 support isn't generally available yet - - ListenerRecord(String type, EventListener listener, boolean useCapture) - { - this.type = type.intern(); - this.listener = listener; - this.useCapture = useCapture; - } - - public boolean equals(Object o) - { - ListenerRecord rec = (ListenerRecord)o; - return listener == rec.listener - && useCapture == rec.useCapture - && type == rec.type; - } - - public int hashCode() - { - return listener.hashCode() ^ type.hashCode(); - } - } - - /** - * <b>DOM L2 (Events)</b> - * Returns an instance of the specified type of event object. - * Understands about DOM Mutation, HTML, and UI events. - * - * <p>If the name of the event type begins with "USER-", then an object - * implementing the "Event" class will be returned; this provides a - * limited facility for application-defined events to use the DOM event - * infrastructure. Alternatively, use one of the standard DOM event - * classes and initialize it using use such a "USER-" event type name; - * or defin, instantiate, and initialize an application-specific subclass - * of DomEvent and pass that to dispatchEvent(). - * - * @param eventType Identifies the particular DOM feature module - * defining the type of event, such as "MutationEvents". - * <em>The event "name" is a different kind of "type".</em> - */ - public Event createEvent(String eventType) - { - eventType = eventType.toLowerCase(); - - if ("mutationevents".equals(eventType)) - { - return new DomEvent.DomMutationEvent(null); - } - - if ("htmlevents".equals(eventType) - || "events".equals(eventType) - || "user-events".equals(eventType)) - { - return new DomEvent(null); - } - - if ("uievents".equals(eventType)) - { - return new DomEvent.DomUIEvent(null); - } - - // mouse events - - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, - eventType, null, 0); - } - - /** - * <b>DOM L2 (Events)</b> - * Registers an event listener's interest in a class of events. - */ - public final void addEventListener(String type, - EventListener listener, - boolean useCapture) - { - // prune duplicates - ListenerRecord record; - - record = new ListenerRecord(type, listener, useCapture); - listeners.add(record); - nListeners = listeners.size(); - } - - // XXX this exception should be discarded from DOM - - // this class can be instantiated, unlike the one in the spec - static final class DomEventException - extends EventException - { - - DomEventException() - { - super(UNSPECIFIED_EVENT_TYPE_ERR, "unspecified event type"); - } - - } - - /** - * <b>DOM L2 (Events)</b> - * Delivers an event to all relevant listeners, returning true if the - * caller should perform their default action. Note that the event - * must have been provided by the createEvent() method on this - * class, else it can't be dispatched. - * - * @see #createEvent - * - * @exception NullPointerException When a null event is passed. - * @exception ClassCastException When the event wasn't provided by - * the createEvent method, or otherwise isn't a DomEvent. - * @exception EventException If the event type wasn't specified - */ - public final boolean dispatchEvent(Event event) - throws EventException - { - DomEvent e = (DomEvent) event; - DomNode[] ancestors = null; - int ancestorMax = 0; - boolean haveDispatchDataLock = false; - - if (e.type == null) - { - throw new DomEventException(); - } - - e.doDefault = true; - e.target = this; - - // - // Typical case: one nonrecursive dispatchEvent call at a time - // for this class. If that's our case, we can avoid allocating - // garbage, which is overall a big win. Even with advanced GCs - // that deal well with short-lived garbage, and wayfast allocators, - // it still helps. - // - // Remember -- EVERY mutation goes though here at least once. - // - // When populating a DOM tree, trying to send mutation events is - // the primary cost; this dominates the critical path. - // - try - { - DomNode current; - int index; - boolean haveAncestorRegistrations = false; - ListenerRecord[] notificationSet; - int ancestorLen; - - synchronized (lockNode) - { - if (!dispatchDataLock) - { - haveDispatchDataLock = dispatchDataLock = true; - notificationSet = DomNode.notificationSet; - ancestors = DomNode.ancestors; - } - else - { - notificationSet = new ListenerRecord[NOTIFICATIONS_INIT]; - ancestors = new DomNode[ANCESTORS_INIT]; - } - ancestorLen = ancestors.length; - } - - // Climb to the top of this subtree and handle capture, letting - // each node (from the top down) capture until one stops it or - // until we get to this one. - current = (parent == null) ? this : parent; - if (current.depth >= ANCESTORS_INIT) - { - DomNode[] newants = new DomNode[current.depth + 1]; - System.arraycopy(ancestors, 0, newants, 0, ancestors.length); - ancestors = newants; - ancestorLen = ancestors.length; - } - for (index = 0; index < ancestorLen; index++) - { - if (current == null || current.depth == 0) - break; - - if (current.nListeners != 0) - { - haveAncestorRegistrations = true; - } - ancestors [index] = current; - current = current.parent; - } - if (current.depth > 0) - { - throw new RuntimeException("dispatchEvent capture stack size"); - } - - ancestorMax = index; - e.stop = false; - - if (haveAncestorRegistrations) - { - e.eventPhase = Event.CAPTURING_PHASE; - while (!e.stop && index-- > 0) - { - current = ancestors [index]; - if (current.nListeners != 0) - { - notifyNode(e, current, true, notificationSet); - } - } - } - - // Always deliver events to the target node (this) - // unless stopPropagation was called. If we saw - // no registrations yet (typical!), we never will. - if (!e.stop && nListeners != 0) - { - e.eventPhase = Event.AT_TARGET; - notifyNode (e, this, false, notificationSet); - } - else if (!haveAncestorRegistrations) - { - e.stop = true; - } - - // If the event bubbles and propagation wasn't halted, - // walk back up the ancestor list. Stop bubbling when - // any bubbled event handler stops it. - - if (!e.stop && e.bubbles) - { - e.eventPhase = Event.BUBBLING_PHASE; - for (index = 0; - !e.stop - && index < ancestorMax - && (current = ancestors[index]) != null; - index++) - { - if (current.nListeners != 0) - { - notifyNode(e, current, false, notificationSet); - } - } - } - e.eventPhase = 0; - - // Caller chooses whether to perform the default - // action based on return from this method. - return e.doDefault; - - } - finally - { - if (haveDispatchDataLock) - { - // synchronize to force write ordering - synchronized (lockNode) - { - // null out refs to ensure they'll be GC'd - for (int i = 0; i < ancestorMax; i++) - { - ancestors [i] = null; - } - // notificationSet handled by notifyNode - - dispatchDataLock = false; - } - } - } - } - - private void notifyNode(DomEvent e, - DomNode current, - boolean capture, - ListenerRecord[] notificationSet) - { - int count = 0; - Iterator iter; - - iter = current.listeners.iterator(); - - // do any of this set of listeners get notified? - while (iter.hasNext()) - { - ListenerRecord rec = (ListenerRecord)iter.next(); - - if (rec.useCapture != capture) - { - continue; - } - if (!e.type.equals (rec.type)) - { - continue; - } - if (count >= notificationSet.length) - { - // very simple growth algorithm - int len = Math.max(notificationSet.length, 1); - ListenerRecord[] tmp = new ListenerRecord[len * 2]; - System.arraycopy(notificationSet, 0, tmp, 0, - notificationSet.length); - notificationSet = tmp; - } - notificationSet[count++] = rec; - } - iter = null; - - // Notify just those listeners - e.currentNode = current; - for (int i = 0; i < count; i++) - { - try - { - iter = current.listeners.iterator(); - // Late in the DOM CR process (3rd or 4th CR?) the - // removeEventListener spec became asymmetric with respect - // to addEventListener ... effect is now immediate. - while (iter.hasNext()) - { - ListenerRecord rec = (ListenerRecord)iter.next(); - - if (rec.equals(notificationSet[i])) - { - notificationSet[i].listener.handleEvent(e); - break; - } - } - iter = null; - } - catch (Exception x) - { - // ignore all exceptions - } - notificationSet[i] = null; // free for GC - } - } - - /** - * <b>DOM L2 (Events)</b> - * Unregisters an event listener. - */ - public final void removeEventListener(String type, - EventListener listener, - boolean useCapture) - { - listeners.remove(new ListenerRecord(type, listener, useCapture)); - nListeners = listeners.size(); - // no exceptions reported - } - - /** - * <b>DOM L1 (relocated in DOM L2)</b> - * In this node and all contained nodes (including attributes if - * relevant) merge adjacent text nodes. This is done while ignoring - * text which happens to use CDATA delimiters). - */ - public final void normalize() - { - // Suspend readonly status - boolean saved = readonly; - readonly = false; - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - boolean saved2 = ctx.readonly; - ctx.readonly = false; - switch (ctx.nodeType) - { - case TEXT_NODE: - case CDATA_SECTION_NODE: - while (ctx.next != null && - (ctx.next.nodeType == TEXT_NODE || - ctx.next.nodeType == CDATA_SECTION_NODE)) - { - Text text = (Text) ctx; - text.appendData(ctx.next.getNodeValue()); - removeChild(ctx.next); - } - break; - case ELEMENT_NODE: - NamedNodeMap attrs = ctx.getAttributes(); - int len = attrs.getLength(); - for (int i = 0; i < len; i++) - { - DomNode attr = (DomNode) attrs.item(i); - boolean saved3 = attr.readonly; - attr.readonly = false; - attr.normalize(); - attr.readonly = saved3; - } - // Fall through - case DOCUMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: - case ATTRIBUTE_NODE: - case ENTITY_REFERENCE_NODE: - ctx.normalize(); - break; - } - ctx.readonly = saved2; - } - readonly = saved; - } - - /** - * Returns true iff node types match, and either (a) both nodes have no - * namespace and their getNodeName() values are the same, or (b) both - * nodes have the same getNamespaceURI() and same getLocalName() values. - * - * <p>Note that notion of a "Per-Element-Type" attribute name scope, as - * found in a non-normative appendix of the XML Namespaces specification, - * is not supported here. Your application must implement that notion, - * typically by not bothering to check nameAndTypeEquals for attributes - * without namespace URIs unless you already know their elements are - * nameAndTypeEquals. - */ - public boolean nameAndTypeEquals(Node other) - { - if (other == this) - { - return true; - } - // node types must match - if (nodeType != other.getNodeType()) - { - return false; - } - - // if both have namespaces, do a "full" comparision - // this is a "global" partition - String ns1 = this.getNamespaceURI(); - String ns2 = other.getNamespaceURI(); - - if (ns1 != null && ns2 != null) - { - return ns1.equals(ns2) && - equal(getLocalName(), other.getLocalName()); - } - - // if neither has a namespace, this is a "no-namespace" name. - if (ns1 == null && ns2 == null) - { - if (!getNodeName().equals(other.getNodeName())) - { - return false; - } - // can test the non-normative "per-element-type" scope here. - // if this is an attribute node and both nodes have been bound - // to elements (!!), then return the nameAndTypeEquals() - // comparison of those elements. - return true; - } - - // otherwise they're unequal: one scoped, one not. - return false; - } - - // DOM Level 3 methods - - public String getBaseURI() - { - return (parent != null) ? parent.getBaseURI() : null; - } - - public short compareDocumentPosition(Node other) - throws DOMException - { - return (short) compareTo(other); - } - - /** - * DOM nodes have a natural ordering: document order. - */ - public final int compareTo(Object other) - { - if (other instanceof DomNode) - { - DomNode n1 = this; - DomNode n2 = (DomNode) other; - if (n1.owner != n2.owner) - { - return 0; - } - int d1 = n1.depth, d2 = n2.depth; - int delta = d1 - d2; - while (d1 > d2) - { - n1 = n1.parent; - d1--; - } - while (d2 > d1) - { - n2 = n2.parent; - d2--; - } - int c = compareTo2(n1, n2); - return (c != 0) ? c : delta; - } - return 0; - } - - /** - * Compare two nodes at the same depth. - */ - final int compareTo2(DomNode n1, DomNode n2) - { - if (n1 == n2 || n1.depth == 0 || n2.depth == 0) - { - return 0; - } - int c = compareTo2(n1.parent, n2.parent); - return (c != 0) ? c : n1.index - n2.index; - } - - public final String getTextContent() - throws DOMException - { - return getTextContent(true); - } - - final String getTextContent(boolean topLevel) - throws DOMException - { - switch (nodeType) - { - case ELEMENT_NODE: - case ENTITY_NODE: - case ENTITY_REFERENCE_NODE: - case DOCUMENT_FRAGMENT_NODE: - CPStringBuilder buffer = new CPStringBuilder(); - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - { - String textContent = ctx.getTextContent(false); - if (textContent != null) - { - buffer.append(textContent); - } - } - return buffer.toString(); - case TEXT_NODE: - case CDATA_SECTION_NODE: - if (((Text) this).isElementContentWhitespace()) - { - return ""; - } - return getNodeValue(); - case ATTRIBUTE_NODE: - return getNodeValue(); - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - return topLevel ? getNodeValue() : ""; - default: - return null; - } - } - - public void setTextContent(String textContent) - throws DOMException - { - switch (nodeType) - { - case ELEMENT_NODE: - case ATTRIBUTE_NODE: - case ENTITY_NODE: - case ENTITY_REFERENCE_NODE: - case DOCUMENT_FRAGMENT_NODE: - for (DomNode ctx = first; ctx != null; ) - { - DomNode n = ctx.next; - removeChild(ctx); - ctx = n; - } - if (textContent != null) - { - Text text = owner.createTextNode(textContent); - appendChild(text); - } - break; - case TEXT_NODE: - case CDATA_SECTION_NODE: - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - setNodeValue(textContent); - break; - } - } - - public boolean isSameNode(Node other) - { - return this == other; - } - - public String lookupPrefix(String namespaceURI) - { - return (parent == null || parent == owner) ? null : - parent.lookupPrefix(namespaceURI); - } - - public boolean isDefaultNamespace(String namespaceURI) - { - return (parent == null || parent == owner) ? false : - parent.isDefaultNamespace(namespaceURI); - } - - public String lookupNamespaceURI(String prefix) - { - return (parent == null || parent == owner) ? null : - parent.lookupNamespaceURI(prefix); - } - - public boolean isEqualNode(Node arg) - { - if (this == arg) - return true; - if (arg == null) - return false; - if (nodeType != arg.getNodeType()) - return false; - switch (nodeType) - { - case ELEMENT_NODE: - case ATTRIBUTE_NODE: - if (!equal(getLocalName(), arg.getLocalName()) || - !equal(getNamespaceURI(), arg.getNamespaceURI())) - return false; - break; - case PROCESSING_INSTRUCTION_NODE: - if (!equal(getNodeName(), arg.getNodeName()) || - !equal(getNodeValue(), arg.getNodeValue())) - return false; - break; - case COMMENT_NODE: - case TEXT_NODE: - case CDATA_SECTION_NODE: - if (!equal(getNodeValue(), arg.getNodeValue())) - return false; - break; - } - // Children - Node argCtx = arg.getFirstChild(); - getFirstChild(); // because of DomAttr lazy children - DomNode ctx = first; - for (; ctx != null && argCtx != null; ctx = ctx.next) - { - if (nodeType == DOCUMENT_NODE) - { - // Ignore whitespace outside document element - while (ctx != null && ctx.nodeType == TEXT_NODE) - ctx = ctx.next; - while (argCtx != null && ctx.getNodeType() == TEXT_NODE) - argCtx = argCtx.getNextSibling(); - if (ctx == null && argCtx != null) - return false; - else if (argCtx == null && ctx != null) - return false; - } - if (!ctx.isEqualNode(argCtx)) - return false; - argCtx = argCtx.getNextSibling(); - } - if (ctx != null || argCtx != null) - return false; - - // TODO DocumentType - return true; - } - - boolean equal(String arg1, String arg2) - { - return ((arg1 == null && arg2 == null) || - (arg1 != null && arg1.equals(arg2))); - } - - public Object getFeature(String feature, String version) - { - DOMImplementation impl = (nodeType == DOCUMENT_NODE) ? - ((Document) this).getImplementation() : owner.getImplementation(); - if (impl.hasFeature(feature, version)) - { - return this; - } - return null; - } - - public Object setUserData(String key, Object data, UserDataHandler handler) - { - if (userData == null) - { - userData = new HashMap(); - } - if (handler != null) - { - if (userDataHandlers == null) - { - userDataHandlers = new HashMap(); - } - userDataHandlers.put(key, handler); - } - return userData.put(key, data); - } - - public Object getUserData(String key) - { - if (userData == null) - { - return null; - } - return userData.get(key); - } - - public String toString() - { - String nodeName = getNodeName(); - String nodeValue = getNodeValue(); - CPStringBuilder buf = new CPStringBuilder(getClass().getName()); - buf.append('['); - if (nodeName != null) - { - buf.append(nodeName); - } - if (nodeValue != null) - { - if (nodeName != null) - { - buf.append('='); - } - buf.append('\''); - buf.append(encode(nodeValue)); - buf.append('\''); - } - buf.append(']'); - return buf.toString(); - } - - String encode(String value) - { - CPStringBuilder buf = null; - int len = value.length(); - for (int i = 0; i < len; i++) - { - char c = value.charAt(i); - if (c == '\n') - { - if (buf == null) - { - buf = new CPStringBuilder(value.substring(0, i)); - } - buf.append("\\n"); - } - else if (c == '\r') - { - if (buf == null) - { - buf = new CPStringBuilder(value.substring(0, i)); - } - buf.append("\\r"); - } - else if (buf != null) - { - buf.append(c); - } - } - return (buf != null) ? buf.toString() : value; - } - - String nodeTypeToString(short nodeType) - { - switch (nodeType) - { - case ELEMENT_NODE: - return "ELEMENT_NODE"; - case ATTRIBUTE_NODE: - return "ATTRIBUTE_NODE"; - case TEXT_NODE: - return "TEXT_NODE"; - case CDATA_SECTION_NODE: - return "CDATA_SECTION_NODE"; - case DOCUMENT_NODE: - return "DOCUMENT_NODE"; - case DOCUMENT_TYPE_NODE: - return "DOCUMENT_TYPE_NODE"; - case COMMENT_NODE: - return "COMMENT_NODE"; - case PROCESSING_INSTRUCTION_NODE: - return "PROCESSING_INSTRUCTION_NODE"; - case DOCUMENT_FRAGMENT_NODE: - return "DOCUMENT_FRAGMENT_NODE"; - case ENTITY_NODE: - return "ENTITY_NODE"; - case ENTITY_REFERENCE_NODE: - return "ENTITY_REFERENCE_NODE"; - case NOTATION_NODE: - return "NOTATION_NODE"; - default: - return "UNKNOWN"; - } - } - - public void list(java.io.PrintStream out, int indent) - { - for (int i = 0; i < indent; i++) - out.print(" "); - out.println(toString()); - for (DomNode ctx = first; ctx != null; ctx = ctx.next) - ctx.list(out, indent + 1); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNodeIterator.java b/libjava/classpath/gnu/xml/dom/DomNodeIterator.java deleted file mode 100644 index 9f9ec7e..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNodeIterator.java +++ /dev/null @@ -1,328 +0,0 @@ -/* DomNodeIterator.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ -package gnu.xml.dom; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; -import org.w3c.dom.traversal.TreeWalker; - -/** - * Node iterator and tree walker. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomNodeIterator - implements NodeIterator, TreeWalker -{ - - Node root; - final int whatToShow; - final NodeFilter filter; - final boolean entityReferenceExpansion; - final boolean walk; - Node current; - - public DomNodeIterator(Node root, int whatToShow, NodeFilter filter, - boolean entityReferenceExpansion, boolean walk) - { - if (root == null) - { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root"); - } - this.root = root; - this.whatToShow = whatToShow; - this.filter = filter; - this.entityReferenceExpansion = entityReferenceExpansion; - this.walk = walk; - current = root; - } - - public Node getRoot() - { - return root; - } - - public int getWhatToShow() - { - return whatToShow; - } - - public NodeFilter getFilter() - { - return filter; - } - - public boolean getExpandEntityReferences() - { - return entityReferenceExpansion; - } - - public Node nextNode() - throws DOMException - { - if (root == null) - { - throw new DOMException(DOMException.INVALID_STATE_ERR, "null root"); - } - Node ret; - do - { - if (current.equals(root)) - { - ret = root.getFirstChild(); - } - else if (walk) - { - ret = current.getFirstChild(); - if (ret == null) - { - ret = current.getNextSibling(); - } - if (ret == null) - { - Node tmp = current; - ret = tmp.getParentNode(); - while (!ret.equals(root) && tmp.equals(ret.getLastChild())) - { - tmp = ret; - ret = tmp.getParentNode(); - } - if (ret.equals(root)) - { - ret = null; - } - else - { - ret = ret.getNextSibling(); - } - } - } - else - { - ret = current.getNextSibling(); - } - current = (ret == null) ? current : ret; - } - while (!accept(ret)); - - return ret; - } - - public Node previousNode() - throws DOMException - { - if (root == null) - { - throw new DOMException(DOMException.INVALID_STATE_ERR, "null root"); - } - Node ret; - do - { - if (current.equals(root)) - { - ret = current.getLastChild(); - } - else if (walk) - { - ret = current.getLastChild(); - if (ret == null) - { - ret = current.getPreviousSibling(); - } - if (ret == null) - { - Node tmp = current; - ret = tmp.getParentNode(); - while (!ret.equals(root) && tmp.equals(ret.getFirstChild())) - { - tmp = ret; - ret = tmp.getParentNode(); - } - if (ret.equals(root)) - { - ret = null; - } - else - { - ret = ret.getPreviousSibling(); - } - } - } - else - { - ret = current.getPreviousSibling(); - } - } - while (!accept(ret)); - current = (ret == null) ? current : ret; - return ret; - } - - public Node getCurrentNode() - { - return current; - } - - public void setCurrentNode(Node current) - throws DOMException - { - if (current == null) - { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root"); - } - this.current = current; - } - - public Node parentNode() - { - Node ret = current.getParentNode(); - if (!accept (ret)) - { - ret = null; - } - current = (ret == null) ? current : ret; - return ret; - } - - public Node firstChild () - { - Node ret = current.getFirstChild(); - while (!accept(ret)) - { - ret = ret.getNextSibling(); - } - current = (ret == null) ? current : ret; - return ret; - } - - public Node lastChild() - { - Node ret = current.getLastChild(); - while (!accept(ret)) - { - ret = ret.getPreviousSibling(); - } - current = (ret == null) ? current : ret; - return ret; - } - - public Node previousSibling() - { - Node ret = current.getPreviousSibling(); - while (!accept(ret)) - { - ret = ret.getPreviousSibling(); - } - current = (ret == null) ? current : ret; - return ret; - } - - public Node nextSibling() - { - Node ret = current.getNextSibling(); - while (!accept(ret)) - { - ret = ret.getNextSibling(); - } - current = (ret == null) ? current : ret; - return ret; - } - - public void detach() - { - root = null; - } - - boolean accept(Node node) - { - if (node == null) - { - return true; - } - boolean ret; - switch (node.getNodeType()) - { - case Node.ATTRIBUTE_NODE: - ret = (whatToShow & NodeFilter.SHOW_ATTRIBUTE) != 0; - break; - case Node.CDATA_SECTION_NODE: - ret = (whatToShow & NodeFilter.SHOW_CDATA_SECTION) != 0; - break; - case Node.COMMENT_NODE: - ret = (whatToShow & NodeFilter.SHOW_COMMENT) != 0; - break; - case Node.DOCUMENT_NODE: - ret = (whatToShow & NodeFilter.SHOW_DOCUMENT) != 0; - break; - case Node.DOCUMENT_FRAGMENT_NODE: - ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT) != 0; - break; - case Node.DOCUMENT_TYPE_NODE: - ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_TYPE) != 0; - break; - case Node.ELEMENT_NODE: - ret = (whatToShow & NodeFilter.SHOW_ELEMENT) != 0; - break; - case Node.ENTITY_NODE: - ret = (whatToShow & NodeFilter.SHOW_ENTITY) != 0; - break; - case Node.ENTITY_REFERENCE_NODE: - ret = (whatToShow & NodeFilter.SHOW_ENTITY_REFERENCE) != 0; - ret = ret && entityReferenceExpansion; - break; - case Node.NOTATION_NODE: - ret = (whatToShow & NodeFilter.SHOW_NOTATION) != 0; - break; - case Node.PROCESSING_INSTRUCTION_NODE: - ret = (whatToShow & NodeFilter.SHOW_PROCESSING_INSTRUCTION) != 0; - break; - case Node.TEXT_NODE: - ret = (whatToShow & NodeFilter.SHOW_TEXT) != 0; - break; - default: - ret = true; - } - if (ret && filter != null) - { - ret = (filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT); - } - return ret; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNotation.java b/libjava/classpath/gnu/xml/dom/DomNotation.java deleted file mode 100644 index abb0e9d..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNotation.java +++ /dev/null @@ -1,102 +0,0 @@ -/* DomNotation.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.Notation; - -/** - * <p> "Notation" implementation. This is a non-core DOM class, supporting - * the "XML" feature. </p> - * - * <p> Although unparsed entities using this notation can be detected using - * DOM, neither NOTATIONS nor ENTITY/ENTITIES attributes can be so detected. - * More, there is no portable way to construct a Notation node, so there's - * no way that vendor-neutral DOM construction APIs could even report a - * NOTATION used to identify the intended meaning of a ProcessingInstruction. - * </p> - * - * <p> In short, <em>avoid using this DOM functionality</em>. - * - * @see DomDoctype - * @see DomEntity - * @see DomPI - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomNotation - extends DomExtern - implements Notation -{ - - /** - * Constructs a Notation node associated with the specified document, - * with the specified descriptive data. Note that at least one of - * the PUBLIC and SYSTEM identifiers must be provided; unlike other - * external objects in XML, notations may have only a PUBLIC identifier. - * - * <p>This constructor should only be invoked by a DomDoctype object - * as part of its declareNotation functionality, or through a subclass - * which is similarly used in a "Sub-DOM" style layer. - * - * @param owner The document with which this notation is associated - * @param name Name of this notation - * @param publicId If non-null, provides the notation's PUBLIC identifier - * @param systemId If non-null, rovides the notation's SYSTEM identifier - */ - protected DomNotation(DomDocument owner, - String name, - String publicId, - String systemId) - { - super(NOTATION_NODE, owner, name, publicId, systemId); - makeReadonly(); - } - - /** - * The base URI of an external entity is its system ID. - * The base URI of an internal entity is the parent document's base URI. - * @since DOM Level 3 Core - */ - public String getBaseURI() - { - String systemId = getSystemId(); - return (systemId == null) ? owner.getBaseURI() : systemId; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomNsNode.java b/libjava/classpath/gnu/xml/dom/DomNsNode.java deleted file mode 100644 index 55e3511..0000000 --- a/libjava/classpath/gnu/xml/dom/DomNsNode.java +++ /dev/null @@ -1,226 +0,0 @@ -/* DomNsNode.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import javax.xml.XMLConstants; -import org.w3c.dom.DOMException; - -/** - * <p> Abstract implemention of namespace support. This facilitates - * sharing code for attribute and element nodes. - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public abstract class DomNsNode - extends DomNode -{ - - private String name; - private String namespace; - private String prefix; - private String localName; - - /** - * Constructs a node associated with the specified document, and - * with the specified namespace information. - * - * @param owner The document with which this entity is associated - * @param namespaceURI Combined with the local part of the name, - * this identifies a type of element or attribute; may be null. - * If this is the empty string, it is reassigned as null so that - * applications only need to test that case. - * @param name Name of this node, which may include a prefix - */ - // package private - DomNsNode(short nodeType, DomDocument owner, String namespaceURI, String name) - { - super(nodeType, owner); - setNodeName(name); - setNamespaceURI(namespaceURI); - } - - /** - * Constructs a node associated with the specified document, and - * with the specified namespace information. The prefix and local part - * are given explicitly rather than being computed. This allows them - * to be explicitly set to {@code null} as required by - * {@link Document#createElement(String)}. - * - * @param owner The document with which this entity is associated - * @param namespaceURI Combined with the local part of the name, - * this identifies a type of element or attribute; may be null. - * If this is the empty string, it is reassigned as null so that - * applications only need to test that case. - * @param name Name of this node, which may include a prefix - * @param prefix the namespace prefix of the name. May be {@code null}. - * @param localName the local part of the name. May be {@code null}. - */ - // package private - DomNsNode(short nodeType, DomDocument owner, String namespaceURI, String name, - String prefix, String localName) - { - super(nodeType, owner); - this.name = name.intern(); - this.prefix = prefix == null ? null : prefix.intern(); - this.localName = localName == null ? null : localName.intern(); - setNamespaceURI(namespaceURI); - } - - /** - * <b>DOM L1</b> - * Returns the node's name, including any namespace prefix. - */ - public final String getNodeName() - { - return name; - } - - final void setNodeName(String name) - { - this.name = name.intern(); - int index = name.indexOf(':'); - if (index == -1) - { - prefix = null; - localName = this.name; - } - else - { - prefix = name.substring(0, index).intern(); - localName = name.substring(index + 1).intern(); - } - } - - /** - * <b>DOM L2</b> - * Returns the node's namespace URI - * <em>or null</em> if the node name is not namespace scoped. - */ - public final String getNamespaceURI() - { - return namespace; - } - - final void setNamespaceURI(String namespaceURI) - { - if ("".equals(namespaceURI)) - { - namespaceURI = null; - } - namespace = (namespaceURI == null) ? null : namespaceURI.intern(); - } - - /** - * <b>DOM L2</b> - * Returns any prefix part of the node's name (before any colon). - */ - public final String getPrefix() - { - return prefix; - } - - /** - * <b>DOM L2</b> - * Assigns the prefix part of the node's name (before any colon). - */ - public final void setPrefix(String prefix) - { - if (readonly) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - - if (prefix == null) - { - name = localName; - return; - } - else if (namespace == null) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "can't set prefix, node has no namespace URI", - this, 0); - } - - DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); - if (prefix.indexOf (':') != -1) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "illegal prefix " + prefix, this, 0); - } - - if (XMLConstants.XML_NS_PREFIX.equals(prefix) - && !XMLConstants.XML_NS_URI.equals(namespace)) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xml namespace is always " + - XMLConstants.XML_NS_URI, this, 0); - } - - if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) - { - if (namespace != null || getNodeType() != ATTRIBUTE_NODE) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "xmlns attribute prefix is reserved", - this, 0); - } - } - else if (getNodeType () == ATTRIBUTE_NODE - && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || - name.startsWith("xmlns:"))) - { - throw new DomDOMException(DOMException.NAMESPACE_ERR, - "namespace declarations can't change names", - this, 0); - } - - this.prefix = prefix.intern(); - } - - /** - * <b>DOM L2</b> - * Returns the local part of the node's name (after any colon). - */ - public final String getLocalName() - { - return localName; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java b/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java deleted file mode 100644 index 6d443a2..0000000 --- a/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java +++ /dev/null @@ -1,146 +0,0 @@ -/* DomProcessingInstruction.java -- - Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.DOMException; -import org.w3c.dom.ProcessingInstruction; - -/** - * <p> "ProcessingInstruction" (PI) implementation. - * This is a non-core DOM class, supporting the "XML" feature. </p> - * - * <p> Unlike other DOM APIs in the "XML" feature, this one fully - * exposes the functionality it describes. So there is no reason - * inherent in DOM to avoid using this API, unless you want to rely - * on NOTATION declarations to associate meaning with your PIs; - * there is no vendor-neutal way to record those notations in DOM.</p> - * - * <p> Also of note is that PI support is part of SAX, so that XML - * systems using PIs can choose among multiple APIs. </p> - * - * @see DomNotation - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomProcessingInstruction - extends DomNode - implements ProcessingInstruction -{ - - private String target; - private String data; - - /** - * Constructs a ProcessingInstruction node associated with the - * specified document, with the specified data. - * - * <p>This constructor should only be invoked by a Document object as - * part of its createProcessingInstruction functionality, or through - * a subclass which is similarly used in a "Sub-DOM" style layer. - */ - protected DomProcessingInstruction(DomDocument owner, - String target, String data) - { - super(PROCESSING_INSTRUCTION_NODE, owner); - this.target = target; - this.data = data; - } - - /** - * <b>DOM L1</b> - * Returns the target of the processing instruction. - */ - public final String getTarget() - { - return target; - } - - /** - * <b>DOM L1</b> - * Returns the target of the processing instruction - * (same as getTarget). - */ - public final String getNodeName() - { - return target; - } - - /** - * <b>DOM L1</b> - * Returns the data associated with the processing instruction. - */ - public final String getData() - { - return data; - } - - /** - * <b>DOM L1</b> - * Returns the data associated with the processing instruction - * (same as getData). - */ - public final String getNodeValue() - { - return data; - } - - /** - * <b>DOM L1</b> - * Assigns the data associated with the processing instruction; - * same as setNodeValue. - */ - public final void setData(String data) - { - setNodeValue(data); - } - - /** - * <b>DOM L1</b> - * Assigns the data associated with the processing instruction. - */ - public final void setNodeValue(String data) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - this.data = data; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomText.java b/libjava/classpath/gnu/xml/dom/DomText.java deleted file mode 100644 index b74c5b4..0000000 --- a/libjava/classpath/gnu/xml/dom/DomText.java +++ /dev/null @@ -1,222 +0,0 @@ -/* DomText.java -- - Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import gnu.java.lang.CPStringBuilder; - -import org.w3c.dom.DOMException; -import org.w3c.dom.Text; - -/** - * <p> "Text" implementation. </p> - * - * @author David Brownell - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomText - extends DomCharacterData - implements Text -{ - - // NOTE: deleted unused per-instance "isIgnorable" - // support to reclaim its space. - - /** - * Constructs a text node associated with the specified - * document and holding the specified data. - * - * <p>This constructor should only be invoked by a Document object - * as part of its createTextNode functionality, or through a subclass - * which is similarly used in a "Sub-DOM" style layer. - */ - protected DomText(DomDocument owner, String value) - { - super(TEXT_NODE, owner, value); - } - - protected DomText(DomDocument owner, char[] buf, int off, int len) - { - super(TEXT_NODE, owner, buf, off, len); - } - - // Used by DomCDATA - DomText(short nodeType, DomDocument owner, String value) - { - super(nodeType, owner, value); - } - - DomText(short nodeType, DomDocument owner, char[] buf, int off, int len) - { - super(nodeType, owner, buf, off, len); - } - - /** - * <b>DOM L1</b> - * Returns the string "#text". - */ - // can't be 'final' with CDATA subclassing - public String getNodeName() - { - return "#text"; - } - - /** - * <b>DOM L1</b> - * Splits this text node in two parts at the offset, returning - * the new text node (the sibling with the second part). - */ - public Text splitText(int offset) - { - if (isReadonly()) - { - throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); - } - try - { - String text = getNodeValue(); - String before = text.substring(0, offset); - String after = text.substring(offset); - Text next; - - if (getNodeType() == TEXT_NODE) - { - next = owner.createTextNode(after); - } - else // CDATA_SECTION_NODE - { - next = owner.createCDATASection(after); - } - - if (this.next != null) - { - parent.insertBefore(next, this.next); - } - else - { - parent.appendChild(next); - } - setNodeValue(before); - return next; - - } - catch (IndexOutOfBoundsException x) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - } - - // DOM Level 3 - - public boolean isElementContentWhitespace() - { - if (parent != null) - { - DomDoctype doctype = (DomDoctype) owner.getDoctype(); - if (doctype != null) - { - DTDElementTypeInfo info = - doctype.getElementTypeInfo(parent.getNodeName()); - if (info != null) - { - if (info.model == null && info.model.indexOf("#PCDATA") != -1) - { - return false; - } - return getNodeValue().trim().length() == 0; - } - } - } - return false; - } - - public String getWholeText() - { - DomNode ref = this; - DomNode ctx; - for (ctx = previous; ctx != null && - (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE); - ctx = ctx.previous) - { - ref = ctx; - } - CPStringBuilder buf = new CPStringBuilder(ref.getNodeValue()); - for (ctx = ref.next; ctx != null && - (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE); - ctx = ctx.next) - { - buf.append(ctx.getNodeValue()); - } - return buf.toString (); - } - - public Text replaceWholeText(String content) - throws DOMException - { - boolean isEmpty = (content == null || content.length () == 0); - if (!isEmpty) - { - setNodeValue(content); - } - - DomNode ref = this; - DomNode ctx; - for (ctx = previous; ctx != null && - (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE); - ctx = ctx.previous) - { - ref = ctx; - } - ctx = ref.next; - if ((isEmpty || ref != this) && parent != null) - { - parent.removeChild(ref); - } - for (; ctx != null && - (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE); - ctx = ref) - { - ref = ctx.next; - if ((isEmpty || ctx != this) && parent != null) - { - parent.removeChild(ctx); - } - } - return (isEmpty) ? null : this; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomXPathExpression.java b/libjava/classpath/gnu/xml/dom/DomXPathExpression.java deleted file mode 100644 index 0b69629..0000000 --- a/libjava/classpath/gnu/xml/dom/DomXPathExpression.java +++ /dev/null @@ -1,147 +0,0 @@ -/* DomXPathExpression.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.xpath.XPathException; -import org.w3c.dom.xpath.XPathNSResolver; -import org.w3c.dom.xpath.XPathResult; -import gnu.xml.xpath.DocumentOrderComparator; - -/** - * An XPath expression. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomXPathExpression -implements org.w3c.dom.xpath.XPathExpression -{ - - final DomDocument doc; - final XPathExpression expression; - final XPathNSResolver resolver; - - DomXPathExpression(DomDocument doc, String expression, - XPathNSResolver resolver) - throws XPathException - { - this.doc = doc; - this.resolver = resolver; - - XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); - if (resolver != null) - { - xpath.setNamespaceContext(new DomNSResolverContext(resolver)); - } - try - { - this.expression = xpath.compile(expression); - } - catch (XPathExpressionException e) - { - throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, - e.getMessage ()); - } - } - - public Object evaluate(Node contextNode, short type, Object result) - throws XPathException, DOMException - { - try - { - QName typeName = null; - switch (type) - { - case XPathResult.BOOLEAN_TYPE: - typeName = XPathConstants.BOOLEAN; - break; - case XPathResult.NUMBER_TYPE: - typeName = XPathConstants.NUMBER; - break; - case XPathResult.STRING_TYPE: - typeName = XPathConstants.STRING; - break; - case XPathResult.ANY_UNORDERED_NODE_TYPE: - case XPathResult.FIRST_ORDERED_NODE_TYPE: - typeName = XPathConstants.NODE; - break; - case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: - case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE: - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - typeName = XPathConstants.NODESET; - break; - default: - throw new XPathException(XPathException.TYPE_ERR, null); - } - Object val = expression.evaluate(contextNode, typeName); - switch (type) - { - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - // Sort the nodes - List ns = new ArrayList((Collection) val); - Collections.sort(ns, new DocumentOrderComparator()); - val = ns; - } - return new DomXPathResult(val, type); - } - catch (javax.xml.xpath.XPathException e) - { - throw new XPathException(XPathException.TYPE_ERR, e.getMessage()); - } - } - - public String toString () - { - return getClass ().getName () + "[expression=" + expression + "]"; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java b/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java deleted file mode 100644 index fb0719a..0000000 --- a/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -/* DomXPathNSResolver.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import org.w3c.dom.Node; -import org.w3c.dom.xpath.XPathNSResolver; - -/** - * Generic XPath namespace resolver using a DOM Node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomXPathNSResolver -implements XPathNSResolver -{ - - Node node; - - DomXPathNSResolver (Node node) - { - this.node = node; - } - - public String lookupNamespaceURI (String prefix) - { - return node.lookupNamespaceURI (prefix); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/DomXPathResult.java b/libjava/classpath/gnu/xml/dom/DomXPathResult.java deleted file mode 100644 index da8fcf5..0000000 --- a/libjava/classpath/gnu/xml/dom/DomXPathResult.java +++ /dev/null @@ -1,233 +0,0 @@ -/* DomXPathResult.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.util.Collection; -import java.util.Iterator; -import org.w3c.dom.Node; -import org.w3c.dom.xpath.XPathException; -import org.w3c.dom.xpath.XPathResult; - -/** - * An XPath result object. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomXPathResult -implements XPathResult -{ - - final Object value; - final short type; - Iterator iterator; - - DomXPathResult (Object value, short requestedType) - { - this.value = value; - if (value instanceof Boolean) - { - type = XPathResult.BOOLEAN_TYPE; - } - else if (value instanceof Double) - { - type = XPathResult.NUMBER_TYPE; - } - else if (value instanceof String) - { - type = XPathResult.STRING_TYPE; - } - else if (value instanceof Collection) - { - Collection ns = (Collection) value; - switch (requestedType) - { - case XPathResult.ANY_TYPE: - case XPathResult.ANY_UNORDERED_NODE_TYPE: - type = (ns.size () == 1) ? XPathResult.FIRST_ORDERED_NODE_TYPE : - XPathResult.ORDERED_NODE_ITERATOR_TYPE; - break; - default: - type = requestedType; - } - iterator = ns.iterator (); - } - else - { - throw new IllegalArgumentException (); - } - } - - public boolean getBooleanValue() - { - if (type == XPathResult.BOOLEAN_TYPE) - { - return ((Boolean) value).booleanValue (); - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public boolean getInvalidIteratorState() - { - return iterator == null; - } - - public double getNumberValue() - { - if (type == XPathResult.NUMBER_TYPE) - { - return ((Double) value).doubleValue (); - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public short getResultType() - { - return type; - } - - public Node getSingleNodeValue() - { - switch (type) - { - case XPathResult.FIRST_ORDERED_NODE_TYPE: - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: - case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE: - Collection ns = (Collection) value; - if (ns.isEmpty ()) - { - return null; - } - else - { - return (Node) ns.iterator ().next (); - } - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public int getSnapshotLength() - { - switch (type) - { - case XPathResult.FIRST_ORDERED_NODE_TYPE: - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: - case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE: - return ((Collection) value).size (); - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public String getStringValue() - { - if (type == XPathResult.STRING_TYPE) - { - return (String) value; - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public Node iterateNext() - { - if (iterator != null) - { - if (iterator.hasNext ()) - { - return (Node) iterator.next (); - } - else - { - iterator = null; - return null; - } - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public Node snapshotItem(int index) - { - switch (type) - { - case XPathResult.FIRST_ORDERED_NODE_TYPE: - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: - case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE: - Collection ns = (Collection) value; - Node[] nodes = new Node[ns.size ()]; - ns.toArray (nodes); - return nodes[index]; - } - throw new XPathException (XPathException.TYPE_ERR, value.toString ()); - } - - public String toString () - { - return getClass ().getName () + "[type=" + typeName (type) + ",value=" + - value + ']'; - } - - private String typeName (short type) - { - switch (type) - { - case XPathResult.BOOLEAN_TYPE: - return "BOOLEAN_TYPE"; - case XPathResult.NUMBER_TYPE: - return "NUMBER_TYPE"; - case XPathResult.STRING_TYPE: - return "STRING_TYPE"; - case XPathResult.FIRST_ORDERED_NODE_TYPE: - return "FIRST_ORDERED_NODE_TYPE"; - case XPathResult.ORDERED_NODE_ITERATOR_TYPE: - return "ORDERED_NODE_ITERATOR_TYPE"; - case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE: - return "ORDERED_NODE_SNAPSHOT_TYPE"; - case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: - return "UNORDERED_NODE_ITERATOR_TYPE"; - case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE: - return "UNORDERED_NODE_SNAPSHOT_TYPE"; - default: - return "(unknown)"; - } - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ImplementationList.java b/libjava/classpath/gnu/xml/dom/ImplementationList.java deleted file mode 100644 index c99f55d..0000000 --- a/libjava/classpath/gnu/xml/dom/ImplementationList.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ImplementationList.java -- - Copyright (C) 2004 Free Software Foundation, Inc.. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ -package gnu.xml.dom; - -import java.util.List; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.DOMImplementationList; - -/** - * Implementation list for GNU JAXP. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class ImplementationList - implements DOMImplementationList -{ - - private List list; - - ImplementationList(List list) - { - this.list = list; - } - - public int getLength() - { - return list.size(); - } - - public DOMImplementation item(int index) - { - return (DOMImplementation) list.get(index); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ImplementationSource.java b/libjava/classpath/gnu/xml/dom/ImplementationSource.java deleted file mode 100644 index 5f40442..0000000 --- a/libjava/classpath/gnu/xml/dom/ImplementationSource.java +++ /dev/null @@ -1,167 +0,0 @@ -/* ImplementationSource.java -- - Copyright (C) 2004 Free Software Foundation, Inc.. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ -package gnu.xml.dom; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.DOMImplementationList; -import org.w3c.dom.DOMImplementationSource; - -/** - * Implementation source for GNU JAXP. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class ImplementationSource - implements DOMImplementationSource -{ - - private static final String DIGITS = "1234567890"; - - /* - * GNU DOM implementations. - */ - private static final DOMImplementation[] implementations; - - static - { - List acc = new ArrayList(); - acc.add(new gnu.xml.dom.DomImpl()); - try - { - Class t = Class.forName("gnu.xml.libxmlj.dom.GnomeDocumentBuilder"); - acc.add(t.newInstance()); - } - catch (Exception e) - { - // libxmlj not available - } - catch (UnsatisfiedLinkError e) - { - // libxmlj not available - } - implementations = new DOMImplementation[acc.size()]; - acc.toArray(implementations); - } - - public DOMImplementation getDOMImplementation(String features) - { - List available = getImplementations(features); - if (available.isEmpty()) - { - return null; - } - return (DOMImplementation) available.get(0); - } - - public DOMImplementationList getDOMImplementationList(String features) - { - List available = getImplementations(features); - return new ImplementationList(available); - } - - /** - * Returns a list of the implementations that support the specified - * features. - */ - private final List getImplementations(String features) - { - List available = new ArrayList(Arrays.asList(implementations)); - for (Iterator i = parseFeatures(features).iterator(); i.hasNext(); ) - { - String feature = (String) i.next(); - String version = null; - int si = feature.indexOf(' '); - if (si != -1) - { - version = feature.substring(si + 1); - feature = feature.substring(0, si); - } - for (Iterator j = available.iterator(); j.hasNext(); ) - { - DOMImplementation impl = (DOMImplementation) j.next(); - if (!impl.hasFeature(feature, version)) - { - j.remove(); - } - } - } - return available; - } - - /** - * Parses the feature list into feature tokens. - */ - final List parseFeatures(String features) - { - List list = new ArrayList(); - int pos = 0, start = 0; - int len = features.length(); - for (; pos < len; pos++) - { - char c = features.charAt(pos); - if (c == ' ') - { - if (pos + 1 < len && - DIGITS.indexOf(features.charAt(pos + 1)) == -1) - { - list.add(getFeature(features, start, pos)); - start = pos + 1; - } - } - } - if (pos > start) - { - list.add(getFeature(features, start, len)); - } - return list; - } - - final String getFeature(String features, int start, int end) - { - if (features.length() > 0 && features.charAt(start) == '+') - { - return features.substring(start + 1, end); - } - return features.substring(start, end); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/JAXPFactory.java b/libjava/classpath/gnu/xml/dom/JAXPFactory.java deleted file mode 100644 index d7d399b..0000000 --- a/libjava/classpath/gnu/xml/dom/JAXPFactory.java +++ /dev/null @@ -1,308 +0,0 @@ -/* JAXPFactory.java -- - Copyright (C) 2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom; - -import java.io.IOException; - -import org.w3c.dom.Document; -import org.w3c.dom.DOMImplementation; - -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; - - -/** - * DOM bootstrapping API, for use with JAXP. - * - * @see Consumer - * - * @author David Brownell - */ -public final class JAXPFactory - extends DocumentBuilderFactory -{ - - private static final String PROPERTY = "http://xml.org/sax/properties/"; - private static final String FEATURE = "http://xml.org/sax/features/"; - - private SAXParserFactory pf; - private boolean secureProcessing; - - /** - * Default constructor. - */ - public JAXPFactory() - { - } - - /** - * Constructs a JAXP document builder which uses the default - * JAXP SAX2 parser and the DOM implementation in this package. - */ - public DocumentBuilder newDocumentBuilder() - throws ParserConfigurationException - { - if (pf == null) - { - // Force use of AElfred2 since not all JAXP parsers - // conform very well to the SAX2 API spec ... - pf = new gnu.xml.aelfred2.JAXPFactory(); - // pf = SAXParserFactory.newInstance (); - } - - // JAXP default: false - pf.setValidating(isValidating()); - - // FIXME: this namespace setup may cause errors in some - // conformant SAX2 parsers, which we CAN patch up by - // splicing a "NSFilter" stage up front ... - - // JAXP default: false - pf.setNamespaceAware(isNamespaceAware()); - - try - { - // undo rude "namespace-prefixes=false" default - pf.setFeature(FEATURE + "namespace-prefixes", true); - - return new JAXPBuilder(pf.newSAXParser().getXMLReader(), this); - } - catch (SAXException e) - { - String msg = "can't create JAXP DocumentBuilder: " + e.getMessage(); - throw new ParserConfigurationException(msg); - } - } - - /** There seems to be no useful specification for attribute names */ - public void setAttribute(String name, Object value) - throws IllegalArgumentException - { - if ("http://java.sun.com/xml/jaxp/properties/schemaLanguage".equals(name)) - { - // TODO - } - else - { - throw new IllegalArgumentException(name); - } - } - - /** There seems to be no useful specification for attribute names */ - public Object getAttribute(String name) - throws IllegalArgumentException - { - throw new IllegalArgumentException(name); - } - - public void setFeature(String name, boolean value) - throws ParserConfigurationException - { - if (name == null) - throw new NullPointerException(); - if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) - { - secureProcessing = true; - return; - } - throw new ParserConfigurationException(name); - } - - public boolean getFeature(String name) - throws ParserConfigurationException - { - if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) - return secureProcessing; - throw new ParserConfigurationException(name); - } - - static final class JAXPBuilder - extends DocumentBuilder - implements ErrorHandler - { - - private Consumer consumer; - private XMLReader producer; - private DomImpl impl; - - JAXPBuilder(XMLReader parser, JAXPFactory factory) - throws ParserConfigurationException - { - impl = new DomImpl(); - - // set up consumer side - try - { - consumer = new Consumer(); - } - catch (SAXException e) - { - throw new ParserConfigurationException(e.getMessage()); - } - - // JAXP defaults: true, noise nodes are good (bleech) - consumer.setHidingReferences(factory.isExpandEntityReferences()); - consumer.setHidingComments(factory.isIgnoringComments()); - consumer.setHidingWhitespace(factory.isIgnoringElementContentWhitespace()); - consumer.setHidingCDATA(factory.isCoalescing()); - - // set up producer side - producer = parser; - producer.setContentHandler(consumer.getContentHandler()); - producer.setDTDHandler(consumer.getDTDHandler()); - - try - { - String id; - - // if validating, report validity errors, and default - // to treating them as fatal - if (factory.isValidating ()) - { - producer.setFeature(FEATURE + "validation", true); - producer.setErrorHandler(this); - } - - // always save prefix info, maybe do namespace processing - producer.setFeature(FEATURE + "namespace-prefixes", true); - producer.setFeature(FEATURE + "namespaces", - factory.isNamespaceAware()); - - // set important handlers - id = PROPERTY + "lexical-handler"; - producer.setProperty(id, consumer.getProperty(id)); - - id = PROPERTY + "declaration-handler"; - producer.setProperty(id, consumer.getProperty(id)); - - } - catch (SAXException e) - { - throw new ParserConfigurationException(e.getMessage()); - } - } - - public Document parse(InputSource source) - throws SAXException, IOException - { - producer.parse(source); - Document doc = consumer.getDocument(); - // TODO inputEncoding - doc.setDocumentURI(source.getSystemId()); - return doc; - } - - public boolean isNamespaceAware() - { - try - { - return producer.getFeature(FEATURE + "namespaces"); - } - catch (SAXException e) - { - // "can't happen" - throw new RuntimeException(e.getMessage()); - } - } - - public boolean isValidating() - { - try - { - return producer.getFeature(FEATURE + "validation"); - } - catch (SAXException e) - { - // "can't happen" - throw new RuntimeException(e.getMessage()); - } - } - - public void setEntityResolver(EntityResolver resolver) - { - producer.setEntityResolver(resolver); - } - - public void setErrorHandler(ErrorHandler handler) - { - producer.setErrorHandler(handler); - consumer.setErrorHandler(handler); - } - - public DOMImplementation getDOMImplementation() - { - return impl; - } - - public Document newDocument() - { - return new DomDocument(); - } - - // implementation of error handler that's used when validating - public void fatalError(SAXParseException e) - throws SAXException - { - throw e; - } - - public void error(SAXParseException e) - throws SAXException - { - throw e; - } - - public void warning(SAXParseException e) - throws SAXException - { - /* ignore */ - } - - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java deleted file mode 100644 index 4448dd5..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java +++ /dev/null @@ -1,188 +0,0 @@ -/* DomHTMLAnchorElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLAnchorElement; - -/** - * An HTML 'A' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLAnchorElement - extends DomHTMLElement - implements HTMLAnchorElement -{ - - protected DomHTMLAnchorElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public String getCharset() - { - return getHTMLAttribute("charset"); - } - - public void setCharset(String charset) - { - setHTMLAttribute("charset", charset); - } - - public String getCoords() - { - return getHTMLAttribute("coords"); - } - - public void setCoords(String coords) - { - setHTMLAttribute("coords", coords); - } - - public String getHref() - { - return getHTMLAttribute("href"); - } - - public void setHref(String href) - { - setHTMLAttribute("href", href); - } - - public String getHreflang() - { - return getHTMLAttribute("hreflang"); - } - - public void setHreflang(String hreflang) - { - setHTMLAttribute("hreflang", hreflang); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getRel() - { - return getHTMLAttribute("rel"); - } - - public void setRel(String rel) - { - setHTMLAttribute("rel", rel); - } - - public String getRev() - { - return getHTMLAttribute("rev"); - } - - public void setRev(String rev) - { - setHTMLAttribute("rev", rev); - } - - public String getShape() - { - return getHTMLAttribute("shape"); - } - - public void setShape(String shape) - { - setHTMLAttribute("shape", shape); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getTarget() - { - return getHTMLAttribute("target"); - } - - public void setTarget(String target) - { - setHTMLAttribute("target", target); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public void blur() - { - dispatchUIEvent("blur"); - } - - public void focus() - { - dispatchUIEvent("focus"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java deleted file mode 100644 index 429fb00..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java +++ /dev/null @@ -1,187 +0,0 @@ -/* DomHTMLAppletElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLAppletElement; - -/** - * An HTML 'APPLET' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLAppletElement - extends DomHTMLElement - implements HTMLAppletElement -{ - - protected DomHTMLAppletElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getCls() - { - return getHTMLAttribute("class"); - } - - public void setCls(String cls) - { - setHTMLAttribute("class", cls); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public String getAlt() - { - return getHTMLAttribute("alt"); - } - - public void setAlt(String alt) - { - setHTMLAttribute("alt", alt); - } - - public String getArchive() - { - return getHTMLAttribute("archive"); - } - - public void setArchive(String archive) - { - setHTMLAttribute("archive", archive); - } - - public String getCode() - { - return getHTMLAttribute("code"); - } - - public void setCode(String code) - { - setHTMLAttribute("code", code); - } - - public String getCodeBase() - { - return getHTMLAttribute("codebase"); - } - - public void setCodeBase(String codeBase) - { - setHTMLAttribute("codebase", codeBase); - } - - public String getHeight() - { - return getHTMLAttribute("height"); - } - - public void setHeight(String height) - { - setHTMLAttribute("height", height); - } - - public int getHspace() - { - return getIntHTMLAttribute("hspace"); - } - - public void setHspace(int hspace) - { - setIntHTMLAttribute("hspace", hspace); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getObject() - { - return getHTMLAttribute("object"); - } - - public void setObject(String object) - { - setHTMLAttribute("object", object); - } - - public int getVspace() - { - return getIntHTMLAttribute("vspace"); - } - - public void setVspace(int vspace) - { - setIntHTMLAttribute("vspace", vspace); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAreaElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLAreaElement.java deleted file mode 100644 index 728b3fd..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLAreaElement.java +++ /dev/null @@ -1,138 +0,0 @@ -/* DomHTMLAreaElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLAreaElement; - -/** - * An HTML 'AREA' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLAreaElement - extends DomHTMLElement - implements HTMLAreaElement -{ - - protected DomHTMLAreaElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public String getAlt() - { - return getHTMLAttribute("alt"); - } - - public void setAlt(String alt) - { - setHTMLAttribute("alt", alt); - } - - public String getCoords() - { - return getHTMLAttribute("coords"); - } - - public void setCoords(String coords) - { - setHTMLAttribute("coords", coords); - } - - public String getHref() - { - return getHTMLAttribute("href"); - } - - public void setHref(String href) - { - setHTMLAttribute("href", href); - } - - public boolean getNoHref() - { - return getBooleanHTMLAttribute("nohref"); - } - - public void setNoHref(boolean nohref) - { - setBooleanHTMLAttribute("nohref", nohref); - } - - public String getShape() - { - return getHTMLAttribute("shape"); - } - - public void setShape(String shape) - { - setHTMLAttribute("shape", shape); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getTarget() - { - return getHTMLAttribute("target"); - } - - public void setTarget(String target) - { - setHTMLAttribute("target", target); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBRElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLBRElement.java deleted file mode 100644 index 5ad49c5..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBRElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLBRElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLBRElement; - -/** - * An HTML 'BR' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLBRElement - extends DomHTMLElement - implements HTMLBRElement -{ - - protected DomHTMLBRElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getClear() - { - return getHTMLAttribute("clear"); - } - - public void setClear(String clear) - { - setHTMLAttribute("clear", clear); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseElement.java deleted file mode 100644 index 99a0993..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLBaseElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLBaseElement; - -/** - * An HTML 'BASE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLBaseElement - extends DomHTMLElement - implements HTMLBaseElement -{ - - protected DomHTMLBaseElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getHref() - { - return getHTMLAttribute("href"); - } - - public void setHref(String href) - { - setHTMLAttribute("href", href); - } - - public String getTarget() - { - return getHTMLAttribute("target"); - } - - public void setTarget(String target) - { - setHTMLAttribute("target", target); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseFontElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseFontElement.java deleted file mode 100644 index 73ec96d..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBaseFontElement.java +++ /dev/null @@ -1,88 +0,0 @@ -/* DomHTMLBaseFontElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLBaseFontElement; - -/** - * An HTML 'BASEFONT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLBaseFontElement - extends DomHTMLElement - implements HTMLBaseFontElement -{ - - protected DomHTMLBaseFontElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getColor() - { - return getHTMLAttribute("color"); - } - - public void setColor(String color) - { - setHTMLAttribute("color", color); - } - - public String getFace() - { - return getHTMLAttribute("face"); - } - - public void setFace(String face) - { - setHTMLAttribute("face", face); - } - - public int getSize() - { - return getIntHTMLAttribute("size"); - } - - public void setSize(int size) - { - setIntHTMLAttribute("size", size); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBodyElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLBodyElement.java deleted file mode 100644 index d452862..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLBodyElement.java +++ /dev/null @@ -1,118 +0,0 @@ -/* DomHTMLBodyElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLBodyElement; - -/** - * An HTML 'BODY' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLBodyElement - extends DomHTMLElement - implements HTMLBodyElement -{ - - protected DomHTMLBodyElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getALink() - { - return getHTMLAttribute("alink"); - } - - public void setALink(String alink) - { - setHTMLAttribute("alink", alink); - } - - public String getBackground() - { - return getHTMLAttribute("background"); - } - - public void setBackground(String background) - { - setHTMLAttribute("background", background); - } - - public String getBgColor() - { - return getHTMLAttribute("bgcolor"); - } - - public void setBgColor(String bgcolor) - { - setHTMLAttribute("bgcolor", bgcolor); - } - - public String getLink() - { - return getHTMLAttribute("link"); - } - - public void setLink(String link) - { - setHTMLAttribute("link", link); - } - - public String getText() - { - return getHTMLAttribute("text"); - } - - public void setText(String text) - { - setHTMLAttribute("text", text); - } - - public String getVLink() - { - return getHTMLAttribute("vlink"); - } - - public void setVLink(String vlink) - { - setHTMLAttribute("vlink", vlink); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLButtonElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLButtonElement.java deleted file mode 100644 index 696169a..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLButtonElement.java +++ /dev/null @@ -1,119 +0,0 @@ -/* DomHTMLButtonElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLButtonElement; -import org.w3c.dom.html2.HTMLFormElement; - -/** - * An HTML 'BUTTON' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLButtonElement - extends DomHTMLElement - implements HTMLButtonElement -{ - - protected DomHTMLButtonElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public String getValue() - { - return getHTMLAttribute("value"); - } - - public void setValue(String value) - { - setHTMLAttribute("value", value); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLCollection.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLCollection.java deleted file mode 100644 index 8300287..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLCollection.java +++ /dev/null @@ -1,225 +0,0 @@ -/* DomHTMLCollection.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.w3c.dom.DOMException; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLOptionsCollection; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; - -/** - * An HTML element collection. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class DomHTMLCollection - implements HTMLCollection, HTMLOptionsCollection, NodeList, NodeFilter -{ - - final DomHTMLDocument doc; - final Node root; - List nodeNames; - List attributeNames; - List results; - - DomHTMLCollection(DomHTMLDocument doc, Node root) - { - this.doc = doc; - this.root = root; - } - - // -- Node name and attribute filtering -- - - void addNodeName(String name) - { - if (nodeNames == null) - { - nodeNames = new LinkedList(); - } - nodeNames.add(name); - } - - void addAttributeName(String name) - { - if (attributeNames == null) - { - attributeNames = new LinkedList(); - } - attributeNames.add(name); - } - - public short acceptNode(Node n) - { - if (n.getNodeType() != Node.ELEMENT_NODE) - { - return NodeFilter.FILTER_SKIP; - } - String localName = n.getLocalName(); - if (localName == null) - { - localName = n.getNodeName(); - } - if (nodeNames != null && !acceptName(localName)) - { - return NodeFilter.FILTER_SKIP; - } - if (attributeNames != null && !acceptAttributes(n.getAttributes())) - { - return NodeFilter.FILTER_SKIP; - } - return NodeFilter.FILTER_ACCEPT; - } - - private boolean acceptName(String name) - { - for (Iterator i = nodeNames.iterator(); i.hasNext(); ) - { - String nodeName = (String) i.next(); - if (nodeName.equalsIgnoreCase(name)) - { - return true; - } - } - return false; - } - - private boolean acceptAttributes(NamedNodeMap attrs) - { - for (Iterator i = attributeNames.iterator(); i.hasNext(); ) - { - String attributeName = (String) i.next(); - Node attr = getNamedItem(attrs, attributeName); - if (attr != null) - { - // Check that attribute has a non-null value - String nodeValue = attr.getNodeValue(); - if (nodeValue != null && nodeValue.length() > 0) - { - return true; - } - } - } - return false; - } - - /** - * Case-insensitive version of getNamedItem. - */ - private Node getNamedItem(NamedNodeMap attrs, String name) - { - int len = attrs.getLength(); - for (int i = 0; i < len; i++) - { - Node attr = attrs.item(i); - String attrName = attr.getLocalName(); - if (attrName == null) - { - attrName = attr.getNodeName(); - } - if (name.equalsIgnoreCase(attrName)) - { - return attr; - } - } - return null; - } - - // -- Perform query -- - - void evaluate() - { - NodeIterator i = doc.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, - this, true); - results = new ArrayList(); - for (Node node = i.nextNode(); node != null; node = i.nextNode()) - { - results.add(node); - } - } - - // -- HTMLCollection/NodeList interface -- - - public int getLength() - { - return results.size(); - } - - public void setLength(int length) - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - - public Node item(int index) - { - return (Node) results.get(index); - } - - public Node namedItem(String name) - { - boolean xhtml = false; // FIXME detect XHTML document - for (Iterator i = results.iterator(); i.hasNext(); ) - { - Node node = (Node) i.next(); - NamedNodeMap attrs = node.getAttributes(); - Node attr = getNamedItem(attrs, "id"); - if (name.equals(attr.getTextContent())) - { - return node; - } - if (!xhtml) - { - attr = getNamedItem(attrs, "name"); - if (name.equals(attr.getTextContent())) - { - return node; - } - } - } - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDListElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLDListElement.java deleted file mode 100644 index 9acce85..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDListElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLDListElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLDListElement; - -/** - * An HTML 'DL' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLDListElement - extends DomHTMLElement - implements HTMLDListElement -{ - - protected DomHTMLDListElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getCompact() - { - return getBooleanHTMLAttribute("compact"); - } - - public void setCompact(boolean compact) - { - setBooleanHTMLAttribute("compact", compact); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDirectoryElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLDirectoryElement.java deleted file mode 100644 index e0f94a1..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDirectoryElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLDirectoryElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLDirectoryElement; - -/** - * An HTML 'DIR' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLDirectoryElement - extends DomHTMLElement - implements HTMLDirectoryElement -{ - - protected DomHTMLDirectoryElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getCompact() - { - return getBooleanHTMLAttribute("compact"); - } - - public void setCompact(boolean compact) - { - setBooleanHTMLAttribute("compact", compact); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDivElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLDivElement.java deleted file mode 100644 index 66b3ac7..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDivElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLDivElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLDivElement; - -/** - * An HTML 'DIV' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLDivElement - extends DomHTMLElement - implements HTMLDivElement -{ - - protected DomHTMLDivElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDocument.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLDocument.java deleted file mode 100644 index 1afed7b..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLDocument.java +++ /dev/null @@ -1,426 +0,0 @@ -/* DomHTMLDocument.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDocument; -import gnu.xml.dom.DomDOMException; -import java.lang.reflect.Constructor; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLDocument; -import org.w3c.dom.html2.HTMLElement; - -/** - * An HTML document. - * This is the factory object used to create HTML elements. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLDocument - extends DomDocument - implements HTMLDocument -{ - - private static final Class[] ELEMENT_PT = new Class[] { - DomHTMLDocument.class, - String.class, - String.class - }; - - private static Map ELEMENT_CLASSES; - static - { - Map map = new HashMap(); - map.put("a", DomHTMLAnchorElement.class); - map.put("applet", DomHTMLAppletElement.class); - map.put("area", DomHTMLAreaElement.class); - map.put("base", DomHTMLBaseElement.class); - map.put("basefont", DomHTMLBaseFontElement.class); - map.put("body", DomHTMLBodyElement.class); - map.put("br", DomHTMLBRElement.class); - map.put("button", DomHTMLButtonElement.class); - map.put("dir", DomHTMLDirectoryElement.class); - map.put("div", DomHTMLDivElement.class); - map.put("dlist", DomHTMLDListElement.class); - map.put("embed", DomHTMLEmbedElement.class); - map.put("fieldset", DomHTMLFieldSetElement.class); - map.put("font", DomHTMLFontElement.class); - map.put("form", DomHTMLFormElement.class); - map.put("frame", DomHTMLFrameElement.class); - map.put("frameset", DomHTMLFrameSetElement.class); - map.put("head", DomHTMLHeadElement.class); - map.put("h1", DomHTMLHeadingElement.class); - map.put("h2", DomHTMLHeadingElement.class); - map.put("h3", DomHTMLHeadingElement.class); - map.put("h4", DomHTMLHeadingElement.class); - map.put("h5", DomHTMLHeadingElement.class); - map.put("h6", DomHTMLHeadingElement.class); - map.put("html", DomHTMLHtmlElement.class); - map.put("iframe", DomHTMLIFrameElement.class); - map.put("img", DomHTMLImageElement.class); - map.put("input", DomHTMLInputElement.class); - map.put("isindex", DomHTMLIsIndexElement.class); - map.put("label", DomHTMLLabelElement.class); - map.put("legend", DomHTMLLegendElement.class); - map.put("li", DomHTMLLIElement.class); - map.put("link", DomHTMLLinkElement.class); - map.put("map", DomHTMLMapElement.class); - map.put("menu", DomHTMLMenuElement.class); - map.put("meta", DomHTMLMetaElement.class); - map.put("ins", DomHTMLModElement.class); - map.put("del", DomHTMLModElement.class); - map.put("object", DomHTMLObjectElement.class); - map.put("ol", DomHTMLOListElement.class); - map.put("optgroup", DomHTMLOptGroupElement.class); - map.put("option", DomHTMLOptionElement.class); - map.put("p", DomHTMLParagraphElement.class); - map.put("param", DomHTMLParamElement.class); - map.put("pre", DomHTMLPreElement.class); - map.put("q", DomHTMLQuoteElement.class); - map.put("blockquote", DomHTMLQuoteElement.class); - map.put("script", DomHTMLScriptElement.class); - map.put("select", DomHTMLSelectElement.class); - map.put("style", DomHTMLStyleElement.class); - map.put("caption", DomHTMLTableCaptionElement.class); - map.put("th", DomHTMLTableCellElement.class); - map.put("td", DomHTMLTableCellElement.class); - map.put("col", DomHTMLTableColElement.class); - map.put("colgroup", DomHTMLTableColElement.class); - map.put("table", DomHTMLTableElement.class); - map.put("tr", DomHTMLTableRowElement.class); - map.put("thead", DomHTMLTableSectionElement.class); - map.put("tfoot", DomHTMLTableSectionElement.class); - map.put("tbody", DomHTMLTableSectionElement.class); - map.put("textarea", DomHTMLTextAreaElement.class); - map.put("title", DomHTMLTitleElement.class); - map.put("ul", DomHTMLUListElement.class); - ELEMENT_CLASSES = Collections.unmodifiableMap(map); - } - - private static Set HTML_NS_URIS; - static - { - Set set = new HashSet(); - set.add("http://www.w3.org/TR/html4/strict"); - set.add("http://www.w3.org/TR/html4/loose"); - set.add("http://www.w3.org/TR/html4/frameset"); - set.add("http://www.w3.org/1999/xhtml"); - set.add("http://www.w3.org/TR/xhtml1/strict"); - set.add("http://www.w3.org/TR/xhtml1/loose"); - set.add("http://www.w3.org/TR/xhtml1/frameset"); - HTML_NS_URIS = Collections.unmodifiableSet(set); - } - - /** - * Convenience constructor. - */ - public DomHTMLDocument() - { - this(new DomHTMLImpl()); - } - - /** - * Constructor. - * This is called by the DOMImplementation. - */ - public DomHTMLDocument(DomHTMLImpl impl) - { - super(impl); - } - - private Node getChildNodeByName(Node parent, String name) - { - for (Node ctx = parent.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - if (name.equalsIgnoreCase(ctx.getNodeName())) - { - return ctx; - } - } - return null; - } - - public String getTitle() - { - Node html = getDocumentElement(); - if (html != null) - { - Node head = getChildNodeByName(html, "head"); - if (head != null) - { - Node title = getChildNodeByName(head, "title"); - if (title != null) - { - return title.getTextContent(); - } - } - } - return null; - } - - public void setTitle(String title) - { - Node html = getDocumentElement(); - if (html == null) - { - html = createElement("html"); - appendChild(html); - } - Node head = getChildNodeByName(html, "head"); - if (head == null) - { - head = createElement("head"); - Node first = html.getFirstChild(); - if (first != null) - { - html.insertBefore(first, head); - } - else - { - html.appendChild(head); - } - } - Node titleNode = getChildNodeByName(head, "title"); - if (titleNode == null) - { - titleNode = createElement("title"); - Node first = head.getFirstChild(); - if (first != null) - { - head.insertBefore(first, titleNode); - } - else - { - head.appendChild(titleNode); - } - } - titleNode.setTextContent(title); - } - - public String getReferrer() - { - // TODO getReferrer - return null; - } - - public String getDomain() - { - try - { - URL url = new URL(getDocumentURI()); - return url.getHost(); - } - catch (MalformedURLException e) - { - return null; - } - } - - public String getURL() - { - return getDocumentURI(); - } - - public HTMLElement getBody() - { - Node html = getDocumentElement(); - if (html != null) - { - Node body = getChildNodeByName(html, "body"); - if (body == null) - { - body = getChildNodeByName(html, "frameset"); - } - return (HTMLElement) body; - } - return null; - } - - public void setBody(HTMLElement body) - { - Node html = getDocumentElement(); - if (html == null) - { - html = createElement("html"); - appendChild(html); - } - Node ref = getBody(); - if (ref == null) - { - html.appendChild(body); - } - else - { - html.replaceChild(body, ref); - } - } - - public HTMLCollection getImages() - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName("img"); - ret.evaluate(); - return ret; - } - - public HTMLCollection getApplets() - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName("embed"); - ret.addNodeName("object"); - ret.addNodeName("applet"); - ret.evaluate(); - return ret; - } - - public HTMLCollection getLinks() - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName("area"); - ret.addNodeName("a"); - ret.evaluate(); - return ret; - } - - public HTMLCollection getForms() - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName("form"); - ret.evaluate(); - return ret; - } - - public HTMLCollection getAnchors() - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName("a"); - ret.addAttributeName("name"); - ret.evaluate(); - return ret; - } - - public String getCookie() - { - // TODO getCookie - return null; - } - - public void setCookie(String cookie) - { - // TODO setCookie - } - - public void open() - { - // TODO open - } - - public void close() - { - // TODO close - } - - public void write(String text) - { - // TODO write - } - - public void writeln(String text) - { - // TODO write - } - - public NodeList getElementsByName(String name) - { - DomHTMLCollection ret = new DomHTMLCollection(this, this); - ret.addNodeName(name); - ret.evaluate(); - return ret; - // TODO xhtml: return only form controls (?) - } - - public Element createElement(String tagName) - { - return createElementNS(null, tagName); - } - - public Element createElementNS(String uri, String qName) - { - /* If a non-HTML element, use the default implementation. */ - if (uri != null && !HTML_NS_URIS.contains(uri)) - { - return super.createElementNS(uri, qName); - } - String localName = qName.toLowerCase(); - int ci = qName.indexOf(':'); - if (ci != -1) - { - localName = qName.substring(ci + 1); - } - Class t = (Class) ELEMENT_CLASSES.get(localName); - /* If a non-HTML element, use the default implementation. */ - if (t == null) - { - return super.createElementNS(uri, qName); - } - try - { - Constructor c = t.getDeclaredConstructor(ELEMENT_PT); - Object[] args = new Object[] { this, uri, qName }; - return (Element) c.newInstance(args); - } - catch (Exception e) - { - DOMException e2 = new DomDOMException(DOMException.TYPE_MISMATCH_ERR); - e2.initCause(e); - throw e2; - } - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLElement.java deleted file mode 100644 index deeefec..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLElement.java +++ /dev/null @@ -1,286 +0,0 @@ -/* DomHTMLElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import gnu.xml.dom.DomElement; -import gnu.xml.dom.DomEvent; -import org.w3c.dom.DOMException; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.events.UIEvent; -import org.w3c.dom.html2.HTMLElement; - -/** - * Abstract implementation of an HTML element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public abstract class DomHTMLElement - extends DomElement - implements HTMLElement -{ - - protected DomHTMLElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - /** - * Returns the value of the specified attribute. - * The attribute name is case insensitive. - */ - protected String getHTMLAttribute(String name) - { - if (hasAttributes()) - { - NamedNodeMap attrs = getAttributes(); - int len = attrs.getLength(); - for (int i = 0; i < len; i++) - { - Node attr = attrs.item(i); - String attrName = attr.getLocalName(); - if (attrName == null) - { - attrName = attr.getNodeName(); - } - if (attrName.equalsIgnoreCase(name)) - { - return attr.getNodeValue(); - } - } - } - return ""; - } - - protected int getIntHTMLAttribute(String name) - { - String value = getHTMLAttribute(name); - if (value == null) - { - return -1; - } - try - { - return Integer.parseInt(value); - } - catch (NumberFormatException e) - { - return -1; - } - } - - protected boolean getBooleanHTMLAttribute(String name) - { - String value = getHTMLAttribute(name); - return value != null; - } - - /** - * Sets the value of the specified attribute. - * The attribute name is case insensitive. - */ - protected void setHTMLAttribute(String name, String value) - { - Node attr; - NamedNodeMap attrs = getAttributes(); - int len = attrs.getLength(); - for (int i = 0; i < len; i++) - { - attr = attrs.item(i); - String attrName = attr.getLocalName(); - if (attrName == null) - { - attrName = attr.getNodeName(); - } - if (attrName.equalsIgnoreCase(name)) - { - if (value != null) - { - attr.setNodeValue(value); - } - else - { - attrs.removeNamedItem(attr.getNodeName()); - } - return; - } - } - if (value != null) - { - // Create a new attribute - DomHTMLDocument doc = (DomHTMLDocument) getOwnerDocument(); - // XXX namespace URI for attribute? - attr = doc.createAttribute(name); - attr.setNodeValue(value); - } - } - - protected void setIntHTMLAttribute(String name, int value) - { - setHTMLAttribute(name, Integer.toString(value)); - } - - protected void setBooleanHTMLAttribute(String name, boolean value) - { - setHTMLAttribute(name, value ? name : null); - } - - /** - * Returns the first parent element with the specified name. - */ - protected Node getParentElement(String name) - { - for (Node parent = getParentNode(); parent != null; - parent = parent.getParentNode()) - { - String parentName = parent.getLocalName(); - if (parentName == null) - { - parentName = parent.getNodeName(); - } - if (name.equalsIgnoreCase(parentName)) - { - return parent; - } - } - return null; - } - - /** - * Returns the first child element with the specified name. - */ - protected Node getChildElement(String name) - { - for (Node child = getFirstChild(); child != null; - child = child.getNextSibling()) - { - String childName = child.getLocalName(); - if (childName == null) - { - childName = child.getLocalName(); - } - if (name.equalsIgnoreCase(childName)) - { - return child; - } - } - return null; - } - - /** - * Returns the index of this element among elements of the same name, - * relative to its parent. - */ - protected int getIndex() - { - int index = 0; - Node parent = getParentNode(); - if (parent != null) - { - for (Node ctx = parent.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - if (ctx == this) - { - return index; - } - index++; - } - } - throw new DomDOMException(DOMException.NOT_FOUND_ERR); - } - - protected void dispatchUIEvent(String name) - { - UIEvent event = new DomEvent.DomUIEvent(name); - dispatchEvent(event); - } - - public String getId() - { - return getHTMLAttribute("id"); - } - - public void setId(String id) - { - setHTMLAttribute("id", id); - } - - public String getTitle() - { - return getHTMLAttribute("title"); - } - - public void setTitle(String title) - { - setHTMLAttribute("title", title); - } - - public String getLang() - { - return getHTMLAttribute("lang"); - } - - public void setLang(String lang) - { - setHTMLAttribute("lang", lang); - } - - public String getDir() - { - return getHTMLAttribute("dir"); - } - - public void setDir(String dir) - { - setHTMLAttribute("dir", dir); - } - - public String getClassName() - { - return getHTMLAttribute("class"); - } - - public void setClassName(String className) - { - setHTMLAttribute("class", className); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLEmbedElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLEmbedElement.java deleted file mode 100644 index 2211315..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLEmbedElement.java +++ /dev/null @@ -1,129 +0,0 @@ -/* DomHTMLEmbedElement.java -- - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.xml.dom.html2; - -public class DomHTMLEmbedElement - extends DomHTMLAppletElement -{ - protected DomHTMLEmbedElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getJavaObject() - { - return getHTMLAttribute("java_object"); - } - - public void setJavaObject(String object) - { - setHTMLAttribute("java_object", object); - } - - public String getJavaCodeBase() - { - return getHTMLAttribute("java_codebase"); - } - - public void setJavaCodeBase(String codeBase) - { - setHTMLAttribute("java_codebase", codeBase); - } - - public String getJavaArchive() - { - return getHTMLAttribute("java_archive"); - } - - public void setJavaArchive(String archive) - { - setHTMLAttribute("java_archive", archive); - } - - public void setJavaCode(String code) - { - setHTMLAttribute("java_code", code); - } - - public String getJavaCode() - { - return getHTMLAttribute("java_code"); - } - - public void setJavaType(String type) - { - setHTMLAttribute("java_type", type); - } - - public String getJavaType() - { - return getHTMLAttribute("java_type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public String getPluginsPage() - { - return getHTMLAttribute("pluginspage"); - } - - public void setPluginsPage(String pluginspage) - { - setHTMLAttribute("pluginspage", pluginspage); - } - - public String getMayscript() - { - return getHTMLAttribute("mayscript"); - } - - public void setMayscript(String mayscript) - { - setHTMLAttribute("mayscript", mayscript); - } -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFieldSetElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLFieldSetElement.java deleted file mode 100644 index 252cd3d..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFieldSetElement.java +++ /dev/null @@ -1,64 +0,0 @@ -/* DomHTMLFieldSetElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFieldSetElement; -import org.w3c.dom.html2.HTMLFormElement; - -/** - * An HTML 'FIELDSET' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLFieldSetElement - extends DomHTMLElement - implements HTMLFieldSetElement -{ - - protected DomHTMLFieldSetElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFontElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLFontElement.java deleted file mode 100644 index 5bfbb6f..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFontElement.java +++ /dev/null @@ -1,88 +0,0 @@ -/* DomHTMLFontElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFontElement; - -/** - * An HTML 'FONT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLFontElement - extends DomHTMLElement - implements HTMLFontElement -{ - - protected DomHTMLFontElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getColor() - { - return getHTMLAttribute("color"); - } - - public void setColor(String color) - { - setHTMLAttribute("color", color); - } - - public String getFace() - { - return getHTMLAttribute("face"); - } - - public void setFace(String face) - { - setHTMLAttribute("face", face); - } - - public String getSize() - { - return getHTMLAttribute("size"); - } - - public void setSize(String size) - { - setHTMLAttribute("size", size); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFormElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLFormElement.java deleted file mode 100644 index 9fe2ae8..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFormElement.java +++ /dev/null @@ -1,149 +0,0 @@ -/* DomHTMLFormElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLFormElement; - -/** - * An HTML 'FORM' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLFormElement - extends DomHTMLElement - implements HTMLFormElement -{ - - protected DomHTMLFormElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLCollection getElements() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("input"); - ret.addNodeName("button"); - ret.addNodeName("select"); - ret.addNodeName("textarea"); - ret.addNodeName("isindex"); - ret.addNodeName("label"); - ret.addNodeName("option"); - ret.evaluate(); - return ret; - } - - public int getLength() - { - return getElements().getLength(); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getAcceptCharset() - { - return getHTMLAttribute("accept-charset"); - } - - public void setAcceptCharset(String acceptCharset) - { - setHTMLAttribute("accept-charset", acceptCharset); - } - - public String getAction() - { - return getHTMLAttribute("action"); - } - - public void setAction(String action) - { - setHTMLAttribute("action", action); - } - - public String getEnctype() - { - return getHTMLAttribute("enctype"); - } - - public void setEnctype(String enctype) - { - setHTMLAttribute("enctype", enctype); - } - - public String getMethod() - { - return getHTMLAttribute("method"); - } - - public void setMethod(String method) - { - setHTMLAttribute("method", method); - } - - public String getTarget() - { - return getHTMLAttribute("target"); - } - - public void setTarget(String target) - { - setHTMLAttribute("target", target); - } - - public void submit() - { - dispatchUIEvent("submit"); - } - - public void reset() - { - dispatchUIEvent("reset"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameElement.java deleted file mode 100644 index 2465c4b..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameElement.java +++ /dev/null @@ -1,145 +0,0 @@ -/* DomHTMLFrameElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.Document; -import org.w3c.dom.html2.HTMLFrameElement; - -/** - * An HTML 'FRAME' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLFrameElement - extends DomHTMLElement - implements HTMLFrameElement -{ - - protected DomHTMLFrameElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getFrameBorder() - { - return getHTMLAttribute("frameborder"); - } - - public void setFrameBorder(String frameBorder) - { - setHTMLAttribute("frameborder", frameBorder); - } - - public String getLongDesc() - { - return getHTMLAttribute("longdesc"); - } - - public void setLongDesc(String longDesc) - { - setHTMLAttribute("longdesc", longDesc); - } - - public String getMarginHeight() - { - return getHTMLAttribute("marginheight"); - } - - public void setMarginHeight(String marginHeight) - { - setHTMLAttribute("marginheight", marginHeight); - } - - public String getMarginWidth() - { - return getHTMLAttribute("marginwidth"); - } - - public void setMarginWidth(String marginWidth) - { - setHTMLAttribute("marginwidth", marginWidth); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public boolean getNoResize() - { - return getBooleanHTMLAttribute("noresize"); - } - - public void setNoResize(boolean noResize) - { - setBooleanHTMLAttribute("noresize", noResize); - } - - public String getScrolling() - { - return getHTMLAttribute("scrolling"); - } - - public void setScrolling(String scrolling) - { - setHTMLAttribute("scrolling", scrolling); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public Document getContentDocument() - { - // TODO getContentDocument - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameSetElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameSetElement.java deleted file mode 100644 index dae9430..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLFrameSetElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLFrameSetElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFrameSetElement; - -/** - * An HTML 'FRAMESET' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLFrameSetElement - extends DomHTMLElement - implements HTMLFrameSetElement -{ - - protected DomHTMLFrameSetElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getCols() - { - return getHTMLAttribute("cols"); - } - - public void setCols(String cols) - { - setHTMLAttribute("cols", cols); - } - - public String getRows() - { - return getHTMLAttribute("rows"); - } - - public void setRows(String rows) - { - setHTMLAttribute("rows", rows); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHRElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLHRElement.java deleted file mode 100644 index e27ef55..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHRElement.java +++ /dev/null @@ -1,98 +0,0 @@ -/* DomHTMLHRElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLHRElement; - -/** - * An HTML 'HR' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLHRElement - extends DomHTMLElement - implements HTMLHRElement -{ - - protected DomHTMLHRElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public boolean getNoShade() - { - return getBooleanHTMLAttribute("noshade"); - } - - public void setNoShade(boolean noShade) - { - setBooleanHTMLAttribute("noshade", noShade); - } - - public String getSize() - { - return getHTMLAttribute("size"); - } - - public void setSize(String size) - { - setHTMLAttribute("size", size); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadElement.java deleted file mode 100644 index 4a8ef995..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLHeadElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLHeadElement; - -/** - * An HTML 'HEAD' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLHeadElement - extends DomHTMLElement - implements HTMLHeadElement -{ - - protected DomHTMLHeadElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getProfile() - { - return getHTMLAttribute("profile"); - } - - public void setProfile(String profile) - { - setHTMLAttribute("profile", profile); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadingElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadingElement.java deleted file mode 100644 index 6e78e90..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHeadingElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLHeadingElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLHeadingElement; - -/** - * An HTML 'H1', 'H2', 'H3', 'H4', 'H5', or 'H6' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLHeadingElement - extends DomHTMLElement - implements HTMLHeadingElement -{ - - protected DomHTMLHeadingElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHtmlElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLHtmlElement.java deleted file mode 100644 index 73f7243..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLHtmlElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLHtmlElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLHtmlElement; - -/** - * An HTML 'HTML' top-level element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLHtmlElement - extends DomHTMLElement - implements HTMLHtmlElement -{ - - protected DomHTMLHtmlElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getVersion() - { - return getHTMLAttribute("version"); - } - - public void setVersion(String version) - { - setHTMLAttribute("version", version); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLIFrameElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLIFrameElement.java deleted file mode 100644 index 1a58fb7..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLIFrameElement.java +++ /dev/null @@ -1,165 +0,0 @@ -/* DomHTMLIFrameElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.Document; -import org.w3c.dom.html2.HTMLIFrameElement; - -/** - * An HTML 'IFRAME' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLIFrameElement - extends DomHTMLElement - implements HTMLIFrameElement -{ - - protected DomHTMLIFrameElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getFrameBorder() - { - return getHTMLAttribute("frameborder"); - } - - public void setFrameBorder(String frameBorder) - { - setHTMLAttribute("frameborder", frameBorder); - } - - public String getHeight() - { - return getHTMLAttribute("height"); - } - - public void setHeight(String height) - { - setHTMLAttribute("height", height); - } - - public String getLongDesc() - { - return getHTMLAttribute("longdesc"); - } - - public void setLongDesc(String longDesc) - { - setHTMLAttribute("longdesc", longDesc); - } - - public String getMarginHeight() - { - return getHTMLAttribute("marginheight"); - } - - public void setMarginHeight(String marginHeight) - { - setHTMLAttribute("marginheight", marginHeight); - } - - public String getMarginWidth() - { - return getHTMLAttribute("marginwidth"); - } - - public void setMarginWidth(String marginWidth) - { - setHTMLAttribute("marginwidth", marginWidth); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getScrolling() - { - return getHTMLAttribute("scrolling"); - } - - public void setScrolling(String scrolling) - { - setHTMLAttribute("scrolling", scrolling); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - - public Document getContentDocument() - { - // TODO getContentDocument - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLImageElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLImageElement.java deleted file mode 100644 index c5d294c..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLImageElement.java +++ /dev/null @@ -1,178 +0,0 @@ -/* DomHTMLImageElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLImageElement; - -/** - * An HTML 'IMG' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLImageElement - extends DomHTMLElement - implements HTMLImageElement -{ - - protected DomHTMLImageElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getAlt() - { - return getHTMLAttribute("alt"); - } - - public void setAlt(String alt) - { - setHTMLAttribute("alt", alt); - } - - public String getBorder() - { - return getHTMLAttribute("border"); - } - - public void setBorder(String border) - { - setHTMLAttribute("border", border); - } - - public int getHeight() - { - return getIntHTMLAttribute("height"); - } - - public void setHeight(int height) - { - setIntHTMLAttribute("height", height); - } - - public int getHspace() - { - return getIntHTMLAttribute("hspace"); - } - - public void setHspace(int hspace) - { - setIntHTMLAttribute("hspace", hspace); - } - - public boolean getIsMap() - { - return getBooleanHTMLAttribute("ismap"); - } - - public void setIsMap(boolean isMap) - { - setBooleanHTMLAttribute("ismap", isMap); - } - - public String getLongDesc() - { - return getHTMLAttribute("longdesc"); - } - - public void setLongDesc(String longDesc) - { - setHTMLAttribute("longdesc", longDesc); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public String getUseMap() - { - return getHTMLAttribute("usemap"); - } - - public void setUseMap(String useMap) - { - setHTMLAttribute("usemap", useMap); - } - - public int getVspace() - { - return getIntHTMLAttribute("vspace"); - } - - public void setVspace(int vspace) - { - setIntHTMLAttribute("vspace", vspace); - } - - public int getWidth() - { - return getIntHTMLAttribute("width"); - } - - public void setWidth(int width) - { - setIntHTMLAttribute("width", width); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLImpl.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLImpl.java deleted file mode 100644 index a5faee5..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* DomHTMLImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomImpl; -import org.w3c.dom.Document; - -/** - * Specialised DOMImplementation for creating HTML documents. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLImpl - extends DomImpl -{ - - protected Document createDocument() - { - return new DomHTMLDocument(this); - } - - public Object getFeature(String feature, String version) - { - if (hasFeature(feature, version)) - { - return this; - } - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLInputElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLInputElement.java deleted file mode 100644 index 2120188..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLInputElement.java +++ /dev/null @@ -1,265 +0,0 @@ -/* DomHTMLInputElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLInputElement; - -/** - * An HTML 'INPUT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLInputElement - extends DomHTMLElement - implements HTMLInputElement -{ - - protected String value; - protected Boolean checked; - - protected DomHTMLInputElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getDefaultValue() - { - return getHTMLAttribute("value"); - } - - public void setDefaultValue(String defaultValue) - { - setHTMLAttribute("value", defaultValue); - } - - public boolean getDefaultChecked() - { - return getBooleanHTMLAttribute("checked"); - } - - public void setDefaultChecked(boolean defaultChecked) - { - setBooleanHTMLAttribute("checked", defaultChecked); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getAccept() - { - return getHTMLAttribute("accept"); - } - - public void setAccept(String accept) - { - setHTMLAttribute("accept", accept); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getAlt() - { - return getHTMLAttribute("alt"); - } - - public void setAlt(String alt) - { - setHTMLAttribute("alt", alt); - } - - public boolean getChecked() - { - if (checked == null) - { - checked = Boolean.valueOf(getDefaultChecked()); - } - return checked.booleanValue(); - } - - public void setChecked(boolean checked) - { - this.checked = Boolean.valueOf(checked); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public int getMaxLength() - { - return getIntHTMLAttribute("maxLength"); - } - - public void setMaxLength(int maxLength) - { - setIntHTMLAttribute("maxLength", maxLength); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public boolean getReadOnly() - { - return getBooleanHTMLAttribute("readonly"); - } - - public void setReadOnly(boolean readOnly) - { - setBooleanHTMLAttribute("readonly", readOnly); - } - - public int getSize() - { - return getIntHTMLAttribute("size"); - } - - public void setSize(int size) - { - setIntHTMLAttribute("size", size); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public String getUseMap() - { - return getHTMLAttribute("usemap"); - } - - public void setUseMap(String useMap) - { - setHTMLAttribute("usemap", useMap); - } - - public String getValue() - { - if (value == null) - { - value = getDefaultValue(); - } - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public void blur() - { - dispatchUIEvent("blur"); - } - - public void focus() - { - dispatchUIEvent("focus"); - } - - public void select() - { - dispatchUIEvent("select"); - } - - public void click() - { - dispatchUIEvent("click"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLIsIndexElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLIsIndexElement.java deleted file mode 100644 index 8578cb6..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLIsIndexElement.java +++ /dev/null @@ -1,74 +0,0 @@ -/* DomHTMLIsIndexElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLIsIndexElement; - -/** - * An HTML 'ISINDEX' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLIsIndexElement - extends DomHTMLElement - implements HTMLIsIndexElement -{ - - protected DomHTMLIsIndexElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getPrompt() - { - return getHTMLAttribute("prompt"); - } - - public void setPrompt(String prompt) - { - setHTMLAttribute("prompt", prompt); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLIElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLLIElement.java deleted file mode 100644 index cab1412..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLIElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLLIElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLLIElement; - -/** - * An HTML 'LI' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLLIElement - extends DomHTMLElement - implements HTMLLIElement -{ - - protected DomHTMLLIElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public int getValue() - { - return getIntHTMLAttribute("value"); - } - - public void setValue(int value) - { - setIntHTMLAttribute("value", value); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLabelElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLLabelElement.java deleted file mode 100644 index 96cfbaa..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLabelElement.java +++ /dev/null @@ -1,84 +0,0 @@ -/* DomHTMLLabelElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLLabelElement; - -/** - * An HTML 'LABEL' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLLabelElement - extends DomHTMLElement - implements HTMLLabelElement -{ - - protected DomHTMLLabelElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public String getHtmlFor() - { - return getHTMLAttribute("for"); - } - - public void setHtmlFor(String htmlFor) - { - setHTMLAttribute("for", htmlFor); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLegendElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLLegendElement.java deleted file mode 100644 index 045861c..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLegendElement.java +++ /dev/null @@ -1,84 +0,0 @@ -/* DomHTMLLegendElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLLegendElement; - -/** - * An HTML 'LEGEND' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLLegendElement - extends DomHTMLElement - implements HTMLLegendElement -{ - - protected DomHTMLLegendElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLinkElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLLinkElement.java deleted file mode 100644 index 292ec93..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLLinkElement.java +++ /dev/null @@ -1,148 +0,0 @@ -/* DomHTMLLinkElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLLinkElement; - -/** - * An HTML 'LINK' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLLinkElement - extends DomHTMLElement - implements HTMLLinkElement -{ - - protected DomHTMLLinkElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getCharset() - { - return getHTMLAttribute("charset"); - } - - public void setCharset(String charset) - { - setHTMLAttribute("charset", charset); - } - - public String getHref() - { - return getHTMLAttribute("href"); - } - - public void setHref(String href) - { - setHTMLAttribute("href", href); - } - - public String getHreflang() - { - return getHTMLAttribute("hreflang"); - } - - public void setHreflang(String hreflang) - { - setHTMLAttribute("hreflang", hreflang); - } - - public String getMedia() - { - return getHTMLAttribute("media"); - } - - public void setMedia(String media) - { - setHTMLAttribute("media", media); - } - - public String getRel() - { - return getHTMLAttribute("rel"); - } - - public void setRel(String rel) - { - setHTMLAttribute("rel", rel); - } - - public String getRev() - { - return getHTMLAttribute("rev"); - } - - public void setRev(String rev) - { - setHTMLAttribute("rev", rev); - } - - public String getTarget() - { - return getHTMLAttribute("target"); - } - - public void setTarget(String target) - { - setHTMLAttribute("target", target); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMapElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLMapElement.java deleted file mode 100644 index 4497b00..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMapElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLMapElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLMapElement; - -/** - * An HTML 'MAP' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLMapElement - extends DomHTMLElement - implements HTMLMapElement -{ - - protected DomHTMLMapElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLCollection getAreas() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("area"); - ret.evaluate(); - return ret; - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMenuElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLMenuElement.java deleted file mode 100644 index 2a6ff08..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMenuElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLMenuElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLMenuElement; - -/** - * An HTML 'MENU' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLMenuElement - extends DomHTMLElement - implements HTMLMenuElement -{ - - protected DomHTMLMenuElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getCompact() - { - return getBooleanHTMLAttribute("compact"); - } - - public void setCompact(boolean compact) - { - setBooleanHTMLAttribute("compact", compact); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMetaElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLMetaElement.java deleted file mode 100644 index e555a42..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLMetaElement.java +++ /dev/null @@ -1,98 +0,0 @@ -/* DomHTMLMetaElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLMetaElement; - -/** - * An HTML 'META' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLMetaElement - extends DomHTMLElement - implements HTMLMetaElement -{ - - protected DomHTMLMetaElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getContent() - { - return getHTMLAttribute("content"); - } - - public void setContent(String content) - { - setHTMLAttribute("content", content); - } - - public String getHttpEquiv() - { - return getHTMLAttribute("http-equiv"); - } - - public void setHttpEquiv(String httpEquiv) - { - setHTMLAttribute("http-equiv", httpEquiv); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getScheme() - { - return getHTMLAttribute("scheme"); - } - - public void setScheme(String scheme) - { - setHTMLAttribute("scheme", scheme); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLModElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLModElement.java deleted file mode 100644 index 8c158f4..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLModElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLModElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLModElement; - -/** - * An HTML 'INS' or 'DEL' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLModElement - extends DomHTMLElement - implements HTMLModElement -{ - - protected DomHTMLModElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getCite() - { - return getHTMLAttribute("cite"); - } - - public void setCite(String cite) - { - setHTMLAttribute("cite", cite); - } - - public String getDateTime() - { - return getHTMLAttribute("datetime"); - } - - public void setDateTime(String dateTime) - { - setHTMLAttribute("datetime", dateTime); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOListElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLOListElement.java deleted file mode 100644 index 54f7fd4..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOListElement.java +++ /dev/null @@ -1,88 +0,0 @@ -/* DomHTMLOListElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLOListElement; - -/** - * An HTML 'OL' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLOListElement - extends DomHTMLElement - implements HTMLOListElement -{ - - protected DomHTMLOListElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getCompact() - { - return getBooleanHTMLAttribute("compact"); - } - - public void setCompact(boolean compact) - { - setBooleanHTMLAttribute("compact", compact); - } - - public int getStart() - { - return getIntHTMLAttribute("start"); - } - - public void setStart(int start) - { - setIntHTMLAttribute("start", start); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLObjectElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLObjectElement.java deleted file mode 100644 index 2ce5f45..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLObjectElement.java +++ /dev/null @@ -1,320 +0,0 @@ -/* DomHTMLObjectElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.Document; -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLObjectElement; - -/** - * An HTML 'OBJECT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLObjectElement - extends DomHTMLElement - implements HTMLObjectElement -{ - - protected DomHTMLObjectElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getCode() - { - return getHTMLAttribute("code"); - } - - public void setCode(String code) - { - setHTMLAttribute("code", code); - } - - public String getJavaCode() - { - return getHTMLAttribute("java_code"); - } - - public void setJavaCode(String code) - { - setHTMLAttribute("java_code", code); - } - - public String getObject() - { - return getHTMLAttribute("object"); - } - - public void setObject(String obj) - { - setHTMLAttribute("object", obj); - } - - public String getJavaObject() - { - return getHTMLAttribute("java_object"); - } - - public void setJavaObject(String obj) - { - setHTMLAttribute("java_object", obj); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getArchive() - { - return getHTMLAttribute("archive"); - } - - public void setArchive(String archive) - { - setHTMLAttribute("archive", archive); - } - - public String getJavaArchive() - { - return getHTMLAttribute("java_archive"); - } - - public void setJavaArchive(String archive) - { - setHTMLAttribute("java_archive", archive); - } - - public String getBorder() - { - return getHTMLAttribute("border"); - } - - public void setBorder(String border) - { - setHTMLAttribute("border", border); - } - - public String getCodeBase() - { - return getHTMLAttribute("codebase"); - } - - public void setCodeBase(String codeBase) - { - setHTMLAttribute("codebase", codeBase); - } - - public String getJavaCodeBase() - { - return getHTMLAttribute("java_codebase"); - } - - public void setJavaCodeBase(String codeBase) - { - setHTMLAttribute("java_codebase", codeBase); - } - - public String getCodeType() - { - return getHTMLAttribute("codetype"); - } - - public void setCodeType(String codeType) - { - setHTMLAttribute("codetype", codeType); - } - - public String getData() - { - return getHTMLAttribute("data"); - } - - public void setData(String data) - { - setHTMLAttribute("data", data); - } - - public boolean getDeclare() - { - return getBooleanHTMLAttribute("declare"); - } - - public void setDeclare(boolean declare) - { - setBooleanHTMLAttribute("declare", declare); - } - - public String getHeight() - { - return getHTMLAttribute("height"); - } - - public void setHeight(String height) - { - setHTMLAttribute("height", height); - } - - public int getHspace() - { - return getIntHTMLAttribute("hspace"); - } - - public void setHspace(int hspace) - { - setIntHTMLAttribute("hspace", hspace); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getStandby() - { - return getHTMLAttribute("standby"); - } - - public void setStandby(String standby) - { - setHTMLAttribute("standby", standby); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public String getJavaType() - { - return getHTMLAttribute("java_type"); - } - - public void setJavaType(String type) - { - setHTMLAttribute("java_type", type); - } - - public String getUseMap() - { - return getHTMLAttribute("usemap"); - } - - public void setUseMap(String useMap) - { - setHTMLAttribute("usemap", useMap); - } - - public int getVspace() - { - return getIntHTMLAttribute("vspace"); - } - - public void setVspace(int vspace) - { - setIntHTMLAttribute("vspace", vspace); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - - public Document getContentDocument() - { - // TODO getContentDocument - return null; - } - - public void setMayscript(String may) - { - setHTMLAttribute("mayscript", may); - } - - public String getMayscript() - { - return getHTMLAttribute("mayscript"); - } - - public void setScriptable(String scr) - { - setHTMLAttribute("scriptable", scr); - } - - public String getScriptable() - { - return getHTMLAttribute("scriptable"); - } -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptGroupElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptGroupElement.java deleted file mode 100644 index acb9484..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptGroupElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLOptGroupElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLOptGroupElement; - -/** - * An HTML 'OPTGROUP' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLOptGroupElement - extends DomHTMLElement - implements HTMLOptGroupElement -{ - - protected DomHTMLOptGroupElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getLabel() - { - return getHTMLAttribute("label"); - } - - public void setLabel(String label) - { - setHTMLAttribute("label", label); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptionElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptionElement.java deleted file mode 100644 index f775c13..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLOptionElement.java +++ /dev/null @@ -1,130 +0,0 @@ -/* DomHTMLOptionElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLOptionElement; - -/** - * An HTML 'OPTION' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLOptionElement - extends DomHTMLElement - implements HTMLOptionElement -{ - - protected Boolean selected; - - protected DomHTMLOptionElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public boolean getDefaultSelected() - { - return getBooleanHTMLAttribute("selected"); - } - - public void setDefaultSelected(boolean defaultSelected) - { - setBooleanHTMLAttribute("selected", defaultSelected); - } - - public String getText() - { - return getTextContent(); - } - - public int getIndex() - { - return super.getIndex(); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getLabel() - { - return getHTMLAttribute("label"); - } - - public void setLabel(String label) - { - setHTMLAttribute("label", label); - } - - public boolean getSelected() - { - if (selected == null) - { - selected = Boolean.valueOf(getDefaultSelected()); - } - return selected.booleanValue(); - } - - public void setSelected(boolean selected) - { - this.selected = Boolean.valueOf(selected); - } - - public String getValue() - { - return getHTMLAttribute("value"); - } - - public void setValue(String value) - { - setHTMLAttribute("value", value); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParagraphElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLParagraphElement.java deleted file mode 100644 index 4c867fd..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParagraphElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLParagraphElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLParagraphElement; - -/** - * An HTML 'P' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLParagraphElement - extends DomHTMLElement - implements HTMLParagraphElement -{ - - protected DomHTMLParagraphElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParamElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLParamElement.java deleted file mode 100644 index cdd74ad..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParamElement.java +++ /dev/null @@ -1,98 +0,0 @@ -/* DomHTMLParamElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLParamElement; - -/** - * An HTML 'PARAM' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLParamElement - extends DomHTMLElement - implements HTMLParamElement -{ - - protected DomHTMLParamElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - - public String getValue() - { - return getHTMLAttribute("value"); - } - - public void setValue(String value) - { - setHTMLAttribute("value", value); - } - - public String getValueType() - { - return getHTMLAttribute("valuetype"); - } - - public void setValueType(String valueType) - { - setHTMLAttribute("valuetype", valueType); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParser.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLParser.java deleted file mode 100644 index 88656d2..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLParser.java +++ /dev/null @@ -1,264 +0,0 @@ -/* DomHTMLParser.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.xml.dom.html2; - -import java.io.IOException; -import java.io.Reader; - -import java.util.Enumeration; -import java.util.Iterator; -import java.util.LinkedList; - -import javax.swing.text.AttributeSet; -import javax.swing.text.html.HTML; -import javax.swing.text.html.parser.DTD; -import javax.swing.text.html.parser.TagElement; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.html2.HTMLDocument; - -/** - * This parser reads HTML from the given stream and stores into - * {@link HTMLDocument}. The HTML tag becomes the {@link Node}. - * The tag attributes become the node attributes. The text inside - * HTML tag is inserted as one or several text nodes. The nested - * HTML tags are inserted as child nodes. - * - * If the strict tree structure, closing the tag means closing all - * nested tags. To work around this, this parser closes the nested - * tags and immediately reopens them after the closed tag. - * In this way, <code><b><i>c</b>d</code> - * is parsed as <code><b><i>c</i></b><i>d</code> . - * - * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) - */ -public class DomHTMLParser - extends gnu.javax.swing.text.html.parser.support.Parser -{ - /** - * The target where HTML document will be inserted. - */ - protected DomHTMLDocument document; - - /** - * The subsequently created new nodes will be inserted as the - * childs of this cursor. - */ - protected Node cursor; - - /** - * Create parser using the given DTD. - * - * @param dtd the DTD (for example, - * {@link gnu.javax.swing.text.html.parser.HTML_401F}). - */ - public DomHTMLParser(DTD dtd) - { - super(dtd); - } - - /** - * Parse SGML insertion ( <! ... > ). - * Currently just treats it as comment. - */ - public boolean parseMarkupDeclarations(StringBuffer strBuff) - throws java.io.IOException - { - Node c = document.createComment(strBuff.toString()); - cursor.appendChild(c); - return false; - } - - /** - * Read the document, present in the given stream, and - * return the corresponding {@link HTMLDocument}. - * - * @param input a stream to read from. - * @return a document, reflecting the structure of the provided HTML - * text. - * - * @throws IOException if the reader throws one. - */ - public HTMLDocument parseDocument(Reader input) - throws IOException - { - try - { - document = new DomHTMLDocument(); - document.setCheckWellformedness(false); - document.setCheckingCharacters(false); - - cursor = document; - - parse(input); - - DomHTMLDocument h = document; - document = null; - return h; - } - catch (Exception ex) - { - ex.printStackTrace(); - throw new IOException("Exception: " + ex.getMessage()); - } - } - - /** - * Create a new node. - * @param name the name of node, case insensitive. - * @return the created node. - */ - protected Node createNode(String name) - { - Node new_node = document.createElement(name.toLowerCase()); - AttributeSet hatts = getAttributes(); - NamedNodeMap natts = new_node.getAttributes(); - - Enumeration enumeration = hatts.getAttributeNames(); - Object key; - Node attribute; - - while (hatts != null) - { - while (enumeration.hasMoreElements()) - { - key = enumeration.nextElement(); - attribute = document.createAttribute(key.toString()); - attribute.setNodeValue(hatts.getAttribute(key).toString()); - natts.setNamedItem(attribute); - } - - // The default values are stored in a parent node. - hatts = hatts.getResolveParent(); - } - - return new_node; - } - - /** - * Handle comment by inserting the comment node. - * @param text the comment text. - */ - protected void handleComment(char[] text) - { - Node c = document.createComment(new String(text)); - cursor.appendChild(c); - } - - /** - * Handle the tag with no content. - * @param tag the tag to handle. - */ - protected void handleEmptyTag(TagElement tag) - { - String name = tag.getHTMLTag().toString(); - - if (name.equalsIgnoreCase("#pcdata")) - return; - - Node c = createNode(name); - cursor.appendChild(c); - } - - /** - * Close the given tag. Close and reopen all nested tags. - * @param tag the tag to close. - */ - protected void handleEndTag(TagElement tag) - { - String name = tag.getHTMLTag().toString(); - String nname = cursor.getNodeName(); - - // Closing the current tag. - if (nname != null && nname.equalsIgnoreCase(name)) - { - cursor = cursor.getParentNode(); - } - else - { - Node nCursor = cursor.getParentNode(); - - // Remember the opened nodes. - LinkedList open = new LinkedList(); - Node close = cursor; - while (close != null && !close.getNodeName().equalsIgnoreCase(name)) - { - if (close != document) - open.addFirst(close); - close = close.getParentNode(); - } - if (close == null) - cursor = document; - else - cursor = close.getParentNode(); - - // Insert the copies of the opened nodes. - Iterator iter = open.iterator(); - while (iter.hasNext()) - { - Node item = (Node) iter.next(); - cursor.appendChild(item); - cursor = item; - } - } - } - - /** - * Handle the start tag by inserting the HTML element. - * @param tag the tag to handle. - */ - protected void handleStartTag(TagElement tag) - { - HTML.Tag h = tag.getHTMLTag(); - Node c = createNode(h.toString()); - cursor.appendChild(c); - cursor = c; - } - - /** - * Handle text by inserting the text node. - * @param text the text to insert. - */ - protected void handleText(char[] text) - { - Node c = document.createTextNode(text, 0, text.length); - cursor.appendChild(c); - } -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLPreElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLPreElement.java deleted file mode 100644 index 9a51aae..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLPreElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLPreElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLPreElement; - -/** - * An HTML 'PRE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLPreElement - extends DomHTMLElement - implements HTMLPreElement -{ - - protected DomHTMLPreElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public int getWidth() - { - return getIntHTMLAttribute("width"); - } - - public void setWidth(int width) - { - setIntHTMLAttribute("width", width); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLQuoteElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLQuoteElement.java deleted file mode 100644 index 811aed5..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLQuoteElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLQuoteElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLQuoteElement; - -/** - * An HTML 'Q' or 'BLOCKQUOTE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLQuoteElement - extends DomHTMLElement - implements HTMLQuoteElement -{ - - protected DomHTMLQuoteElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getCite() - { - return getHTMLAttribute("cite"); - } - - public void setCite(String cite) - { - setHTMLAttribute("cite", cite); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLScriptElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLScriptElement.java deleted file mode 100644 index 1bd7b34..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLScriptElement.java +++ /dev/null @@ -1,128 +0,0 @@ -/* DomHTMLScriptElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLScriptElement; - -/** - * An HTML 'SCRIPT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLScriptElement - extends DomHTMLElement - implements HTMLScriptElement -{ - - protected DomHTMLScriptElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getText() - { - return getTextContent(); - } - - public void setText(String text) - { - setTextContent(text); - } - - public String getHtmlFor() - { - return getHTMLAttribute("for"); - } - - public void setHtmlFor(String htmlFor) - { - setHTMLAttribute("for", htmlFor); - } - - public String getEvent() - { - return getHTMLAttribute("event"); - } - - public void setEvent(String event) - { - setHTMLAttribute("event", event); - } - - public String getCharset() - { - return getHTMLAttribute("charset"); - } - - public void setCharset(String charset) - { - setHTMLAttribute("charset", charset); - } - - public boolean getDefer() - { - return getBooleanHTMLAttribute("defer"); - } - - public void setDefer(boolean defer) - { - setBooleanHTMLAttribute("defer", defer); - } - - public String getSrc() - { - return getHTMLAttribute("src"); - } - - public void setSrc(String src) - { - setHTMLAttribute("src", src); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLSelectElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLSelectElement.java deleted file mode 100644 index fc1debb..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLSelectElement.java +++ /dev/null @@ -1,210 +0,0 @@ -/* DomHTMLSelectElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import org.w3c.dom.DOMException; -import org.w3c.dom.html2.HTMLElement; -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLOptionElement; -import org.w3c.dom.html2.HTMLOptionsCollection; -import org.w3c.dom.html2.HTMLSelectElement; - -/** - * An HTML 'SELECT' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLSelectElement - extends DomHTMLElement - implements HTMLSelectElement -{ - - protected DomHTMLSelectElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public int getSelectedIndex() - { - HTMLOptionsCollection options = getOptions(); - int len = options.getLength(); - for (int i = 0; i < len; i++) - { - HTMLOptionElement option = (HTMLOptionElement) options.item(i); - if (option.getSelected()) - { - return i; - } - } - return -1; - } - - public void setSelectedIndex(int selectedIndex) - { - HTMLOptionsCollection options = getOptions(); - int len = options.getLength(); - if (selectedIndex < 0 || selectedIndex >= len) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - for (int i = 0; i < len; i++) - { - HTMLOptionElement option = (HTMLOptionElement) options.item(i); - option.setSelected(i == selectedIndex); - } - } - - public String getValue() - { - return getHTMLAttribute("value"); - } - - public void setValue(String value) - { - setHTMLAttribute("value", value); - } - - public int getLength() - { - return getIntHTMLAttribute("length"); - } - - public void setLength(int length) - { - setIntHTMLAttribute("length", length); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public HTMLOptionsCollection getOptions() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("option"); - ret.evaluate(); - return ret; - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public boolean getMultiple() - { - return getBooleanHTMLAttribute("multiple"); - } - - public void setMultiple(boolean multiple) - { - setBooleanHTMLAttribute("multiple", multiple); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public int getSize() - { - return getIntHTMLAttribute("size"); - } - - public void setSize(int size) - { - setIntHTMLAttribute("size", size); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public void add(HTMLElement element, HTMLElement before) - { - insertBefore(before, element); - } - - public void remove(int index) - { - HTMLOptionsCollection options = getOptions(); - int len = options.getLength(); - if (index < 0 || index >= len) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - HTMLOptionElement option = (HTMLOptionElement) options.item(index); - option.getParentNode().removeChild(option); - } - - public void blur() - { - dispatchUIEvent("blur"); - } - - public void focus() - { - dispatchUIEvent("focus"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLStyleElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLStyleElement.java deleted file mode 100644 index 78cef3b..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLStyleElement.java +++ /dev/null @@ -1,88 +0,0 @@ -/* DomHTMLStyleElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLStyleElement; - -/** - * An HTML 'STYLE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLStyleElement - extends DomHTMLElement - implements HTMLStyleElement -{ - - protected DomHTMLStyleElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getMedia() - { - return getHTMLAttribute("media"); - } - - public void setMedia(String media) - { - setHTMLAttribute("media", media); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCaptionElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCaptionElement.java deleted file mode 100644 index 2133b14..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCaptionElement.java +++ /dev/null @@ -1,69 +0,0 @@ -/* DomHTMLTableCaptionElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLTableCaptionElement; - -/** - * An HTML 'CAPTION' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableCaptionElement - extends DomHTMLElement - implements HTMLTableCaptionElement -{ - - protected DomHTMLTableCaptionElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCellElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCellElement.java deleted file mode 100644 index 350f0bf..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableCellElement.java +++ /dev/null @@ -1,204 +0,0 @@ -/* DomHTMLTableCellElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLTableCellElement; - -/** - * An HTML 'TH' or 'TD' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableCellElement - extends DomHTMLElement - implements HTMLTableCellElement -{ - - protected DomHTMLTableCellElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public int getCellIndex() - { - return getIndex(); - } - - public String getAbbr() - { - return getHTMLAttribute("abbr"); - } - - public void setAbbr(String abbr) - { - setHTMLAttribute("abbr", abbr); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getAxis() - { - return getHTMLAttribute("axis"); - } - - public void setAxis(String axis) - { - setHTMLAttribute("axis", axis); - } - - public String getBgColor() - { - return getHTMLAttribute("bgcolor"); - } - - public void setBgColor(String bgColor) - { - setHTMLAttribute("bgcolor", bgColor); - } - - public String getCh() - { - return getHTMLAttribute("char"); - } - - public void setCh(String ch) - { - setHTMLAttribute("char", ch); - } - - public String getChOff() - { - return getHTMLAttribute("charoff"); - } - - public void setChOff(String chOff) - { - setHTMLAttribute("charoff", chOff); - } - - public int getColSpan() - { - return getIntHTMLAttribute("colspan"); - } - - public void setColSpan(int colSpan) - { - setIntHTMLAttribute("colspan", colSpan); - } - - public String getHeaders() - { - return getHTMLAttribute("headers"); - } - - public void setHeaders(String headers) - { - setHTMLAttribute("headers", headers); - } - - public String getHeight() - { - return getHTMLAttribute("height"); - } - - public void setHeight(String height) - { - setHTMLAttribute("height", height); - } - - public boolean getNoWrap() - { - return getBooleanHTMLAttribute("nowrap"); - } - - public void setNoWrap(boolean noWrap) - { - setBooleanHTMLAttribute("nowrap", noWrap); - } - - public int getRowSpan() - { - return getIntHTMLAttribute("rowspan"); - } - - public void setRowSpan(int rowSpan) - { - setIntHTMLAttribute("rowspan", rowSpan); - } - - public String getScope() - { - return getHTMLAttribute("scope"); - } - - public void setScope(String scope) - { - setHTMLAttribute("scope", scope); - } - - public String getVAlign() - { - return getHTMLAttribute("valign"); - } - - public void setVAlign(String vAlign) - { - setHTMLAttribute("valign", vAlign); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableColElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableColElement.java deleted file mode 100644 index c7cef31..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableColElement.java +++ /dev/null @@ -1,119 +0,0 @@ -/* DomHTMLTableColElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLTableColElement; - -/** - * An HTML 'COL' or 'COLGROUP' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableColElement - extends DomHTMLElement - implements HTMLTableColElement -{ - - protected DomHTMLTableColElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getCh() - { - return getHTMLAttribute("char"); - } - - public void setCh(String ch) - { - setHTMLAttribute("char", ch); - } - - public String getChOff() - { - return getHTMLAttribute("charoff"); - } - - public void setChOff(String chOff) - { - setHTMLAttribute("charoff", chOff); - } - - public int getSpan() - { - return getIntHTMLAttribute("span"); - } - - public void setSpan(int span) - { - setIntHTMLAttribute("span", span); - } - - public String getVAlign() - { - return getHTMLAttribute("valign"); - } - - public void setVAlign(String vAlign) - { - setHTMLAttribute("valign", vAlign); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableElement.java deleted file mode 100644 index ade463e..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableElement.java +++ /dev/null @@ -1,397 +0,0 @@ -/* DomHTMLTableElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLElement; -import org.w3c.dom.html2.HTMLTableCaptionElement; -import org.w3c.dom.html2.HTMLTableElement; -import org.w3c.dom.html2.HTMLTableSectionElement; - -/** - * An HTML 'TABLE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableElement - extends DomHTMLElement - implements HTMLTableElement -{ - - protected DomHTMLTableElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public HTMLTableCaptionElement getCaption() - { - return (HTMLTableCaptionElement) getChildElement("caption"); - } - - public void setCaption(HTMLTableCaptionElement caption) - { - HTMLTableCaptionElement ref = getCaption(); - if (ref == null) - { - appendChild(caption); - } - else - { - replaceChild(caption, ref); - } - } - - public HTMLTableSectionElement getTHead() - { - return (HTMLTableSectionElement) getChildElement("thead"); - } - - public void setTHead(HTMLTableSectionElement tHead) - { - HTMLTableSectionElement ref = getTHead(); - if (ref == null) - { - appendChild(tHead); - } - else - { - replaceChild(tHead, ref); - } - } - - public HTMLTableSectionElement getTFoot() - { - return (HTMLTableSectionElement) getChildElement("tfoot"); - } - - public void setTFoot(HTMLTableSectionElement tFoot) - { - HTMLTableSectionElement ref = getTFoot(); - if (ref == null) - { - appendChild(tFoot); - } - else - { - replaceChild(tFoot, ref); - } - } - - public HTMLCollection getRows() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("tr"); - ret.evaluate(); - return ret; - } - - public HTMLCollection getTBodies() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("tbody"); - ret.evaluate(); - return ret; - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getBgColor() - { - return getHTMLAttribute("bgcolor"); - } - - public void setBgColor(String bgColor) - { - setHTMLAttribute("bgcolor", bgColor); - } - - public String getBorder() - { - return getHTMLAttribute("border"); - } - - public void setBorder(String border) - { - setHTMLAttribute("border", border); - } - - public String getCellPadding() - { - return getHTMLAttribute("cellpadding"); - } - - public void setCellPadding(String cellPadding) - { - setHTMLAttribute("cellpadding", cellPadding); - } - - public String getCellSpacing() - { - return getHTMLAttribute("cellspacing"); - } - - public void setCellSpacing(String cellSpacing) - { - setHTMLAttribute("cellspacing", cellSpacing); - } - - public String getFrame() - { - return getHTMLAttribute("frame"); - } - - public void setFrame(String frame) - { - setHTMLAttribute("frame", frame); - } - - public String getRules() - { - return getHTMLAttribute("rules"); - } - - public void setRules(String rules) - { - setHTMLAttribute("rules", rules); - } - - public String getSummary() - { - return getHTMLAttribute("summary"); - } - - public void setSummary(String summary) - { - setHTMLAttribute("summary", summary); - } - - public String getWidth() - { - return getHTMLAttribute("width"); - } - - public void setWidth(String width) - { - setHTMLAttribute("width", width); - } - - public HTMLElement createTHead() - { - HTMLTableSectionElement ref = getTHead(); - if (ref == null) - { - return (HTMLElement) getOwnerDocument().createElement("thead"); - } - else - { - return ref; - } - } - - public void deleteTHead() - { - HTMLTableSectionElement ref = getTHead(); - if (ref != null) - { - removeChild(ref); - } - } - - public HTMLElement createTFoot() - { - HTMLTableSectionElement ref = getTFoot(); - if (ref == null) - { - return (HTMLElement) getOwnerDocument().createElement("tfoot"); - } - else - { - return ref; - } - } - - public void deleteTFoot() - { - HTMLTableSectionElement ref = getTFoot(); - if (ref != null) - { - removeChild(ref); - } - } - - public HTMLElement createCaption() - { - HTMLTableCaptionElement ref = getCaption(); - if (ref == null) - { - return (HTMLElement) getOwnerDocument().createElement("caption"); - } - else - { - return ref; - } - } - - public void deleteCaption() - { - HTMLTableCaptionElement ref = getCaption(); - if (ref != null) - { - removeChild(ref); - } - } - - public HTMLElement insertRow(int index) - { - Node ref = getRow(index); - Node row = getOwnerDocument().createElement("tr"); - if (ref == null) - { - Node tbody = getChildElement("tbody"); - if (tbody == null) - { - tbody = getOwnerDocument().createElement("tfoot"); - appendChild(tbody); - } - tbody.appendChild(row); - } - else - { - ref.getParentNode().insertBefore(row, ref); - } - return (HTMLElement) row; - } - - public void deleteRow(int index) - { - Node ref = getRow(index); - if (ref == null) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - ref.getParentNode().removeChild(ref); - } - - Node getRow(final int index) - { - int i = 0; - Node thead = getChildElement("thead"); - if (thead != null) - { - for (Node ctx = thead.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - String ctxName = ctx.getLocalName(); - if (ctxName == null) - { - ctxName = ctx.getNodeName(); - } - if (!"tr".equalsIgnoreCase(ctxName)) - { - continue; - } - if (index == i) - { - return ctx; - } - i++; - } - } - Node tbody = getChildElement("tbody"); - if (tbody == null) - { - tbody = this; - } - for (Node ctx = tbody.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - String ctxName = ctx.getLocalName(); - if (ctxName == null) - { - ctxName = ctx.getNodeName(); - } - if (!"tr".equalsIgnoreCase(ctxName)) - { - continue; - } - if (index == i) - { - return ctx; - } - i++; - } - Node tfoot = getChildElement("tfoot"); - if (tfoot != null) - { - for (Node ctx = tfoot.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - String ctxName = ctx.getLocalName(); - if (ctxName == null) - { - ctxName = ctx.getNodeName(); - } - if (!"tr".equalsIgnoreCase(ctxName)) - { - continue; - } - if (index == i) - { - return ctx; - } - i++; - } - } - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableRowElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableRowElement.java deleted file mode 100644 index 9943585..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableRowElement.java +++ /dev/null @@ -1,228 +0,0 @@ -/* DomHTMLTableRowElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLElement; -import org.w3c.dom.html2.HTMLTableRowElement; - -/** - * An HTML 'TR' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableRowElement - extends DomHTMLElement - implements HTMLTableRowElement -{ - - protected DomHTMLTableRowElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public int getRowIndex() - { - return getIndex(); - } - - public int getSectionRowIndex() - { - int index = 0; - DomHTMLElement parent = (DomHTMLElement) getParentElement("table"); - if (parent != null) - { - Node thead = parent.getChildElement("thead"); - if (thead != null) - { - for (Node ctx = thead.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - if (ctx == this) - { - return index; - } - index++; - } - } - Node tbody = parent.getChildElement("tbody"); - if (tbody != null) - { - for (Node ctx = tbody.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - if (ctx == this) - { - return index; - } - index++; - } - } - Node tfoot = parent.getChildElement("tfoot"); - if (tfoot != null) - { - for (Node ctx = tfoot.getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - if (ctx == this) - { - return index; - } - index++; - } - } - } - throw new DomDOMException(DOMException.NOT_FOUND_ERR); - } - - public HTMLCollection getCells() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("th"); - ret.addNodeName("td"); - ret.evaluate(); - return ret; - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getBgColor() - { - return getHTMLAttribute("bgcolor"); - } - - public void setBgColor(String bgColor) - { - setHTMLAttribute("bgcolor", bgColor); - } - - public String getCh() - { - return getHTMLAttribute("char"); - } - - public void setCh(String ch) - { - setHTMLAttribute("char", ch); - } - - public String getChOff() - { - return getHTMLAttribute("charoff"); - } - - public void setChOff(String chOff) - { - setHTMLAttribute("charoff", chOff); - } - - public String getVAlign() - { - return getHTMLAttribute("valign"); - } - - public void setVAlign(String vAlign) - { - setHTMLAttribute("valign", vAlign); - } - - public HTMLElement insertCell(int index) - { - Node ref = getCell(index); - Node cell = getOwnerDocument().createElement("td"); - if (ref == null) - { - appendChild(cell); - } - else - { - insertBefore(cell, ref); - } - return (HTMLElement) cell; - } - - public void deleteCell(int index) - { - Node ref = getCell(index); - if (ref == null) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - removeChild(ref); - } - - Node getCell(final int index) - { - int i = 0; - for (Node ctx = getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - String name = ctx.getLocalName(); - if (name == null) - { - name = ctx.getNodeName(); - } - if (!"td".equalsIgnoreCase(name) && - !"th".equalsIgnoreCase(name)) - { - continue; - } - if (index == i) - { - return ctx; - } - i++; - } - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableSectionElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableSectionElement.java deleted file mode 100644 index 389eb59..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTableSectionElement.java +++ /dev/null @@ -1,162 +0,0 @@ -/* DomHTMLTableSectionElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import gnu.xml.dom.DomDOMException; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -import org.w3c.dom.html2.HTMLCollection; -import org.w3c.dom.html2.HTMLElement; -import org.w3c.dom.html2.HTMLTableSectionElement; - -/** - * An HTML 'THEAD', 'TFOOT', or 'TBODY' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTableSectionElement - extends DomHTMLElement - implements HTMLTableSectionElement -{ - - protected DomHTMLTableSectionElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getAlign() - { - return getHTMLAttribute("align"); - } - - public void setAlign(String align) - { - setHTMLAttribute("align", align); - } - - public String getCh() - { - return getHTMLAttribute("char"); - } - - public void setCh(String ch) - { - setHTMLAttribute("char", ch); - } - - public String getChOff() - { - return getHTMLAttribute("charoff"); - } - - public void setChOff(String chOff) - { - setHTMLAttribute("charoff", chOff); - } - - public String getVAlign() - { - return getHTMLAttribute("valign"); - } - - public void setVAlign(String vAlign) - { - setHTMLAttribute("valign", vAlign); - } - - public HTMLCollection getRows() - { - DomHTMLCollection ret = - new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this); - ret.addNodeName("tr"); - ret.evaluate(); - return ret; - } - - public HTMLElement insertRow(int index) - { - Node ref = getRow(index); - Node row = getOwnerDocument().createElement("tr"); - if (ref == null) - { - appendChild(row); - } - else - { - insertBefore(row, ref); - } - return (HTMLElement) row; - } - - public void deleteRow(int index) - { - Node ref = getRow(index); - if (ref == null) - { - throw new DomDOMException(DOMException.INDEX_SIZE_ERR); - } - removeChild(ref); - } - - Node getRow(final int index) - { - int i = 0; - for (Node ctx = getFirstChild(); ctx != null; - ctx = ctx.getNextSibling()) - { - String name = ctx.getLocalName(); - if (name == null) - { - name = ctx.getNodeName(); - } - if (!"tr".equalsIgnoreCase(name)) - { - continue; - } - if (index == i) - { - return ctx; - } - i++; - } - return null; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTextAreaElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTextAreaElement.java deleted file mode 100644 index 9acfab1..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTextAreaElement.java +++ /dev/null @@ -1,181 +0,0 @@ -/* DomHTMLTextAreaElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLFormElement; -import org.w3c.dom.html2.HTMLTextAreaElement; - -/** - * An HTML 'TEXTAREA' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTextAreaElement - extends DomHTMLElement - implements HTMLTextAreaElement -{ - - protected String value; - - protected DomHTMLTextAreaElement(DomHTMLDocument owner, - String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getDefaultValue() - { - return getHTMLAttribute("value"); - } - - public void setDefaultValue(String defaultValue) - { - setHTMLAttribute("value", defaultValue); - } - - public HTMLFormElement getForm() - { - return (HTMLFormElement) getParentElement("form"); - } - - public String getAccessKey() - { - return getHTMLAttribute("accesskey"); - } - - public void setAccessKey(String accessKey) - { - setHTMLAttribute("accesskey", accessKey); - } - - public int getCols() - { - return getIntHTMLAttribute("cols"); - } - - public void setCols(int cols) - { - setIntHTMLAttribute("cols", cols); - } - - public boolean getDisabled() - { - return getBooleanHTMLAttribute("disabled"); - } - - public void setDisabled(boolean disabled) - { - setBooleanHTMLAttribute("disabled", disabled); - } - - public String getName() - { - return getHTMLAttribute("name"); - } - - public void setName(String name) - { - setHTMLAttribute("name", name); - } - - public boolean getReadOnly() - { - return getBooleanHTMLAttribute("readOnly"); - } - - public void setReadOnly(boolean readOnly) - { - setBooleanHTMLAttribute("readonly", readOnly); - } - - public int getRows() - { - return getIntHTMLAttribute("rows"); - } - - public void setRows(int rows) - { - setIntHTMLAttribute("rows", rows); - } - - public int getTabIndex() - { - return getIntHTMLAttribute("tabindex"); - } - - public void setTabIndex(int tabIndex) - { - setIntHTMLAttribute("tabindex", tabIndex); - } - - public String getType() - { - return "textarea"; - } - - public String getValue() - { - if (value == null) - { - value = getDefaultValue(); - } - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public void blur() - { - dispatchUIEvent("blur"); - } - - public void focus() - { - dispatchUIEvent("focus"); - } - - public void select() - { - dispatchUIEvent("select"); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTitleElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLTitleElement.java deleted file mode 100644 index 4f58106..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLTitleElement.java +++ /dev/null @@ -1,68 +0,0 @@ -/* DomHTMLTitleElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLTitleElement; - -/** - * An HTML 'TITLE' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLTitleElement - extends DomHTMLElement - implements HTMLTitleElement -{ - - protected DomHTMLTitleElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public String getText() - { - return getTextContent(); - } - - public void setText(String text) - { - setTextContent(text); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/html2/DomHTMLUListElement.java b/libjava/classpath/gnu/xml/dom/html2/DomHTMLUListElement.java deleted file mode 100644 index 39cdce7..0000000 --- a/libjava/classpath/gnu/xml/dom/html2/DomHTMLUListElement.java +++ /dev/null @@ -1,78 +0,0 @@ -/* DomHTMLUListElement.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.html2; - -import org.w3c.dom.html2.HTMLUListElement; - -/** - * An HTML 'UL' element node. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomHTMLUListElement - extends DomHTMLElement - implements HTMLUListElement -{ - - protected DomHTMLUListElement(DomHTMLDocument owner, String namespaceURI, - String name) - { - super(owner, namespaceURI, name); - } - - public boolean getCompact() - { - return getBooleanHTMLAttribute("compact"); - } - - public void setCompact(boolean compact) - { - setBooleanHTMLAttribute("compact", compact); - } - - public String getType() - { - return getHTMLAttribute("type"); - } - - public void setType(String type) - { - setHTMLAttribute("type", type); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/DomLSException.java b/libjava/classpath/gnu/xml/dom/ls/DomLSException.java deleted file mode 100644 index 31efc84..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/DomLSException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* DomLSException.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import org.w3c.dom.ls.LSException; - -/** - * A DOM LS exception incorporating a cause. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomLSException - extends LSException -{ - - public DomLSException(short type, Exception cause) - { - super(type, (cause == null) ? null : cause.getMessage()); - initCause(cause); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/DomLSInput.java b/libjava/classpath/gnu/xml/dom/ls/DomLSInput.java deleted file mode 100644 index 39b1769..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/DomLSInput.java +++ /dev/null @@ -1,159 +0,0 @@ -/* DomLSInput.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import gnu.java.lang.CPStringBuilder; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import org.w3c.dom.ls.LSInput; - -/** - * Specification of XML input to parse. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomLSInput - implements LSInput -{ - - private InputStream in; - private String systemId; - private String publicId; - private String baseURI; - private String encoding; - private boolean certifiedText; - - public Reader getCharacterStream() - { - return new InputStreamReader(in); - } - - public void setCharacterStream(Reader characterStream) - { - in = new ReaderInputStream(characterStream); - } - - public InputStream getByteStream() - { - return in; - } - - public void setByteStream(InputStream byteStream) - { - in = byteStream; - } - - public String getStringData() - { - CPStringBuilder acc = new CPStringBuilder(); - Reader reader = getCharacterStream(); - try - { - char[] buf = new char[4096]; - for (int len = reader.read(buf); len != -1; len = reader.read(buf)) - { - acc.append(buf, 0, len); - } - } - catch (IOException e) - { - return null; // ? - } - return acc.toString(); - } - - public void setStringData(String stringData) - { - in = new ReaderInputStream(new StringReader(stringData)); - } - - public String getSystemId() - { - return systemId; - } - - public void setSystemId(String systemId) - { - this.systemId = systemId; - } - - public String getPublicId() - { - return publicId; - } - - public void setPublicId(String publicId) - { - this.publicId = publicId; - } - - public String getBaseURI() - { - return baseURI; - } - - public void setBaseURI(String baseURI) - { - this.baseURI = baseURI; - } - - public String getEncoding() - { - return encoding; - } - - public void setEncoding(String encoding) - { - this.encoding = encoding; - } - - public boolean getCertifiedText() - { - return certifiedText; - } - - public void setCertifiedText(boolean certifiedText) - { - this.certifiedText = certifiedText; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/DomLSOutput.java b/libjava/classpath/gnu/xml/dom/ls/DomLSOutput.java deleted file mode 100644 index e8bec2e..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/DomLSOutput.java +++ /dev/null @@ -1,98 +0,0 @@ -/* DomLSOutput.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import org.w3c.dom.ls.LSOutput; - -/** - * Specification of XML output to produce. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomLSOutput - implements LSOutput -{ - - private OutputStream out; - private String systemId; - private String encoding; - - public Writer getCharacterStream() - { - return new OutputStreamWriter(out); - } - - public void setCharacterStream(Writer characterStream) - { - out = new WriterOutputStream(characterStream); - } - - public OutputStream getByteStream() - { - return out; - } - - public void setByteStream(OutputStream out) - { - this.out = out; - } - - public String getSystemId() - { - return systemId; - } - - public void setSystemId(String systemId) - { - this.systemId = systemId; - } - - public String getEncoding() - { - return encoding; - } - - public void setEncoding(String encoding) - { - this.encoding = encoding; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/DomLSParser.java b/libjava/classpath/gnu/xml/dom/ls/DomLSParser.java deleted file mode 100644 index 99db79d..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/DomLSParser.java +++ /dev/null @@ -1,567 +0,0 @@ -/* DomLSParser.java -- - Copyright (C) 1999,2000,2001,2007 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.io.File; -import java.io.InputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import org.w3c.dom.Document; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMStringList; -import org.w3c.dom.Node; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSException; -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSParser; -import org.w3c.dom.ls.LSParserFilter; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXParseException; -import org.xml.sax.XMLReader; -import gnu.xml.dom.DomDocument; -import gnu.xml.dom.DomDOMException; - -/** - * Parser implementation for GNU DOM. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomLSParser - implements LSParser, DOMConfiguration, DOMStringList, ErrorHandler -{ - - private static final List SUPPORTED_PARAMETERS - = Arrays.asList(new String[] { "cdata-sections", - "comments", - "element-content-whitespace", - "namespaces", - "expand-entity-references", - "coalescing", - "validating", - "xinclude-aware", - "entity-resolver", - "error-handler" }); - - private LSParserFilter filter; - private final boolean async; - private String schemaType; - private SAXEventSink eventSink; - private SAXParserFactory factory; - private XMLReader reader; - - private boolean namespaceAware = true; - private boolean ignoreWhitespace; - private boolean expandEntityReferences; - private boolean ignoreComments; - private boolean coalescing; - private boolean validating; - private boolean xIncludeAware; - private EntityResolver entityResolver; - private ErrorHandler errorHandler; - - public DomLSParser(short mode, String schemaType) - throws DOMException - { - switch (mode) - { - case DOMImplementationLS.MODE_ASYNCHRONOUS: - async = true; - break; - case DOMImplementationLS.MODE_SYNCHRONOUS: - async = false; - break; - default: - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - // TODO schemaType - this.schemaType = schemaType; - factory = SAXParserFactory.newInstance(); - } - - // -- LSParser -- - - public DOMConfiguration getDomConfig() - { - return this; - } - - public LSParserFilter getFilter() - { - return filter; - } - - public void setFilter(LSParserFilter filter) - { - this.filter = filter; - } - - public boolean getAsync() - { - return async; - } - - public boolean getBusy() - { - return eventSink != null; - } - - public Document parse(LSInput input) - throws DOMException, LSException - { - if (async) - { - return doParse(input); - } - else - { - synchronized (this) - { - return doParse(input); - } - } - } - - public Document parseURI(String uri) - throws DOMException, LSException - { - LSInput input = new DomLSInput(); - input.setSystemId(uri); - return parse(input); - } - - public Node parseWithContext(LSInput input, Node context, short action) - throws DOMException, LSException - { - Document doc = (context.getNodeType() == Node.DOCUMENT_NODE) ? - (Document) context : context.getOwnerDocument(); - input.setBaseURI(doc.getDocumentURI()); - // TODO use namespaces defined on context node - Document ret = parse(input); - Node root = ret.getDocumentElement(); - root = doc.adoptNode(root); - switch (action) - { - case ACTION_APPEND_AS_CHILDREN: - context.appendChild(root); - break; - case ACTION_REPLACE_CHILDREN: - Node c1 = context.getFirstChild(); - while (c1 != null) - { - Node next = c1.getNextSibling(); - context.removeChild(c1); - c1 = next; - } - context.appendChild(root); - break; - case ACTION_INSERT_BEFORE: - Node p1 = context.getParentNode(); - p1.insertBefore(root, context); - break; - case ACTION_INSERT_AFTER: - Node p2 = context.getParentNode(); - Node r1 = context.getNextSibling(); - if (r1 == null) - { - p2.appendChild(root); - } - else - { - p2.insertBefore(root, r1); - } - break; - case ACTION_REPLACE: - Node p3 = context.getParentNode(); - Node r2 = context.getNextSibling(); - p3.removeChild(context); - if (r2 == null) - { - p3.appendChild(root); - } - else - { - p3.insertBefore(root, r2); - } - break; - } - return root; - } - - public void abort() - { - if (eventSink != null) - { - eventSink.interrupt(); - } - } - - private Document doParse(LSInput input) - throws DOMException, LSException - { - // create event sink - if (eventSink != null) - { - throw new LSException(LSException.PARSE_ERR, "parse in progress"); - } - InputSource source = getInputSource(input); - eventSink = (filter == null) ? new SAXEventSink() : - new FilteredSAXEventSink(filter); - // configure sink - eventSink.setNamespaceAware(namespaceAware); - eventSink.ignoreWhitespace = ignoreWhitespace; - eventSink.expandEntityReferences = expandEntityReferences; - eventSink.ignoreComments = ignoreComments; - eventSink.coalescing = coalescing; - // get and configure reader - XMLReader reader = getXMLReader(); - eventSink.reader = reader; - try - { - reader.setContentHandler(eventSink); - reader.setDTDHandler(eventSink); - reader.setProperty("http://xml.org/sax/properties/lexical-handler", - eventSink); - reader.setProperty("http://xml.org/sax/properties/declaration-handler", - eventSink); - reader.setFeature("http://xml.org/sax/features/namespaces", - namespaceAware); - reader.setFeature("http://xml.org/sax/features/namespace-prefixes", - true); - reader.setFeature("http://xml.org/sax/features/validation", - validating); - try - { - reader.setFeature("http://gnu.org/sax/features/coalescing", - coalescing); - } - catch (SAXNotRecognizedException e) - { - // ignore - } - try - { - reader.setFeature("http://xml.org/sax/features/use-attributes2", - true); - } - catch (SAXNotRecognizedException e) - { - // ignore - } - try - { - reader.setFeature("http://xml.org/sax/features/external-general-entities", - true); - } - catch (SAXNotRecognizedException e) - { - // ignore - } - reader.setEntityResolver(entityResolver); - reader.setErrorHandler(errorHandler); - // parse - reader.parse(source); - } - catch (DOMException e) - { - reader = null; - eventSink = null; - throw e; - } - catch (SAXException e) - { - reader = null; - eventSink = null; - throw new DomLSException(LSException.PARSE_ERR, e); - } - catch (IOException e) - { - reader = null; - eventSink = null; - throw new DomLSException(LSException.PARSE_ERR, e); - } - // return document - Document ret = eventSink.doc; - String systemId = input.getSystemId(); - if (systemId != null && ret instanceof DomDocument) - { - ((DomDocument) ret).setDocumentURI(systemId); - } - eventSink = null; - return ret; - } - - private XMLReader getXMLReader() - throws LSException - { - if (reader == null) - { - factory.setNamespaceAware(namespaceAware); - factory.setValidating(validating); - factory.setXIncludeAware(xIncludeAware); - try - { - SAXParser parser = factory.newSAXParser(); - reader = parser.getXMLReader(); - } - catch (ParserConfigurationException e) - { - throw new DomLSException(LSException.PARSE_ERR, e); - } - catch (SAXException e) - { - throw new DomLSException(LSException.PARSE_ERR, e); - } - } - return reader; - } - - private InputSource getInputSource(LSInput input) - throws LSException - { - InputSource source = null; - String systemId = input.getSystemId(); - InputStream in = input.getByteStream(); - if (in != null) - { - source = new InputSource(in); - source.setSystemId(systemId); - } - if (source == null) - { - URL url = null; - String base = input.getBaseURI(); - try - { - try - { - URL baseURL = (base == null) ? null : new URL(base); - url = (baseURL == null) ? new URL(systemId) : - new URL(baseURL, systemId); - } - catch (MalformedURLException e) - { - File baseFile = (base == null) ? null : new File(base); - url = (baseFile == null) ? new File(systemId).toURL() : - new File(baseFile, systemId).toURL(); - } - in = url.openStream(); - systemId = url.toString(); - source = new InputSource(in); - source.setSystemId(systemId); - } - catch (IOException e) - { - throw new DomLSException(LSException.PARSE_ERR, e); - } - } - return source; - } - - // -- DOMConfiguration -- - - public void setParameter(String name, Object value) - throws DOMException - { - name = name.toLowerCase(); - if ("cdata-sections".equals(name)) - { - coalescing = !((Boolean) value).booleanValue(); - } - else if ("comments".equals(name)) - { - ignoreComments = !((Boolean) value).booleanValue(); - } - else if ("element-content-whitespace".equals(name)) - { - ignoreWhitespace = !((Boolean) value).booleanValue(); - } - else if ("namespaces".equals(name)) - { - namespaceAware = ((Boolean) value).booleanValue(); - } - else if ("expand-entity-references".equals(name)) - { - expandEntityReferences = ((Boolean) value).booleanValue(); - } - else if ("coalescing".equals(name)) - { - coalescing = ((Boolean) value).booleanValue(); - } - else if ("validating".equals(name)) - { - validating = ((Boolean) value).booleanValue(); - } - else if ("xinclude-aware".equals(name)) - { - xIncludeAware = ((Boolean) value).booleanValue(); - } - else if ("entity-resolver".equals(name)) - { - entityResolver = (EntityResolver) value; - } - else if ("error-handler".equals(name)) - { - errorHandler = (ErrorHandler) value; - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - // invalidate reader, a new one will be created - reader = null; - } - - public Object getParameter(String name) - throws DOMException - { - name = name.toLowerCase(); - if ("cdata-sections".equals(name)) - { - return coalescing ? Boolean.FALSE : Boolean.TRUE; - } - else if ("comments".equals(name)) - { - return ignoreComments ? Boolean.FALSE : Boolean.TRUE; - } - else if ("element-content-whitespace".equals(name)) - { - return ignoreWhitespace ? Boolean.FALSE : Boolean.TRUE; - } - else if ("namespaces".equals(name)) - { - return namespaceAware ? Boolean.TRUE : Boolean.FALSE; - } - else if ("expand-entity-references".equals(name)) - { - return expandEntityReferences ? Boolean.TRUE : Boolean.FALSE; - } - else if ("coalescing".equals(name)) - { - return coalescing ? Boolean.TRUE : Boolean.FALSE; - } - else if ("validating".equals(name)) - { - return validating ? Boolean.TRUE : Boolean.FALSE; - } - else if ("xinclude-aware".equals(name)) - { - return xIncludeAware ? Boolean.TRUE : Boolean.FALSE; - } - else if ("entity-resolver".equals(name)) - { - return entityResolver; - } - else if ("error-handler".equals(name)) - { - return errorHandler; - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - } - - public boolean canSetParameter(String name, Object value) - { - return contains(name); - } - - public DOMStringList getParameterNames() - { - return this; - } - - // -- DOMStringList -- - - public String item(int i) - { - return (String) SUPPORTED_PARAMETERS.get(i); - } - - public int getLength() - { - return SUPPORTED_PARAMETERS.size(); - } - - public boolean contains(String str) - { - return SUPPORTED_PARAMETERS.contains(str); - } - - // -- ErrorHandler -- - - public void warning(SAXParseException e) - throws SAXException - { - if (errorHandler != null) - { - errorHandler.warning(e); - } - } - - public void error(SAXParseException e) - throws SAXException - { - if (errorHandler != null) - { - errorHandler.error(e); - } - } - - public void fatalError(SAXParseException e) - throws SAXException - { - if (errorHandler != null) - { - errorHandler.fatalError(e); - } - abort(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/DomLSSerializer.java b/libjava/classpath/gnu/xml/dom/ls/DomLSSerializer.java deleted file mode 100644 index c282b0b..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/DomLSSerializer.java +++ /dev/null @@ -1,353 +0,0 @@ -/* DomLSSerializer.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.StringWriter; -import java.io.Writer; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.Arrays; -import java.util.List; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMStringList; -import org.w3c.dom.Node; -import org.w3c.dom.ls.LSException; -import org.w3c.dom.ls.LSOutput; -import org.w3c.dom.ls.LSSerializer; -import org.w3c.dom.ls.LSSerializerFilter; -import org.w3c.dom.traversal.NodeFilter; -import gnu.xml.dom.DomDOMException; -import gnu.xml.transform.StreamSerializer; - -/** - * Serialize a DOM node to a stream. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class DomLSSerializer - extends StreamSerializer - implements LSSerializer, DOMConfiguration, DOMStringList -{ - - private static final List SUPPORTED_PARAMETERS = - Arrays.asList(new String[] {"discard-default-content", - "xml-declaration"}); - - private LSSerializerFilter filter; - private StreamSerializer serializer; - - public DomLSSerializer() - { - super(); - discardDefaultContent = true; - } - - // -- LSSerializer -- - - public DOMConfiguration getDomConfig() - { - return this; - } - - public String getNewLine() - { - return eol; - } - - public void setNewLine(String newLine) - { - if (newLine == null) - { - newLine = System.getProperty("line.separator"); - } - eol = newLine; - } - - public LSSerializerFilter getFilter() - { - return filter; - } - - public void setFilter(LSSerializerFilter filter) - { - this.filter = filter; - } - - public boolean write(Node node, LSOutput output) - throws LSException - { - OutputStream out = output.getByteStream(); - try - { - if (out == null) - { - String systemId = output.getSystemId(); - try - { - URL url = new URL(systemId); - URLConnection connection = url.openConnection(); - connection.setDoOutput(true); - if (connection instanceof HttpURLConnection) - { - ((HttpURLConnection) connection).setRequestMethod("PUT"); - } - out = connection.getOutputStream(); - } - catch (MalformedURLException e) - { - File file = new File(systemId); - out = new FileOutputStream(file); - } - } - serialize(node, out); - out.flush(); - return true; - } - catch (IOException e) - { - throw new DomLSException(LSException.SERIALIZE_ERR, e); - } - } - - public boolean writeToURI(Node node, String uri) - throws LSException - { - LSOutput output = new DomLSOutput(); - output.setSystemId(uri); - return write(node, output); - } - - public String writeToString(Node node) - throws DOMException, LSException - { - Writer writer = new StringWriter(); - LSOutput output = new DomLSOutput(); - output.setCharacterStream(writer); - write(node, output); - return writer.toString(); - } - - public void serialize(Node node, OutputStream out) - throws IOException - { - if (filter == null) - { - super.serialize(node, out); - } - else - { - int wts = filter.getWhatToShow(); - if (wts != NodeFilter.SHOW_ALL) - { - switch (node.getNodeType()) - { - case Node.ATTRIBUTE_NODE: - if ((wts & NodeFilter.SHOW_ATTRIBUTE) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.TEXT_NODE: - if ((wts & NodeFilter.SHOW_TEXT) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.ELEMENT_NODE: - if ((wts & NodeFilter.SHOW_ELEMENT) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.CDATA_SECTION_NODE: - if ((wts & NodeFilter.SHOW_CDATA_SECTION) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.COMMENT_NODE: - if ((wts & NodeFilter.SHOW_COMMENT) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.DOCUMENT_NODE: - if ((wts & NodeFilter.SHOW_DOCUMENT) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.DOCUMENT_TYPE_NODE: - if ((wts & NodeFilter.SHOW_DOCUMENT_TYPE) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.PROCESSING_INSTRUCTION_NODE: - if ((wts & NodeFilter.SHOW_PROCESSING_INSTRUCTION) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.DOCUMENT_FRAGMENT_NODE: - if ((wts & NodeFilter.SHOW_DOCUMENT_FRAGMENT) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.ENTITY_NODE: - if ((wts & NodeFilter.SHOW_ENTITY) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.ENTITY_REFERENCE_NODE: - if ((wts & NodeFilter.SHOW_ENTITY_REFERENCE) == 0) - { - super.serialize(node, out); - return; - } - break; - case Node.NOTATION_NODE: - if ((wts & NodeFilter.SHOW_NOTATION) == 0) - { - super.serialize(node, out); - return; - } - break; - } - } - switch (filter.acceptNode(node)) - { - case NodeFilter.FILTER_ACCEPT: - super.serialize(node, out); - break; - case NodeFilter.FILTER_REJECT: - break; - case NodeFilter.FILTER_SKIP: - Node first = node.getFirstChild(); - if (first != null) - { - serialize(first, out); - } - break; - } - } - } - - // -- DOMConfiguration -- - - public void setParameter(String name, Object value) - throws DOMException - { - if ("discard-default-content".equals(name)) - { - discardDefaultContent = "true".equals(value.toString()); - } - else if ("xml-declaration".equals(name)) - { - xmlDeclaration = "false".equals(value.toString()); - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - } - - public Object getParameter(String name) - throws DOMException - { - if ("discard-default-content".equals(name)) - { - return discardDefaultContent ? "true" : "false"; - } - else if ("xml-declaration".equals(name)) - { - return xmlDeclaration ? "true" : "false"; - } - else - { - throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); - } - } - - public boolean canSetParameter(String name, Object value) - { - return contains(name); - } - - public DOMStringList getParameterNames() - { - return this; - } - - // -- DOMStringList -- - - public String item(int i) - { - return (String) SUPPORTED_PARAMETERS.get(i); - } - - public int getLength() - { - return SUPPORTED_PARAMETERS.size(); - } - - public boolean contains(String str) - { - return SUPPORTED_PARAMETERS.contains(str); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/FilteredSAXEventSink.java b/libjava/classpath/gnu/xml/dom/ls/FilteredSAXEventSink.java deleted file mode 100644 index 65c1d37..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/FilteredSAXEventSink.java +++ /dev/null @@ -1,353 +0,0 @@ -/* FilteredSAXEventSink.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.util.LinkedList; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.Text; -import org.w3c.dom.ls.LSParserFilter; -import org.w3c.dom.traversal.NodeFilter; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * A SAX event sink that calls out to a parser filter in order to decide - * whether to insert nodes into the tree. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -class FilteredSAXEventSink - extends SAXEventSink -{ - - final LSParserFilter filter; - final int whatToShow; - - /** - * Stack of elements to insert. - */ - LinkedList nodes; - - /** - * Corresponding stack of filter decisions about the nodes. - */ - LinkedList decisions; - - /** - * True when rejecting child nodes. - */ - boolean rejecting; - - FilteredSAXEventSink(LSParserFilter filter) - { - this.filter = filter; - whatToShow = filter.getWhatToShow(); - } - - public void startDocument() - throws SAXException - { - if (interrupted) - { - return; - } - nodes = new LinkedList(); - decisions = new LinkedList(); - - super.startDocument(); - } - - public void endDocument() - throws SAXException - { - if (interrupted) - { - return; - } - super.endDocument(); - - switch (getDecision(ctx, false)) - { - case LSParserFilter.FILTER_REJECT: - ctx = null; - doc = null; - break; - } - - nodes = null; - decisions = null; - } - - public void startElement(String uri, String localName, String qName, - Attributes atts) - throws SAXException - { - if (rejecting || interrupted) - { - return; - } - Element element = createElement(uri, localName, qName, atts); - ctx = element; - - short decision = getDecision(element, true); - nodes.addLast(element); - decisions.addLast(new Short(decision)); - - switch (decision) - { - case LSParserFilter.FILTER_REJECT: - rejecting = true; - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - protected Attr createAttr(Attributes atts, int index) - { - Attr attr = super.createAttr(atts, index); - short decision = getDecision(attr, false); - switch (decision) - { - case LSParserFilter.FILTER_REJECT: - return null; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - return null; - } - return attr; - } - - public void endElement(String uri, String localName, String qName) - throws SAXException - { - if (rejecting || interrupted) - { - return; - } - super.endElement(uri, localName, qName); - - Element element = (Element) nodes.removeLast(); - Node parent = nodes.isEmpty() ? doc : (Node) nodes.getLast(); - ctx = parent; - short decision = ((Short) decisions.removeLast()).shortValue(); - switch (decision) - { - case LSParserFilter.FILTER_SKIP: - // Add all children of element to parent - for (Node child = element.getFirstChild(); child != null; - child = child.getNextSibling()) - { - parent.insertBefore(child, element); - } - return; - case LSParserFilter.FILTER_REJECT: - rejecting = false; - break; - } - decision = getDecision(element, false); - switch (decision) - { - case LSParserFilter.FILTER_ACCEPT: - parent.appendChild(element); - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - public void characters(char[] c, int off, int len) - throws SAXException - { - if (rejecting || interrupted) - { - return; - } - Text text = createText(c, off, len); - short decision = getDecision(text, false); - switch (decision) - { - case LSParserFilter.FILTER_ACCEPT: - ctx.appendChild(text); - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - public void processingInstruction(String target, String data) - throws SAXException - { - if (rejecting || interrupted || inDTD) - { - return; - } - Node pi = createProcessingInstruction(target, data); - short decision = getDecision(pi, false); - switch (decision) - { - case LSParserFilter.FILTER_ACCEPT: - ctx.appendChild(pi); - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - public void startDTD(String name, String publicId, String systemId) - throws SAXException - { - if (interrupted) - { - return; - } - Node doctype = createDocumentType(name, publicId, systemId); - ctx = doctype; - inDTD = true; - nodes.addLast(doctype); - decisions.addLast(new Short(LSParserFilter.FILTER_ACCEPT)); - } - - public void endDTD() - throws SAXException - { - if (interrupted) - { - return; - } - Node doctype = (Node) nodes.removeLast(); - decisions.removeLast(); - inDTD = false; - ctx = doc; - short decision = getDecision(doctype, false); - switch (decision) - { - case LSParserFilter.FILTER_ACCEPT: - ctx.appendChild(doctype); - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - public void comment(char[] c, int off, int len) - throws SAXException - { - if (rejecting || interrupted || inDTD) - { - return; - } - Node comment = createComment(c, off, len); - short decision = getDecision(comment, false); - switch (decision) - { - case LSParserFilter.FILTER_ACCEPT: - ctx.appendChild(comment); - break; - case LSParserFilter.FILTER_INTERRUPT: - interrupted = true; - break; - } - } - - // TODO declarations - - short getDecision(Node node, boolean start) - { - boolean show = (whatToShow == NodeFilter.SHOW_ALL); - if (!show) - { - switch (node.getNodeType()) - { - case Node.ATTRIBUTE_NODE: - show = ((whatToShow & NodeFilter.SHOW_ATTRIBUTE) != 0); - break; - case Node.TEXT_NODE: - show = ((whatToShow & NodeFilter.SHOW_TEXT) != 0); - break; - case Node.CDATA_SECTION_NODE: - show = ((whatToShow & NodeFilter.SHOW_CDATA_SECTION) != 0); - break; - case Node.ELEMENT_NODE: - show = ((whatToShow & NodeFilter.SHOW_ELEMENT) != 0); - break; - case Node.COMMENT_NODE: - show = ((whatToShow & NodeFilter.SHOW_COMMENT) != 0); - break; - case Node.DOCUMENT_NODE: - show = ((whatToShow & NodeFilter.SHOW_DOCUMENT) != 0); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - show = ((whatToShow & NodeFilter.SHOW_PROCESSING_INSTRUCTION) != 0); - break; - case Node.DOCUMENT_FRAGMENT_NODE: - show = ((whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT) != 0); - break; - case Node.DOCUMENT_TYPE_NODE: - show = ((whatToShow & NodeFilter.SHOW_DOCUMENT_TYPE) != 0); - break; - case Node.ENTITY_REFERENCE_NODE: - show = ((whatToShow & NodeFilter.SHOW_ENTITY_REFERENCE) != 0); - break; - case Node.ENTITY_NODE: - show = ((whatToShow & NodeFilter.SHOW_ENTITY) != 0); - break; - case Node.NOTATION_NODE: - show = ((whatToShow & NodeFilter.SHOW_NOTATION) != 0); - break; - } - } - if (!show) - { - return LSParserFilter.FILTER_ACCEPT; - } - if (start) - { - return filter.startElement((Element) node); - } - return filter.acceptNode(node); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/ReaderInputStream.java b/libjava/classpath/gnu/xml/dom/ls/ReaderInputStream.java deleted file mode 100644 index cf279ab..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/ReaderInputStream.java +++ /dev/null @@ -1,236 +0,0 @@ -/* ReaderInputStream.java -- - Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.io.InputStream; -import java.io.IOException; -import java.io.Reader; - -/** - * Character stream wrapper. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - * @author <a href='mailto:mark@klomp.org'>Mark Wielaard</a> - */ -public class ReaderInputStream - extends InputStream -{ - - private Reader reader; - private String encoding; - - // Holds extra spillover data if necessary - private byte extra[]; - private int pos; - - private byte extra_marked[]; - private int pos_marked; - - public ReaderInputStream(Reader reader) - { - this.reader = reader; - this.encoding = "UTF-8"; - } - - void setEncoding(String encoding) - { - this.encoding = encoding; - } - - public int read() - throws IOException - { - if (extra != null) - { - int result = extra[pos]; - pos++; - if (pos >= extra.length) - { - extra = null; - } - return result; - } - return reader.read(); - } - - public int read(byte[] b) - throws IOException - { - return read(b, 0, b.length); - } - - public int read(byte[] b, int off, int len) - throws IOException - { - if (len == 0) - { - return 0; - } - - if (extra != null) - { - int available = extra.length - pos; - int l = available < len ? available : len; - System.arraycopy(extra, 0, b, off, l); - pos += l; - if (pos >= extra.length) - { - extra = null; - } - return l; - } - - char[] c = new char[len]; - int l = reader.read(c, 0, len); - if (l == -1) - { - return -1; - } - - String s = new String(c, 0, l); - byte[] d = s.getBytes(encoding); - - int available = d.length; - int more = d.length - len; - if (more > 0) - { - extra = new byte[more]; - pos = 0; - System.arraycopy(d, len, extra, 0, more); - available -= more; - } - - System.arraycopy(d, 0, b, off, available); - return available; - } - - public void close() - throws IOException - { - reader.close(); - } - - public boolean markSupported() - { - return reader.markSupported(); - } - - public void mark(int limit) - { - if (extra != null) - { - extra_marked = new byte[extra.length]; - System.arraycopy(extra, 0, extra_marked, 0, extra.length); - pos_marked = pos; - } - else - { - extra_marked = null; - } - - try - { - // Note that this might be a bit more than asked for. - // Because we might also have the extra_marked bytes. - // That is fine (and necessary for reset() to work). - reader.mark(limit); - } - catch (IOException ioe) - { - throw new RuntimeException(ioe); - } - } - - public void reset() - throws IOException - { - extra = extra_marked; - pos = pos_marked; - extra_marked = null; - - reader.reset(); - } - - public long skip(long n) - throws IOException - { - long done = 0; - if (extra != null) - { - int available = extra.length - pos; - done = available < n ? available : n; - pos += done; - if (pos >= extra.length) - { - extra = null; - } - } - - n -= done; - if (n > 0) - { - return reader.skip(n) + done; - } - else - { - return done; - } - } - - /** - * Returns conservative number of bytes available without blocking. - * Actual number of bytes that can be read without blocking might - * be (much) bigger. - */ - public int available() - throws IOException - { - if (extra != null) - { - return pos - extra.length; - } - - return reader.ready() ? 1 : 0; - } - - public String toString() - { - return getClass().getName() + "[" + reader + ", " + encoding + "]"; - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java b/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java deleted file mode 100644 index 06333dd..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/SAXEventSink.java +++ /dev/null @@ -1,603 +0,0 @@ -/* SAXEventSink.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import javax.xml.XMLConstants; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Entity; -import org.w3c.dom.EntityReference; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.Text; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.Attributes2; -import org.xml.sax.ext.DeclHandler; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.ext.Locator2; -import gnu.xml.dom.DomAttr; -import gnu.xml.dom.DomDocument; -import gnu.xml.dom.DomDoctype; -import gnu.xml.dom.DomNode; - -/** - * A SAX content and lexical handler used to construct a DOM document. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class SAXEventSink - implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler -{ - - private static final String XMLNS_URI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - private static final String XMLNS_PREFIX = XMLConstants.XMLNS_ATTRIBUTE; - private static final HashSet PREDEFINED_ENTITIES = new HashSet(); - static - { - PREDEFINED_ENTITIES.add("amp"); - PREDEFINED_ENTITIES.add("lt"); - PREDEFINED_ENTITIES.add("gt"); - PREDEFINED_ENTITIES.add("quot"); - PREDEFINED_ENTITIES.add("apos"); - } - - private boolean namespaceAware; - boolean ignoreWhitespace; - boolean expandEntityReferences; - boolean ignoreComments; - boolean coalescing; - - XMLReader reader; // reference back to the parser to get features - - DomDocument doc; // document being constructed - Node ctx; // current context (parent node) - LinkedList entityCtx; // entity context - List pending; // namespace nodes waiting for a declaring element - Locator locator; - boolean inCDATA; - boolean inDTD; - boolean interrupted; - - void interrupt() - { - interrupted = true; - } - - public Document getDocument() - { - return doc; - } - - public void setReader(XMLReader reader) - { - this.reader = reader; - } - - // -- ContentHandler2 -- - - public void setDocumentLocator(Locator locator) - { - this.locator = locator; - } - - public void setNamespaceAware(boolean namespaceAware) - { - this.namespaceAware = namespaceAware; - } - - public void startDocument() - throws SAXException - { - if (namespaceAware) - { - pending = new LinkedList(); - } - doc = new DomDocument(); - doc.setStrictErrorChecking(false); - doc.setBuilding(true); - doc.setDefaultAttributes(false); - ctx = doc; - - final String FEATURES = "http://xml.org/sax/features/"; - final String PROPERTIES = "http://xml.org/sax/properties/"; - final String GNU_PROPERTIES = "http://gnu.org/sax/properties/"; - - if (reader != null) - { - boolean standalone = reader.getFeature(FEATURES + "is-standalone"); - doc.setXmlStandalone(standalone); - try - { - String version = (String) reader.getProperty(PROPERTIES + - "document-xml-version"); - doc.setXmlVersion(version); - } - catch (SAXNotRecognizedException e) - { - } - catch (SAXNotSupportedException e) - { - } - try - { - String encoding = (String) reader.getProperty(GNU_PROPERTIES + - "document-xml-encoding"); - doc.setXmlEncoding(encoding); - } - catch (SAXNotRecognizedException e) - { - } - catch (SAXNotSupportedException e) - { - } - } - if (locator != null && locator instanceof Locator2) - { - String encoding = ((Locator2) locator).getEncoding(); - doc.setInputEncoding(encoding); - } - } - - public void endDocument() - throws SAXException - { - doc.setStrictErrorChecking(true); - doc.setBuilding(false); - doc.setDefaultAttributes(true); - DomDoctype doctype = (DomDoctype) doc.getDoctype(); - if (doctype != null) - { - doctype.makeReadonly(); - } - ctx = null; - locator = null; - } - - public void startPrefixMapping(String prefix, String uri) - throws SAXException - { - if (namespaceAware) - { - String nsName = (prefix != null && prefix.length() > 0) ? - XMLNS_PREFIX + ":" + prefix : XMLNS_PREFIX; - DomAttr ns = (DomAttr) doc.createAttributeNS(XMLNS_URI, nsName); - ns.setNodeValue(uri); - if (ctx.getNodeType() == Node.ATTRIBUTE_NODE) - { - // Add to owner element - Node target = ((Attr) ctx).getOwnerElement(); - target.getAttributes().setNamedItemNS(ns); - } - else - { - // Add to pending list; namespace node will be inserted when - // element is seen - pending.add(ns); - } - } - } - - public void endPrefixMapping(String prefix) - throws SAXException - { - } - - public void startElement(String uri, String localName, String qName, - Attributes atts) - throws SAXException - { - if (interrupted) - { - return; - } - Element element = createElement(uri, localName, qName, atts); - // add element to context - ctx.appendChild(element); - ctx = element; - } - - protected Element createElement(String uri, String localName, String qName, - Attributes atts) - throws SAXException - { - // create element node - Element element = namespaceAware ? - doc.createElementNS(uri, qName) : - doc.createElement(qName); - NamedNodeMap attrs = element.getAttributes(); - if (namespaceAware && !pending.isEmpty()) - { - // add pending namespace nodes - for (Iterator i = pending.iterator(); i.hasNext(); ) - { - Node ns = (Node) i.next(); - attrs.setNamedItemNS(ns); - } - pending.clear(); - } - // add attributes - int len = atts.getLength(); - for (int i = 0; i < len; i++) - { - // create attribute - Attr attr = createAttr(atts, i); - if (attr != null) - { - // add attribute to element - if (namespaceAware) - { - attrs.setNamedItemNS(attr); - } - else - { - attrs.setNamedItem(attr); - } - } - } - return element; - } - - protected Attr createAttr(Attributes atts, int index) - { - DomAttr attr; - if (namespaceAware) - { - String a_uri = atts.getURI(index); - String a_qName = atts.getQName(index); - attr = (DomAttr) doc.createAttributeNS(a_uri, a_qName); - } - else - { - String a_qName = atts.getQName(index); - attr = (DomAttr) doc.createAttribute(a_qName); - } - attr.setNodeValue(atts.getValue(index)); - if (atts instanceof Attributes2) - { - Attributes2 atts2 = (Attributes2) atts; - // TODO attr.setDeclared(atts2.isDeclared(index)); - attr.setSpecified(atts2.isSpecified(index)); - } - return attr; - } - - public void endElement(String uri, String localName, String qName) - throws SAXException - { - if (interrupted) - { - return; - } - if (namespaceAware) - { - pending.clear(); - } - ctx = ctx.getParentNode(); - } - - public void characters(char[] c, int off, int len) - throws SAXException - { - if (interrupted || len < 1) - { - return; - } - ctx.appendChild(createText(c, off, len)); - } - - protected Text createText(char[] c, int off, int len) - throws SAXException - { - Text text = (inCDATA && !coalescing) ? - doc.createCDATASection(new String(c, off, len)) : - doc.createTextNode(new String(c, off, len)); - return text; - } - - public void ignorableWhitespace(char[] c, int off, int len) - throws SAXException - { - if (interrupted) - { - return; - } - if (!ignoreWhitespace) - { - characters(c, off, len); - } - } - - public void processingInstruction(String target, String data) - throws SAXException - { - if (interrupted) - { - return; - } - Node pi = createProcessingInstruction(target, data); - ctx.appendChild(pi); - } - - protected Node createProcessingInstruction(String target, String data) - { - return doc.createProcessingInstruction(target, data); - } - - public void skippedEntity(String name) - throws SAXException - { - // This callback is totally pointless - } - - // -- LexicalHandler -- - - public void startDTD(String name, String publicId, String systemId) - throws SAXException - { - if (interrupted) - { - return; - } - Node doctype = createDocumentType(name, publicId, systemId); - doc.appendChild(doctype); - ctx = doctype; - inDTD = true; - } - - protected Node createDocumentType(String name, String publicId, - String systemId) - { - return new DomDoctype(doc, name, publicId, systemId); - } - - public void endDTD() - throws SAXException - { - if (interrupted) - { - return; - } - inDTD = false; - ctx = ctx.getParentNode(); - } - - public void startEntity(String name) - throws SAXException - { - if (interrupted) - return; - DocumentType doctype = doc.getDoctype(); - if (doctype == null) - { - throw new SAXException("SAX parser error: " + - "reference to entity in undeclared doctype"); - } - if ("[dtd]".equals(name) || name.charAt(0) == '%') - return; - if (PREDEFINED_ENTITIES.contains(name)) - return; - // Get entity - NamedNodeMap entities = doctype.getEntities(); - Entity entity = (Entity) entities.getNamedItem(name); - if (entity == null) - { - throw new SAXException("SAX parser error: " + - "reference to undeclared entity: " + name); - } - EntityReference ref = doc.createEntityReference(name); - // DomDocument populates with the entity replacement text, remove this - Node child = ref.getFirstChild(); - while (child != null) - { - Node nextChild = child.getNextSibling(); - ref.removeChild(child); - child = nextChild; - } - ctx.appendChild(ref); - ctx = ref; - } - - public void endEntity(String name) - throws SAXException - { - if (interrupted) - return; - if ("[dtd]".equals(name) || name.charAt(0) == '%') - return; - if (PREDEFINED_ENTITIES.contains(name)) - return; - // Get entity reference - EntityReference ref = (EntityReference) ctx; - if (!ref.getNodeName().equals(name)) - throw new SAXException("expecting end of "+ref.getNodeName()+" entity"); - ctx = ctx.getParentNode(); - if (ref instanceof DomNode) - ((DomNode) ref).makeReadonly(); - if (expandEntityReferences) - { - // Move entity content from reference node onto context - Node child = ref.getFirstChild(); - while (child != null) - { - Node nextChild = child.getNextSibling(); - ctx.appendChild(child); - child = nextChild; - } - ctx.removeChild(ref); - } - } - - public void startCDATA() - throws SAXException - { - inCDATA = true; - } - - public void endCDATA() - throws SAXException - { - inCDATA = false; - } - - public void comment(char[] c, int off, int len) - throws SAXException - { - if (interrupted) - { - return; - } - Node comment = createComment(c, off, len); - ctx.appendChild(comment); - } - - protected Node createComment(char[] c, int off, int len) - { - return doc.createComment(new String(c, off, len)); - } - - // -- DTDHandler -- - - public void notationDecl(String name, String publicId, String systemId) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("notation decl outside DTD"); - DomDoctype doctype = (DomDoctype) ctx; - doctype.declareNotation(name, publicId, systemId); - } - - public void unparsedEntityDecl(String name, String publicId, String systemId, - String notationName) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("unparsed entity decl outside DTD"); - DomDoctype doctype = (DomDoctype) ctx; - Entity entity = doctype.declareEntity(name, publicId, systemId, - notationName); - } - - // -- DeclHandler -- - - public void elementDecl(String name, String model) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("element decl outside DTD"); - // Ignore fake element declarations generated by ValidationConsumer. - // If an element is not really declared in the DTD it will not be - // declared in the document model. - if (!(ctx instanceof DomDoctype)) - { - return; - } - DomDoctype doctype = (DomDoctype) ctx; - doctype.elementDecl(name, model); - } - - public void attributeDecl(String eName, String aName, String type, - String mode, String value) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("attribute decl outside DTD"); - DomDoctype doctype = (DomDoctype) ctx; - doctype.attributeDecl(eName, aName, type, mode, value); - } - - public void internalEntityDecl(String name, String value) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("internal entity decl outside DTD"); - DomDoctype doctype = (DomDoctype) ctx; - Entity entity = doctype.declareEntity(name, null, null, null); - if (entity != null) - { - Node text = doc.createTextNode(value); - entity.appendChild(text); - } - } - - public void externalEntityDecl(String name, String publicId, String systemId) - throws SAXException - { - if (interrupted) - { - return; - } - if (!inDTD) - throw new SAXException("external entity decl outside DTD"); - DomDoctype doctype = (DomDoctype) ctx; - Entity entity = doctype.declareEntity(name, publicId, systemId, null); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/ls/WriterOutputStream.java b/libjava/classpath/gnu/xml/dom/ls/WriterOutputStream.java deleted file mode 100644 index f1ae344..0000000 --- a/libjava/classpath/gnu/xml/dom/ls/WriterOutputStream.java +++ /dev/null @@ -1,97 +0,0 @@ -/* WriterOutputStream.java -- - Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath 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 the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.dom.ls; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -/** - * Character stream wrapper. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class WriterOutputStream - extends OutputStream -{ - - private Writer writer; - private String encoding; - - public WriterOutputStream(Writer writer) - { - this.writer = writer; - this.encoding = "UTF-8"; - } - - void setEncoding(String encoding) - { - this.encoding = encoding; - } - - public void write(int c) - throws IOException - { - writer.write(c); - } - - public void write(byte[] b) - throws IOException - { - write(b, 0, b.length); - } - - public void write(byte[] b, int off, int len) - throws IOException - { - writer.write(new String(b, off, len, encoding)); - } - - public void close() - throws IOException - { - writer.close(); - } - - public void flush() - throws IOException - { - writer.flush(); - } - -} diff --git a/libjava/classpath/gnu/xml/dom/package.html b/libjava/classpath/gnu/xml/dom/package.html deleted file mode 100644 index fbc864a..0000000 --- a/libjava/classpath/gnu/xml/dom/package.html +++ /dev/null @@ -1,273 +0,0 @@ -<html> -<body> - -<p> -This is a Free Software DOM Level 3 implementation, supporting these features: -<ul> -<li>"XML"</li> -<li>"Events"</li> -<li>"MutationEvents"</li> -<li>"HTMLEvents" (won't generate them though)</li> -<li>"UIEvents" (also won't generate them)</li> -<li>"USER-Events" (a conformant extension)</li> -<li>"Traversal" (optional)</li> -<li>"XPath"</li> -<li>"LS" and "LS-Async"</li> -</ul> -It is intended to be a reasonable base both for -experimentation and supporting additional DOM modules as clean layers. -</p> - -<p> -Note that while DOM does not specify its behavior in the -face of concurrent access, this implementation does. -Specifically: -<ul> -<li>If only one thread at a time accesses a Document, -of if several threads cooperate for read-only access, -then no concurrency conflicts will occur.</li> -<li>If several threads mutate a given document -(or send events using it) at the same time, -there is currently no guarantee that -they won't interfere with each other.</li> -</ul> -</p> - -<h3>Design Goals</h3> - -<p> -A number of DOM implementations are available in Java, including -commercial ones from Sun, IBM, Oracle, and DataChannel as well as -noncommercial ones from Docuverse, OpenXML, and Silfide. Why have -another? Some of the goals of this version: -</p> - -<ul> -<li>Advanced DOM support. This was the first generally available -implementation of DOM Level 2 in Java, and one of the first Level 3 -and XPath implementations.</li> - -<li> Free Software. This one is distributed under the GPL (with -"library exception") so it can be used with a different class of -application.</li> - -<li>Second implementation syndrome. I can do it simpler this time -around ... and heck, writing it only takes a bit over a day once you -know your way around.</li> - -<li>Sanity check the then-current Last Call DOM draft. Best to find -bugs early, when they're relatively fixable. Yes, bugs were found.</li> - -<li>Modularity. Most of the implementations mentioned above are part -of huge packages; take all (including bugs, of which some have far -too many), or take nothing. I prefer a menu approach, when possible. -This code is standalone, not beholden to any particular parser or XSL -or XPath code.</li> - -<li>OK, I'm a hacker, I like to write code.</li> -</ul> - -<p> -This also works with the GNU Compiler for Java (GCJ). GCJ promises -to be quite the environment for programming Java, both directly and from -C++ using the new CNI interfaces (which really use C++, unlike JNI). </p> - - -<h3>Open Issues</h3> - -<p>At this writing:</p> -<ul> -<li>See below for some restrictions on the mutation event -support ... some events aren't reported (and likely won't be).</li> - -<li>More testing and conformance work is needed.</li> - -<li>We need an XML Schema validator (actually we need validation in the DOM -full stop).</li> -</ul> - -<p> -I ran a profiler a few times and remove some of the performance hotspots, -but it's not tuned. Reporting mutation events, in particular, is -rather costly -- it started at about a 40% penalty for appendNode calls, -I've got it down around 12%, but it'll be hard to shrink it much further. -The overall code size is relatively small, though you may want to be rid of -many of the unused DOM interface classes (HTML, CSS, and so on). -</p> - - -<h2><a name="features">Features of this Package</a></h2> - -<p> Starting with DOM Level 2, you can really see that DOM is constructed -as a bunch of optional modules around a core of either XML or HTML -functionality. Different implementations will support different optional -modules. This implementation provides a set of features that should be -useful if you're not depending on the HTML functionality (lots of convenience -functions that mostly don't buy much except API surface area) and user -interface support. That is, browsers will want more -- but what they -need should be cleanly layered over what's already here. </p> - -<h3> Core Feature Set: "XML" </h3> - -<p> This DOM implementation supports the "XML" feature set, which basically -gets you four things over the bare core (which you're officially not supposed -to implement except in conjunction with the "XML" or "HTML" feature). In -order of decreasing utility, those four things are: </p> <ol> - - <li> ProcessingInstruction nodes. These are probably the most - valuable thing. Handy little buggers, in part because all the APIs - you need to use them are provided, and they're designed to let you - escape XML document structure rules in controlled ways.</li> - - <li> CDATASection nodes. These are of of limited utility since CDATA - is just text that prints funny. These are of use to some sorts of - applications, though I encourage folk to not use them. </li> - - <li> DocumentType nodes, and associated Notation and Entity nodes. - These appear to be useless. Briefly, these "Type" nodes expose no - typing information. They're only really usable to expose some lexical - structure that almost every application needs to ignore. (XML editors - might like to see them, but they need true typing information much more.) - I strongly encourage people not to use these. </li> - - <li> EntityReference nodes can show up. These are actively annoying, - since they add an extra level of hierarchy, are the cause of most of - the complexity in attribute values, and their contents are immutable. - Avoid these.</li> - - </ol> - -<h3> Optional Feature Sets: "Events", and friends </h3> - -<p> Events may be one of the more interesting new features in Level 2. -This package provides the core feature set and exposes mutation events. -No gooey events though; if you want that, write a layered implementation! </p> - -<p> Three mutation events aren't currently generated:</p> <ul> - - <li> <em>DOMSubtreeModified</em> is poorly specified. Think of this - as generating one such event around the time of finalization, which - is a fully conformant implementation. This implementation is exactly - as useful as that one. </li> - - <li> <em>DOMNodeRemovedFromDocument</em> and - <em>DOMNodeInsertedIntoDocument</em> are supposed to get sent to - every node in a subtree that gets removed or inserted (respectively). - This can be <em>extremely costly</em>, and the removal and insertion - processing is already significantly slower due to event reporting. - It's much easier, and more efficient, to have a listener higher in the - tree watch removal and insertion events through the bubbling or capture - mechanisms, than it is to watch for these two events.</li> - - </ul> - -<p> In addition, certain kinds of attribute modification aren't reported. -A fix is known, but it couldn't report the previous value of the attribute. -More work could fix all of this (as well as reduce the generally high cost -of childful attributes), but that's not been done yet. </p> - -<p> Also, note that it is a <em>Bad Thing™</em> to have the listener -for a mutation event change the ancestry for the target of that event. -Or to prevent mutation events from bubbling to where they're needed. -Just don't do those, OK? </p> - -<p> As an experimental feature (named "USER-Events"), you can provide -your own "user" events. Just name them anything starting with "USER-" -and you're set. Dispatch them through, bubbling, capturing, or what -ever takes your fancy. One important thing you can't currently do is -pass any data (like an object) with those events. Maybe later there -will be a "UserEvent" interface letting you get some substantial use -out of this mechanism even if you're not "inside" of a DOM package.</p> - -<p> You can create and send HTML events. Ditto UIEvents. Since DOM -doesn't require a UI, it's the UI's job to send them; perhaps that's -part of your application. </p> - -<p><em>This package may be built without the ability to report mutation -events, gaining a significant speedup in DOM construction time. However, -if that is done then certain other features -- notably node iterators -and getElementsByTagname -- will not be available.</em> - - -<h3> Optional Feature: "Traversal" </h3> - -<p> Each DOM node has all you need to walk to everything connected -to that node. Lightweight, efficient utilities are easily layered on -top of just the core APIs. </p> - -<p> Traversal APIs are an optional part of DOM Level 2, providing -a not-so-lightweight way to walk over DOM trees, if your application -didn't already have such utilities for use with data represented via -DOM. Implementing this helped debug the (optional) event and mutation -event subsystems, so it's provided here. </p> - -<p> At this writing, the "TreeWalker" interface isn't implemented. </p> - - - -<h2><a name='avoid'>DOM Functionality to Avoid</a></h2> - -<p> For what appear to be a combination of historical and "committee -logic" reasons, DOM has a number of <em>features which I strongly advise -you to avoid using</em> in your library and application code. These -include the following types of DOM nodes; see the documentation for the -implementation class for more information: <ul> - - <li> CDATASection - (<a href='DomCDATA.html'>DomCDATA</a> class) - ... use normal Text nodes instead, so you don't have to make - every algorithm recognize multiple types of character data - - <li> DocumentType - (<a href='DomDoctype.html'>DomDocType</a> class) - ... if this held actual typing information, it might be useful - - <li> Entity - (<a href='DomEntity.html'>DomEntity</a> class) - ... neither parsed nor unparsed entities work well in DOM; it - won't even tell you which attributes identify unparsed entities - - <li> EntityReference - (<a href='DomEntityReference.html'>DomEntityReference</a> class) - ... permitted implementation variances are extreme, all children - are readonly, and these can interact poorly with namespaces - - <li> Notation - (<a href='DomNotation.html'>DomNotation</a> class) - ... only really usable with unparsed entities (which aren't well - supported; see above) or perhaps with PIs after the DTD, not with - NOTATION attributes - - </ul> - -<p> If you really need to use unparsed entities or notations, use SAX; -it offers better support for all DTD-related functionality. -It also exposes actual -document typing information (such as element content models).</p> - -<p> Also, when accessing attribute values, use methods that provide their -values as single strings, rather than those which expose value substructure -(Text and EntityReference nodes). (See the <a href='DomAttr.html'>DomAttr</a> -documentation for more information.) </p> - -<p> Note that many of these features were provided as partial support for -editor functionality (including the incomplete DTD access). Full editor -functionality requires access to potentially malformed lexical structure, -at the level of unparsed tokens and below. Access at such levels is so -complex that using it in non-editor applications sacrifices all the -benefits of XML; editor aplications need extremely specialized APIs. </p> - -<p> (This isn't a slam against DTDs, note; only against the broken support -for them in DOM. Even despite inclusion of some dubious SGML legacy features -such as notations and unparsed entities, -and the ongoing proliferation of alternative schema and validation tools, -DTDs are still the most widely adopted tool -to constrain XML document structure. -Alternative schemes generally focus on data transfer style -applications; open document architectures comparable to -DocBook 4.0 don't yet exist in the schema world. -Feel free to use DTDs; just don't expect DOM to help you.) </p> - -</body> -</html> - |