summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
authorscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-03-31 15:25:19 +0000
committerscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-03-31 15:25:19 +0000
commit5fe7e15f37d722a5563ca625a45dc101cf65045c (patch)
tree8323095d7bac20e7960328ce728b1be2edaac141 /sca-java-2.x/trunk/modules
parent28ce69a39ba3dac238d53fdb8ec6d6fc0eb27794 (diff)
Revert 1086760 change pending solution to TUSCANY-3857 to keep itest functioning. Ignore new test in databinding-axiom for now as well.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1087339 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java31
-rw-r--r--sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java2
2 files changed, 17 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
index fcaa596f6f..9084f09dc0 100644
--- a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
+++ b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
@@ -108,7 +108,7 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
List<Object> elements = new ArrayList<Object>();
int i = 0;
for (ElementInfo e : childElements) {
- elements.add(getChild(wrapper, e));
+ elements.add(getChild(wrapper, e, i));
i++;
}
return elements;
@@ -152,10 +152,6 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
private static final QName XSI_TYPE_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi");
- /*
- * Left this method in the code to show the idea of grouping like wrapper children without
- * knowing the QName from the ElementInfo, but this code isn't currently used any more.
- */
private List<List<OMElement>> getElements(OMElement wrapper) {
List<List<OMElement>> elements = new ArrayList<List<OMElement>>();
List<OMElement> current = new ArrayList<OMElement>();
@@ -179,18 +175,21 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
return elements;
}
- public Object getChild(OMElement wrapper, ElementInfo childElement) {
+ public Object getChild(OMElement wrapper, ElementInfo childElement, int index) {
Iterator children = wrapper.getChildrenWithName(childElement.getQName());
if (!children.hasNext()) {
- // We used to at this point call getElements(wrapper) to group children
- // into like elements and then try to index into this list by integer index.
- // The problem with this approach is that it ignores the possibility that
- // we have a wrapper child with schema specifying minOccurs="0", in which case
- // there are no wrapper children with this QName and so the index would be wrong.
- //
- // It doesn't look like anyone is depending on this function currently, so just remove
- // it and return "null".
- return null;
+ // No name match, try by index
+ List<List<OMElement>> list = getElements(wrapper);
+ List<OMElement> elements = list.get(index);
+ if (!childElement.isMany()) {
+ return elements.isEmpty() ? null : attachXSIType(childElement, elements.get(0));
+ } else {
+ Object[] array = elements.toArray();
+ for (Object item : array) {
+ attachXSIType(childElement, (OMElement)item);
+ }
+ return array;
+ }
}
if (!childElement.isMany()) {
if (children.hasNext()) {
@@ -212,7 +211,7 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
}
/**
- * Create xsi:type if required
+ * Create xis:type if required
* @param childElement
* @param element
* @return
diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java b/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java
index 1d2a22d057..874013e886 100644
--- a/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java
+++ b/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java
@@ -33,6 +33,7 @@ import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
@@ -79,6 +80,7 @@ public class OMElementWrapperHandlerTestCase {
// Would be nice to do a "set" test too.
@Test
+ @Ignore("TUSCANY-3857")
public void testGetChildren() {
try {
OMElement wrapperElem = AXIOMUtil.stringToOM(WRAPPER_XML);