ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1625646 - in /webservices/xmlschema/trunk: xmlschema-core/src/main/java/org/apache/ws/commons/schema/ xmlschema-core/src/test/java/tests/ xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/
Date Wed, 17 Sep 2014 16:42:43 GMT
Author: dkulp
Date: Wed Sep 17 16:42:42 2014
New Revision: 1625646

URL: http://svn.apache.org/r1625646
Log:
[XMLSCHEMA-37, XMLSCHEMA-11] Update the object model a bit to allow all to have a proper list
of child types.  Also update choice appropriately.   Slightly incompatible API change.

Modified:
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAll.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAny.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoice.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoiceMember.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
    webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ChoiceTest.java
    webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/GroupTest.java
    webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaWalker.java

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAll.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAll.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAll.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAll.java
Wed Sep 17 16:42:42 2014
@@ -28,16 +28,16 @@ import java.util.List;
  */
 public class XmlSchemaAll extends XmlSchemaGroupParticle {
     
-    private List<XmlSchemaElement> items;
+    private List<XmlSchemaAllMember> items;
 
     /**
      * Creates new XmlSchemaAll
      */
     public XmlSchemaAll() {
-        items = new ArrayList<XmlSchemaElement>();
+        items = new ArrayList<XmlSchemaAllMember>();
     }
 
-    public List<XmlSchemaElement> getItems() {
+    public List<XmlSchemaAllMember> getItems() {
         return items;
     }
 

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAny.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAny.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAny.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaAny.java
Wed Sep 17 16:42:42 2014
@@ -25,7 +25,7 @@ package org.apache.ws.commons.schema;
  */
 
 public class XmlSchemaAny extends XmlSchemaParticle 
-    implements XmlSchemaChoiceMember, XmlSchemaSequenceMember {
+    implements XmlSchemaChoiceMember, XmlSchemaSequenceMember, XmlSchemaAllMember {
 
     /**
      * Namespaces containing the elements that can be used.

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoice.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoice.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoice.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoice.java
Wed Sep 17 16:42:42 2014
@@ -30,16 +30,16 @@ import java.util.List;
  */
 public class XmlSchemaChoice extends XmlSchemaGroupParticle implements XmlSchemaChoiceMember,
     XmlSchemaSequenceMember {
-    private List<XmlSchemaObject> items;
+    private List<XmlSchemaChoiceMember> items;
 
     /**
      * Creates new XmlSchemaChoice
      */
     public XmlSchemaChoice() {
-        items = new ArrayList<XmlSchemaObject>();
+        items = new ArrayList<XmlSchemaChoiceMember>();
     }
 
-    public List<XmlSchemaObject> getItems() {
+    public List<XmlSchemaChoiceMember> getItems() {
         return items;
     }
 

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoiceMember.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoiceMember.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoiceMember.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaChoiceMember.java
Wed Sep 17 16:42:42 2014
@@ -19,9 +19,11 @@
 
 package org.apache.ws.commons.schema;
 
+import org.apache.ws.commons.schema.utils.XmlSchemaObjectBase;
+
 /**
  * This interface exists to allow all of the items that can occur in a choice element
  * to have a type in common. It has no protocol.
  */
-public interface XmlSchemaChoiceMember {
+public interface XmlSchemaChoiceMember extends XmlSchemaObjectBase {
 }

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
Wed Sep 17 16:42:42 2014
@@ -41,7 +41,7 @@ import org.apache.ws.commons.schema.util
  */
 
 public class XmlSchemaElement extends XmlSchemaParticle implements TypeReceiver, XmlSchemaNamedWithForm,
-    XmlSchemaChoiceMember, XmlSchemaSequenceMember,
+    XmlSchemaChoiceMember, XmlSchemaSequenceMember, XmlSchemaAllMember,
     XmlSchemaItemWithRef<XmlSchemaElement> {
 
     /**

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
Wed Sep 17 16:42:42 2014
@@ -36,7 +36,7 @@ import java.util.Arrays;
  */
 
 public class XmlSchemaGroup extends XmlSchemaAnnotated implements XmlSchemaNamed,
-    XmlSchemaChoiceMember, XmlSchemaSequenceMember {
+    XmlSchemaChoiceMember, XmlSchemaSequenceMember, XmlSchemaAllMember {
 
     private XmlSchemaGroupParticle particle;
     private XmlSchemaNamedImpl namedDelegate;

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
Wed Sep 17 16:42:42 2014
@@ -25,7 +25,8 @@ import javax.xml.namespace.QName;
  * Class used within complex types that defines the reference to groups defined at the schema
level.
  * Represents the World Wide Web Consortium (W3C) group element with ref attribute.
  */
-public class XmlSchemaGroupRef extends XmlSchemaParticle implements XmlSchemaSequenceMember
{
+public class XmlSchemaGroupRef extends XmlSchemaParticle 
+    implements XmlSchemaSequenceMember, XmlSchemaChoiceMember, XmlSchemaAllMember {
 
     private XmlSchemaGroupParticle particle;
 

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
Wed Sep 17 16:42:42 2014
@@ -160,16 +160,22 @@ public class XmlSchemaSerializer {
             allEl.appendChild(annotation);
         }
 
-        List<XmlSchemaElement> itemColl = allObj.getItems();
+        List<XmlSchemaAllMember> itemColl = allObj.getItems();
 
         if (itemColl != null) {
             int itemLength = itemColl.size();
 
             for (int i = 0; i < itemLength; i++) {
-                XmlSchemaObject obj = itemColl.get(i);
+                XmlSchemaAllMember obj = itemColl.get(i);
                 if (obj instanceof XmlSchemaElement) {
                     Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);
                     allEl.appendChild(el);
+                } else if (obj instanceof XmlSchemaGroupRef) {
+                    Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
+                    allEl.appendChild(group);
+                } else if (obj instanceof XmlSchemaAny) {
+                    Element any = serializeAny(doc, (XmlSchemaAny)obj, schema);
+                    allEl.appendChild(any);
                 } else {
                     throw new XmlSchemaSerializerException("Only element "
                                                            + "allowed as child of all model
type");
@@ -612,13 +618,13 @@ public class XmlSchemaSerializer {
             choice.appendChild(annotation);
         }
 
-        List<XmlSchemaObject> itemColl = choiceObj.getItems();
+        List<XmlSchemaChoiceMember> itemColl = choiceObj.getItems();
 
         if (itemColl != null) {
             int itemLength = itemColl.size();
 
             for (int i = 0; i < itemLength; i++) {
-                XmlSchemaObject obj = itemColl.get(i);
+                XmlSchemaChoiceMember obj = itemColl.get(i);
 
                 if (obj instanceof XmlSchemaElement) {
                     Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);

Modified: webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ChoiceTest.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ChoiceTest.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ChoiceTest.java (original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ChoiceTest.java Wed Sep
17 16:42:42 2014
@@ -30,10 +30,10 @@ import javax.xml.namespace.QName;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaChoiceMember;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObject;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -78,8 +78,8 @@ public class ChoiceTest extends Assert {
         Set<String> s = new HashSet<String>();
         s.add("desktop");
         s.add("laptop");
-        List<XmlSchemaObject> items = choice.getItems();
-        Iterator<XmlSchemaObject> iterator = items.iterator();
+        List<XmlSchemaChoiceMember> items = choice.getItems();
+        Iterator<XmlSchemaChoiceMember> iterator = items.iterator();
         while (iterator.hasNext()) {
             XmlSchemaElement e = (XmlSchemaElement)iterator.next();
             String eName = e.getName();

Modified: webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/GroupTest.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/GroupTest.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/GroupTest.java (original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/GroupTest.java Wed Sep
17 16:42:42 2014
@@ -32,12 +32,12 @@ import javax.xml.transform.stream.Stream
 
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaChoiceMember;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaGroup;
 import org.apache.ws.commons.schema.XmlSchemaGroupRef;
-import org.apache.ws.commons.schema.XmlSchemaObject;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -113,8 +113,8 @@ public class GroupTest extends Assert {
         s.add("salePrice");
         s.add("clearancePrice");
         s.add("freePrice");
-        List<XmlSchemaObject> items = xsc.getItems();
-        Iterator<XmlSchemaObject> iterator = items.iterator();
+        List<XmlSchemaChoiceMember> items = xsc.getItems();
+        Iterator<XmlSchemaChoiceMember> iterator = items.iterator();
         while (iterator.hasNext()) {
             XmlSchemaElement e = (XmlSchemaElement)iterator.next();
             String eName = e.getName();

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaWalker.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaWalker.java?rev=1625646&r1=1625645&r2=1625646&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaWalker.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaWalker.java
Wed Sep 17 16:42:42 2014
@@ -30,14 +30,15 @@ import javax.xml.namespace.QName;
 
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAll;
+import org.apache.ws.commons.schema.XmlSchemaAllMember;
 import org.apache.ws.commons.schema.XmlSchemaAny;
 import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaChoiceMember;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaGroup;
 import org.apache.ws.commons.schema.XmlSchemaGroupParticle;
 import org.apache.ws.commons.schema.XmlSchemaGroupRef;
-import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaParticle;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
@@ -437,11 +438,20 @@ public final class XmlSchemaWalker {
         // 4. Walk the children.
         if (all != null) {
             children = new ArrayList<XmlSchemaParticle>(all.getItems().size());
-            children.addAll(all.getItems());
-
+            for (XmlSchemaAllMember item : all.getItems()) {
+                if (item instanceof XmlSchemaGroup) {
+                    children.add(((XmlSchemaGroup)item).getParticle());
+                } else if (item instanceof XmlSchemaParticle) {
+                    children.add((XmlSchemaParticle)item);
+                } else {
+                    throw new IllegalArgumentException(
+                                                       "All child is not an XmlSchemaGroup
or XmlSchemaParticle; "
+                                                           + "it is a " + item.getClass().getName());
+                }
+            }
         } else if (choice != null) {
             children = new ArrayList<XmlSchemaParticle>(choice.getItems().size());
-            for (XmlSchemaObject item : choice.getItems()) {
+            for (XmlSchemaChoiceMember item : choice.getItems()) {
                 if (item instanceof XmlSchemaGroup) {
                     children.add(((XmlSchemaGroup)item).getParticle());
                 } else if (item instanceof XmlSchemaParticle) {



Mime
View raw message