Author: bimargulies Date: Sat Nov 7 20:10:08 2009 New Revision: 833746 URL: http://svn.apache.org/viewvc?rev=833746&view=rev Log: XmlSchemaComplexContentRestriction 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/XmlSchemaComplexContentRestriction.java webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.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=833746&r1=833745&r2=833746&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 20:10:08 2009 @@ -1260,28 +1260,28 @@ if (restrictionEl.hasAttribute("base")) { String name = restrictionEl.getAttribute("base"); - restriction.baseTypeName = getRefQName(name, restrictionEl); + restriction.setBaseTypeName(getRefQName(name, restrictionEl)); } for (Element el = XDOMUtil.getFirstChildElementNS(restrictionEl, XmlSchema.SCHEMA_NS); el != null; el = XDOMUtil .getNextSiblingElementNS(el, XmlSchema.SCHEMA_NS)) { if (el.getLocalName().equals("sequence")) { - restriction.particle = handleSequence(schema, el, schemaEl); + restriction.setParticle(handleSequence(schema, el, schemaEl)); } else if (el.getLocalName().equals("choice")) { - restriction.particle = handleChoice(schema, el, schemaEl); + restriction.setParticle(handleChoice(schema, el, schemaEl)); } else if (el.getLocalName().equals("all")) { - restriction.particle = handleAll(schema, el, schemaEl); + restriction.setParticle(handleAll(schema, el, schemaEl)); } else if (el.getLocalName().equals("attribute")) { - restriction.attributes + restriction.getAttributes() .add(handleAttribute(schema, el, schemaEl)); } else if (el.getLocalName().equals("attributeGroup")) { - restriction.attributes.add(handleAttributeGroupRef(schema, el)); + restriction.getAttributes().add(handleAttributeGroupRef(schema, el)); } else if (el.getLocalName().equals("group")) { - restriction.particle = handleGroupRef(schema, el, schemaEl); + restriction.setParticle(handleGroupRef(schema, el, schemaEl)); } else if (el.getLocalName().equals("anyAttribute")) { - restriction.anyAttribute = handleAnyAttribute(schema, el, - schemaEl); + restriction.setAnyAttribute(handleAnyAttribute(schema, el, + schemaEl)); } else if (el.getLocalName().equals("annotation")) { restriction.setAnnotation(handleAnnotation(el)); } Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java?rev=833746&r1=833745&r2=833746&view=diff ============================================================================== --- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java (original) +++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java Sat Nov 7 20:10:08 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; /** @@ -29,25 +33,25 @@ public class XmlSchemaComplexContentRestriction extends XmlSchemaContent { /* Allows an XmlSchemaAnyAttribute to be used for the attribute value. */ - XmlSchemaAnyAttribute anyAttribute; + private XmlSchemaAnyAttribute anyAttribute; /* * Contains XmlSchemaAttribute and XmlSchemaAttributeGroupRef. Collection of attributes for the simple * type. */ - XmlSchemaObjectCollection attributes; + private List<XmlSchemaAttributeOrGroupRef> attributes; /* Name of the built-in data type, simple type, or complex type. */ - QName baseTypeName; + private QName baseTypeName; /* * One of the XmlSchemaGroupRef, XmlSchemaChoice, XmlSchemaAll, or XmlSchemaSequence classes. */ - XmlSchemaParticle particle; + private XmlSchemaParticle particle; /** * Creates new XmlSchemaComplexContentRestriction */ public XmlSchemaComplexContentRestriction() { - attributes = new XmlSchemaObjectCollection(); + attributes = Collections.synchronizedList(new ArrayList<XmlSchemaAttributeOrGroupRef>()); } public void setAnyAttribute(XmlSchemaAnyAttribute anyAttribute) { @@ -58,7 +62,7 @@ return this.anyAttribute; } - public XmlSchemaObjectCollection getAttributes() { + public List<XmlSchemaAttributeOrGroupRef> getAttributes() { return this.attributes; } @@ -77,4 +81,8 @@ public void setParticle(XmlSchemaParticle particle) { this.particle = particle; } + + void setAttributes(List<XmlSchemaAttributeOrGroupRef> attributes) { + this.attributes = attributes; + } } 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=833746&r1=833745&r2=833746&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 20:10:08 2009 @@ -778,8 +778,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); } @@ -792,25 +792,26 @@ restriction.appendChild(annotation); } - if (restrictionObj.particle instanceof XmlSchemaSequence) { - Element sequenceParticle = serializeSequence(doc, (XmlSchemaSequence)restrictionObj.particle, + if (restrictionObj.getParticle() instanceof XmlSchemaSequence) { + Element sequenceParticle = serializeSequence(doc, (XmlSchemaSequence)restrictionObj.getParticle(), schema); restriction.appendChild(sequenceParticle); - } else if (restrictionObj.particle instanceof XmlSchemaChoice) { - Element choiceParticle = serializeChoice(doc, (XmlSchemaChoice)restrictionObj.particle, schema); + } else if (restrictionObj.getParticle() instanceof XmlSchemaChoice) { + Element choiceParticle = serializeChoice(doc, + (XmlSchemaChoice)restrictionObj.getParticle(), schema); restriction.appendChild(choiceParticle); - } else if (restrictionObj.particle instanceof XmlSchemaAll) { - Element allParticle = serializeAll(doc, (XmlSchemaAll)restrictionObj.particle, schema); + } else if (restrictionObj.getParticle() instanceof XmlSchemaAll) { + Element allParticle = serializeAll(doc, (XmlSchemaAll)restrictionObj.getParticle(), schema); restriction.appendChild(allParticle); - } else if (restrictionObj.particle instanceof XmlSchemaGroupRef) { - Element groupRefParticle = serializeGroupRef(doc, (XmlSchemaGroupRef)restrictionObj.particle, + } else if (restrictionObj.getParticle() instanceof XmlSchemaGroupRef) { + Element groupRefParticle = serializeGroupRef(doc, (XmlSchemaGroupRef)restrictionObj.getParticle(), schema); restriction.appendChild(groupRefParticle); } - int attributesLength = restrictionObj.attributes.getCount(); + int attributesLength = restrictionObj.getAttributes().size(); for (int i = 0; i < attributesLength; i++) { - XmlSchemaObject obj = restrictionObj.attributes.getItem(i); + XmlSchemaAttributeOrGroupRef obj = restrictionObj.getAttributes().get(i); if (obj instanceof XmlSchemaAttribute) { Element attr = serializeAttribute(doc, (XmlSchemaAttribute)obj, schema); @@ -821,8 +822,8 @@ } } - if (restrictionObj.anyAttribute != null) { - Element anyAttribute = serializeAnyAttribute(doc, restrictionObj.anyAttribute, schema); + if (restrictionObj.getAnyAttribute() != null) { + Element anyAttribute = serializeAnyAttribute(doc, restrictionObj.getAnyAttribute(), schema); restriction.appendChild(anyAttribute); }