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 2012/05/28 21:50:01 UTC
svn commit: r1343378 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/
axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
Author: veithen
Date: Mon May 28 19:50:00 2012
New Revision: 1343378
URL: http://svn.apache.org/viewvc?rev=1343378&view=rev
Log:
Fixed a method conflict. NodeList and CharacterData both declare getLength(), but the result is not the same. Therefore, the class implementing CharacterData cannot implement NodeList.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1343378&r1=1343377&r2=1343378&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java Mon May 28 19:50:00 2012
@@ -95,6 +95,7 @@ public class DOMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.dom.element.attributes.TestSetNamedItemWrongDocument(dbf));
addTest(new org.apache.axiom.ts.dom.text.TestAppendData(dbf));
addTest(new org.apache.axiom.ts.dom.text.TestGetChildNodes(dbf));
+ addTest(new org.apache.axiom.ts.dom.text.TestGetLength(dbf));
addTest(new org.apache.axiom.ts.dom.text.TestGetWholeText(dbf));
addTest(new org.apache.axiom.ts.dom.text.TestGetWholeTextWithCDATASection(dbf));
addTest(new org.apache.axiom.ts.dom.text.TestGetWholeTextWithComment(dbf));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java?rev=1343378&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java Mon May 28 19:50:00 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.dom.text;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Text;
+
+/**
+ * Tests that {@link CharacterData#getLength()} returns the expected result.
+ */
+public class TestGetLength extends DOMTestCase {
+ public TestGetLength(DocumentBuilderFactory dbf) {
+ super(dbf);
+ }
+
+ protected void runTest() throws Throwable {
+ Document document = dbf.newDocumentBuilder().newDocument();
+ String content = "This is a test string";
+ Text textNode = document.createTextNode(content);
+ assertEquals(content.length(), textNode.getLength());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestGetLength.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java?rev=1343378&r1=1343377&r2=1343378&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java Mon May 28 19:50:00 2012
@@ -126,4 +126,12 @@ public abstract class CharacterImpl exte
int end = Math.min(count + offset, textValue.length());
return this.textValue.substring(offset, end);
}
+
+ /**
+ * Returns the length of the string value.
+ */
+ public int getLength() {
+ return (this.textValue != null) ? this.textValue.length() : 0;
+ }
+
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java?rev=1343378&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java Mon May 28 19:50:00 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.dom;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+class EmptyNodeList implements NodeList {
+ static final EmptyNodeList INSTANCE = new EmptyNodeList();
+
+ private EmptyNodeList() {}
+
+ public int getLength() {
+ return 0;
+ }
+
+ public Node item(int index) {
+ return null;
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EmptyNodeList.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java?rev=1343378&r1=1343377&r2=1343378&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java Mon May 28 19:50:00 2012
@@ -23,7 +23,7 @@ import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-public abstract class LeafNode extends ChildNode implements NodeList {
+public abstract class LeafNode extends ChildNode {
private ParentNode ownerNode;
private ChildNode previousSibling;
@@ -63,15 +63,7 @@ public abstract class LeafNode extends C
}
public final NodeList getChildNodes() {
- return this;
- }
-
- public final int getLength() {
- return 0;
- }
-
- public final Node item(int index) {
- return null;
+ return EmptyNodeList.INSTANCE;
}
public final Node appendChild(Node newChild) throws DOMException {