Commit 7526f355 by Mark Wielaard

[multiple changes]

2005-02-16  Mark Wielaard  <mark@klomp.org>

        * Makefile.am (gnu_xml_source_files): Removed
        gnu/xml/dom/DomCDATA.java, gnu/xml/dom/DomEx.java,
        gnu/xml/dom/DomFragment.java, gnu/xml/dom/DomPI.java and
        gnu/xml/dom/ls/DomLSEx.java. Replaced by adding
        gnu/xml/dom/DomCDATASection.java, gnu/xml/dom/DomDOMException.java,
        gnu/xml/dom/DomDocumentFragment.java,
        gnu/xml/dom/DomProcessingInstruction.java and
        gnu/xml/dom/ls/DomLSException.java.
        * Makefile.in: Regenerated.

2005-02-16  Tom Tromey  <tromey@redhat.com>

        * gnu/xml/aelfred2/SAXDriver.java: Ensure that null is returned when
        attribute index is out of bounds.

2005-02-16  Chris Burdess  <dog@gnu.org>

        * gnu/xml/aelfred2/SAXDriver.java: Corrected implementation of
        isDeclared methods. Improved performance of isSpecified methods.

2005-02-16  Chris Burdess  <dog@gnu.org>

        Fixes bug libgcj/19864
        * gnu/xml/dom/DomAttr.java,
        gnu/xml/dom/DomCDATA.java,
        gnu/xml/dom/DomCDATASection.java,
        gnu/xml/dom/DomCharacterData.java,
        gnu/xml/dom/DomDOMException.java,
        gnu/xml/dom/DomDoctype.java,
        gnu/xml/dom/DomDocument.java,
        gnu/xml/dom/DomDocumentConfiguration.java,
        gnu/xml/dom/DomDocumentFragment.java,
        gnu/xml/dom/DomElement.java,
        gnu/xml/dom/DomEx.java,
        gnu/xml/dom/DomFragment.java,
        gnu/xml/dom/DomImpl.java,
        gnu/xml/dom/DomIterator.java,
        gnu/xml/dom/DomNamedNodeMap.java,
        gnu/xml/dom/DomNode.java,
        gnu/xml/dom/DomNsNode.java,
        gnu/xml/dom/DomPI.java,
        gnu/xml/dom/DomProcessingInstruction.java,
        gnu/xml/dom/DomText.java,
        gnu/xml/dom/DomLSEx.java,
        gnu/xml/dom/DomLSException.java,
        gnu/xml/dom/DomLSParser.java,
        gnu/xml/dom/DomLSSerializer.java: Refactoring of exception and DOM
        implementation class names to conform to Classpath guidelines.  Make
        DomLSException use JDK 1.4+ exception chaining.
        * gnu/xml/util/SAXNullTransformerFactory.java,
        gnu/xml/xpath/Predicate.java: Use constants relative to
        declaring class or interface.

