Author: bimargulies
Date: Sat Nov  7 19:15:33 2009
New Revision: 833736

URL: http://svn.apache.org/viewvc?rev=833736&view=rev
Log:
SimpleContentRestriction modernization.

Modified:
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
    
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=833736&r1=833735&r2=833736&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 Sat Nov  7 19:15:33 2009
@@ -1724,7 +1724,7 @@
 
         if (restrictionEl.hasAttribute("base")) {
             String name = restrictionEl.getAttribute("base");
-            restriction.baseTypeName = getRefQName(name, restrictionEl);
+            restriction.setBaseTypeName(getRefQName(name, restrictionEl));
         }
 
         if (restrictionEl.hasAttribute("id")) {
@@ -1739,14 +1739,14 @@
 
             if (el.getLocalName().equals("attribute")) {
                 XmlSchemaAttribute attr = handleAttribute(schema, el, 
schemaEl);
-                restriction.attributes.add(attr);
+                restriction.getAttributes().add(attr);
             } else if (el.getLocalName().equals("attributeGroup")) {
                 XmlSchemaAttributeGroupRef attrGroup = handleAttributeGroupRef(
                         schema, el);
-                restriction.attributes.add(attrGroup);
+                restriction.getAttributes().add(attrGroup);
             } else if (el.getLocalName().equals("simpleType")) {
-                restriction.baseType = handleSimpleType(schema, el, schemaEl,
-                        false);
+                restriction.setBaseType(handleSimpleType(schema, el, schemaEl,
+                        false));
             } else if (el.getLocalName().equals("anyAttribute")) {
                 restriction.anyAttribute = handleAnyAttribute(schema, el,
                         schemaEl);
@@ -1760,7 +1760,7 @@
                     facet.setAnnotation(facetAnnotation);
 
                 }
-                restriction.facets.add(facet);
+                restriction.getFacets().add(facet);
                 //process extra attributes and elements
                 processExtensibilityComponents(facet, el);
             }

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=833736&r1=833735&r2=833736&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
 Sat Nov  7 19:15:33 2009
@@ -1877,8 +1877,8 @@
         Element restriction = createNewElement(doc, "restriction", 
schema.getSchemaNamespacePrefix(),
                                                XmlSchema.SCHEMA_NS);
 
