Author: bimargulies
Date: Wed Jan 7 12:04:05 2009
New Revision: 732455
URL: http://svn.apache.org/viewvc?rev=732455&view=rev
Log:
Finish making all the named objects consistent.
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/XmlSchemaAttributeGroup.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.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/XmlSchemaSimpleType.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XmlSchemaRef.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeGroupTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.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=732455&r1=732454&r2=732455&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 12:04:05 2009
@@ -239,7 +239,7 @@
}
/**
- * create new XmlSchemaAppinfo and add value goten from element to this obj
+ * create new XmlSchemaAppinfo and add value gotten from element to this
obj
*
* @param content
*/
@@ -261,28 +261,19 @@
* @param schema
* @param complexEl
* @param schemaEl
+ * @param b
*/
- XmlSchemaComplexType handleComplexType(XmlSchema schema, Element
complexEl, Element schemaEl) {
+ XmlSchemaComplexType handleComplexType(XmlSchema schema, Element
complexEl,
+ Element schemaEl, boolean topLevel)
{
- /******
- * set the complexTypeName if any for( eachChildNode) if (
simpleContent) if( restrcition)
- * handle_simple_content_restriction else if( extension)
handle_simple_content_extension break; // it
- * has to be the only child else if( complexContent) if( restriction)
- * handle_complex_content_restriction else if( extension)
handle_complex_content_extension break; //
- * it has to be the only child else if( group) if( group has ref)
store the group name else
- * handleGroup else if( sequence ) handleSequence else if( all )
handleAll else if(choice)
- * handleChoice else if(attribute) handleAttribute else
if(attributeGroup) handleAttributeGroup else
- * if(anyAttribute) handleAnyAttribute
- */
-
- XmlSchemaComplexType ct = new XmlSchemaComplexType(schema);
+ XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, topLevel);
if (complexEl.hasAttribute("name")) {
// String namespace = (schema.targetNamespace==null)?
// "":schema.targetNamespace;
- ct.name = complexEl.getAttribute("name");
+ ct.setName(complexEl.getAttribute("name"));
}
for (Element el = XDOMUtil.getFirstChildElementNS(complexEl,
XmlSchema.SCHEMA_NS);
el != null;
@@ -400,13 +391,13 @@
simpleTypeEl = XDOMUtil.getFirstChildElementNS(el,
XmlSchema.SCHEMA_NS, "simpleType");
if (simpleTypeEl != null) {
- XmlSchemaSimpleType simpleType = handleSimpleType(schema,
simpleTypeEl, schemaEl);
+ XmlSchemaSimpleType simpleType = handleSimpleType(schema,
simpleTypeEl, schemaEl, false);
element.setSchemaType(simpleType);
element.setSchemaTypeName(simpleType.getQName());
} else {
complexTypeEl = XDOMUtil.getFirstChildElementNS(el,
XmlSchema.SCHEMA_NS, "complexType");
if (complexTypeEl != null) {
- element.setSchemaType(handleComplexType(schema, complexTypeEl,
schemaEl));
+ element.setSchemaType(handleComplexType(schema, complexTypeEl,
schemaEl, false));
}
}
@@ -623,10 +614,11 @@
* @param simpleEl
* @param schemaEl
*/
- XmlSchemaSimpleType handleSimpleType(XmlSchema schema, Element simpleEl,
Element schemaEl) {
- XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+ XmlSchemaSimpleType handleSimpleType(XmlSchema schema, Element simpleEl,
+ Element schemaEl, boolean topLevel) {
+ XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema,
topLevel);
if (simpleEl.hasAttribute("name")) {
- simpleType.name = simpleEl.getAttribute("name");
+ simpleType.setName(simpleEl.getAttribute("name"));
}
handleSimpleTypeFinal(simpleEl, simpleType);
@@ -691,12 +683,13 @@
"simpleType");
while (inlineUnionType != null) {
- XmlSchemaSimpleType unionSimpleType = handleSimpleType(schema,
inlineUnionType, schemaEl);
+ XmlSchemaSimpleType unionSimpleType = handleSimpleType(schema,
inlineUnionType, schemaEl,
+ false);
union.baseTypes.add(unionSimpleType);
- if (unionSimpleType.name != null) {
- union.memberTypesSource += " " + unionSimpleType.name;
+ if (!unionSimpleType.isAnonymous()) {
+ union.memberTypesSource += " " + unionSimpleType.getName();
}
inlineUnionType =
XDOMUtil.getNextSiblingElementNS(inlineUnionType, XmlSchema.SCHEMA_NS,
@@ -733,7 +726,7 @@
list.itemTypeName = getRefQName(name, listEl);
} else if (inlineListType != null) {
- list.itemType = handleSimpleType(schema, inlineListType, schemaEl);
+ list.itemType = handleSimpleType(schema, inlineListType, schemaEl,
false);
}
listAnnotationEl = XDOMUtil.getFirstChildElementNS(listEl,
XmlSchema.SCHEMA_NS, "annotation");
@@ -771,7 +764,7 @@
restriction.baseTypeName =
getRefQName(restrictionEl.getAttribute("base"), ctx);
} else if (inlineSimpleType != null) {
- restriction.baseType = handleSimpleType(schema, inlineSimpleType,
schemaEl);
+ restriction.baseType = handleSimpleType(schema, inlineSimpleType,
schemaEl, false);
}
for (Element el = XDOMUtil.getFirstChildElementNS(restrictionEl,
XmlSchema.SCHEMA_NS);
el != null;
@@ -838,12 +831,12 @@
private void handleSchemaElementChild(Element schemaEl, Element el) {
if (el.getLocalName().equals("simpleType")) {
- XmlSchemaType type = handleSimpleType(currentSchema, el, schemaEl);
+ XmlSchemaType type = handleSimpleType(currentSchema, el, schemaEl,
true);
currentSchema.addType(type);
currentSchema.items.add(type);
collection.resolveType(type.getQName(), type);
} else if (el.getLocalName().equals("complexType")) {
- XmlSchemaType type = handleComplexType(currentSchema, el,
schemaEl);
+ XmlSchemaType type = handleComplexType(currentSchema, el,
schemaEl, true);
currentSchema.addType(type);
currentSchema.items.add(type);
collection.resolveType(type.getQName(), type);
@@ -867,11 +860,11 @@
} else if (el.getLocalName().equals("group")) {
XmlSchemaGroup group = handleGroup(currentSchema, el, schemaEl);
- currentSchema.groups.collection.put(group.name, group);
+ currentSchema.groups.collection.put(group.getQName(), group);
currentSchema.items.add(group);
} else if (el.getLocalName().equals("attributeGroup")) {
XmlSchemaAttributeGroup group =
handleAttributeGroup(currentSchema, el, schemaEl);
- currentSchema.attributeGroups.collection.put(group.name, group);
+ currentSchema.attributeGroups.collection.put(group.getQName(),
group);
currentSchema.items.add(group);
} else if (el.getLocalName().equals("attribute")) {
XmlSchemaAttribute attr = handleAttribute(currentSchema, el,
schemaEl, true); // pass true to
@@ -1207,7 +1200,7 @@
Element simpleTypeEl = XDOMUtil.getFirstChildElementNS(attrEl,
XmlSchema.SCHEMA_NS, "simpleType");
if (simpleTypeEl != null) {
- attr.setSchemaType(handleSimpleType(schema, simpleTypeEl,
schemaEl));
+ attr.setSchemaType(handleSimpleType(schema, simpleTypeEl,
schemaEl, false));
}
Element annotationEl = XDOMUtil.getFirstChildElementNS(attrEl,
XmlSchema.SCHEMA_NS, "annotation");
@@ -1268,10 +1261,10 @@
private XmlSchemaAttributeGroup handleAttributeGroup(XmlSchema schema,
Element groupEl,
Element schemaEl) {
- XmlSchemaAttributeGroup attrGroup = new XmlSchemaAttributeGroup();
+ XmlSchemaAttributeGroup attrGroup = new
XmlSchemaAttributeGroup(schema);
if (groupEl.hasAttribute("name")) {
- attrGroup.name = new QName(schema.getTargetNamespace(),
groupEl.getAttribute("name"));
+ attrGroup.setName(groupEl.getAttribute("name"));
}
if (groupEl.hasAttribute("id")) {
attrGroup.setId(groupEl.getAttribute("id"));
@@ -1519,8 +1512,8 @@
private XmlSchemaGroup handleGroup(XmlSchema schema, Element groupEl,
Element schemaEl) {
- XmlSchemaGroup group = new XmlSchemaGroup();
- group.name = new QName(schema.getTargetNamespace(),
groupEl.getAttribute("name"));
+ XmlSchemaGroup group = new XmlSchemaGroup(schema);
+ group.setName(groupEl.getAttribute("name"));
for (Element el = XDOMUtil.getFirstChildElementNS(groupEl,
XmlSchema.SCHEMA_NS);
el != null;
@@ -1640,24 +1633,24 @@
el = XDOMUtil.getNextSiblingElementNS(el, XmlSchema.SCHEMA_NS)) {
if (el.getLocalName().equals("simpleType")) {
- XmlSchemaType type = handleSimpleType(schema, el, schemaEl);
+ XmlSchemaType type = handleSimpleType(schema, el, schemaEl,
false);
redefine.schemaTypes.collection.put(type.getQName(), type);
redefine.items.add(type);
} else if (el.getLocalName().equals("complexType")) {
- XmlSchemaType type = handleComplexType(schema, el, schemaEl);
+ XmlSchemaType type = handleComplexType(schema, el, schemaEl,
true);
redefine.schemaTypes.collection.put(type.getQName(), type);
redefine.items.add(type);
} else if (el.getLocalName().equals("group")) {
XmlSchemaGroup group = handleGroup(schema, el, schemaEl);
- redefine.groups.collection.put(group.name, group);
+ redefine.groups.collection.put(group.getQName(), group);
redefine.items.add(group);
} else if (el.getLocalName().equals("attributeGroup")) {
XmlSchemaAttributeGroup group = handleAttributeGroup(schema,
el, schemaEl);
- redefine.attributeGroups.collection.put(group.name, group);
+ redefine.attributeGroups.collection.put(group.getQName(),
group);
redefine.items.add(group);
} else if (el.getLocalName().equals("annotation")) {
XmlSchemaAnnotation annotation = handleAnnotation(el);
@@ -1778,7 +1771,7 @@
XmlSchemaAttributeGroupRef attrGroup =
handleAttributeGroupRef(el);
restriction.attributes.add(attrGroup);
} else if (el.getLocalName().equals("simpleType")) {
- restriction.baseType = handleSimpleType(schema, el, schemaEl);
+ restriction.baseType = handleSimpleType(schema, el, schemaEl,
false);
} else if (el.getLocalName().equals("anyAttribute")) {
restriction.anyAttribute = handleAnyAttribute(schema, el,
schemaEl);
} else if (el.getLocalName().equals("annotation")) {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroup.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroup.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroup.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroup.java
Wed Jan 7 12:04:05 2009
@@ -21,20 +21,27 @@
import javax.xml.namespace.QName;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamed;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamedImpl;
+
/**
- * Class for attribute groups. Groups a set of attribute declarations so that
they can be incorporated as a
- * group into complex type definitions. Represents the World Wide Web
Consortium (W3C) attributeGroup element.
+ * Class for attribute groups. Groups a set of attribute declarations so that
+ * they can be incorporated as a
+ * group into complex type definitions. Represents the World Wide Web
+ * consortium (W3C) attributeGroup element when it does <i>not</i> have a
'ref='
+ * attribute.
*/
-public class XmlSchemaAttributeGroup extends XmlSchemaAnnotated {
+public class XmlSchemaAttributeGroup extends XmlSchemaAnnotated implements
XmlSchemaNamed {
XmlSchemaAnyAttribute anyAttribute;
XmlSchemaObjectCollection attributes;
- QName name;
+ XmlSchemaNamedImpl namedDelegate;
/**
* Creates new XmlSchemaAttributeGroup
*/
- public XmlSchemaAttributeGroup() {
+ public XmlSchemaAttributeGroup(XmlSchema parent) {
+ namedDelegate = new XmlSchemaNamedImpl(parent, true);
attributes = new XmlSchemaObjectCollection();
}
@@ -54,11 +61,27 @@
this.attributes = attributes;
}
- public QName getName() {
- return this.name;
+ public String getName() {
+ return namedDelegate.getName();
+ }
+
+ public XmlSchema getParent() {
+ return namedDelegate.getParent();
+ }
+
+ public QName getQName() {
+ return namedDelegate.getQName();
+ }
+
+ public boolean isAnonymous() {
+ return namedDelegate.isAnonymous();
+ }
+
+ public boolean isTopLevel() {
+ return namedDelegate.isTopLevel();
}
- public void setName(QName name) {
- this.name = name;
+ public void setName(String name) {
+ namedDelegate.setName(name);
}
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
Wed Jan 7 12:04:05 2009
@@ -648,7 +648,7 @@
private void addSimpleType(XmlSchema schema, String typeName) {
XmlSchemaSimpleType type;
- type = new XmlSchemaSimpleType(schema);
+ type = new XmlSchemaSimpleType(schema, true);
type.setName(typeName);
schema.addType(type);
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
Wed Jan 7 12:04:05 2009
@@ -43,8 +43,8 @@
/**
* Creates new XmlSchemaComplexType
*/
- public XmlSchemaComplexType(XmlSchema schema) {
- super(schema);
+ public XmlSchemaComplexType(XmlSchema schema, boolean topLevel) {
+ super(schema, topLevel);
attributes = new XmlSchemaObjectCollection();
block = XmlSchemaDerivationMethod.NONE;
isAbstract = false;
@@ -138,7 +138,7 @@
prefix += ":";
}
- String typeName = name != null ? name : "";
+ String typeName = !isAnonymous() ? getName() : "";
xml += "<" + prefix + "complexType name=\"" + typeName + "\">\n";
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroup.java
Wed Jan 7 12:04:05 2009
@@ -19,39 +19,59 @@
package org.apache.ws.commons.schema;
+
import javax.xml.namespace.QName;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamed;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamedImpl;
+
/**
* Class that defines groups at the schema level that are referenced from the
complex types. Groups a set of
* element declarations so that they can be incorporated as a group into
complex type definitions. Represents
* the World Wide Web Consortium (W3C) group element.
*/
-public class XmlSchemaGroup extends XmlSchemaAnnotated {
+public class XmlSchemaGroup extends XmlSchemaAnnotated implements
XmlSchemaNamed {
- QName name;
XmlSchemaGroupBase particle;
- /**
- * Creates new XmlSchemaGroup
- */
- public XmlSchemaGroup() {
- }
-
- public QName getName() {
- return name;
+ private XmlSchemaNamedImpl namedDelegate;
+
+ public XmlSchemaGroup(XmlSchema parent) {
+ namedDelegate = new XmlSchemaNamedImpl(parent, true);
}
+
public XmlSchemaGroupBase getParticle() {
return particle;
}
- public void setName(QName name) {
- this.name = name;
- }
-
public void setParticle(XmlSchemaGroupBase particle) {
this.particle = particle;
}
+ public String getName() {
+ return namedDelegate.getName();
+ }
+
+ public XmlSchema getParent() {
+ return namedDelegate.getParent();
+ }
+
+ public QName getQName() {
+ return namedDelegate.getQName();
+ }
+
+ public boolean isAnonymous() {
+ return namedDelegate.isAnonymous();
+ }
+
+ public boolean isTopLevel() {
+ return namedDelegate.isTopLevel();
+ }
+
+ public void setName(String name) {
+ namedDelegate.setName(name);
+ }
+
}
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=732455&r1=732454&r2=732455&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 12:04:05 2009
@@ -489,8 +489,8 @@
Element attributeGroup = createNewElement(doc, "attributeGroup",
schema.schemaNamespacePrefix,
XmlSchema.SCHEMA_NS);
- if (attributeGroupObj.name != null) {
- String attGroupName = attributeGroupObj.name.getLocalPart();
+ if (!attributeGroupObj.isAnonymous()) {
+ String attGroupName = attributeGroupObj.getName();
attributeGroup.setAttribute("name", attGroupName);
} else {
throw new XmlSchemaSerializerException("Attribute group must" +
"have name");
@@ -853,12 +853,11 @@
Element serializeComplexType(Document doc, XmlSchemaComplexType
complexTypeObj, XmlSchema schema)
throws XmlSchemaSerializerException {
- // todo: need to implement abstract, id, mixed
Element serializedComplexType = createNewElement(doc, "complexType",
schema.schemaNamespacePrefix,
XmlSchema.SCHEMA_NS);
- if (complexTypeObj.name != null && !complexTypeObj.name.equals("")) {
- serializedComplexType.setAttribute("name", complexTypeObj.name);
+ if (!complexTypeObj.isAnonymous()) {
+ serializedComplexType.setAttribute("name",
complexTypeObj.getName());
/*
* if(complexTypeObj.annotation != null){ Element annotationEl =
serializeAnnotation(doc,
* complexTypeObj.annotation, schema);
serializedComplexType.appendChild(annotationEl); }
@@ -1208,8 +1207,8 @@
Element group = createNewElement(doc, "group",
schema.schemaNamespacePrefix, XmlSchema.SCHEMA_NS);
- if (groupObj.name != null) {
- String grpName = groupObj.name.getLocalPart();
+ if (!groupObj.isAnonymous()) {
+ String grpName = groupObj.getName();
if (grpName.length() > 0) {
group.setAttribute("name", grpName);
}
@@ -1921,8 +1920,8 @@
if (simpleTypeObj.getId() != null) {
serializedSimpleType.setAttribute("id", simpleTypeObj.getId());
}
- if (simpleTypeObj.name != null && !simpleTypeObj.name.equals("")) {
- serializedSimpleType.setAttribute("name", simpleTypeObj.name);
+ if (!simpleTypeObj.isAnonymous()) {
+ serializedSimpleType.setAttribute("name", simpleTypeObj.getName());
}
if (simpleTypeObj.getAnnotation() != null) {
Element annotationEl = serializeAnnotation(doc,
simpleTypeObj.getAnnotation(), schema);
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
Wed Jan 7 12:04:05 2009
@@ -31,8 +31,8 @@
/**
* Creates new XmlSchemaSimpleType
*/
- public XmlSchemaSimpleType(XmlSchema schema) {
- super(schema);
+ public XmlSchemaSimpleType(XmlSchema schema, boolean topLevel) {
+ super(schema, topLevel);
}
public XmlSchemaSimpleTypeContent getContent() {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
Wed Jan 7 12:04:05 2009
@@ -21,12 +21,15 @@
import javax.xml.namespace.QName;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamed;
+import org.apache.ws.commons.schema.utils.XmlSchemaNamedImpl;
+
/**
* The base class for all simple types and complex types.
*/
-public class XmlSchemaType extends XmlSchemaAnnotated {
+public abstract class XmlSchemaType extends XmlSchemaAnnotated implements
XmlSchemaNamed {
Object baseSchemaType;
XmlSchemaDerivationMethod deriveBy;
@@ -34,16 +37,13 @@
XmlSchemaDerivationMethod finalResolved;
boolean isMixed;
- // name of the type
- String name;
-
- XmlSchema schema;
+ private XmlSchemaNamedImpl namedDelegate;
/**
* Creates new XmlSchemaType
*/
- public XmlSchemaType(XmlSchema schema) {
- this.schema = schema;
+ protected XmlSchemaType(XmlSchema schema, boolean topLevel) {
+ namedDelegate = new XmlSchemaNamedImpl(schema, topLevel);
finalDerivation = XmlSchemaDerivationMethod.NONE;
}
@@ -91,29 +91,40 @@
this.isMixed = isMixedValue;
}
+ public String toString() {
+ if (getName() == null) {
+ return super.toString() + "[anonymous]";
+ } else if (namedDelegate.getParent().logicalTargetNamespace == null) {
+ return super.toString() + "[{}" + getName() + "]";
+
+ } else {
+ return super.toString()
+ + "[{" + namedDelegate.getParent().logicalTargetNamespace +
"}"
+ + getName() + "]";
+ }
+ }
+
public String getName() {
- return name;
+ return namedDelegate.getName();
}
- public void setName(String name) {
- this.name = name;
+ public XmlSchema getParent() {
+ return namedDelegate.getParent();
}
public QName getQName() {
- if (name == null) {
- return null;
- }
- return new QName(schema.logicalTargetNamespace, name);
+ return namedDelegate.getQName();
}
- public String toString() {
- if (name == null) {
- return super.toString() + "[anonymous]";
- } else if (schema.logicalTargetNamespace == null) {
- return super.toString() + "[{}" + name + "]";
+ public boolean isAnonymous() {
+ return namedDelegate.isAnonymous();
+ }
- } else {
- return super.toString() + "[{" + schema.logicalTargetNamespace +
"}" + name + "]";
- }
+ public boolean isTopLevel() {
+ return namedDelegate.isTopLevel();
+ }
+
+ public void setName(String name) {
+ namedDelegate.setName(name);
}
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XmlSchemaRef.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XmlSchemaRef.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XmlSchemaRef.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XmlSchemaRef.java
Wed Jan 7 12:04:05 2009
@@ -45,6 +45,7 @@
}
public T getTarget() {
+
if (targetObject == null) {
Class<?> cls = targetClass;
XmlSchemaCollection parentCollection = parent.getParent();
Modified:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeGroupTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeGroupTest.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeGroupTest.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeGroupTest.java
Wed Jan 7 12:04:05 2009
@@ -104,7 +104,7 @@
for (Iterator i = attG.getValues(); i.hasNext();) {
Object obj1 = i.next();
if (obj1 instanceof XmlSchemaAttributeGroup) {
- assertEquals("department",
((XmlSchemaAttributeGroup)obj1).getName().getLocalPart());
+ assertEquals("department",
((XmlSchemaAttributeGroup)obj1).getName());
XmlSchemaObjectCollection attributes =
((XmlSchemaAttributeGroup)obj1).getAttributes();
assertNotNull(attributes);
assertEquals(2, attributes.getCount());
Modified:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java
Wed Jan 7 12:04:05 2009
@@ -101,7 +101,7 @@
assertTrue("The set should have been empty, but instead contained: " +
s + ".", s.isEmpty());
assertNotNull(xsg);
- assertEquals("priceGroup", xsg.getName().getLocalPart());
+ assertEquals("priceGroup", xsg.getName());
XmlSchemaChoice xsc = (XmlSchemaChoice)xsg.getParticle();
assertNotNull(xsc);
Modified:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java?rev=732455&r1=732454&r2=732455&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
Wed Jan 7 12:04:05 2009
@@ -311,7 +311,7 @@
}
assertNotNull(xsag);
- assertEquals("AttribGroup", xsag.getName().getLocalPart());
+ assertEquals("AttribGroup", xsag.getName());
xsoc = xsag.getAttributes();
Set<String> s = new HashSet<String>();