From-SVN: r95114
parent 3bd09563
2005-02-16 Mark Wielaard <mark@klomp.org>
* Makefile.am (gnu_xml_source_files): Removed
gnu/xml/dom/DomCDATA.java, gnu/xml/dom/DomEx.java,
gnu/xml/dom/DomFragment.java, gnu/xml/dom/DomPI.java and
gnu/xml/dom/ls/DomLSEx.java. Replaced by adding
gnu/xml/dom/DomCDATASection.java, gnu/xml/dom/DomDOMException.java,
gnu/xml/dom/DomDocumentFragment.java,
gnu/xml/dom/DomProcessingInstruction.java and
gnu/xml/dom/ls/DomLSException.java.
* Makefile.in: Regenerated.
2005-02-16 Tom Tromey <tromey@redhat.com>
* gnu/xml/aelfred2/SAXDriver.java: Ensure that null is returned when
attribute index is out of bounds.
2005-02-16 Chris Burdess <dog@gnu.org>
* gnu/xml/aelfred2/SAXDriver.java: Corrected implementation of
isDeclared methods. Improved performance of isSpecified methods.
2005-02-16 Chris Burdess <dog@gnu.org>
Fixes bug libgcj/19864
* gnu/xml/dom/DomAttr.java,
gnu/xml/dom/DomCDATA.java,
gnu/xml/dom/DomCDATASection.java,
gnu/xml/dom/DomCharacterData.java,
gnu/xml/dom/DomDOMException.java,
gnu/xml/dom/DomDoctype.java,
gnu/xml/dom/DomDocument.java,
gnu/xml/dom/DomDocumentConfiguration.java,
gnu/xml/dom/DomDocumentFragment.java,
gnu/xml/dom/DomElement.java,
gnu/xml/dom/DomEx.java,
gnu/xml/dom/DomFragment.java,
gnu/xml/dom/DomImpl.java,
gnu/xml/dom/DomIterator.java,
gnu/xml/dom/DomNamedNodeMap.java,
gnu/xml/dom/DomNode.java,
gnu/xml/dom/DomNsNode.java,
gnu/xml/dom/DomPI.java,
gnu/xml/dom/DomProcessingInstruction.java,
gnu/xml/dom/DomText.java,
gnu/xml/dom/DomLSEx.java,
gnu/xml/dom/DomLSException.java,
gnu/xml/dom/DomLSParser.java,
gnu/xml/dom/DomLSSerializer.java: Refactoring of exception and DOM
implementation class names to conform to Classpath guidelines. Make
DomLSException use JDK 1.4+ exception chaining.
* gnu/xml/util/SAXNullTransformerFactory.java,
gnu/xml/xpath/Predicate.java: Use constants relative to
declaring class or interface.
2005-02-16 Andrew Haley <aph@redhat.com> 2005-02-16 Andrew Haley <aph@redhat.com>
......
...@@ -2498,10 +2498,9 @@ gnu/xml/util/Resolver.java \ ...@@ -2498,10 +2498,9 @@ gnu/xml/util/Resolver.java \
gnu/xml/util/DoParse.java \ gnu/xml/util/DoParse.java \
gnu/xml/util/XHTMLWriter.java \ gnu/xml/util/XHTMLWriter.java \
gnu/xml/util/SAXNullTransformerFactory.java \ gnu/xml/util/SAXNullTransformerFactory.java \
gnu/xml/dom/DomCDATA.java \
gnu/xml/dom/DomXPathNSResolver.java \ gnu/xml/dom/DomXPathNSResolver.java \
gnu/xml/dom/ls/DomLSEx.java \
gnu/xml/dom/ls/FilteredSAXEventSink.java \ gnu/xml/dom/ls/FilteredSAXEventSink.java \
gnu/xml/dom/ls/DomLSException.java \
gnu/xml/dom/ls/DomLSSerializer.java \ gnu/xml/dom/ls/DomLSSerializer.java \
gnu/xml/dom/ls/DomLSInput.java \ gnu/xml/dom/ls/DomLSInput.java \
gnu/xml/dom/ls/DomLSOutput.java \ gnu/xml/dom/ls/DomLSOutput.java \
...@@ -2512,14 +2511,14 @@ gnu/xml/dom/ls/WriterOutputStream.java \ ...@@ -2512,14 +2511,14 @@ gnu/xml/dom/ls/WriterOutputStream.java \
gnu/xml/dom/DomElement.java \ gnu/xml/dom/DomElement.java \
gnu/xml/dom/DomNsNode.java \ gnu/xml/dom/DomNsNode.java \
gnu/xml/dom/DomAttr.java \ gnu/xml/dom/DomAttr.java \
gnu/xml/dom/DomPI.java \
gnu/xml/dom/DTDAttributeTypeInfo.java \ gnu/xml/dom/DTDAttributeTypeInfo.java \
gnu/xml/dom/DomDocumentBuilder.java \ gnu/xml/dom/DomDocumentBuilder.java \
gnu/xml/dom/DTDElementTypeInfo.java \ gnu/xml/dom/DTDElementTypeInfo.java \
gnu/xml/dom/DomEx.java \
gnu/xml/dom/DomDocument.java \ gnu/xml/dom/DomDocument.java \
gnu/xml/dom/DomXPathExpression.java \ gnu/xml/dom/DomXPathExpression.java \
gnu/xml/dom/DomDocumentConfiguration.java \ gnu/xml/dom/DomDocumentConfiguration.java \
gnu/xml/dom/DomDocumentFragment.java \
gnu/xml/dom/DomProcessingInstruction.java \
gnu/xml/dom/Consumer.java \ gnu/xml/dom/Consumer.java \
gnu/xml/dom/DomComment.java \ gnu/xml/dom/DomComment.java \
gnu/xml/dom/DomCharacterData.java \ gnu/xml/dom/DomCharacterData.java \
...@@ -2539,9 +2538,10 @@ gnu/xml/dom/DomNodeIterator.java \ ...@@ -2539,9 +2538,10 @@ gnu/xml/dom/DomNodeIterator.java \
gnu/xml/dom/DomNotation.java \ gnu/xml/dom/DomNotation.java \
gnu/xml/dom/JAXPFactory.java \ gnu/xml/dom/JAXPFactory.java \
gnu/xml/dom/DomIterator.java \ gnu/xml/dom/DomIterator.java \
gnu/xml/dom/DomFragment.java \
gnu/xml/dom/DomEvent.java \ gnu/xml/dom/DomEvent.java \
gnu/xml/dom/DomEntity.java \ gnu/xml/dom/DomEntity.java \
gnu/xml/dom/DomCDATASection.java \
gnu/xml/dom/DomDOMException.java \
gnu/xml/transform/GenerateIdFunction.java \ gnu/xml/transform/GenerateIdFunction.java \
gnu/xml/transform/FormatNumberFunction.java \ gnu/xml/transform/FormatNumberFunction.java \
gnu/xml/transform/ValueOfNode.java \ gnu/xml/transform/ValueOfNode.java \
......
...@@ -150,10 +150,7 @@ final public class SAXDriver ...@@ -150,10 +150,7 @@ final public class SAXDriver
private Stack entityStack; private Stack entityStack;
// one vector (of object/struct): faster, smaller // one vector (of object/struct): faster, smaller
private List attributesList = Collections.synchronizedList(new ArrayList()); private List attributesList;
private boolean attributeSpecified [] = new boolean[10];
private boolean attributeDeclared [] = new boolean[10];
private boolean namespaces = true; private boolean namespaces = true;
private boolean xmlNames = false; private boolean xmlNames = false;
...@@ -183,8 +180,6 @@ final public class SAXDriver ...@@ -183,8 +180,6 @@ final public class SAXDriver
elementName = null; elementName = null;
entityStack = new Stack (); entityStack = new Stack ();
attributesList = Collections.synchronizedList(new ArrayList()); attributesList = Collections.synchronizedList(new ArrayList());
attributeSpecified = new boolean[10];
attributeDeclared = new boolean[10];
attributeCount = 0; attributeCount = 0;
attributes = false; attributes = false;
nsTemp = new String[3]; nsTemp = new String[3];
...@@ -849,17 +844,10 @@ final public class SAXDriver ...@@ -849,17 +844,10 @@ final public class SAXDriver
} }
// remember this attribute ... // remember this attribute ...
if (attributeCount == attributeSpecified.length) { // grow array?
boolean temp [] = new boolean [attributeSpecified.length + 5];
System.arraycopy (attributeSpecified, 0, temp, 0, attributeCount);
attributeSpecified = temp;
}
attributeSpecified [attributeCount] = isSpecified;
attributeCount++; attributeCount++;
// attribute type comes from querying parser's DTD records // attribute type comes from querying parser's DTD records
attributesList.add(new Attribute(qname, value)); attributesList.add(new Attribute(qname, value, isSpecified));
} }
...@@ -1043,7 +1031,7 @@ final public class SAXDriver ...@@ -1043,7 +1031,7 @@ final public class SAXDriver
*/ */
public int getLength () public int getLength ()
{ {
return attributesList.size (); return attributesList.size();
} }
/** /**
...@@ -1051,7 +1039,11 @@ final public class SAXDriver ...@@ -1051,7 +1039,11 @@ final public class SAXDriver
*/ */
public String getURI (int index) public String getURI (int index)
{ {
return ((Attribute) attributesList.get (index)).nameSpace; if (index < 0 || index >= attributesList.size())
{
return null;
}
return ((Attribute) attributesList.get(index)).nameSpace;
} }
/** /**
...@@ -1059,7 +1051,11 @@ final public class SAXDriver ...@@ -1059,7 +1051,11 @@ final public class SAXDriver
*/ */
public String getLocalName (int index) public String getLocalName (int index)
{ {
Attribute attr = (Attribute) attributesList.get (index); if (index < 0 || index >= attributesList.size())
{
return null;
}
Attribute attr = (Attribute) attributesList.get(index);
// FIXME attr.localName is sometimes null, why? // FIXME attr.localName is sometimes null, why?
if (namespaces && attr.localName == null) if (namespaces && attr.localName == null)
{ {
...@@ -1068,38 +1064,51 @@ final public class SAXDriver ...@@ -1068,38 +1064,51 @@ final public class SAXDriver
attr.localName = (ci == -1) ? attr.name : attr.localName = (ci == -1) ? attr.name :
attr.name.substring(ci + 1); attr.name.substring(ci + 1);
} }
return attr.localName; return (attr.localName == null) ? "" : attr.localName;
} }
/** /**
* <b>SAX2 Attributes</b> method (don't invoke on parser); * <b>SAX2 Attributes</b> method (don't invoke on parser);
*/ */
public String getQName (int i) public String getQName (int index)
{ {
return ((Attribute) attributesList.get (i)).name; if (index < 0 || index >= attributesList.size())
{
return null;
}
Attribute attr = (Attribute) attributesList.get(index);
return (attr.name == null) ? "" : attr.name;
} }
/** /**
* <b>SAX1 AttributeList</b> method (don't invoke on parser); * <b>SAX1 AttributeList</b> method (don't invoke on parser);
*/ */
public String getName (int i) public String getName (int index)
{ {
return ((Attribute) attributesList.get (i)).name; return getQName(index);
} }
/** /**
* <b>SAX1 AttributeList, SAX2 Attributes</b> method * <b>SAX1 AttributeList, SAX2 Attributes</b> method
* (don't invoke on parser); * (don't invoke on parser);
*/ */
public String getType (int i) public String getType (int index)
{ {
String type = parser.getAttributeType (elementName, getQName (i)); if (index < 0 || index >= attributesList.size())
{
return null;
}
String type = parser.getAttributeType(elementName, getQName(index));
if (type == null) if (type == null)
{
return "CDATA"; return "CDATA";
}
// ... use DeclHandler.attributeDecl to see enumerations // ... use DeclHandler.attributeDecl to see enumerations
if (type == "ENUMERATION") if (type == "ENUMERATION")
return "NMTOKEN"; {
return type; return "NMTOKEN";
}
return type;
} }
...@@ -1107,9 +1116,13 @@ final public class SAXDriver ...@@ -1107,9 +1116,13 @@ final public class SAXDriver
* <b>SAX1 AttributeList, SAX2 Attributes</b> method * <b>SAX1 AttributeList, SAX2 Attributes</b> method
* (don't invoke on parser); * (don't invoke on parser);
*/ */
public String getValue (int i) public String getValue (int index)
{ {
return ((Attribute) attributesList.get (i)).value; if (index < 0 || index >= attributesList.size())
{
return null;
}
return ((Attribute) attributesList.get(index)).value;
} }
...@@ -1118,14 +1131,19 @@ final public class SAXDriver ...@@ -1118,14 +1131,19 @@ final public class SAXDriver
*/ */
public int getIndex (String uri, String local) public int getIndex (String uri, String local)
{ {
int length = getLength (); int length = getLength();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++)
if (!getURI (i).equals (uri)) {
if (!getURI(i).equals(uri))
{
continue; continue;
if (getLocalName (i).equals (local)) }
if (getLocalName(i).equals(local))
{
return i; return i;
} }
}
return -1; return -1;
} }
...@@ -1135,12 +1153,15 @@ final public class SAXDriver ...@@ -1135,12 +1153,15 @@ final public class SAXDriver
*/ */
public int getIndex (String xmlName) public int getIndex (String xmlName)
{ {
int length = getLength (); int length = getLength();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++)
if (getQName (i).equals (xmlName)) {
if (getQName(i).equals(xmlName))
{
return i; return i;
} }
}
return -1; return -1;
} }
...@@ -1150,11 +1171,13 @@ final public class SAXDriver ...@@ -1150,11 +1171,13 @@ final public class SAXDriver
*/ */
public String getType (String uri, String local) public String getType (String uri, String local)
{ {
int index = getIndex (uri, local); int index = getIndex(uri, local);
if (index < 0) if (index < 0)
{
return null; return null;
return getType (index); }
return getType(index);
} }
...@@ -1164,11 +1187,13 @@ final public class SAXDriver ...@@ -1164,11 +1187,13 @@ final public class SAXDriver
*/ */
public String getType (String xmlName) public String getType (String xmlName)
{ {
int index = getIndex (xmlName); int index = getIndex(xmlName);
if (index < 0) if (index < 0)
{
return null; return null;
return getType (index); }
return getType(index);
} }
...@@ -1177,11 +1202,13 @@ final public class SAXDriver ...@@ -1177,11 +1202,13 @@ final public class SAXDriver
*/ */
public String getValue (String uri, String local) public String getValue (String uri, String local)
{ {
int index = getIndex (uri, local); int index = getIndex(uri, local);
if (index < 0) if (index < 0)
{
return null; return null;
return getValue (index); }
return getValue(index);
} }
...@@ -1191,11 +1218,13 @@ final public class SAXDriver ...@@ -1191,11 +1218,13 @@ final public class SAXDriver
*/ */
public String getValue (String xmlName) public String getValue (String xmlName)
{ {
int index = getIndex (xmlName); int index = getIndex(xmlName);
if (index < 0) if (index < 0)
{
return null; return null;
return getValue (index); }
return getValue(index);
} }
...@@ -1212,31 +1241,31 @@ final public class SAXDriver ...@@ -1212,31 +1241,31 @@ final public class SAXDriver
{ {
if (index < 0 || index >= attributeCount) if (index < 0 || index >= attributeCount)
throw new ArrayIndexOutOfBoundsException (); throw new ArrayIndexOutOfBoundsException ();
return attributeDeclared [index]; String type = parser.getAttributeType(elementName, getQName(index));
return (type != null);
} }
/** @return false unless the attribute was declared in the DTD. /** @return false unless the attribute was declared in the DTD.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* When the supplied names do not identify an attribute. * When the supplied names do not identify an attribute.
*/ */
public boolean isDeclared (java.lang.String qName) public boolean isDeclared (String qName)
{ {
int index = getIndex (qName); int index = getIndex (qName);
if (index < 0) if (index < 0)
throw new IllegalArgumentException (); throw new IllegalArgumentException ();
return attributeDeclared [index]; String type = parser.getAttributeType(elementName, qName);
return (type != null);
} }
/** @return false unless the attribute was declared in the DTD. /** @return false unless the attribute was declared in the DTD.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* When the supplied names do not identify an attribute. * When the supplied names do not identify an attribute.
*/ */
public boolean isDeclared (java.lang.String uri, java.lang.String localName) public boolean isDeclared (String uri, String localName)
{ {
int index = getIndex (uri, localName); int index = getIndex (uri, localName);
if (index < 0) return isDeclared(index);
throw new IllegalArgumentException ();
return attributeDeclared [index];
} }
...@@ -1245,9 +1274,7 @@ final public class SAXDriver ...@@ -1245,9 +1274,7 @@ final public class SAXDriver
*/ */
public boolean isSpecified (int index) public boolean isSpecified (int index)
{ {
if (index < 0 || index >= attributeCount) return ((Attribute) attributesList.get(index)).specified;
throw new ArrayIndexOutOfBoundsException ();
return attributeSpecified [index];
} }
/** /**
...@@ -1256,10 +1283,7 @@ final public class SAXDriver ...@@ -1256,10 +1283,7 @@ final public class SAXDriver
public boolean isSpecified (String uri, String local) public boolean isSpecified (String uri, String local)
{ {
int index = getIndex (uri, local); int index = getIndex (uri, local);
return isSpecified(index);
if (index < 0)
throw new IllegalArgumentException ();
return attributeSpecified [index];
} }
/** /**
...@@ -1268,10 +1292,7 @@ final public class SAXDriver ...@@ -1268,10 +1292,7 @@ final public class SAXDriver
public boolean isSpecified (String xmlName) public boolean isSpecified (String xmlName)
{ {
int index = getIndex (xmlName); int index = getIndex (xmlName);
return isSpecified(index);
if (index < 0)
throw new IllegalArgumentException ();
return attributeSpecified [index];
} }
...@@ -1374,12 +1395,14 @@ class Attribute ...@@ -1374,12 +1395,14 @@ class Attribute
String value; String value;
String nameSpace; String nameSpace;
String localName; String localName;
boolean specified;
Attribute(String name, String value) Attribute(String name, String value, boolean specified)
{ {
this.name = name; this.name = name;
this.value = value; this.value = value;
this.nameSpace = ""; this.nameSpace = "";
this.specified = specified;
} }
} }
...@@ -38,6 +38,7 @@ exception statement from your version. */ ...@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.xml.dom; package gnu.xml.dom;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.TypeInfo; import org.w3c.dom.TypeInfo;
...@@ -194,7 +195,7 @@ public class DomAttr ...@@ -194,7 +195,7 @@ public class DomAttr
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
if (value == null) if (value == null)
{ {
...@@ -284,11 +285,11 @@ public class DomAttr ...@@ -284,11 +285,11 @@ public class DomAttr
{ {
if (parent != null) if (parent != null)
{ {
throw new DomEx (DomEx.HIERARCHY_REQUEST_ERR); throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
} }
if (!(e instanceof DomElement)) if (!(e instanceof DomElement))
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR); throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
} }
parent = (DomElement) e; parent = (DomElement) e;
depth = parent.depth + 1; depth = parent.depth + 1;
......
/* DomCDATA.java -- /* DomCDATASection.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -54,7 +54,7 @@ import org.w3c.dom.CDATASection; ...@@ -54,7 +54,7 @@ import org.w3c.dom.CDATASection;
* @author David Brownell * @author David Brownell
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/ */
public class DomCDATA public class DomCDATASection
extends DomText extends DomText
implements CDATASection implements CDATASection
{ {
...@@ -68,12 +68,12 @@ public class DomCDATA ...@@ -68,12 +68,12 @@ public class DomCDATA
* similarly used in a "Sub-DOM" style layer. * similarly used in a "Sub-DOM" style layer.
* *
*/ */
protected DomCDATA(DomDocument owner, String value) protected DomCDATASection(DomDocument owner, String value)
{ {
super(CDATA_SECTION_NODE, owner, value); super(CDATA_SECTION_NODE, owner, value);
} }
protected DomCDATA(DomDocument owner, char buf [], int off, int len) protected DomCDATASection(DomDocument owner, char buf [], int off, int len)
{ {
super(CDATA_SECTION_NODE, owner, buf, off, len); super(CDATA_SECTION_NODE, owner, buf, off, len);
} }
...@@ -84,7 +84,7 @@ public class DomCDATA ...@@ -84,7 +84,7 @@ public class DomCDATA
*/ */
final public String getNodeName() final public String getNodeName()
{ {
return "#cdata-section"; return "#cdata-section";
} }
} }
......
...@@ -38,6 +38,7 @@ exception statement from your version. */ ...@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.xml.dom; package gnu.xml.dom;
import org.w3c.dom.CharacterData; import org.w3c.dom.CharacterData;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.w3c.dom.events.MutationEvent; import org.w3c.dom.events.MutationEvent;
...@@ -82,7 +83,7 @@ public abstract class DomCharacterData ...@@ -82,7 +83,7 @@ public abstract class DomCharacterData
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
String value = text + arg; String value = text + arg;
mutating(value); mutating(value);
...@@ -98,12 +99,12 @@ public abstract class DomCharacterData ...@@ -98,12 +99,12 @@ public abstract class DomCharacterData
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
char[] raw = text.toCharArray(); char[] raw = text.toCharArray();
if (offset < 0 || count < 0 || offset > raw.length) if (offset < 0 || count < 0 || offset > raw.length)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
if ((offset + count) > raw.length) if ((offset + count) > raw.length)
{ {
...@@ -125,7 +126,7 @@ public abstract class DomCharacterData ...@@ -125,7 +126,7 @@ public abstract class DomCharacterData
} }
catch (IndexOutOfBoundsException x) catch (IndexOutOfBoundsException x)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
} }
...@@ -164,7 +165,7 @@ public abstract class DomCharacterData ...@@ -164,7 +165,7 @@ public abstract class DomCharacterData
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
char[] raw = text.toCharArray(); char[] raw = text.toCharArray();
char[] tmp = arg.toCharArray (); char[] tmp = arg.toCharArray ();
...@@ -182,7 +183,7 @@ public abstract class DomCharacterData ...@@ -182,7 +183,7 @@ public abstract class DomCharacterData
} }
catch (IndexOutOfBoundsException x) catch (IndexOutOfBoundsException x)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
} }
...@@ -195,14 +196,14 @@ public abstract class DomCharacterData ...@@ -195,14 +196,14 @@ public abstract class DomCharacterData
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
char[] raw = text.toCharArray(); char[] raw = text.toCharArray();
// deleteData // deleteData
if (offset < 0 || count < 0 || offset > raw.length) if (offset < 0 || count < 0 || offset > raw.length)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
if ((offset + count) > raw.length) if ((offset + count) > raw.length)
{ {
...@@ -228,7 +229,7 @@ public abstract class DomCharacterData ...@@ -228,7 +229,7 @@ public abstract class DomCharacterData
} }
catch (IndexOutOfBoundsException x) catch (IndexOutOfBoundsException x)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
} }
...@@ -241,7 +242,7 @@ public abstract class DomCharacterData ...@@ -241,7 +242,7 @@ public abstract class DomCharacterData
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx (DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
if (value == null) if (value == null)
{ {
...@@ -276,7 +277,7 @@ public abstract class DomCharacterData ...@@ -276,7 +277,7 @@ public abstract class DomCharacterData
{ {
return text.substring(offset); return text.substring(offset);
} }
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
} }
......
/* DomEx.java -- /* DomDOMException.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -50,7 +50,7 @@ import org.w3c.dom.Node; ...@@ -50,7 +50,7 @@ import org.w3c.dom.Node;
* *
* @author David Brownell * @author David Brownell
*/ */
public class DomEx public class DomDOMException
extends DOMException extends DOMException
{ {
...@@ -67,7 +67,7 @@ public class DomEx ...@@ -67,7 +67,7 @@ public class DomEx
* Constructs an exception, with the diagnostic message * Constructs an exception, with the diagnostic message
* corresponding to the specified code. * corresponding to the specified code.
*/ */
public DomEx(short code) public DomDOMException(short code)
{ {
super(code, diagnostic(code)); super(code, diagnostic(code));
} }
...@@ -77,7 +77,7 @@ public class DomEx ...@@ -77,7 +77,7 @@ public class DomEx
* corresponding to the specified code and additional * corresponding to the specified code and additional
* information as provided. * information as provided.
*/ */
public DomEx(short code, String data, Node node, int value) public DomDOMException(short code, String data, Node node, int value)
{ {
super(code, diagnostic(code)); super(code, diagnostic(code));
this.data = data; this.data = data;
......
...@@ -39,6 +39,7 @@ package gnu.xml.dom; ...@@ -39,6 +39,7 @@ package gnu.xml.dom;
import java.util.HashMap; import java.util.HashMap;
import org.w3c.dom.DocumentType; import org.w3c.dom.DocumentType;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation; import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Entity; import org.w3c.dom.Entity;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
...@@ -194,7 +195,7 @@ public class DomDoctype ...@@ -194,7 +195,7 @@ public class DomDoctype
} }
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
getEntities(); getEntities();
...@@ -250,7 +251,7 @@ public class DomDoctype ...@@ -250,7 +251,7 @@ public class DomDoctype
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
getNotations(); getNotations();
......
...@@ -99,8 +99,8 @@ class DomDocumentConfiguration ...@@ -99,8 +99,8 @@ class DomDocumentConfiguration
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new DomEx(DomEx.TYPE_MISMATCH_ERR, throw new DomDOMException(DOMException.TYPE_MISMATCH_ERR,
value.getClass().getName(), null, 0); value.getClass().getName(), null, 0);
} }
} }
else if ("namespace-declarations".equals(name)) else if ("namespace-declarations".equals(name))
...@@ -140,7 +140,8 @@ class DomDocumentConfiguration ...@@ -140,7 +140,8 @@ class DomDocumentConfiguration
} }
else else
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
name, null, 0);
} }
} }
...@@ -197,7 +198,7 @@ class DomDocumentConfiguration ...@@ -197,7 +198,7 @@ class DomDocumentConfiguration
namespaceDeclarations == true && namespaceDeclarations == true &&
comments == true) ? Boolean.TRUE : Boolean.FALSE; comments == true) ? Boolean.TRUE : Boolean.FALSE;
} }
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0);
} }
public boolean canSetParameter(String name, Object value) public boolean canSetParameter(String name, Object value)
......
/* DomFragment.java -- /* DomDocumentFragment.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -45,7 +45,7 @@ import org.w3c.dom.DocumentFragment; ...@@ -45,7 +45,7 @@ import org.w3c.dom.DocumentFragment;
* @author David Brownell * @author David Brownell
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/ */
public class DomFragment public class DomDocumentFragment
extends DomNode extends DomNode
implements DocumentFragment implements DocumentFragment
{ {
...@@ -58,7 +58,7 @@ public class DomFragment ...@@ -58,7 +58,7 @@ public class DomFragment
* its createDocumentFragment functionality, or through a subclass which * its createDocumentFragment functionality, or through a subclass which
* is similarly used in a "Sub-DOM" style layer. * is similarly used in a "Sub-DOM" style layer.
*/ */
protected DomFragment(DomDocument owner) protected DomDocumentFragment(DomDocument owner)
{ {
super(DOCUMENT_FRAGMENT_NODE, owner); super(DOCUMENT_FRAGMENT_NODE, owner);
} }
......
...@@ -42,6 +42,7 @@ import java.util.Set; ...@@ -42,6 +42,7 @@ import java.util.Set;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -262,7 +263,7 @@ public class DomElement ...@@ -262,7 +263,7 @@ public class DomElement
if (("xmlns".equals (aname) || aname.startsWith ("xmlns:")) if (("xmlns".equals (aname) || aname.startsWith ("xmlns:"))
&& !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (uri)) && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (uri))
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"setting xmlns attribute to illegal value", this, 0); "setting xmlns attribute to illegal value", this, 0);
} }
...@@ -318,9 +319,9 @@ public class DomElement ...@@ -318,9 +319,9 @@ public class DomElement
{ {
attributes.removeNamedItem(name); attributes.removeNamedItem(name);
} }
catch (DomEx e) catch (DomDOMException e)
{ {
if (e.code != DomEx.NOT_FOUND_ERR) if (e.code != DOMException.NOT_FOUND_ERR)
{ {
throw e; throw e;
} }
...@@ -340,7 +341,7 @@ public class DomElement ...@@ -340,7 +341,7 @@ public class DomElement
{ {
if (attributes == null) if (attributes == null)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, null, node, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR, null, node, 0);
} }
return (Attr) attributes.removeNamedItem(node.getNodeName()); return (Attr) attributes.removeNamedItem(node.getNodeName());
} }
...@@ -358,7 +359,7 @@ public class DomElement ...@@ -358,7 +359,7 @@ public class DomElement
{ {
if (attributes == null) if (attributes == null)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, localPart, null, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR, localPart, null, 0);
} }
attributes.removeNamedItemNS (namespace, localPart); attributes.removeNamedItemNS (namespace, localPart);
} }
...@@ -487,11 +488,11 @@ public class DomElement ...@@ -487,11 +488,11 @@ public class DomElement
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
if (attr == null || attr.getOwnerElement() != this) if (attr == null || attr.getOwnerElement() != this)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR); throw new DomDOMException(DOMException.NOT_FOUND_ERR);
} }
if (isId) if (isId)
{ {
......
...@@ -207,7 +207,8 @@ public class DomImpl ...@@ -207,7 +207,8 @@ public class DomImpl
root = doc.createElementNS(namespaceURI, rootName); root = doc.createElementNS(namespaceURI, rootName);
if (rootName.startsWith("xmlns:")) if (rootName.startsWith("xmlns:"))
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns is reserved", null, 0); throw new DomDOMException(DOMException.NAMESPACE_ERR,
"xmlns is reserved", null, 0);
} }
} }
// Bleech -- L2 seemingly _requires_ omission of xmlns attributes. // Bleech -- L2 seemingly _requires_ omission of xmlns attributes.
......
...@@ -39,6 +39,7 @@ package gnu.xml.dom; ...@@ -39,6 +39,7 @@ package gnu.xml.dom;
import java.util.Vector; import java.util.Vector;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.events.Event; import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener; import org.w3c.dom.events.EventListener;
...@@ -76,7 +77,7 @@ public final class DomIterator ...@@ -76,7 +77,7 @@ public final class DomIterator
{ {
if (!root.isSupported("MutationEvents", "2.0")) if (!root.isSupported("MutationEvents", "2.0"))
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
"Iterator needs mutation events", root, 0); "Iterator needs mutation events", root, 0);
} }
...@@ -154,7 +155,7 @@ public final class DomIterator ...@@ -154,7 +155,7 @@ public final class DomIterator
{ {
if (done) if (done)
{ {
throw new DomEx(DomEx.INVALID_STATE_ERR); throw new DomDOMException(DOMException.INVALID_STATE_ERR);
} }
right = true; right = true;
return walk(true); return walk(true);
...@@ -171,7 +172,7 @@ public final class DomIterator ...@@ -171,7 +172,7 @@ public final class DomIterator
{ {
if (done) if (done)
{ {
throw new DomEx(DomEx.INVALID_STATE_ERR); throw new DomDOMException(DOMException.INVALID_STATE_ERR);
} }
Node previous = reference; Node previous = reference;
right = false; right = false;
......
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.xml.dom; package gnu.xml.dom;
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -166,24 +167,24 @@ public class DomNamedNodeMap ...@@ -166,24 +167,24 @@ public class DomNamedNodeMap
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
DomNode node = (DomNode) arg; DomNode node = (DomNode) arg;
if (node.owner != owner.owner) if (node.owner != owner.owner)
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR); throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
} }
if (node.nodeType != type) if (node.nodeType != type)
{ {
throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR); throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
} }
if (node.nodeType == Node.ATTRIBUTE_NODE) if (node.nodeType == Node.ATTRIBUTE_NODE)
{ {
DomNode element = node.parent; DomNode element = node.parent;
if (element != null && element != owner) if (element != null && element != owner)
{ {
throw new DomEx(DomEx.INUSE_ATTRIBUTE_ERR); throw new DomDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
} }
node.parent = owner; node.parent = owner;
node.depth = owner.depth + 1; node.depth = owner.depth + 1;
...@@ -302,7 +303,7 @@ public class DomNamedNodeMap ...@@ -302,7 +303,7 @@ public class DomNamedNodeMap
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
// report attribute REMOVAL event? // report attribute REMOVAL event?
...@@ -369,7 +370,7 @@ public class DomNamedNodeMap ...@@ -369,7 +370,7 @@ public class DomNamedNodeMap
return ctx; return ctx;
} }
} }
throw new DomEx(DomEx.NOT_FOUND_ERR); throw new DomDOMException(DOMException.NOT_FOUND_ERR);
} }
String getDefaultValue(String name) String getDefaultValue(String name)
......
...@@ -308,15 +308,16 @@ public abstract class DomNode ...@@ -308,15 +308,16 @@ public abstract class DomNode
{ {
if (readonly && !owner.building) if (readonly && !owner.building)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR, throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
null, this, 0); null, this, 0);
} }
for (DomNode ctx = this; ctx != null; ctx = ctx.parent) for (DomNode ctx = this; ctx != null; ctx = ctx.parent)
{ {
if (child == ctx) if (child == ctx)
{ {
throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
"can't make ancestor into a child", this, 0); "can't make ancestor into a child",
this, 0);
} }
} }
...@@ -330,8 +331,8 @@ public abstract class DomNode ...@@ -330,8 +331,8 @@ public abstract class DomNode
// new in DOM L2, this case -- patch it up later, in reparent() // new in DOM L2, this case -- patch it up later, in reparent()
if (!(childNodeType == DOCUMENT_TYPE_NODE && childOwner == null)) if (!(childNodeType == DOCUMENT_TYPE_NODE && childOwner == null))
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
null, child, 0); null, child, 0);
} }
} }
...@@ -376,10 +377,12 @@ public abstract class DomNode ...@@ -376,10 +377,12 @@ public abstract class DomNode
} }
if (owner.checkingWellformedness) if (owner.checkingWellformedness)
{ {
throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
"can't append " + nodeTypeToString(childNodeType) + "can't append " +
" to node of type " + nodeTypeToString(nodeType), nodeTypeToString(childNodeType) +
this, 0); " to node of type " +
nodeTypeToString(nodeType),
this, 0);
} }
} }
...@@ -578,8 +581,8 @@ public abstract class DomNode ...@@ -578,8 +581,8 @@ public abstract class DomNode
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
null, newChild, 0); null, newChild, 0);
} }
} }
...@@ -630,12 +633,14 @@ public abstract class DomNode ...@@ -630,12 +633,14 @@ public abstract class DomNode
checkMisc(child); checkMisc(child);
if (ref == null || ref.parent != this) if (ref == null || ref.parent != this)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR,
null, ref, 0);
} }
if (ref == child) if (ref == child)
{ {
throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
"can't insert node before itself", ref, 0); "can't insert node before itself",
ref, 0);
} }
if (child.parent != null) if (child.parent != null)
...@@ -672,8 +677,8 @@ public abstract class DomNode ...@@ -672,8 +677,8 @@ public abstract class DomNode
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
null, newChild, 0); null, newChild, 0);
} }
} }
...@@ -721,7 +726,8 @@ public abstract class DomNode ...@@ -721,7 +726,8 @@ public abstract class DomNode
} }
if (ref == null || ref.parent != this) if (ref == null || ref.parent != this)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR,
null, ref, 0);
} }
if (reportMutations) if (reportMutations)
...@@ -784,7 +790,8 @@ public abstract class DomNode ...@@ -784,7 +790,8 @@ public abstract class DomNode
checkMisc(child); checkMisc(child);
if (ref == null || ref.parent != this) if (ref == null || ref.parent != this)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR,
null, ref, 0);
} }
if (reportMutations) if (reportMutations)
...@@ -837,8 +844,8 @@ public abstract class DomNode ...@@ -837,8 +844,8 @@ public abstract class DomNode
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
null, newChild, 0); null, newChild, 0);
} }
} }
...@@ -860,12 +867,13 @@ public abstract class DomNode ...@@ -860,12 +867,13 @@ public abstract class DomNode
if (ref == null || ref.parent != this) if (ref == null || ref.parent != this)
{ {
throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); throw new DomDOMException(DOMException.NOT_FOUND_ERR,
null, ref, 0);
} }
if (readonly && !owner.building) if (readonly && !owner.building)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR, throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
null, this, 0); null, this, 0);
} }
for (DomNode child = first; child != null; child = child.next) for (DomNode child = first; child != null; child = child.next)
...@@ -909,13 +917,13 @@ public abstract class DomNode ...@@ -909,13 +917,13 @@ public abstract class DomNode
return ref; return ref;
} }
} }
throw new DomEx(DomEx.NOT_FOUND_ERR, throw new DomDOMException(DOMException.NOT_FOUND_ERR,
"that's no child of mine", refChild, 0); "that's no child of mine", refChild, 0);
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
null, refChild, 0); null, refChild, 0);
} }
} }
...@@ -1446,8 +1454,8 @@ public abstract class DomNode ...@@ -1446,8 +1454,8 @@ public abstract class DomNode
// mouse events // mouse events
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
eventType, null, 0); eventType, null, 0);
} }
/** /**
......
...@@ -38,6 +38,7 @@ exception statement from your version. */ ...@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.xml.dom; package gnu.xml.dom;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import org.w3c.dom.DOMException;
/** /**
* <p> Abstract implemention of namespace support. This facilitates * <p> Abstract implemention of namespace support. This facilitates
...@@ -135,7 +136,7 @@ public abstract class DomNsNode ...@@ -135,7 +136,7 @@ public abstract class DomNsNode
{ {
if (readonly) if (readonly)
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
if (prefix == null) if (prefix == null)
...@@ -145,40 +146,42 @@ public abstract class DomNsNode ...@@ -145,40 +146,42 @@ public abstract class DomNsNode
} }
else if (namespace == null) else if (namespace == null)
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"can't set prefix, node has no namespace URI", "can't set prefix, node has no namespace URI",
this, 0); this, 0);
} }
DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion()));
if (prefix.indexOf (':') != -1) if (prefix.indexOf (':') != -1)
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"illegal prefix " + prefix, this, 0); "illegal prefix " + prefix, this, 0);
} }
if (XMLConstants.XML_NS_PREFIX.equals(prefix) if (XMLConstants.XML_NS_PREFIX.equals(prefix)
&& !XMLConstants.XML_NS_URI.equals(namespace)) && !XMLConstants.XML_NS_URI.equals(namespace))
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"xml namespace is always " + "xml namespace is always " +
XMLConstants.XML_NS_URI, this, 0); XMLConstants.XML_NS_URI, this, 0);
} }
if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))
{ {
if (namespace != null || getNodeType() != ATTRIBUTE_NODE) if (namespace != null || getNodeType() != ATTRIBUTE_NODE)
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"xmlns attribute prefix is reserved", this, 0); "xmlns attribute prefix is reserved",
this, 0);
} }
} }
else if (getNodeType () == ATTRIBUTE_NODE else if (getNodeType () == ATTRIBUTE_NODE
&& (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
name.startsWith("xmlns:"))) name.startsWith("xmlns:")))
{ {
throw new DomEx(DomEx.NAMESPACE_ERR, throw new DomDOMException(DOMException.NAMESPACE_ERR,
"namespace declarations can't change names", this, 0); "namespace declarations can't change names",
this, 0);
} }
this.prefix = prefix.intern(); this.prefix = prefix.intern();
......
/* DomPI.java -- /* DomProcessingInstruction.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.xml.dom; package gnu.xml.dom;
import org.w3c.dom.DOMException;
import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.ProcessingInstruction;
/** /**
...@@ -57,7 +58,7 @@ import org.w3c.dom.ProcessingInstruction; ...@@ -57,7 +58,7 @@ import org.w3c.dom.ProcessingInstruction;
* @author David Brownell * @author David Brownell
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/ */
public class DomPI public class DomProcessingInstruction
extends DomNode extends DomNode
implements ProcessingInstruction implements ProcessingInstruction
{ {
...@@ -73,7 +74,8 @@ public class DomPI ...@@ -73,7 +74,8 @@ public class DomPI
* part of its createProcessingInstruction functionality, or through * part of its createProcessingInstruction functionality, or through
* a subclass which is similarly used in a "Sub-DOM" style layer. * a subclass which is similarly used in a "Sub-DOM" style layer.
*/ */
protected DomPI(DomDocument owner, String target, String data) protected DomProcessingInstruction(DomDocument owner,
String target, String data)
{ {
super(PROCESSING_INSTRUCTION_NODE, owner); super(PROCESSING_INSTRUCTION_NODE, owner);
this.target = target; this.target = target;
...@@ -136,7 +138,7 @@ public class DomPI ...@@ -136,7 +138,7 @@ public class DomPI
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
this.data = data; this.data = data;
} }
......
...@@ -102,7 +102,7 @@ public class DomText ...@@ -102,7 +102,7 @@ public class DomText
{ {
if (isReadonly()) if (isReadonly())
{ {
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
} }
try try
{ {
...@@ -134,7 +134,7 @@ public class DomText ...@@ -134,7 +134,7 @@ public class DomText
} }
catch (IndexOutOfBoundsException x) catch (IndexOutOfBoundsException x)
{ {
throw new DomEx(DomEx.INDEX_SIZE_ERR); throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
} }
} }
......
/* DomLSEx.java -- /* DomLSException.java --
Copyright (C) 2004 Free Software Foundation, Inc. Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -37,8 +37,6 @@ exception statement from your version. */ ...@@ -37,8 +37,6 @@ exception statement from your version. */
package gnu.xml.dom.ls; package gnu.xml.dom.ls;
import java.io.PrintStream;
import java.io.PrintWriter;
import org.w3c.dom.ls.LSException; import org.w3c.dom.ls.LSException;
/** /**
...@@ -46,30 +44,14 @@ import org.w3c.dom.ls.LSException; ...@@ -46,30 +44,14 @@ import org.w3c.dom.ls.LSException;
* *
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/ */
public class DomLSEx public class DomLSException
extends LSException extends LSException
{ {
private final Exception cause2; public DomLSException(short type, Exception cause)
public DomLSEx(short type, Exception cause)
{ {
super(type, cause.getMessage()); super(type, (cause == null) ? null : cause.getMessage());
cause2 = cause; initCause(cause);
} }
public void printStackTrace(PrintStream out)
{
super.printStackTrace(out);
out.print("caused by ");
cause2.printStackTrace(out);
}
public void printStackTrace(PrintWriter out)
{
super.printStackTrace(out);
out.print("caused by ");
cause2.printStackTrace(out);
}
} }
...@@ -65,7 +65,7 @@ import org.xml.sax.SAXNotRecognizedException; ...@@ -65,7 +65,7 @@ import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import gnu.xml.dom.DomDocument; import gnu.xml.dom.DomDocument;
import gnu.xml.dom.DomEx; import gnu.xml.dom.DomDOMException;
/** /**
* Parser implementation for GNU DOM. * Parser implementation for GNU DOM.
...@@ -117,7 +117,7 @@ public class DomLSParser ...@@ -117,7 +117,7 @@ public class DomLSParser
async = false; async = false;
break; break;
default: default:
throw new DomEx(DOMException.NOT_SUPPORTED_ERR); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
// TODO schemaType // TODO schemaType
this.schemaType = schemaType; this.schemaType = schemaType;
...@@ -307,13 +307,13 @@ public class DomLSParser ...@@ -307,13 +307,13 @@ public class DomLSParser
{ {
reader = null; reader = null;
eventSink = null; eventSink = null;
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
catch (IOException e) catch (IOException e)
{ {
reader = null; reader = null;
eventSink = null; eventSink = null;
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
// return document // return document
Document ret = eventSink.doc; Document ret = eventSink.doc;
...@@ -341,11 +341,11 @@ public class DomLSParser ...@@ -341,11 +341,11 @@ public class DomLSParser
} }
catch (ParserConfigurationException e) catch (ParserConfigurationException e)
{ {
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
catch (SAXException e) catch (SAXException e)
{ {
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
} }
return reader; return reader;
...@@ -371,11 +371,11 @@ public class DomLSParser ...@@ -371,11 +371,11 @@ public class DomLSParser
} }
catch (SAXException e) catch (SAXException e)
{ {
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
catch (IOException e) catch (IOException e)
{ {
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
} }
if (source == null) if (source == null)
...@@ -403,7 +403,7 @@ public class DomLSParser ...@@ -403,7 +403,7 @@ public class DomLSParser
} }
catch (IOException e) catch (IOException e)
{ {
throw new DomLSEx(LSException.PARSE_ERR, e); throw new DomLSException(LSException.PARSE_ERR, e);
} }
} }
return source; return source;
...@@ -457,7 +457,7 @@ public class DomLSParser ...@@ -457,7 +457,7 @@ public class DomLSParser
} }
else else
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
// invalidate reader, a new one will be created // invalidate reader, a new one will be created
reader = null; reader = null;
...@@ -509,7 +509,7 @@ public class DomLSParser ...@@ -509,7 +509,7 @@ public class DomLSParser
} }
else else
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
} }
......
...@@ -58,7 +58,7 @@ import org.w3c.dom.ls.LSOutput; ...@@ -58,7 +58,7 @@ import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer; import org.w3c.dom.ls.LSSerializer;
import org.w3c.dom.ls.LSSerializerFilter; import org.w3c.dom.ls.LSSerializerFilter;
import org.w3c.dom.traversal.NodeFilter; import org.w3c.dom.traversal.NodeFilter;
import gnu.xml.dom.DomEx; import gnu.xml.dom.DomDOMException;
import gnu.xml.transform.StreamSerializer; import gnu.xml.transform.StreamSerializer;
/** /**
...@@ -147,7 +147,7 @@ public class DomLSSerializer ...@@ -147,7 +147,7 @@ public class DomLSSerializer
} }
catch (IOException e) catch (IOException e)
{ {
throw new DomLSEx(LSException.SERIALIZE_ERR, e); throw new DomLSException(LSException.SERIALIZE_ERR, e);
} }
} }
...@@ -302,7 +302,7 @@ public class DomLSSerializer ...@@ -302,7 +302,7 @@ public class DomLSSerializer
} }
else else
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
} }
...@@ -319,7 +319,7 @@ public class DomLSSerializer ...@@ -319,7 +319,7 @@ public class DomLSSerializer
} }
else else
{ {
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
} }
......
...@@ -635,7 +635,8 @@ public class SAXNullTransformerFactory extends SAXTransformerFactory ...@@ -635,7 +635,8 @@ public class SAXNullTransformerFactory extends SAXTransformerFactory
// preserve original namespace prefixes // preserve original namespace prefixes
try try
{ {
producer.setFeature(handler.FEATURE_URI + "namespace-prefixes", producer.setFeature(EventFilter.FEATURE_URI +
"namespace-prefixes",
true); true);
} }
catch (Exception e) catch (Exception e)
...@@ -646,7 +647,7 @@ public class SAXNullTransformerFactory extends SAXTransformerFactory ...@@ -646,7 +647,7 @@ public class SAXNullTransformerFactory extends SAXTransformerFactory
// arrange the output // arrange the output
handler.setResult (out); handler.setResult (out);
handler.bind (producer, handler); EventFilter.bind (producer, handler);
// then parse ... single element pipeline // then parse ... single element pipeline
producer.parse (input); producer.parse (input);
......
...@@ -63,7 +63,7 @@ class Predicate ...@@ -63,7 +63,7 @@ class Predicate
// Same as [position() = x] // Same as [position() = x]
return ((Double) ret).intValue() == pos; return ((Double) ret).intValue() == pos;
} }
return expr._boolean(node, expr.evaluate(node, pos, len)); return Expr._boolean(node, expr.evaluate(node, pos, len));
} }
public Test clone(Object context) public Test clone(Object context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment