mrglavas 2003/11/02 07:07:58
Modified: java/src/org/apache/xerces/dom RangeImpl.java
Log:
Fixing Bug #22329. Patch submitted by Neil Delima.
This implements DOM L2 Ranges Errata - range-1.
Also fixed up some typos in the Apache license.
Revision Changes Path
1.28 +57 -10 xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java
Index: RangeImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- RangeImpl.java 2 Nov 2003 13:13:27 -0000 1.27
+++ RangeImpl.java 2 Nov 2003 15:07:58 -0000 1.28
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,9 @@
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
- *4dorse or promote products derived from this
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
@@ -201,6 +203,12 @@
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
+
checkIndex(refNode, offset);
@@ -221,12 +229,18 @@
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
checkIndex(refNode, offset);
fEndContainer = refNode;
fEndOffset = offset;
}
+
public void setStartBefore(Node refNode)
throws RangeException
{
@@ -235,13 +249,18 @@
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR", null));
}
- if ( !hasLegalRootContainer(refNode) ||
- !isLegalContainedNode(refNode) )
- {
+ if ( !hasLegalRootContainer(refNode) ||
+ !isLegalContainedNode(refNode) )
+ {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
fStartContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
@@ -249,6 +268,7 @@
}
fStartOffset = i-1;
}
+
public void setStartAfter(Node refNode)
throws RangeException
{
@@ -258,11 +278,16 @@
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR", null));
}
if ( !hasLegalRootContainer(refNode) ||
- !isLegalContainedNode(refNode)) {
+ !isLegalContainedNode(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
fStartContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
@@ -270,6 +295,7 @@
}
fStartOffset = i;
}
+
public void setEndBefore(Node refNode)
throws RangeException
{
@@ -279,11 +305,16 @@
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR", null));
}
if ( !hasLegalRootContainer(refNode) ||
- !isLegalContainedNode(refNode)) {
+ !isLegalContainedNode(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
fEndContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
@@ -301,11 +332,16 @@
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR", null));
}
if ( !hasLegalRootContainer(refNode) ||
- !isLegalContainedNode(refNode)) {
+ !isLegalContainedNode(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
fEndContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
@@ -313,6 +349,7 @@
}
fEndOffset = i;
}
+
public void collapse(boolean toStart) {
if( fDetach) {
@@ -339,11 +376,16 @@
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_STATE_ERR", null));
}
if ( !isLegalContainer( refNode.getParentNode() ) ||
- !isLegalContainedNode( refNode ) ) {
+ !isLegalContainedNode( refNode ) ) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
}
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
+ }
Node parent = refNode.getParentNode();
if (parent != null ) // REVIST: what to do if it IS null?
{
@@ -370,6 +412,11 @@
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_NODE_TYPE_ERR", null));
+ }
+ if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
+ throw new DOMException(
+ DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
}
fStartContainer = refNode;
fEndContainer = refNode;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]