You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/04/21 00:31:19 UTC
svn commit: r1740208 - in /webservices/axiom/trunk:
aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/
implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/
Author: veithen
Date: Wed Apr 20 22:31:19 2016
New Revision: 1740208
URL: http://svn.apache.org/viewvc?rev=1740208&view=rev
Log:
Move the splitText implementation to dom-aspects.
Modified:
webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java
Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj?rev=1740208&r1=1740207&r2=1740208&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj Wed Apr 20 22:31:19 2016
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.dom.impl.mixin;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.core.CoreModelException;
import org.apache.axiom.dom.DOMExceptionUtil;
@@ -107,6 +109,27 @@ public aspect DOMTextNodeSupport {
}
return newText;
} catch (CoreModelException ex) {
+ throw DOMExceptionUtil.toUncheckedException(ex);
+ }
+ }
+
+ public final Text DOMTextNode.splitText(int offset) throws DOMException {
+ try {
+ String value = getData();
+ if (offset < 0 || offset > value.length()) {
+ throw newDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ String newValue = value.substring(offset);
+ deleteData(offset, value.length());
+ DOMText newText = coreCreateNode(DOMText.class);
+ newText.coreSetCharacterData(newValue);
+ if (coreHasParent()) {
+ coreInsertSiblingAfter(newText);
+ } else {
+ newText.coreSetOwnerDocument(coreGetOwnerDocument(true));
+ }
+ return newText;
+ } catch (CoreModelException ex) {
throw DOMExceptionUtil.toUncheckedException(ex);
}
}
Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=1740208&r1=1740207&r2=1740208&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java Wed Apr 20 22:31:19 2016
@@ -19,47 +19,10 @@
package org.apache.axiom.om.impl.dom;
-import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
-
-import org.apache.axiom.core.CoreModelException;
-import org.apache.axiom.dom.DOMExceptionUtil;
import org.apache.axiom.dom.DOMTextNode;
import org.apache.axiom.om.impl.intf.AxiomText;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Text;
public abstract class TextNodeImpl extends LeafNode implements DOMTextNode, AxiomText {
- /**
- * Breaks this node into two nodes at the specified offset, keeping both in the tree as
- * siblings. After being split, this node will contain all the content up to the offset point. A
- * new node of the same type, which contains all the content at and after the offset point, is
- * returned. If the original node had a parent node, the new node is inserted as the next
- * sibling of the original node. When the offset is equal to the length of this node, the new
- * node has no data.
- */
- public Text splitText(int offset) throws DOMException {
- try {
- String value = getData();
- if (offset < 0 || offset > value.length()) {
- throw newDOMException(DOMException.INDEX_SIZE_ERR);
- }
- String newValue = value.substring(offset);
- this.deleteData(offset, value.length());
-
- TextImpl newText = (TextImpl) this.getOwnerDocument().createTextNode(
- newValue);
-
- ParentNode parentNode = (ParentNode)coreGetParent();
- if (parentNode != null) {
- coreInsertSiblingAfter(newText);
- }
-
- return newText;
- } catch (CoreModelException ex) {
- throw DOMExceptionUtil.toUncheckedException(ex);
- }
- }
-
/*
* DOM-Level 3 methods
*/
Modified: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java?rev=1740208&r1=1740207&r2=1740208&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java (original)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java Wed Apr 20 22:31:19 2016
@@ -41,5 +41,6 @@ public class TestSplitTextWithoutParent
Text newText = text.splitText(2);
assertThat(text.getData()).isEqualTo("AB");
assertThat(newText.getData()).isEqualTo("CD");
+ assertThat(newText.getOwnerDocument()).isSameAs(document);
}
}