You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2009/01/07 13:12:34 UTC
svn commit: r732314 - in
/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema:
./ utils/
Author: bimargulies
Date: Wed Jan 7 04:12:33 2009
New Revision: 732314
URL: http://svn.apache.org/viewvc?rev=732314&view=rev
Log:
Begin to introduce 'XmlSchemaNamed' to centralize processing of named objects. Make preparations for
eventual removal of XmlSchemaObjectCollection in favor of plain-old-collections.
Added:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java (with props)
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java (with props)
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/XmlSchema.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotated.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.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=732314&r1=732313&r2=732314&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 Wed Jan 7 04:12:33 2009
@@ -460,7 +460,7 @@
}
if (el.hasAttribute("id")) {
- element.id = el.getAttribute("id");
+ element.setId(el.getAttribute("id"));
}
if (el.hasAttribute("nillable")) {
@@ -881,7 +881,7 @@
XmlSchemaAttribute attr = handleAttribute(currentSchema, el, schemaEl, true); // pass true to
// indicate that it is
// a top level child
- currentSchema.attributes.collection.put(attr.qualifiedName, attr);
+ currentSchema.attributes.collection.put(attr.getQName(), attr);
currentSchema.items.add(attr);
} else if (el.getLocalName().equals("redefine")) {
XmlSchemaRedefine redefine = handleRedefine(currentSchema, el, schemaEl);
@@ -914,7 +914,7 @@
currentSchema.setFinalDefault(this.getDerivation(schemaEl, "finalDefault"));
/* set id attribute */
if (schemaEl.hasAttribute("id")) {
- currentSchema.id = schemaEl.getAttribute("id");
+ currentSchema.setId(schemaEl.getAttribute("id"));
}
currentSchema.setSourceURI(systemId);
@@ -1133,7 +1133,7 @@
anyAttr.processContent = XmlSchemaContentProcessing.schemaValueOf(contentProcessing);
}
if (anyAttrEl.hasAttribute("id")) {
- anyAttr.id = anyAttrEl.getAttribute("id");
+ anyAttr.setId(anyAttrEl.getAttribute("id"));
}
Element annotationEl = XDOMUtil.getFirstChildElementNS(anyAttrEl, XmlSchema.SCHEMA_NS, "annotation");
@@ -1169,27 +1169,11 @@
*/
private XmlSchemaAttribute handleAttribute(XmlSchema schema, Element attrEl, Element schemaEl,
boolean topLevel) {
- // todo: need to implement different rule of attribute such as
- // restriction between ref and name. This can be implemented
- // in the compile function
- XmlSchemaAttribute attr = new XmlSchemaAttribute();
+ XmlSchemaAttribute attr = new XmlSchemaAttribute(schema, topLevel);
if (attrEl.hasAttribute("name")) {
String name = attrEl.getAttribute("name");
- // String namespace = (schema.targetNamespace==null)?
- // "" :schema.targetNamespace;
-
- attr.name = name;
- }
-
- boolean isQualified = schema.getAttributeFormDefault() == XmlSchemaForm.QUALIFIED;
- if (attr.name != null) {
- final String name = attr.name;
- if (topLevel) {
- attr.qualifiedName = newLocalQName(name);
- } else {
- attr.qualifiedName = isQualified ? newLocalQName(name) : new QName(name);
- }
+ attr.setName(name);
}
if (attrEl.hasAttribute("type")) {
@@ -1211,7 +1195,7 @@
}
if (attrEl.hasAttribute("id")) {
- attr.id = attrEl.getAttribute("id");
+ attr.setId(attrEl.getAttribute("id"));
}
if (attrEl.hasAttribute("use")) {
@@ -1221,7 +1205,7 @@
if (attrEl.hasAttribute("ref")) {
String name = attrEl.getAttribute("ref");
attr.refName = getRefQName(name, attrEl);
- attr.name = name;
+ attr.setName(name);
}
Element simpleTypeEl = XDOMUtil.getFirstChildElementNS(attrEl, XmlSchema.SCHEMA_NS, "simpleType");
@@ -1294,7 +1278,7 @@
attrGroup.name = new QName(schema.getTargetNamespace(), groupEl.getAttribute("name"));
}
if (groupEl.hasAttribute("id")) {
- attrGroup.id = groupEl.getAttribute("id");
+ attrGroup.setId(groupEl.getAttribute("id"));
}
for (Element el = XDOMUtil.getFirstChildElementNS(groupEl, XmlSchema.SCHEMA_NS);
@@ -1327,7 +1311,7 @@
}
if (attrGroupEl.hasAttribute("id")) {
- attrGroup.id = attrGroupEl.getAttribute("id");
+ attrGroup.setId(attrGroupEl.getAttribute("id"));
}
Element annotationEl = XDOMUtil
@@ -1344,7 +1328,7 @@
XmlSchemaChoice choice = new XmlSchemaChoice();
if (choiceEl.hasAttribute("id")) {
- choice.id = choiceEl.getAttribute("id");
+ choice.setId(choiceEl.getAttribute("id"));
}
choice.minOccurs = getMinOccurs(choiceEl);
@@ -1600,7 +1584,7 @@
XmlSchemaNotation notation = new XmlSchemaNotation();
if (notationEl.hasAttribute("id")) {
- notation.id = notationEl.getAttribute("id");
+ notation.setId(notationEl.getAttribute("id"));
}
if (notationEl.hasAttribute("name")) {
@@ -1783,7 +1767,7 @@
}
if (restrictionEl.hasAttribute("id")) {
- restriction.id = restrictionEl.getAttribute("id");
+ restriction.setId(restrictionEl.getAttribute("id"));
}
// check back simpleContent tag children to add attributes and simpleType if any occur
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java?rev=732314&r1=732313&r2=732314&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java Wed Jan 7 04:12:33 2009
@@ -606,12 +606,12 @@
XmlSchema xs = (XmlSchema)what;
- if (this.id != null) {
- if (!this.id.equals(xs.id)) {
+ if (this.getId() != null) {
+ if (!this.getId().equals(xs.getId())) {
return false;
}
} else {
- if (xs.id != null) {
+ if (xs.getId() != null) {
return false;
}
}
@@ -652,7 +652,13 @@
return inputEncoding;
}
+ public String getLogicalTargetNamespace() {
+ return logicalTargetNamespace;
+ }
+
public String toString() {
return super.toString() + "[" + logicalTargetNamespace + "]";
}
+
+
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotated.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotated.java?rev=732314&r1=732313&r2=732314&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotated.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotated.java Wed Jan 7 04:12:33 2009
@@ -22,27 +22,18 @@
import org.w3c.dom.Attr;
/**
- * The base class for any element that can contain annotation elements.
+ * The base class for any element that can contain an annotation element.
+ * This class also provides storage for an id and a set of non-XML-schema
+ * XML attributes.
*/
-public class XmlSchemaAnnotated extends XmlSchemaObject {
+public abstract class XmlSchemaAnnotated extends XmlSchemaObject {
- /**
- * Defines an annotation. Creates an annotation element. Represents the W3C annotation element.
- */
- XmlSchemaAnnotation annotation;
- String id;
-
- // Stores qualified attributes that do not belong to the schema target namespace.
+ private XmlSchemaAnnotation annotation;
+ private String id;
private Attr[] unhandledAttributes;
- /**
- * Creates new XmlSchemaAnnotated
- */
- public XmlSchemaAnnotated() {
- }
-
public String getId() {
return id;
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java?rev=732314&r1=732313&r2=732314&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java Wed Jan 7 04:12:33 2009
@@ -26,23 +26,24 @@
*/
// October 15th - momo - initial implementation
-public class XmlSchemaAttribute extends XmlSchemaAnnotated {
+public class XmlSchemaAttribute extends XmlSchemaNamed {
Object attributeType;
String defaultValue;
String fixedValue;
- String name;
XmlSchemaForm form;
XmlSchemaSimpleType schemaType;
QName schemaTypeName;
- QName qualifiedName;
QName refName;
XmlSchemaUse use;
/**
- * Creates new XmlSchemaAttribute
+ * Create a new attribute.
+ * @param schema containing scheme.
+ * @param topLevel true if a global attribute.
*/
- public XmlSchemaAttribute() {
+ public XmlSchemaAttribute(XmlSchema schema, boolean topLevel) {
+ super(schema, topLevel);
form = XmlSchemaForm.NONE;
use = XmlSchemaUse.NONE;
}
@@ -75,22 +76,6 @@
this.form = formValue;
}
- public QName getQName() {
- return qualifiedName;
- }
-
- public void setQName(QName qualifiedNameValue) {
- this.qualifiedName = qualifiedNameValue;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public QName getRefName() {
return refName;
}
@@ -135,7 +120,8 @@
xml += "\t";
}
- xml += "<" + prefix + "attribute name=\"" + name + "\" type=\"" + schemaTypeName + "\"/>\n";
+ xml += "<" + prefix + "attribute name=\""
+ + getName() + "\" type=\"" + schemaTypeName + "\"/>\n";
return xml;
}
Added: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java?rev=732314&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java Wed Jan 7 04:12:33 2009
@@ -0,0 +1,97 @@
+/**
+ * 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.ws.commons.schema;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Common base class of all of the named objects in the XML Schema model.
+ * Note that several of these come in both 'named' and anonymous flavors.
+ * This class provides an API that keeps track.
+ *
+ * By definition, all of these objects live in some particular (parent)
+ * schema.
+ *
+ * The parent is intentionally immutable; there's no good reason to move
+ * an object from one schema to another, and this simplifies some of the
+ * book-keeping.
+ *
+ */
+public abstract class XmlSchemaNamed extends XmlSchemaAnnotated {
+
+ protected XmlSchema parentSchema;
+ // Store the name as a QName for the convenience of QName fans.
+ private QName qname;
+ private boolean topLevel;
+
+ /**
+ * Create a new named object.
+ * @param parent the parent schema.
+ */
+ protected XmlSchemaNamed(XmlSchema parent, boolean topLevel) {
+ this.parentSchema = parent;
+ this.topLevel = topLevel;
+ }
+
+ /**
+ * Retrieve the name.
+ * @return
+ */
+ public String getName() {
+ if (qname == null) {
+ return null;
+ } else {
+ return qname.getLocalPart();
+ }
+ }
+
+ public boolean isAnonymous() {
+ return qname == null;
+ }
+
+ /**
+ * Set the name. Set to null to render the object anonymous.
+ * @param name
+ */
+ public void setName(String name) {
+ if ("".equals(name)) {
+ throw new XmlSchemaException("Attempt to set empty name.");
+ }
+ // even non-top-level named items have a full qname. After all,
+ // if form='qualified', we need to serialize it.
+ qname = new QName(parentSchema.getLogicalTargetNamespace(), name);
+ }
+
+ /**
+ * Retrieve the parent schema.
+ * @return
+ */
+ public XmlSchema getParent() {
+ return parentSchema;
+ }
+
+ public QName getQName() {
+ return qname;
+ }
+
+ public boolean isTopLevel() {
+ return topLevel;
+ }
+}
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaNamed.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=732314&r1=732313&r2=732314&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 Wed Jan 7 04:12:33 2009
@@ -158,8 +158,8 @@
serializeMaxMinOccurs(allObj, allEl);
- if (allObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, allObj.annotation, schema);
+ if (allObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, allObj.getAnnotation(), schema);
allEl.appendChild(annotation);
}
@@ -245,8 +245,8 @@
*/
Element serializeAny(Document doc, XmlSchemaAny anyObj, XmlSchema schema) {
Element anyEl = createNewElement(doc, "any", schema.schemaNamespacePrefix, XmlSchema.SCHEMA_NS);
- if (anyObj.id != null && anyObj.id.length() > 0) {
- anyEl.setAttribute("id", anyObj.id);
+ if (anyObj.getId() != null && anyObj.getId().length() > 0) {
+ anyEl.setAttribute("id", anyObj.getId());
}
serializeMaxMinOccurs(anyObj, anyEl);
@@ -259,8 +259,8 @@
anyEl.setAttribute("processContents", anyObj.processContent.toString());
}
- if (anyObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, anyObj.annotation, schema);
+ if (anyObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, anyObj.getAnnotation(), schema);
anyEl.appendChild(annotation);
}
@@ -292,16 +292,16 @@
anyAttribute.setAttribute("namespace", anyAttributeObj.namespace);
}
- if (anyAttributeObj.id != null) {
- anyAttribute.setAttribute("id", anyAttributeObj.id);
+ if (anyAttributeObj.getId() != null) {
+ anyAttribute.setAttribute("id", anyAttributeObj.getId());
}
if (anyAttributeObj.processContent != null
&& anyAttributeObj.processContent != XmlSchemaContentProcessing.NONE) {
anyAttribute.setAttribute("processContents", anyAttributeObj.processContent.toString());
}
- if (anyAttributeObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, anyAttributeObj.annotation, schema);
+ if (anyAttributeObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, anyAttributeObj.getAnnotation(), schema);
anyAttribute.appendChild(annotation);
}
@@ -368,8 +368,8 @@
if (attributeObj.refName != null) {
String refName = resolveQName(attributeObj.refName, schema);
attribute.setAttribute("ref", refName);
- } else if (attributeObj.name != null) {
- attribute.setAttribute("name", attributeObj.name);
+ } else if (!attributeObj.isAnonymous()) {
+ attribute.setAttribute("name", attributeObj.getName());
}
if (attributeObj.schemaTypeName != null) {
@@ -388,16 +388,16 @@
attribute.setAttribute("form", attributeObj.form.toString());
}
- if (attributeObj.id != null) {
- attribute.setAttribute("id", attributeObj.id);
+ if (attributeObj.getId() != null) {
+ attribute.setAttribute("id", attributeObj.getId());
}
if (attributeObj.use != null && attributeObj.use != XmlSchemaUse.NONE) {
attribute.setAttribute("use", attributeObj.use.toString());
}
- if (attributeObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, attributeObj.annotation, schema);
+ if (attributeObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, attributeObj.getAnnotation(), schema);
attribute.appendChild(annotation);
}
@@ -495,12 +495,12 @@
} else {
throw new XmlSchemaSerializerException("Attribute group must" + "have name");
}
- if (attributeGroupObj.id != null) {
- attributeGroup.setAttribute("id", attributeGroupObj.id);
+ if (attributeGroupObj.getId() != null) {
+ attributeGroup.setAttribute("id", attributeGroupObj.getId());
}
- if (attributeGroupObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, attributeGroupObj.annotation, schema);
+ if (attributeGroupObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, attributeGroupObj.getAnnotation(), schema);
attributeGroup.appendChild(annotation);
}
int attributesLength = attributeGroupObj.attributes.getCount();
@@ -554,12 +554,12 @@
throw new XmlSchemaSerializerException("Attribute group must have " + "ref name set");
}
- if (attributeGroupObj.id != null) {
- attributeGroupRef.setAttribute("id", attributeGroupObj.id);
+ if (attributeGroupObj.getId() != null) {
+ attributeGroupRef.setAttribute("id", attributeGroupObj.getId());
}
- if (attributeGroupObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, attributeGroupObj.annotation, schema);
+ if (attributeGroupObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, attributeGroupObj.getAnnotation(), schema);
attributeGroupRef.appendChild(annotation);
}
@@ -587,8 +587,8 @@
// todo: handle any non schema attri ?
Element choice = createNewElement(doc, "choice", schema.schemaNamespacePrefix, XmlSchema.SCHEMA_NS);
- if (choiceObj.id != null && choiceObj.id.length() > 0) {
- choice.setAttribute("id", choiceObj.id);
+ if (choiceObj.getId() != null && choiceObj.getId().length() > 0) {
+ choice.setAttribute("id", choiceObj.getId());
}
serializeMaxMinOccurs(choiceObj, choice);
@@ -598,8 +598,8 @@
* else if(choiceObj.maxOccurs > 1) choice.setAttribute("maxOccurs", choiceObj.maxOccurs +"");
*/
- if (choiceObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, choiceObj.annotation, schema);
+ if (choiceObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, choiceObj.getAnnotation(), schema);
choice.appendChild(annotation);
}
@@ -656,16 +656,16 @@
Element complexContent = createNewElement(doc, "complexContent", schema.schemaNamespacePrefix,
XmlSchema.SCHEMA_NS);
- if (complexContentObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, complexContentObj.annotation, schema);
+ if (complexContentObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, complexContentObj.getAnnotation(), schema);
complexContent.appendChild(annotation);
}
if (complexContentObj.isMixed()) {
complexContent.setAttribute("mixed", "true");
}
- if (complexContentObj.id != null) {
- complexContent.setAttribute("id", complexContentObj.id);
+ if (complexContentObj.getId() != null) {
+ complexContent.setAttribute("id", complexContentObj.getId());
}
Element content;
@@ -717,8 +717,8 @@
String baseType = resolveQName(extensionObj.baseTypeName, schema);
extension.setAttribute("base", baseType);
}
- if (extensionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, extensionObj.annotation, schema);
+ if (extensionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, extensionObj.getAnnotation(), schema);
extension.appendChild(annotation);
}
@@ -788,12 +788,12 @@
restriction.setAttribute("base", baseTypeName);
}
- if (restrictionObj.id != null) {
- restriction.setAttribute("id", restrictionObj.id);
+ if (restrictionObj.getId() != null) {
+ restriction.setAttribute("id", restrictionObj.getId());
}
- if (restrictionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, restrictionObj.annotation, schema);
+ if (restrictionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, restrictionObj.getAnnotation(), schema);
restriction.appendChild(annotation);
}
@@ -871,12 +871,12 @@
if (complexTypeObj.isAbstract) {
serializedComplexType.setAttribute("abstract", "true");
}
- if (complexTypeObj.id != null) {
- serializedComplexType.setAttribute("id", complexTypeObj.id);
+ if (complexTypeObj.getId() != null) {
+ serializedComplexType.setAttribute("id", complexTypeObj.getId());
}
- if (complexTypeObj.annotation != null) {
- Element annotationEl = serializeAnnotation(doc, complexTypeObj.annotation, schema);
+ if (complexTypeObj.getAnnotation() != null) {
+ Element annotationEl = serializeAnnotation(doc, complexTypeObj.getAnnotation(), schema);
serializedComplexType.appendChild(annotationEl);
}
@@ -1043,8 +1043,8 @@
serializedEl.setAttribute("form", elementObj.form.toString());
}
- if (elementObj.id != null) {
- serializedEl.setAttribute("id", elementObj.id);
+ if (elementObj.getId() != null) {
+ serializedEl.setAttribute("id", elementObj.getId());
}
serializeMaxMinOccurs(elementObj, serializedEl);
@@ -1057,8 +1057,8 @@
String resolvedName = resolveQName(elementObj.schemaTypeName, schema);
serializedEl.setAttribute("type", resolvedName);
}
- if (elementObj.annotation != null) {
- Element annotationEl = serializeAnnotation(doc, elementObj.annotation, schema);
+ if (elementObj.getAnnotation() != null) {
+ Element annotationEl = serializeAnnotation(doc, elementObj.getAnnotation(), schema);
serializedEl.appendChild(annotationEl);
}
if (elementObj.schemaType != null && elementObj.schemaTypeName == null) {
@@ -1138,8 +1138,8 @@
throw new XmlSchemaSerializerException("facet not exist " + facetObj.getClass().getName());
}
- if (facetObj.id != null) {
- serializedFacet.setAttribute("id", facetObj.id);
+ if (facetObj.getId() != null) {
+ serializedFacet.setAttribute("id", facetObj.getId());
// if (facetObj.annotation != null) {
// Element annotation = serializeAnnotation(doc, facetObj.annotation,
// schema);
@@ -1177,8 +1177,8 @@
throw new XmlSchemaSerializerException("xpath can't be null");
}
- if (fieldObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, fieldObj.annotation, schema);
+ if (fieldObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, fieldObj.getAnnotation(), schema);
field.appendChild(annotation);
}
@@ -1216,8 +1216,8 @@
}
/* annotations are supposed to be written first!!!!! */
- if (groupObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, groupObj.annotation, schema);
+ if (groupObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, groupObj.getAnnotation(), schema);
group.appendChild(annotation);
}
@@ -1279,8 +1279,8 @@
+ "www.w3.org/TR/xmlschema-1#element-group-3.7.2");
}
}
- if (groupRefObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, groupRefObj.annotation, schema);
+ if (groupRefObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, groupRefObj.getAnnotation(), schema);
groupRef.appendChild(annotation);
}
@@ -1327,8 +1327,8 @@
if (constraintObj.name != null) {
constraint.setAttribute("name", constraintObj.name);
}
- if (constraintObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, constraintObj.annotation, schema);
+ if (constraintObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, constraintObj.getAnnotation(), schema);
constraint.appendChild(annotation);
}
@@ -1377,12 +1377,12 @@
importEl.setAttribute("schemaLocation", importObj.schemaLocation);
}
- if (importObj.id != null) {
- importEl.setAttribute("id", importObj.id);
+ if (importObj.getId() != null) {
+ importEl.setAttribute("id", importObj.getId());
}
- if (importObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, importObj.annotation, schema);
+ if (importObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, importObj.getAnnotation(), schema);
importEl.appendChild(annotation);
}
@@ -1423,12 +1423,12 @@
includeEl.setAttribute("schemaLocation", includeObj.schemaLocation);
}
- if (includeObj.id != null) {
- includeEl.setAttribute("id", includeObj.id);
+ if (includeObj.getId() != null) {
+ includeEl.setAttribute("id", includeObj.getId());
}
- if (includeObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, includeObj.annotation, schema);
+ if (includeObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, includeObj.getAnnotation(), schema);
includeEl.appendChild(annotation);
}
@@ -1473,12 +1473,12 @@
throw new XmlSchemaSerializerException("redefine must have " + "schemaLocation fields fill");
}
- if (redefineObj.id != null) {
- redefine.setAttribute("id", redefineObj.id);
+ if (redefineObj.getId() != null) {
+ redefine.setAttribute("id", redefineObj.getId());
}
- if (redefineObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, redefineObj.annotation, schema);
+ if (redefineObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, redefineObj.getAnnotation(), schema);
redefine.appendChild(annotation);
}
int itemsLength = redefineObj.items.getCount();
@@ -1569,13 +1569,14 @@
serializedSchema.setAttribute("elementFormDefault", schemaObj.elementFormDefault.toString());
}
- if (schemaObj.annotation != null) {
- Element annotation = serializeAnnotation(serializedSchemaDocs, schemaObj.annotation, schemaObj);
+ if (schemaObj.getAnnotation() != null) {
+ Element annotation =
+ serializeAnnotation(serializedSchemaDocs, schemaObj.getAnnotation(), schemaObj);
serializedSchema.appendChild(annotation);
}
- if (schemaObj.id != null) {
- serializedSchema.setAttribute("id", schemaObj.id);
+ if (schemaObj.getId() != null) {
+ serializedSchema.setAttribute("id", schemaObj.getId());
}
if (schemaObj.blockDefault != null && schemaObj.blockDefault != XmlSchemaDerivationMethod.NONE) {
@@ -1645,8 +1646,8 @@
throw new XmlSchemaSerializerException("xpath can't be null");
}
- if (selectorObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, selectorObj.annotation, schema);
+ if (selectorObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, selectorObj.getAnnotation(), schema);
selector.appendChild(annotation);
}
// process extension
@@ -1674,8 +1675,8 @@
Element sequence = createNewElement(doc, "sequence", schema.schemaNamespacePrefix,
XmlSchema.SCHEMA_NS);
- if (sequenceObj.id != null) {
- sequence.setAttribute("id", sequenceObj.id);
+ if (sequenceObj.getId() != null) {
+ sequence.setAttribute("id", sequenceObj.getId());
}
serializeMaxMinOccurs(sequenceObj, sequence);
@@ -1728,8 +1729,8 @@
XmlSchema.SCHEMA_NS);
Element content;
- if (simpleContentObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, simpleContentObj.annotation, schema);
+ if (simpleContentObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, simpleContentObj.getAnnotation(), schema);
simpleContent.appendChild(annotation);
}
if (simpleContentObj.content instanceof XmlSchemaSimpleContentRestriction) {
@@ -1784,12 +1785,12 @@
extension.setAttribute("base", baseTypeName);
}
- if (extensionObj.id != null) {
- extension.setAttribute("id", extensionObj.id);
+ if (extensionObj.getId() != null) {
+ extension.setAttribute("id", extensionObj.getId());
}
- if (extensionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, extensionObj.annotation, schema);
+ if (extensionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, extensionObj.getAnnotation(), schema);
extension.appendChild(annotation);
}
@@ -1849,12 +1850,12 @@
restriction.setAttribute("base", baseTypeName);
}
- if (restrictionObj.id != null) {
- restriction.setAttribute("id", restrictionObj.id);
+ if (restrictionObj.getId() != null) {
+ restriction.setAttribute("id", restrictionObj.getId());
}
- if (restrictionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, restrictionObj.annotation, schema);
+ if (restrictionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, restrictionObj.getAnnotation(), schema);
restriction.appendChild(annotation);
}
int attrCollLength = restrictionObj.attributes.getCount();
@@ -1915,14 +1916,14 @@
&& simpleTypeObj.finalDerivation != XmlSchemaDerivationMethod.NONE) {
serializedSimpleType.setAttribute("final", simpleTypeObj.finalDerivation.toString());
}
- if (simpleTypeObj.id != null) {
- serializedSimpleType.setAttribute("id", simpleTypeObj.id);
+ if (simpleTypeObj.getId() != null) {
+ serializedSimpleType.setAttribute("id", simpleTypeObj.getId());
}
if (simpleTypeObj.name != null && !simpleTypeObj.name.equals("")) {
serializedSimpleType.setAttribute("name", simpleTypeObj.name);
}
- if (simpleTypeObj.annotation != null) {
- Element annotationEl = serializeAnnotation(doc, simpleTypeObj.annotation, schema);
+ if (simpleTypeObj.getAnnotation() != null) {
+ Element annotationEl = serializeAnnotation(doc, simpleTypeObj.getAnnotation(), schema);
serializedSimpleType.appendChild(annotationEl);
}
if (simpleTypeObj.content != null) {
@@ -1984,14 +1985,14 @@
String listItemType = resolveQName(listObj.itemTypeName, schema);
list.setAttribute("itemType", listItemType);
}
- if (listObj.id != null) {
- list.setAttribute("id", listObj.id);
+ if (listObj.getId() != null) {
+ list.setAttribute("id", listObj.getId());
} else if (listObj.itemType != null) {
Element inlineSimpleEl = serializeSimpleType(doc, listObj.itemType, schema);
list.appendChild(inlineSimpleEl);
}
- if (listObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, listObj.annotation, schema);
+ if (listObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, listObj.getAnnotation(), schema);
list.appendChild(annotation);
}
@@ -2035,12 +2036,12 @@
+ "with specifying base or inline simpleType");
}
- if (restrictionObj.id != null) {
- serializedRestriction.setAttribute("id", restrictionObj.id);
+ if (restrictionObj.getId() != null) {
+ serializedRestriction.setAttribute("id", restrictionObj.getId());
}
- if (restrictionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, restrictionObj.annotation, schema);
+ if (restrictionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, restrictionObj.getAnnotation(), schema);
serializedRestriction.appendChild(annotation);
}
if (restrictionObj.facets.getCount() > 0) {
@@ -2076,8 +2077,8 @@
throws XmlSchemaSerializerException {
Element union = createNewElement(doc, "union", schema.schemaNamespacePrefix, XmlSchema.SCHEMA_NS);
- if (unionObj.id != null) {
- union.setAttribute("id", unionObj.id);
+ if (unionObj.getId() != null) {
+ union.setAttribute("id", unionObj.getId());
}
if (unionObj.memberTypesSource != null) {
@@ -2097,8 +2098,8 @@
}
}
}
- if (unionObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, unionObj.annotation, schema);
+ if (unionObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, unionObj.getAnnotation(), schema);
union.appendChild(annotation);
}
@@ -2173,8 +2174,8 @@
facetEl.setAttribute("fixed", "true");
}
- if (facetObj.annotation != null) {
- Element annotation = serializeAnnotation(doc, facetObj.annotation, schema);
+ if (facetObj.getAnnotation() != null) {
+ Element annotation = serializeAnnotation(doc, facetObj.getAnnotation(), schema);
facetEl.appendChild(annotation);
}
return facetEl;
Added: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java?rev=732314&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java Wed Jan 7 04:12:33 2009
@@ -0,0 +1,46 @@
+/**
+ * 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.ws.commons.schema.utils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * There are many collections of XML Schema objects inside XmlSchema.
+ * This class provides consistent construction to centralize policy
+ * for thread synchronization and the like.
+ */
+public final class CollectionFactory {
+
+ private CollectionFactory() {
+ }
+
+ public static <T> List<T> getList(Class<T> type) {
+ return Collections.synchronizedList(new ArrayList<T>());
+ }
+
+ public static <T> Set<T> getSet(Class<T> type) {
+ return Collections.synchronizedSet(new HashSet<T>());
+ }
+
+}
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/CollectionFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date