Author: veithen
Date: Sat Apr 7 07:50:45 2012
New Revision: 1310689
URL: http://svn.apache.org/viewvc?rev=1310689&view=rev
Log:
Moved the owner document checks to a single method.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java?rev=1310689&r1=1310688&r2=1310689&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
Sat Apr 7 07:50:45 2012
@@ -117,12 +117,7 @@ public class AttributeMap implements Nam
/** Almost a copy of the Xerces impl. */
public Node setNamedItem(Node attribute) throws DOMException {
- if (attribute.getOwnerDocument() != ownerNode.getOwnerDocument()) {
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- DOMException.WRONG_DOCUMENT_ERR, null);
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
- }
+ ownerNode.checkSameOwnerDocument(attribute);
if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
@@ -176,11 +171,7 @@ public class AttributeMap implements Nam
/** Almost a copy of the Xerces impl. */
public Node setNamedItemNS(Node attribute) throws DOMException {
- if (attribute.getOwnerDocument() != ownerNode.getOwnerDocument()) {
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
DOMException.WRONG_DOCUMENT_ERR, null);
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
- }
+ ownerNode.checkSameOwnerDocument(attribute);
if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
DOMException.HIERARCHY_REQUEST_ERR,
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1310689&r1=1310688&r2=1310689&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
Sat Apr 7 07:50:45 2012
@@ -34,6 +34,7 @@ import org.apache.axiom.om.impl.MTOMXMLS
import org.apache.axiom.om.impl.OMNodeEx;
import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.om.util.StAXUtils;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -75,6 +76,17 @@ public abstract class ChildNode extends
}
}
+ void checkSameOwnerDocument(Node otherNode) {
+ if (ownerDocument() != (otherNode instanceof AttrImpl
+ ? ((AttrImpl)otherNode).getOwnerDocument()
+ : ((ChildNode)otherNode).ownerDocument())) {
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ DOMException.WRONG_DOCUMENT_ERR,
null));
+ }
+ }
+
/**
* Sets the owner document.
*
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1310689&r1=1310688&r2=1310689&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Sat Apr 7 07:50:45 2012
@@ -432,12 +432,7 @@ public class ElementImpl extends ParentN
public Attr setAttributeNode(Attr attr) throws DOMException {
AttrImpl attrImpl = (AttrImpl) attr;
- if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
DOMException.WRONG_DOCUMENT_ERR,
- null);
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
- }
+ checkSameOwnerDocument(attr);
// check whether the attr is in use
if (attrImpl.isUsed()) {
@@ -509,12 +504,7 @@ public class ElementImpl extends ParentN
} else {
AttrImpl attrImpl = (AttrImpl) attr;
- if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- DOMException.WRONG_DOCUMENT_ERR, null);
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
- }
+ checkSameOwnerDocument(attr);
// check whether the attr is in use
if (attrImpl.isUsed()) {
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1310689&r1=1310688&r2=1310689&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Sat Apr 7 07:50:45 2012
@@ -209,11 +209,8 @@ public abstract class ParentNode extends
ChildNode newDomChild = (ChildNode) newChild;
ChildNode refDomChild = (ChildNode) refChild;
- if (useDomSemantics && ownerDocument() != newDomChild.ownerDocument())
{
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- DOMException.WRONG_DOCUMENT_ERR,
null));
+ if (useDomSemantics) {
+ checkSameOwnerDocument(newDomChild);
}
if (isAncestorOrSelf(newChild)) {
@@ -383,12 +380,7 @@ public abstract class ParentNode extends
DOMException.HIERARCHY_REQUEST_ERR,
null));
}
- if (ownerDocument() != newDomChild.ownerDocument()) {
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- DOMException.WRONG_DOCUMENT_ERR,
null));
- }
+ checkSameOwnerDocument(newDomChild);
Iterator children = this.getChildren();
boolean found = false;