-        if (restrictionObj.baseTypeName != null) {
-            String baseTypeName = resolveQName(restrictionObj.baseTypeName, 
schema);
+        if (restrictionObj.getBaseTypeName() != null) {
+            String baseTypeName = 
resolveQName(restrictionObj.getBaseTypeName(), schema);
 
             restriction.setAttribute("base", baseTypeName);
 
@@ -1891,9 +1891,9 @@
             Element annotation = serializeAnnotation(doc, 
restrictionObj.getAnnotation(), schema);
             restriction.appendChild(annotation);
         }
-        int attrCollLength = restrictionObj.attributes.getCount();
+        int attrCollLength = restrictionObj.getAttributes().size();
         for (int i = 0; i < attrCollLength; i++) {
-            XmlSchemaObject obj = restrictionObj.attributes.getItem(i);
+            XmlSchemaAnnotated obj = restrictionObj.getAttributes().get(i);
 
             if (obj instanceof XmlSchemaAttribute) {
                 Element attribute = serializeAttribute(doc, 
(XmlSchemaAttribute)obj, schema);
@@ -1904,18 +1904,18 @@
                 restriction.appendChild(attributeGroup);
             }
         }
-        if (restrictionObj.baseType != null) {
-            Element inlineSimpleType = serializeSimpleType(doc, 
restrictionObj.baseType, schema);
+        if (restrictionObj.getBaseType() != null) {
+            Element inlineSimpleType = serializeSimpleType(doc, 
restrictionObj.getBaseType(), schema);
             restriction.appendChild(inlineSimpleType);
         }
         if (restrictionObj.anyAttribute != null) {
             Element anyAttribute = serializeAnyAttribute(doc, 
restrictionObj.anyAttribute, schema);
             restriction.appendChild(anyAttribute);
         }
-        XmlSchemaObjectCollection facets = restrictionObj.facets;
-        int facetLength = facets.getCount();
+        List<XmlSchemaFacet> facets = restrictionObj.getFacets();
+        int facetLength = facets.size();
         for (int i = 0; i < facetLength; i++) {
-            Element facet = serializeFacet(doc, 
(XmlSchemaFacet)facets.getItem(i), schema);
+            Element facet = serializeFacet(doc, facets.get(i), schema);
             restriction.appendChild(facet);
         }
 

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java?rev=833736&r1=833735&r2=833736&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
 Sat Nov  7 19:15:33 2009
@@ -19,6 +19,10 @@
 
 package org.apache.ws.commons.schema;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
 /**
@@ -33,25 +37,25 @@
      * Contains XmlSchemaAttribute and XmlSchemaAttributeGroupRef. Collection 
of attributes for the simple
      * type.
      */
-    XmlSchemaObjectCollection attributes;
+    private List<XmlSchemaAnnotated> attributes;
 
     /* Derived from the type specified by the base value. */
-    XmlSchemaSimpleType baseType;
+    private XmlSchemaSimpleType baseType;
 
     /* Name of the built-in data type, simple type, or complex type. */
-    QName baseTypeName;
+    private QName baseTypeName;
 
 
     /* One or more of the facet classes: */
-    XmlSchemaObjectCollection facets;
+    private List<XmlSchemaFacet> facets;
 
 
     /**
      * Creates new XmlSchemaSimpleContentRestriction
      */
     public XmlSchemaSimpleContentRestriction() {
-        facets = new XmlSchemaObjectCollection();
-        attributes = new XmlSchemaObjectCollection();
+        facets = Collections.synchronizedList(new ArrayList<XmlSchemaFacet>());
+        attributes = Collections.synchronizedList(new 
ArrayList<XmlSchemaAnnotated>());
     }
 
     /* Allows an XmlSchemaAnyAttribute to be used for the attribute value. */
@@ -64,9 +68,7 @@
         return this.anyAttribute;
     }
 
-
-
-    public XmlSchemaObjectCollection getAttributes() {
+    public List<XmlSchemaAnnotated> getAttributes() {
         return this.attributes;
     }
 
@@ -85,7 +87,7 @@
         return this.baseTypeName;
     }
 
-    public XmlSchemaObjectCollection getFacets() {
+    public List<XmlSchemaFacet> getFacets() {
         return this.facets;
     }
 

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java?rev=833736&r1=833735&r2=833736&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java
 Sat Nov  7 19:15:33 2009
@@ -22,17 +22,19 @@
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAnnotated;
 import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaFacet;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction;
 
@@ -91,15 +93,15 @@
         XmlSchemaSimpleContentRestriction xsscr = 
(XmlSchemaSimpleContentRestriction)xssc.getContent();
         assertNotNull(xsscr);
         assertEquals(new QName("http://soapinterop.org/types";, "drinksize"), 
xsscr.getBaseTypeName());
-        XmlSchemaObjectCollection xsoc = xsscr.getAttributes();
+        List<XmlSchemaAnnotated> xsoc = xsscr.getAttributes();
         assertNotNull(xsoc);
-        assertEquals(2, xsoc.getCount());
+        assertEquals(2, xsoc.size());
 
         Set<String> s = new HashSet<String>();
         s.add("units");
         s.add("id");
-        for (int i = 0; i < xsoc.getCount(); i++) {
-            XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
+        for (int i = 0; i < xsoc.size(); i++) {
+            XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.get(i);
             String name = xsa.getName();
             if ("units".equals(name)) {
                 assertEquals(new QName("http://soapinterop.org/types";, 
"units"), xsa.getQName());
@@ -122,15 +124,15 @@
         }
         assertTrue("The set should have been empty, but instead contained: " + 
s + ".", s.isEmpty());
 
-        XmlSchemaObjectCollection xsoc2 = xsscr.getFacets();
+        List<XmlSchemaFacet> xsoc2 = xsscr.getFacets();
         assertNotNull(xsoc2);
-        assertEquals(2, xsoc2.getCount());
+        assertEquals(2, xsoc2.size());
 
         s.clear();
         s.add("small");
         s.add("medium");
-        for (int i = 0; i < xsoc2.getCount(); i++) {
-            XmlSchemaEnumerationFacet xsef = 
(XmlSchemaEnumerationFacet)xsoc2.getItem(i);
+        for (int i = 0; i < xsoc2.size(); i++) {
+            XmlSchemaEnumerationFacet xsef = 
(XmlSchemaEnumerationFacet)xsoc2.get(i);
             String value = (String)xsef.getValue();
             if (!("small".equals(value) || "medium".equals(value))) {
                 fail("Unexpected enumeration value of \"" + value + "\" 
found.");


Reply via email to