diff options
author | pfullbright | 2011-06-30 18:50:04 +0000 |
---|---|---|
committer | pfullbright | 2011-06-30 18:50:04 +0000 |
commit | 2ca8086206c741b8f60c606ceb195a32fff19869 (patch) | |
tree | 0e39dabb3775e6b5281d48f62ec6ac4f548f7fed | |
parent | c6be1d89411f9ea8b96839699a4a02fe97d07b60 (diff) | |
download | webtools.dali-2ca8086206c741b8f60c606ceb195a32fff19869.tar.gz webtools.dali-2ca8086206c741b8f60c606ceb195a32fff19869.tar.xz webtools.dali-2ca8086206c741b8f60c606ceb195a32fff19869.zip |
added schema component ref impl for @XmlSchemaType
7 files changed, 196 insertions, 256 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchemaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchemaType.java index f2fb6625ab..20ed1b56de 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchemaType.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchemaType.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.core.context; import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode; import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; +import org.eclipse.xsd.util.XSDUtil; /** * @@ -25,35 +26,17 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; * @since 3.0 */ public interface XmlSchemaType - extends - JavaContextNode -{ - - XmlSchemaTypeAnnotation getResourceXmlSchemaType(); - - - /**************** name *****************/ - - String getName(); - void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - - - /**************** namespace *****************/ - - /** - * Corresponds to the XmlSchemaType annotation 'namespace' element - */ - String getNamespace(); - String getDefaultNamespace(); - String getSpecifiedNamespace(); - void setSpecifiedNamespace(String namespace); - String SPECIFIED_NAMESPACE_PROPERTY = "namespace"; //$NON-NLS-1$ - String DEFAULT_NAMESPACE = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$ - - + extends JavaContextNode { + + String DEFAULT_NAMESPACE = XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001; + + XmlSchemaTypeAnnotation getXmlSchemaTypeAnnotation(); + + JaxbSchemaComponentRef getSchemaTypeRef(); + + /**************** type *****************/ - + /** * Corresponds to the XmlSchemaType annotation 'type' element */ diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaContainmentMappingXmlSchemaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaContainmentMappingXmlSchemaType.java index a423ecc3a0..a5da767391 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaContainmentMappingXmlSchemaType.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaContainmentMappingXmlSchemaType.java @@ -16,9 +16,8 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; public class GenericJavaContainmentMappingXmlSchemaType - extends GenericJavaXmlSchemaType -{ - + extends GenericJavaXmlSchemaType { + public GenericJavaContainmentMappingXmlSchemaType(JaxbContainmentMapping parent, XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation) { super(parent, xmlSchemaTypeAnnotation); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java index 06022fb034..0f4e6c3c4b 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java @@ -336,6 +336,10 @@ public class GenericJavaPackageInfo this.xmlSchema.validate(messages, reporter, astRoot); + for (XmlSchemaType schemaType : getXmlSchemaTypes()) { + schemaType.validate(messages, reporter, astRoot); + } + for (XmlJavaTypeAdapter adapter : getXmlJavaTypeAdapters()) { adapter.validate(messages, reporter, astRoot); } @@ -362,7 +366,7 @@ public class GenericJavaPackageInfo } @Override protected XmlSchemaTypeAnnotation getResourceElement(XmlSchemaType contextElement) { - return contextElement.getResourceXmlSchemaType(); + return contextElement.getXmlSchemaTypeAnnotation(); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchemaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchemaType.java index a9d0c4dabc..e2e667ee78 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchemaType.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchemaType.java @@ -14,183 +14,188 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.common.utility.Filter; import org.eclipse.jpt.common.utility.internal.CollectionTools; +import org.eclipse.jpt.common.utility.internal.StringTools; import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; import org.eclipse.jpt.jaxb.core.context.JaxbContextNode; import org.eclipse.jpt.jaxb.core.context.JaxbPackage; +import org.eclipse.jpt.jaxb.core.context.JaxbSchemaComponentRef; import org.eclipse.jpt.jaxb.core.context.XmlSchemaType; +import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode; +import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages; +import org.eclipse.jpt.jaxb.core.resource.java.SchemaComponentRefAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; import org.eclipse.jpt.jaxb.core.xsd.XsdSchema; +import org.eclipse.jpt.jaxb.core.xsd.XsdTypeDefinition; import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.xsd.util.XSDUtil; public abstract class GenericJavaXmlSchemaType extends AbstractJavaContextNode implements XmlSchemaType { - protected final XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation; + protected final XmlSchemaTypeAnnotation annotation; - protected String name; - - protected String specifiedNamespace; + protected JaxbSchemaComponentRef schemaTypeRef; protected String type; - protected GenericJavaXmlSchemaType(JaxbContextNode parent, XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation) { + protected GenericJavaXmlSchemaType(JaxbContextNode parent, XmlSchemaTypeAnnotation annotation) { super(parent); - this.xmlSchemaTypeAnnotation = xmlSchemaTypeAnnotation; - this.name = this.getResourceName(); - this.specifiedNamespace = this.getResourceNamespace(); + this.annotation = annotation; + this.schemaTypeRef = buildSchemaTypeRef(); this.type = this.getResourceTypeString(); } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setName_(this.getResourceName()); - this.setNamespace_(this.getResourceNamespace()); - this.setType_(this.getResourceTypeString()); - } - - - // ********** xml schema type annotation ********** - - public XmlSchemaTypeAnnotation getResourceXmlSchemaType() { - return this.xmlSchemaTypeAnnotation; - } - - // ********** name ********** - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.xmlSchemaTypeAnnotation.setName(name); - this.setName_(name); - } - - protected void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - protected String getResourceName() { - return this.xmlSchemaTypeAnnotation.getName(); - } - - // ********** namespace ********** - - public String getNamespace() { - return getSpecifiedNamespace() == null ? getDefaultNamespace() : getSpecifiedNamespace(); - } - public String getDefaultNamespace() { - return XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001; + + protected JaxbSchemaComponentRef buildSchemaTypeRef() { + return new XmlSchemaTypeRef(this); } - public String getSpecifiedNamespace() { - return this.specifiedNamespace; + public JaxbSchemaComponentRef getSchemaTypeRef() { + return this.schemaTypeRef; } - public void setSpecifiedNamespace(String location) { - this.xmlSchemaTypeAnnotation.setNamespace(location); - this.setNamespace_(location); + public XmlSchemaTypeAnnotation getXmlSchemaTypeAnnotation() { + return this.annotation; } + + protected abstract JaxbPackage getJaxbPackage(); + - protected void setNamespace_(String namespace) { - String old = this.specifiedNamespace; - this.specifiedNamespace = namespace; - this.firePropertyChanged(SPECIFIED_NAMESPACE_PROPERTY, old, namespace); + // ********** synchronize/update ********** + + @Override + public void synchronizeWithResourceModel() { + super.synchronizeWithResourceModel(); + this.schemaTypeRef.synchronizeWithResourceModel(); + this.setType_(this.getResourceTypeString()); } - protected String getResourceNamespace() { - return this.xmlSchemaTypeAnnotation.getNamespace(); + @Override + public void update() { + super.update(); + this.schemaTypeRef.update(); } // ********** type ********** - + public String getType() { return this.type; } - + public void setType(String location) { - this.xmlSchemaTypeAnnotation.setType(location); + this.annotation.setType(location); this.setType_(location); } - + protected void setType_(String type) { String old = this.type; this.type = type; this.firePropertyChanged(TYPE_PROPERTY, old, type); } - + protected String getResourceTypeString() { - return this.xmlSchemaTypeAnnotation.getType(); + return this.annotation.getType(); } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - } - - @Override - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.xmlSchemaTypeAnnotation.getTextRange(astRoot); - } - - - // *********** content assist *********** - + + + // ***** content assist ***** + @Override - public Iterable<String> getJavaCompletionProposals( - int pos, Filter<String> filter, CompilationUnit astRoot) { + public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); if (! CollectionTools.isEmpty(result)) { return result; } - if (namespaceTouches(pos, astRoot)) { - return getNamespaceProposals(filter); - } - - if (nameTouches(pos, astRoot)) { - return getNameProposals(filter); + result = this.schemaTypeRef.getJavaCompletionProposals(pos, filter, astRoot); + if (! CollectionTools.isEmpty(result)) { + return result; } return EmptyIterable.instance(); } - protected boolean namespaceTouches(int pos, CompilationUnit astRoot) { - return getResourceXmlSchemaType().namespaceTouches(pos, astRoot); - } - protected Iterable<String> getNamespaceProposals(Filter<String> filter) { - XsdSchema schema = getJaxbPackage().getXsdSchema(); - if (schema == null) { - return EmptyIterable.instance(); - } - return schema.getNamespaceProposals(filter); + // ***** validation ***** + + @Override + public TextRange getValidationTextRange(CompilationUnit astRoot) { + return this.annotation.getTextRange(astRoot); } - protected boolean nameTouches(int pos, CompilationUnit astRoot) { - return getResourceXmlSchemaType().nameTouches(pos, astRoot); + @Override + public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + super.validate(messages, reporter, astRoot); + + this.schemaTypeRef.validate(messages, reporter, astRoot); } - protected Iterable<String> getNameProposals(Filter<String> filter) { - XsdSchema schema = getJaxbPackage().getXsdSchema(); - if (schema == null) { - return EmptyIterable.instance(); + + protected class XmlSchemaTypeRef + extends AbstractJavaSchemaComponentRef { + + protected XmlSchemaTypeRef(JavaContextNode parent) { + super(parent); + } + + + @Override + protected SchemaComponentRefAnnotation getAnnotation(boolean createIfNull) { + // never null + return GenericJavaXmlSchemaType.this.annotation; + } + + @Override + protected String getSchemaComponentTypeDescription() { + return JptJaxbCoreMessages.XML_TYPE_DESC; + } + + @Override + public String getDefaultName() { + return null; + } + + @Override + public String getDefaultNamespace() { + return XmlSchemaType.DEFAULT_NAMESPACE; + } + + @Override + protected Iterable<String> getNamespaceProposals(Filter<String> filter) { + XsdSchema schema = GenericJavaXmlSchemaType.this.getJaxbPackage().getXsdSchema(); + if (schema == null) { + return EmptyIterable.instance(); + } + return schema.getNamespaceProposals(filter); + } + + @Override + protected Iterable<String> getNameProposals(Filter<String> filter) { + XsdSchema schema = GenericJavaXmlSchemaType.this.getJaxbPackage().getXsdSchema(); + if (schema == null) { + return EmptyIterable.instance(); + } + return schema.getSimpleTypeNameProposals(getNamespace(), filter); + } + + @Override + protected void validateSchemaComponentRef(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + String name = getName(); + String namespace = getNamespace(); + + if (! StringTools.stringIsEmpty(name)) { + XsdSchema schema = GenericJavaXmlSchemaType.this.getJaxbPackage().getXsdSchema(); + + if (schema != null) { + XsdTypeDefinition schemaType = schema.getTypeDefinition(namespace, name); + if (schemaType == null) { + messages.add(getUnresolveSchemaComponentMessage(astRoot)); + } + } + } } - return schema.getSimpleTypeNameProposals(getNamespace(), filter); } - - protected abstract JaxbPackage getJaxbPackage(); - } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypeAnnotation.java index c953f37d8b..8a287a405a 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypeAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypeAnnotation.java @@ -27,60 +27,9 @@ import org.eclipse.jpt.common.core.utility.TextRange; * @since 3.0 */ public interface XmlSchemaTypeAnnotation - extends NestableAnnotation { + extends SchemaComponentRefAnnotation, NestableAnnotation { String ANNOTATION_NAME = JAXB.XML_SCHEMA_TYPE; - - /** - * Corresponds to the 'name' element of the XmlSchemaType annotation. - * Return null if the element does not exist in Java. - */ - String getName(); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - - /** - * Corresponds to the 'name' element of the XmlSchemaType annotation. - * Set to null to remove the element. - */ - void setName(String name); - - /** - * Return the {@link TextRange} for the 'name' element. If the element - * does not exist return the {@link TextRange} for the XmlSchemaType annotation. - */ - TextRange getNameTextRange(CompilationUnit astRoot); - - /** - * Return whether the specified position touches the 'name' element. - * Return false if the element does not exist. - */ - boolean nameTouches(int pos, CompilationUnit astRoot); - - /** - * Corresponds to the 'namespace' element of the XmlSchemaType annotation. - * Return null if the element does not exist in Java. - */ - String getNamespace(); - String NAMESPACE_PROPERTY = "namespace"; //$NON-NLS-1$ - - /** - * Corresponds to the 'namespace' element of the XmlSchemaType annotation. - * Set to null to remove the element. - */ - void setNamespace(String namespace); - - /** - * Return the {@link TextRange} for the 'namespace' element. If the element - * does not exist return the {@link TextRange} for the XmlSchemaType annotation. - */ - TextRange getNamespaceTextRange(CompilationUnit astRoot); - - /** - * Return whether the specified position touches the 'namespace' element. - * Return false if the element does not exist. - */ - boolean namespaceTouches(int pos, CompilationUnit astRoot); - /** * Corresponds to the 'type' element of the XmlSchemaType annotation. * Return null if the element does not exist in Java. diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java index 932d1495fe..84b505a456 100644 --- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java +++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java @@ -213,8 +213,8 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); } @@ -253,10 +253,10 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase this.createPackageInfoWithAccessorType(); JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - - contextPackageInfo.addXmlSchemaType(0).setName("bar"); - contextPackageInfo.addXmlSchemaType(0).setName("foo"); - contextPackageInfo.addXmlSchemaType(0).setName("baz"); + + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("bar"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("foo"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("baz"); Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage); @@ -278,9 +278,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - contextPackageInfo.addXmlSchemaType(0).setName("bar"); - contextPackageInfo.addXmlSchemaType(1).setName("foo"); - contextPackageInfo.addXmlSchemaType(0).setName("baz"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("bar"); + contextPackageInfo.addXmlSchemaType(1).getSchemaTypeRef().setSpecifiedName("foo"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("baz"); Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage); @@ -295,9 +295,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - contextPackageInfo.addXmlSchemaType(0).setName("bar"); - contextPackageInfo.addXmlSchemaType(1).setName("foo"); - contextPackageInfo.addXmlSchemaType(2).setName("baz"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("bar"); + contextPackageInfo.addXmlSchemaType(1).getSchemaTypeRef().setSpecifiedName("foo"); + contextPackageInfo.addXmlSchemaType(2).getSchemaTypeRef().setSpecifiedName("baz"); Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage); assertEquals("bar", xmlSchemaTypes.next().getName()); @@ -327,9 +327,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - contextPackageInfo.addXmlSchemaType(0).setName("bar"); - contextPackageInfo.addXmlSchemaType(1).setName("foo"); - contextPackageInfo.addXmlSchemaType(2).setName("baz"); + contextPackageInfo.addXmlSchemaType(0).getSchemaTypeRef().setSpecifiedName("bar"); + contextPackageInfo.addXmlSchemaType(1).getSchemaTypeRef().setSpecifiedName("foo"); + contextPackageInfo.addXmlSchemaType(2).getSchemaTypeRef().setSpecifiedName("baz"); Iterator<XmlSchemaTypeAnnotation> xmlSchemaTypes = this.getSchemaTypeAnnotations(resourcePackage); assertEquals("bar", xmlSchemaTypes.next().getName()); @@ -373,9 +373,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -387,9 +387,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -401,9 +401,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -415,8 +415,8 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -428,7 +428,7 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -461,7 +461,7 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); ListIterator<XmlSchemaType> xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); @@ -475,8 +475,8 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); //add 1 XmlSchemaType when a container annotations exists @@ -489,9 +489,9 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); //add 1 XmlSchemaType to beginning of list when a container annotations exists @@ -504,10 +504,10 @@ public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase xmlSchemaTypes = contextPackageInfo.getXmlSchemaTypes(); xmlSchemaTypesIterator = xmlSchemaTypes.iterator(); assertTrue(xmlSchemaTypesIterator.hasNext()); - assertEquals("foobaz", xmlSchemaTypesIterator.next().getName()); - assertEquals("bar", xmlSchemaTypesIterator.next().getName()); - assertEquals("foo", xmlSchemaTypesIterator.next().getName()); - assertEquals("baz", xmlSchemaTypesIterator.next().getName()); + assertEquals("foobaz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("bar", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("foo", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); + assertEquals("baz", xmlSchemaTypesIterator.next().getSchemaTypeRef().getName()); assertFalse(xmlSchemaTypesIterator.hasNext()); } diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java index c4f7022a54..74d59c14b5 100644 --- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java +++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSchemaTypeTests.java @@ -47,18 +47,18 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - assertNull(contextXmlSchemaType.getName()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getName()); - contextXmlSchemaType.setName("foo"); + contextXmlSchemaType.getSchemaTypeRef().setSpecifiedName("foo"); XmlSchemaTypeAnnotation schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, XmlSchemaTypeAnnotation.ANNOTATION_NAME); assertEquals("foo", schemaTypeAnnotation.getName()); - assertEquals("foo", contextXmlSchemaType.getName()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getName()); //verify the xml schema type annotation is not removed when the name is set to null - contextXmlSchemaType.setName(null); + contextXmlSchemaType.getSchemaTypeRef().setSpecifiedName(null); schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, XmlSchemaTypeAnnotation.ANNOTATION_NAME); assertNull(schemaTypeAnnotation.getName()); - assertNull(contextXmlSchemaType.getName()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getName()); } public void testUpdateName() throws Exception { @@ -67,7 +67,7 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - assertNull(contextXmlSchemaType.getName()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getName()); //add a name member value pair AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage); @@ -76,7 +76,7 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase GenericJavaXmlSchemaTypeTests.this.addXmlSchemaTypeMemberValuePair(declaration, JAXB.XML_SCHEMA_TYPE__NAME, "foo"); } }); - assertEquals("foo", contextXmlSchemaType.getName()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getName()); annotatedElement.edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { @@ -92,22 +92,22 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - assertNull(contextXmlSchemaType.getSpecifiedNamespace()); - assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getDefaultNamespace()); - assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getNamespace()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getSpecifiedNamespace()); + assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getSchemaTypeRef().getDefaultNamespace()); + assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getSchemaTypeRef().getNamespace()); - contextXmlSchemaType.setSpecifiedNamespace("foo"); + contextXmlSchemaType.getSchemaTypeRef().setSpecifiedNamespace("foo"); XmlSchemaTypeAnnotation schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, XmlSchemaTypeAnnotation.ANNOTATION_NAME); assertEquals("foo", schemaTypeAnnotation.getNamespace()); - assertEquals("foo", contextXmlSchemaType.getSpecifiedNamespace()); - assertEquals("foo", contextXmlSchemaType.getNamespace()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getSpecifiedNamespace()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getNamespace()); //verify the xml schema type annotation is not removed when the namespace is set to null - contextXmlSchemaType.setSpecifiedNamespace(null); + contextXmlSchemaType.getSchemaTypeRef().setSpecifiedNamespace(null); schemaTypeAnnotation = (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, XmlSchemaTypeAnnotation.ANNOTATION_NAME); assertNull(schemaTypeAnnotation.getNamespace()); - assertNull(contextXmlSchemaType.getSpecifiedNamespace()); - assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getNamespace()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getSpecifiedNamespace()); + assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getSchemaTypeRef().getNamespace()); } public void testUpdateNamespace() throws Exception { @@ -116,9 +116,9 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase XmlSchemaType contextXmlSchemaType = contextPackageInfo.getXmlSchemaTypes().iterator().next(); JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage(); - assertNull(contextXmlSchemaType.getSpecifiedNamespace()); - assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getDefaultNamespace()); - assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getNamespace()); + assertNull(contextXmlSchemaType.getSchemaTypeRef().getSpecifiedNamespace()); + assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getSchemaTypeRef().getDefaultNamespace()); + assertEquals(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001, contextXmlSchemaType.getSchemaTypeRef().getNamespace()); //add a namespace member value pair AnnotatedElement annotatedElement = this.annotatedElement(resourcePackage); @@ -127,8 +127,8 @@ public class GenericJavaXmlSchemaTypeTests extends JaxbContextModelTestCase GenericJavaXmlSchemaTypeTests.this.addXmlSchemaTypeMemberValuePair(declaration, JAXB.XML_SCHEMA_TYPE__NAMESPACE, "foo"); } }); - assertEquals("foo", contextXmlSchemaType.getSpecifiedNamespace()); - assertEquals("foo", contextXmlSchemaType.getNamespace()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getSpecifiedNamespace()); + assertEquals("foo", contextXmlSchemaType.getSchemaTypeRef().getNamespace()); annotatedElement.edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { |