Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2011-10-11 20:42:32 +0000
committerpfullbright2011-10-11 20:42:32 +0000
commitf48e5b68979d6e8c127590e69ddd2b0330945356 (patch)
tree01c2bd776143d009f81569817963537687828bee
parent9eca03ee893093bdb8c9dd422845e1b9721e76d2 (diff)
downloadwebtools.dali-f48e5b68979d6e8c127590e69ddd2b0330945356.tar.gz
webtools.dali-f48e5b68979d6e8c127590e69ddd2b0330945356.tar.xz
webtools.dali-f48e5b68979d6e8c127590e69ddd2b0330945356.zip
refactored JaxbPersistentType/TransientType/Registry to JaxbType, JaxbTypeMapping (with xml transient flag), XmlRegistry, XmlJavaTypeAdapter
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java63
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java24
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbBasicMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClass.java40
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java117
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java87
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnum.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientClass.java)21
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnumMapping.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentEnum.java)52
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentAttribute.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java80
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentType.java96
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java77
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java85
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java35
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java33
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptable.java20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptableMapping.java22
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdapter.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyAttributeMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyElementMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElement.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementMapping.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRef.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefs.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementWrapper.java27
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlJavaTypeAdapter.java48
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRegistry.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRegistry.java)30
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRootElement.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSeeAlso.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlValueMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java68
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextRoot.java283
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaElementQName.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaPersistentType.java453
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java213
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java475
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaXmlJavaTypeAdapter.java186
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/FieldAccessor.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeMappingXmlSchemaType.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapter.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributesContainer.java20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaBasicMapping.java152
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java846
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java36
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumConstant.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumMapping.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentEnum.java)148
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbClass.java141
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbEnum.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java9
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageXmlJavaTypeAdapter.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentAttribute.java25
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java811
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientClass.java237
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTypeXmlJavaTypeAdapter.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdaptable.java127
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdapter.java131
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java140
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java102
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java35
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java97
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefs.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java91
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java23
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java92
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlIDREF.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaRegistry.java)68
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRootElement.java30
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSeeAlso.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java144
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/PropertyAccessor.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_class.gif (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_class.gif)bin1005 -> 1005 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_enum.gif (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_enum.gif)bin981 -> 981 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_registry.gif (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif)bin1010 -> 1010 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_transient_class.gif (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/transient_class.gif)bin1007 -> 1007 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java9
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemContentProvider.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java)53
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemLabelProvider.java131
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemContentProvider.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java)32
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemLabelProvider.java113
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java34
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java303
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java32
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java62
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java (renamed from jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java)1494
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java183
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java34
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java375
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java25
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentEnumTests.java740
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java38
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java51
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java112
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java62
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java270
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java142
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java207
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java128
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java56
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java43
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java39
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java17
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java15
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java5
119 files changed, 5989 insertions, 5414 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
index 67583d644f..c97623657c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
@@ -20,17 +20,17 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.context.Accessor;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
@@ -39,6 +39,7 @@ import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.context.XmlSchema;
import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
@@ -104,38 +105,38 @@ public interface JaxbFactory {
JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage);
- JaxbRegistry buildRegistry(JaxbContextRoot parent, JavaResourceType resourceType);
-
- JaxbTransientClass buildJavaTransientClass(JaxbContextRoot parent, JavaResourceType resourceType);
-
- JaxbPersistentClass buildJavaPersistentClass(JaxbContextRoot parent, JavaResourceType resourceType);
-
- JaxbPersistentEnum buildJavaPersistentEnum(JaxbContextRoot parent, JavaResourceEnum resourceEnum);
-
XmlSchema buildJavaXmlSchema(JaxbPackageInfo parent);
XmlNs buildJavaXmlNs(XmlSchema parent, XmlNsAnnotation xmlNsAnnotation);
-
- XmlRootElement buildJavaXmlRootElement(JaxbPersistentType parent, XmlRootElementAnnotation xmlRootElementAnnotation);
-
- JaxbEnumConstant buildJavaEnumConstant(JaxbPersistentEnum parent, JavaResourceEnumConstant resourceEnumConstant);
-
- JaxbElementFactoryMethod buildJavaElementFactoryMethod(JaxbRegistry parent, JavaResourceMethod resourceMethod);
-
- JaxbPersistentAttribute buildJavaPersistentAttribute(JaxbPersistentClass parent, Accessor accessor);
-
- JaxbPersistentAttribute buildJavaPersistentField(JaxbPersistentClass parent, JavaResourceField resourceField);
-
- JaxbPersistentAttribute buildJavaPersistentProperty(JaxbPersistentClass parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter);
-
+
+ JaxbClass buildJaxbClass(JaxbContextRoot parent, JavaResourceType resourceType);
+
+ JaxbEnum buildJaxbEnum(JaxbContextRoot parent, JavaResourceEnum resourceEnum);
+
+ JaxbClassMapping buildJaxbClassMapping(JaxbClass parent);
+
+ JaxbEnumMapping buildJaxbEnumMapping(JaxbEnum parent);
+
+ XmlRegistry buildXmlRegistry(JaxbClass parent);
+
+ JaxbElementFactoryMethod buildJavaElementFactoryMethod(XmlRegistry parent, JavaResourceMethod resourceMethod);
+
+ XmlRootElement buildJavaXmlRootElement(JaxbTypeMapping parent, XmlRootElementAnnotation xmlRootElementAnnotation);
+
+ JaxbPersistentAttribute buildJavaPersistentAttribute(JaxbClassMapping parent, Accessor accessor);
+
+ JaxbPersistentAttribute buildJavaPersistentField(JaxbClassMapping parent, JavaResourceField resourceField);
+
+ JaxbPersistentAttribute buildJavaPersistentProperty(JaxbClassMapping parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter);
+
JaxbAttributeMapping buildJavaNullAttributeMapping(JaxbPersistentAttribute parent);
-
+
XmlAnyAttributeMapping buildJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent);
-
+
XmlAnyElementMapping buildJavaXmlAnyElementMapping(JaxbPersistentAttribute parent);
-
+
XmlAttributeMapping buildJavaXmlAttributeMapping(JaxbPersistentAttribute parent);
-
+
XmlElementMapping buildJavaXmlElementMapping(JaxbPersistentAttribute parent);
XmlElementRefMapping buildJavaXmlElementRefMapping(JaxbPersistentAttribute parent);
@@ -147,4 +148,6 @@ public interface JaxbFactory {
JaxbAttributeMapping buildJavaXmlTransientMapping(JaxbPersistentAttribute parent);
XmlValueMapping buildJavaXmlValueMapping(JaxbPersistentAttribute parent);
+
+ JaxbEnumConstant buildJavaEnumConstant(JaxbEnumMapping parent, JavaResourceEnumConstant resourceEnumConstant);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
index a6ecc055bf..9ca79b3e2a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbAttributeMapping.java
@@ -34,19 +34,37 @@ public interface JaxbAttributeMapping
String getKey();
+
+ // ***** default *****
+
+ String DEFAULT_PROPERTY = "default"; //$NON-NLS-1$
+
/**
* Return whether the mapping is its attribute's <em>default</em> mapping
* (as opposed to its <em>specified</em> mapping).
*/
boolean isDefault();
- String DEFAULT_PROPERTY = "default"; //$NON-NLS-1$
void updateDefault();
+
+ // ***** misc *****
+
+// /**
+// * Return the (fully qualified) type of the attribute.
+// * (This is almost always the same as the base type.)
+// */
+// String getBoundTypeName();
+//
+// /**
+// * Return the (fully qualified) type that is to be associated with a schema type.
+// * (Usually the same as the base type, except when an XmlJavaTypeAdapters is used.)
+// */
+// String getValueTypeName();
+
/**
* Return all directly referenced types, fully qualified.
* (Used for constructing Jaxb context)
- * Nulls and empty strings are to be expected.
*/
- Iterable<String> getDirectlyReferencedTypeNames();
+ Iterable<String> getReferencedXmlTypeNames();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbBasicMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbBasicMapping.java
index 30bf566874..345b968e52 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbBasicMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbBasicMapping.java
@@ -22,7 +22,7 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface JaxbBasicMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
// ***** xml schema type *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClass.java
index f115e68553..6a85bf3de7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClass.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClass.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.context;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
/**
- * Represents a JAXB class.
+ * Represents a <i>class</i> in a JAXB context.
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -24,30 +24,18 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
* @since 3.0
*/
public interface JaxbClass
- extends JaxbType, XmlAccessTypeHolder, XmlAccessOrderHolder {
-
- /**
- * covariant override
- */
+ extends JaxbType {
+
+ // ***** overrides *****
+
JavaResourceType getJavaResourceType();
-
- JaxbClass getSuperClass();
- String SUPER_CLASS_PROPERTY = "superClass"; //$NON-NLS-1$
-
- /**
- * Return the persistent type's "persistence" inheritance hierarchy,
- * <em>including</em> the persistent type itself.
- * The returned iterator will return elements infinitely if the hierarchy
- * has a loop. This includes classes annotated with @XmlTransient.
- */
- Iterable<JaxbClass> getInheritanceHierarchy();
-
- /**
- * Return the persistent type's "persistence" inheritance hierarchy,
- * <em>excluding</em> the persistent type itself.
- * The returned iterator will return elements infinitely if the hierarchy
- * has a loop. This includes classes annotated with @XmlTransient.
- */
- Iterable<JaxbClass> getAncestors();
-
+
+ public JaxbClassMapping getMapping();
+
+
+ // ***** XmlRegistry *****
+
+ String XML_REGISTRY_PROPERTY = "xmlRegistry"; //$NON-NLS-1$
+
+ XmlRegistry getXmlRegistry();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java
new file mode 100644
index 0000000000..8018e07349
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbClassMapping.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.context;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
+
+
+public interface JaxbClassMapping
+ extends JaxbTypeMapping, XmlAccessTypeHolder, XmlAccessOrderHolder {
+
+ // ***** overrides *****
+
+ public JaxbClass getJaxbType();
+
+
+ // ***** XmlType.factoryClass *****
+
+ String FACTORY_CLASS_PROPERTY = "factoryClass"; //$NON-NLS-1$
+
+ /**
+ * factory class corresponds to the XmlType annotation factoryClass element
+ */
+ String getFactoryClass();
+
+ void setFactoryClass(String factoryClass);
+
+
+ // ***** XmlType.factoryMethod *****
+
+ String FACTORY_METHOD_PROPERTY = "factoryMethod"; //$NON-NLS-1$
+
+ /**
+ * factory method corresponds to the XmlType annotation factoryMethod element
+ */
+ String getFactoryMethod();
+
+ void setFactoryMethod(String factoryMethod);
+
+
+ // ***** XmlType.propOrder *****
+
+ String PROP_ORDER_LIST = "propOrder"; //$NON-NLS-1$
+
+ /**
+ * propOrder corresponds to the XmlType annotation propOrder element
+ */
+ ListIterable<String> getPropOrder();
+
+ int getPropOrderSize();
+
+ void addProp(int index, String prop);
+
+ void removeProp(int index);
+
+ void removeProp(String prop);
+
+ void moveProp(int targetIndex, int sourceIndex);
+
+
+ // ***** superclass *****
+
+ String SUPERCLASS_PROPERTY = "superclass"; //$NON-NLS-1$
+
+ JaxbClassMapping getSuperclass();
+
+
+ // ***** attributes *****
+
+ String ATTRIBUTES_COLLECTION = "attributes"; //$NON-NLS-1$
+
+ Iterable<JaxbPersistentAttribute> getAttributes();
+
+ int getAttributesSize();
+
+
+ // ***** inherited attributes *****
+
+ String INHERITED_ATTRIBUTES_COLLECTION = "inheritedAttributes"; //$NON-NLS-1$
+
+ /**
+ * Inherited attributes come from any direct superclasses that are mapped as @XmlTransient.
+ * (If there is an intervening class that is not transient, then that class will hold any
+ * inherited attributes from anything further up the hierarchy.)
+ * @see JaxbClassMapping#getSuperclass()
+ */
+ Iterable<JaxbPersistentAttribute> getInheritedAttributes();
+
+ int getInheritedAttributesSize();
+
+ /**
+ * Return true if the given attribute is one of the inherited attributes.
+ */
+ boolean isInherited(JaxbPersistentAttribute attribute);
+
+ /**
+ * Only ask this of inherited persistent attributes. Returns the simple
+ * type name of the attribute's resource type.
+ *
+ * @see JaxbPersistentAttribute#isInherited()
+ */
+ String getJavaResourceAttributeOwningTypeName(JaxbPersistentAttribute attribute);
+
+
+ // ***** misc *****
+
+ /**
+ * Return true if 1 or more attributes include the @XmlId annotation
+ */
+ boolean containsXmlId();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java
index 65cdf850ce..0c0844101d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java
@@ -28,99 +28,80 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public interface JaxbContextRoot
extends JaxbContextNode {
+ // ***** packages *****
+
+ static String PACKAGES_COLLECTION = "packages"; //$NON-NLS-1$
+
/**
* The set of packages. Includes any package with any interesting JAXB content.
*/
Iterable<JaxbPackage> getPackages();
- public final static String PACKAGES_COLLECTION = "packages"; //$NON-NLS-1$
- int getPackagesSize();
-
/**
* Return the package with the given name
*/
JaxbPackage getPackage(String packageName);
+ int getPackagesSize();
+
+
+ // ***** jaxb types *****
+
+ public final static String TYPES_COLLECTION = "types"; //$NON-NLS-1$
+
/**
* Return the set of all JAXB types within this context root.
*/
Iterable<JaxbType> getTypes();
- public final static String TYPES_COLLECTION = "types"; //$NON-NLS-1$
-
- int getTypesSize();
/**
- * Return the type with the given name
+ * Return the type with the given (fully qualified) type name
*/
JaxbType getType(String typeName);
+ int getTypesSize();
+
/**
* Return the set of types that are in the given package
*/
Iterable<JaxbType> getTypes(JaxbPackage jaxbPackage);
/**
- * The set of persistent classes. These may be explicitly or implicitly included.
+ * The set of jaxb classes. These may be explicitly or implicitly included.
*/
- Iterable<JaxbPersistentClass> getPersistentClasses();
+ Iterable<JaxbClass> getClasses();
/**
- * Return the set of persistent classes that are in the given package
- */
- Iterable<JaxbPersistentClass> getPersistentClasses(JaxbPackage jaxbPackage);
-
- /**
- * Return the persistent class with the given fully qualified name
- */
- JaxbPersistentClass getPersistentClass(String fullyQualifiedTypeName);
-
- /**
- * The set of persistent enums. These may be explicitly or implicitly included.
+ * Return the set of jaxb classes that are in the given package
*/
- Iterable<JaxbPersistentEnum> getPersistentEnums();
-
- /**
- * Return the set of persistent enums that are in the given package
- */
- Iterable<JaxbPersistentEnum> getPersistentEnums(JaxbPackage jaxbPackage);
-
- /**
- * Return the persistent enum with the given fully qualified name
- */
- JaxbPersistentEnum getPersistentEnum(String fullyQualifiedTypeName);
-
- /**
- * The set of registries.
- */
- Iterable<JaxbRegistry> getRegistries();
+ Iterable<JaxbClass> getClasses(JaxbPackage jaxbPackage);
/**
- * Return the set of registries that are in the given package
- * (There should typically be a max of 1, but there are invalid states ...)
+ * The set of jaxb enums. These may be explicitly or implicitly included.
*/
- Iterable<JaxbRegistry> getRegistries(JaxbPackage jaxbPackage);
-
+ Iterable<JaxbEnum> getEnums();
+
/**
- * The set of transient classes.
+ * Return the set of jaxb enums that are in the given package
*/
- Iterable<JaxbTransientClass> getTransientClasses();
-
+ Iterable<JaxbEnum> getEnums(JaxbPackage jaxbPackage);
+
/**
- * Return the set of transient classes that are in the given package
+ * Return the set of {@link XmlRegistry}(ie)s that are in the given package
*/
- Iterable<JaxbTransientClass> getTransientClasses(JaxbPackage jaxbPackage);
-
+ Iterable<XmlRegistry> getXmlRegistries(JaxbPackage jaxbPackage);
+
/**
- * Return the transient class with the given fully qualified name
+ * Return the {@link JaxbTypeMapping} for the given (fully qualified) type name
*/
- JaxbTransientClass getTransientClass(String fullyQualifiedTypeName);
-
-
+ JaxbTypeMapping getTypeMapping(String typeName);
+
/**
- * Return the persistent class or transient type with the given fully qualified name
+ * Return the {@link JaxbClassMapping} for the given (fully qualified) type name
*/
- JaxbClass getClass(String fullyQualifiedTypeName);
-
+ JaxbClassMapping getClassMapping(String typeName);
+
+
// **************** validation ********************************************
/**
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnum.java
index 4714a3e436..5a98a688b8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientClass.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnum.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,9 +9,10 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
+
/**
- * Represents a transient JAXB type
- * (A class with an explicit @XmlTransient annotation)
+ * Represents an <i>enum</i> in a JAXB context.
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -19,9 +20,15 @@ package org.eclipse.jpt.jaxb.core.context;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 3.0
- * @since 3.0
+ * @version 3.1
+ * @since 3.1
*/
-public interface JaxbTransientClass extends JaxbClass {
-
+public interface JaxbEnum
+ extends JaxbType {
+
+ // ***** covariant overrides *****
+
+ JavaResourceEnum getJavaResourceType();
+
+ public JaxbEnumMapping getMapping();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnumMapping.java
index 1c49ab7792..6dd9b362bd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentEnum.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbEnumMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,12 +9,8 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-
-
/**
- * Represents a JAXB persistent enum.
- * (A enum with either an explicit or implicit @XmlEnum annotation)
+ * Represents mapping metadata on an enum (specified or implied).
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -22,32 +18,28 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 3.0
- * @since 3.0
+ * @version 3.1
+ * @since 3.1
*/
-public interface JaxbPersistentEnum
- extends JaxbPersistentType {
-
- /**
- * covariant override
- */
- JavaResourceEnum getJavaResourceType();
-
- /**************** enum type *****************/
-
- /**
- * enum type corresponds to the XmlEnum annotation value element
- */
+public interface JaxbEnumMapping
+ extends JaxbTypeMapping {
+
+ // ***** XmlEnum.value *****
+
+ String ENUM_TYPE_PROPERTY = "enumType"; //$NON-NLS-1$
+
String getEnumType();
+
void setEnumType(String enumType);
- String ENUM_TYPE_PROPERTY = "enumType"; //$NON-NLS-1$
- String DEFAULT_ENUM_TYPE = "java.lang.String"; //$NON-NLS-1$
-
-
- /********** enum constants **********/
-
+
+ String DEFAULT_ENUM_TYPE = "java.lang.String"; //$NON-NLS-1$
+
+
+ // ***** enum constants *****
+
+ String ENUM_CONSTANTS_COLLECTION = "enumConstants"; //$NON-NLS-1$
+
Iterable<JaxbEnumConstant> getEnumConstants();
- int getEnumConstantsSize();
- String ENUM_CONSTANTS_COLLECTION = "enumConstants"; //$NON-NLS-1$
-
+
+ int getEnumConstantsSize();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java
index b1fa5fe6d8..739cbe8806 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -66,10 +66,10 @@ public interface JaxbPackage
boolean isEmpty();
/**
- * Return the {@link JaxbRegistry} for this package if there is one.
+ * Return the {@link XmlRegistry} for this package if there is one.
* Return *one* if there are more than one (which is an error case at any rate)
*/
- JaxbRegistry getRegistry();
+ XmlRegistry getRegistry();
/**
* Return the {@link XsdSchema} associated with this package, if there is one, null otherwise
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentAttribute.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentAttribute.java
index f97da438b6..34f8e624e7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentAttribute.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentAttribute.java
@@ -29,7 +29,7 @@ import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
public interface JaxbPersistentAttribute
extends JavaContextNode {
- JaxbPersistentClass getPersistentClass();
+ JaxbClassMapping getJaxbClassMapping();
/**
* Return true if this JaxbPersistentAttribute is inherited from one of the
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java
deleted file mode 100644
index 74331cfa72..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.core.context;
-
-/**
- * Represents a JAXB persistent class.
- * (A class with either an explicit or implicit @XmlType annotation)
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JaxbPersistentClass
- extends JaxbPersistentType, JaxbClass, XmlAdaptable {
-
- // ******** see also ************
-
- String XML_SEE_ALSO_PROPERTY = "xmlSeeAlso"; //$NON-NLS-1$
-
- XmlSeeAlso getXmlSeeAlso();
-
- XmlSeeAlso addXmlSeeAlso();
-
- void removeXmlSeeAlso();
-
-
- /********** attributes **********/
-
- Iterable<JaxbPersistentAttribute> getAttributes();
- int getAttributesSize();
- String ATTRIBUTES_COLLECTION = "attributes"; //$NON-NLS-1$
-
-
- /********** inherited attributes **********/
-
- /**
- * Inherited attributes come from any superclasses that are mapped as @XmlTransient.
- * @see JaxbClass#getSuperClass()
- * @see JaxbClass#getInheritanceHierarchy()
- */
- Iterable<JaxbPersistentAttribute> getInheritedAttributes();
- int getInheritedAttributesSize();
- String INHERITED_ATTRIBUTES_COLLECTION = "inheritedAttributes"; //$NON-NLS-1$
-
-
- /**
- * Return true if the given attribute is one of the inherited attributes.
- */
- boolean isInherited(JaxbPersistentAttribute attribute);
-
- /**
- * Only ask this of inherited persistent attributes. Returns the simple
- * type name of the attribute's resource type.
- *
- * @see JaxbPersistentAttribute#isInherited()
- */
- String getJavaResourceAttributeOwningTypeName(JaxbPersistentAttribute attribute);
-
- /**
- * Return true if 1 or more attributes include the @XmlId annotation
- */
- boolean containsXmlId();
-
- /**
- * Return true if this class or a subclass has a root element defined
- */
- boolean hasRootElementInHierarchy();
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentType.java
deleted file mode 100644
index 674d654b21..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentType.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.core.context;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.jaxb.core.xsd.XsdTypeDefinition;
-
-/**
- * Represents a JAXB persistent type (class or enum).
- * (A class with either an explicit or implicit @XmlType annotation)
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JaxbPersistentType
- extends JaxbType {
-
- // ***** qname *****
-
- JaxbQName getQName();
-
-
- // **************** factory class *****************/
-
- /**
- * factory class corresponds to the XmlType annotation factoryClass element
- */
- String getFactoryClass();
- void setFactoryClass(String factoryClass);
- String FACTORY_CLASS_PROPERTY = "factoryClass"; //$NON-NLS-1$
-
-
- // **************** factory method *****************/
-
- /**
- * factory method corresponds to the XmlType annotation factoryMethod element
- */
- String getFactoryMethod();
- void setFactoryMethod(String factoryMethod);
- String FACTORY_METHOD_PROPERTY = "factoryMethod"; //$NON-NLS-1$
-
-
- // ********** propOrder **********/
-
- /**
- * propOrder corresponds to the XmlType annotation propOrder element
- */
- ListIterable<String> getPropOrder();
- int getPropOrderSize();
- void addProp(int index, String prop);
- void removeProp(int index);
- void removeProp(String prop);
- void moveProp(int targetIndex, int sourceIndex);
- String PROP_ORDER_LIST = "propOrder"; //$NON-NLS-1$
-
-
- // ********** root element ************
-
- /**
- * Return whether this class is a root element (has the XmlRootElement annotation)
- */
- boolean isRootElement();
-
- /**
- * Return the root element or null if it is not a root element.
- */
- XmlRootElement getRootElement();
-
- /**
- * Set the root element name, this will add the XmlRootElement annotation
- * and set its name to the specified name.
- * To remove the XmlRootElement annotation, pass in null.
- * To set the name when the class is already a root element,
- * set it directly on the XmlRootElement.
- */
- XmlRootElement setRootElement(String name);
- String ROOT_ELEMENT = "rootElement"; //$NON-NLS-1$
-
-
- // **************** misc **************************************************
-
- XsdTypeDefinition getXsdTypeDefinition();
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
index 8b80d91857..2f573931d7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
@@ -24,16 +24,46 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 3.0
- * @since 3.0
+ * @version 3.1
+ * @since 3.1
*/
public interface JaxbType
- extends JavaContextNode {
+ extends JavaContextNode, XmlAdaptable {
+
+ // ***** kind *****
+
+ Kind getKind();
+
+
+ // ***** type mapping *****
+
+ final String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$
/**
- * Return the kind of JaxbType this represents
+ * Return the mapping of this type.
+ * May be null.
+ * Will <b>not</b> be null if this type has an XmlType annotation (or other mapping annotation)
+ * or if this type is default mapped.
*/
- Kind getKind();
+ JaxbTypeMapping getMapping();
+
+
+ // ***** default mapped *****
+
+ final String DEFAULT_MAPPED_PROPERTY = "defaultMapped"; //$NON-NLS-1$
+
+ /**
+ * Return true if this type is mapped by reference.
+ * (If this type has a default mapping by virtue of it being referenced by another mapped type.)
+ */
+ boolean isDefaultMapped();
+
+ /**
+ * Set this to <code>true</code> if this type is referenced by another mapped type.
+ * (NB: should only be called by {@link JaxbContextRoot} object.)
+ */
+ void setDefaultMapped(boolean newValue);
+
/**
* Return the associated java resource type
@@ -41,10 +71,9 @@ public interface JaxbType
JavaResourceAbstractType getJavaResourceType();
/**
- * Returns the fully qualified name of this type, including qualification for any
- * enclosing types and packages.
+ * Return the name of the type without any package or type qualifiers
*/
- String getFullyQualifiedName();
+ String getSimpleName();
/**
* Returns the type-qualified name of this type, including qualification for any
@@ -53,9 +82,10 @@ public interface JaxbType
String getTypeQualifiedName();
/**
- * Return the name of the type without any package or type qualifiers
+ * Returns the fully qualified name of this type, including qualification for any
+ * enclosing types and packages.
*/
- String getSimpleName();
+ String getFullyQualifiedName();
/**
* Return the name of the type's package. Empty string if none.
@@ -71,10 +101,10 @@ public interface JaxbType
* Return all directly referenced types, fully qualified.
* (Used for constructing Jaxb context)
*/
- Iterable<String> getDirectlyReferencedTypeNames();
+ Iterable<String> getReferencedXmlTypeNames();
- // **************** validation ********************************************
+ // ****** validation *****
/**
* Add to the list of current validation messages
@@ -82,29 +112,16 @@ public interface JaxbType
void validate(List<IMessage> messages, IReporter reporter);
- /**
- * The kind of metadata specified on the java type.
- */
- public static enum Kind {
-
- /**
- * A JaxbType of {@link Kind} PERSISTENT_CLASS may safely be cast as a {@link JaxbPersistentClass}
- */
- PERSISTENT_CLASS,
-
- /**
- * A JaxbType of {@link Kind} PERSISTENT_ENUM may safely be cast as a {@link JaxbPersistentEnum}
- */
- PERSISTENT_ENUM,
+ public enum Kind {
/**
- * A JaxbType of {@link Kind} REGISTRY may safely be cast as a {@link JaxbRegistry}
+ * {@link JaxbType}s of {@link Kind} CLASS may safely be cast as {@link JaxbClass}
*/
- REGISTRY,
+ CLASS,
/**
- * A JaxbType of {@link Kind} TRANSIENT may safely be cast as a {@link JaxbTransientClass}
+ * {@link JaxbType}s of {@link Kind} ENUM may safely be cast as {@link JaxbEnum}
*/
- TRANSIENT
+ ENUM;
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java
new file mode 100644
index 0000000000..2aa4110064
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTypeMapping.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.context;
+
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
+import org.eclipse.jpt.jaxb.core.xsd.XsdTypeDefinition;
+
+/**
+ * Represents mapping metadata on a JaxbType (specified or implied).
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.1
+ * @since 3.1
+ */
+public interface JaxbTypeMapping
+ extends JavaContextNode {
+
+ // ***** JaxbType *****
+
+ JaxbType getJaxbType();
+
+
+ // ***** XmlTransient *****
+
+ String XML_TRANSIENT_PROPERTY = "xmlTransient"; //$NON-NLS-1$
+
+ boolean isXmlTransient();
+
+ void setXmlTransient(boolean newValue);
+
+
+ // ***** XmlType.name and XmlType.namespace *****
+
+ JaxbQName getQName();
+
+
+ // ***** XmlRootElement *****
+
+ String XML_ROOT_ELEMENT_PROPERTY = "xmlRootElement"; //$NON-NLS-1$
+
+ XmlRootElement getXmlRootElement();
+
+ XmlRootElement addXmlRootElement();
+
+ void removeXmlRootElement();
+
+
+ // ***** XmlSeeAlso *****
+
+ String XML_SEE_ALSO_PROPERTY = "xmlSeeAlso"; //$NON-NLS-1$
+
+ XmlSeeAlso getXmlSeeAlso();
+
+ XmlSeeAlso addXmlSeeAlso();
+
+ void removeXmlSeeAlso();
+
+
+ // ***** misc *****
+
+ /**
+ * Return all directly referenced types, fully qualified.
+ * (Used for constructing Jaxb context)
+ */
+ Iterable<String> getReferencedXmlTypeNames();
+
+ XsdTypeDefinition getXsdTypeDefinition();
+
+ /**
+ * Return true if this class or a subclass (if it can have subclasses) has a root element defined
+ */
+ boolean hasRootElementInHierarchy();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java
index 8110846e90..6fa5eae416 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,8 +11,6 @@ package org.eclipse.jpt.jaxb.core.context;
/**
- *
- *
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
* stability. It is available at this early stage to solicit feedback from
@@ -23,37 +21,36 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface XmlAccessOrderHolder
- extends JaxbContextNode
-{
+ extends JaxbContextNode {
+
/**
* Return the access order, whether specified or defaulted.
* This should never return null since at least the default will be set
*/
XmlAccessOrder getAccessOrder();
-
+
+ /**
+ * String constant associated with changes to the default access order
+ */
+ String DEFAULT_ACCESS_ORDER_PROPERTY = "defaultAccessOrder"; //$NON-NLS-1$
+
/**
* Return the default access order, never null
*/
XmlAccessOrder getDefaultAccessOrder();
-
- /**
- * String constant associated with changes to the default access order
- */
- String DEFAULT_ACCESS_ORDER_PROPERTY = "defaultAccessOrder"; //$NON-NLS-1$
-
+
+ /**
+ * String constant associated with changes to the specified access order
+ */
+ String SPECIFIED_ACCESS_ORDER_PROPERTY = "specifiedAccessOrder"; //$NON-NLS-1$
+
/**
* Return the specified access order;
*/
XmlAccessOrder getSpecifiedAccessOrder();
-
+
/**
* Set the specified access order.
*/
void setSpecifiedAccessOrder(XmlAccessOrder newSpecifiedAccessOrder);
-
- /**
- * String constant associated with changes to the specified access order
- */
- String SPECIFIED_ACCESS_ORDER_PROPERTY = "specifiedAccessOrder"; //$NON-NLS-1$
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java
index 986195e690..6a562650ca 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,8 +11,6 @@ package org.eclipse.jpt.jaxb.core.context;
/**
- *
- *
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
* stability. It is available at this early stage to solicit feedback from
@@ -23,24 +21,29 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface XmlAccessTypeHolder
- extends JaxbContextNode
-{
+ extends JaxbContextNode {
+
/**
* Return the access type, whether specified or defaulted.
* This should never return null since at least the default will be set
*/
XmlAccessType getAccessType();
-
+
+ /**
+ * String constant associated with changes to the default access type
+ */
+ String DEFAULT_ACCESS_TYPE_PROPERTY = "defaultAccessType"; //$NON-NLS-1$
+
/**
* Return the default access type, never null
*/
XmlAccessType getDefaultAccessType();
-
- /**
- * String constant associated with changes to the default access type
- */
- String DEFAULT_ACCESS_TYPE_PROPERTY = "defaultAccessType"; //$NON-NLS-1$
-
+
+ /**
+ * String constant associated with changes to the specified access type
+ */
+ String SPECIFIED_ACCESS_TYPE_PROPERTY = "specifiedAccessType"; //$NON-NLS-1$
+
/**
* Return the specified access type;
*/
@@ -50,10 +53,4 @@ public interface XmlAccessTypeHolder
* Set the specified access type.
*/
void setSpecifiedAccessType(XmlAccessType newSpecifiedAccessType);
-
- /**
- * String constant associated with changes to the specified access type
- */
- String SPECIFIED_ACCESS_TYPE_PROPERTY = "specifiedAccessType"; //$NON-NLS-1$
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptable.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptable.java
index be062894e9..1597b485f7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptable.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptable.java
@@ -9,22 +9,18 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
public interface XmlAdaptable
- extends JavaContextNode
-{
- /********** XmlJavaTypeAdapter **********/
+ extends JavaContextNode {
+
+ // ***** XmlJavaTypeAdapter *****
+
+ String XML_JAVA_TYPE_ADAPTER_PROPERTY = "xmlJavaTypeAdapter"; //$NON-NLS-1$
+
XmlJavaTypeAdapter getXmlJavaTypeAdapter();
+
XmlJavaTypeAdapter addXmlJavaTypeAdapter();
+
void removeXmlJavaTypeAdapter();
- String XML_JAVA_TYPE_ADAPTER_PROPERTY = "xmlJavaTypeAdapter"; //$NON-NLS-1$
-
- interface Owner {
- JavaResourceAnnotatedElement getResource();
- XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation);
- void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter);
- }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptableMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptableMapping.java
new file mode 100644
index 0000000000..6023533fd9
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdaptableMapping.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.context;
+
+/**
+ * Represents an attribute mapping that may also have an XmlJavaTypeAdapter
+ */
+public interface XmlAdaptableMapping extends XmlAdaptable {
+
+// /**
+// * Return either the {@link XmlAdapter} defined here or any XmlAdapter defined at a higher level
+// * that also applies here.
+// */
+// XmlAdapter getXmlAdapter();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdapter.java
new file mode 100644
index 0000000000..99fc144c4b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAdapter.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.context;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+
+/**
+ * Represents a java class used as an XmlAdapter
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.0
+ * @since 3.0
+ */
+public interface XmlAdapter
+ extends JaxbContextNode {
+
+ static String MARSHAL_METHOD_NAME = "marshal"; //$NON-NLS-1$
+
+
+ // ***** bound type *****
+
+ /**
+ * String associated with changes to the "boundType" property
+ */
+ static String BOUND_TYPE_PROPERTY = "boundType"; //$NON-NLS-1$
+
+ /**
+ * Return the fully qualified bound type name (the type used in the java model)
+ */
+ String getBoundType();
+
+
+ // ***** value type *****
+
+ /**
+ * String associated with changes to the "valueType" property
+ */
+ static String VALUE_TYPE_PROPERTY = "valueType"; //$NON-NLS-1$
+
+ /**
+ * Return the fully qualified value type name (the type that corresponds to the xml schema)
+ */
+ String getValueType();
+
+
+ // ***** misc *****
+
+ JavaResourceType getJavaResourceType();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyAttributeMapping.java
index ee6cddc2e5..d118b04ae4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyAttributeMapping.java
@@ -23,6 +23,6 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface XmlAnyAttributeMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyElementMapping.java
index 0533b8e38e..f5695b1007 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAnyElementMapping.java
@@ -23,7 +23,7 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface XmlAnyElementMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
// ***** lax *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElement.java
index cd4780f986..9cfb33f08b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElement.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElement.java
@@ -96,9 +96,10 @@ public interface XmlElement
// ***** misc *****
/**
- * Return all type names that are directly referenced (for purposes of building a JAXB context)
+ * Return all directly referenced xml types, fully qualified.
+ * (Used for constructing Jaxb context)
*/
- Iterable<String> getDirectlyReferencedTypeNames();
+ Iterable<String> getReferencedXmlTypeNames();
// ***** validation *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementMapping.java
index 3d659c0374..80661f39d4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementMapping.java
@@ -27,10 +27,13 @@ public interface XmlElementMapping
XmlElement getXmlElement();
- /********** XmlElementWrapper **********/
+ // ***** XmlElementWrapper *****
+
+ String XML_ELEMENT_WRAPPER_PROPERTY = "xmlElementWrapper"; //$NON-NLS-1$
XmlElementWrapper getXmlElementWrapper();
+
XmlElementWrapper addXmlElementWrapper();
+
void removeXmlElementWrapper();
- String XML_ELEMENT_WRAPPER_PROPERTY = "xmlElementWrapper"; //$NON-NLS-1$
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRef.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRef.java
index 0aaf6bc7f5..9a713bba4a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRef.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRef.java
@@ -72,9 +72,10 @@ public interface XmlElementRef
// ***** misc *****
/**
- * Return all type names that are directly referenced (for purposes of building a JAXB context)
+ * Return all directly referenced xml types, fully qualified.
+ * (Used for constructing Jaxb context)
*/
- Iterable<String> getDirectlyReferencedTypeNames();
+ Iterable<String> getReferencedXmlTypeNames();
// ***** validation *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java
index ebce6810a7..51c8cd587d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java
@@ -22,7 +22,7 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.1
*/
public interface XmlElementRefMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
// ***** XmlElementRef *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefs.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefs.java
index efbc6bdebc..01d8fdba14 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefs.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefs.java
@@ -36,7 +36,8 @@ public interface XmlElementRefs
// ***** misc *****
/**
- * Return all type names that are directly referenced (for purposes of building a JAXB context)
+ * Return all directly referenced xml types, fully qualified.
+ * (Used for constructing Jaxb context)
*/
- Iterable<String> getDirectlyReferencedTypeNames();
+ Iterable<String> getReferencedXmlTypeNames();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java
index 1ad02f9644..14a4a55934 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java
@@ -23,7 +23,7 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.1
*/
public interface XmlElementRefsMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
// ***** XmlElementRefs *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementWrapper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementWrapper.java
index d5e1e7fd4a..2f227762d0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementWrapper.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementWrapper.java
@@ -27,7 +27,7 @@ import org.eclipse.jpt.jaxb.core.xsd.XsdElementDeclaration;
*/
public interface XmlElementWrapper
extends JavaContextNode {
-
+
// ***** qname *****
JaxbQName getQName();
@@ -36,23 +36,34 @@ public interface XmlElementWrapper
// ***** nillable *****
boolean isNillable();
- boolean isDefaultNillable();
- boolean DEFAULT_NILLABLE = false;
+
+ String SPECIFIED_NILLABLE_PROPERTY = "specifiedNillable"; //$NON-NLS-1$
+
Boolean getSpecifiedNillable();
+
void setSpecifiedNillable(Boolean specifiedNillable);
- String SPECIFIED_NILLABLE_PROPERTY = "specifiedNillable"; //$NON-NLS-1$
+ boolean isDefaultNillable();
+
+ boolean DEFAULT_NILLABLE = false;
+
// ***** required *****
boolean isRequired();
- boolean isDefaultRequired();
- boolean DEFAULT_REQUIRED = false;
+
+ String SPECIFIED_REQUIRED_PROPERTY = "specifiedRequired"; //$NON-NLS-1$
+
Boolean getSpecifiedRequired();
+
void setSpecifiedRequired(Boolean specifiedRequired);
- String SPECIFIED_REQUIRED_PROPERTY = "specifiedRequired"; //$NON-NLS-1$
- // **************** misc **************************************************
+ boolean isDefaultRequired();
+
+ boolean DEFAULT_REQUIRED = false;
+
+
+ // ***** misc *****
XsdElementDeclaration getXsdElementDeclaration();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java
index 3cbce6b4c9..fd4bd249ee 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java
@@ -24,7 +24,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
* @since 3.1
*/
public interface XmlElementsMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
// ***** XmlElements *****
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlJavaTypeAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlJavaTypeAdapter.java
index ed84284df4..18f59e9622 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlJavaTypeAdapter.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlJavaTypeAdapter.java
@@ -27,23 +27,43 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
public interface XmlJavaTypeAdapter
extends JavaContextNode {
- XmlJavaTypeAdapterAnnotation getResourceXmlJavaTypeAdapter();
-
- /**************** value *****************/
-
+ XmlJavaTypeAdapterAnnotation getAnnotation();
+
+
+ // ***** value *****
+
+ String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
String getValue();
-
+
void setValue(String value);
- String VALUE_PROPERTY = "value"; //$NON-NLS-1$
-
- /**************** type *****************/
-
+
+ String getFullyQualifiedValue();
+
+
+ // ***** xmlAdapter *****
+
+ String XML_ADAPTER_PROPERTY = "xmlAdapter"; //$NON-NLS-1$
+
+ /**
+ * Object based on specified "value"
+ */
+ XmlAdapter getXmlAdapter();
+
+
+ // ***** type *****
+
String getType();
- String getDefaultType();
- String DEFAULT_TYPE_PROPERTY = "defaultType"; //$NON-NLS-1$
+
+ String SPECIFIED_TYPE_PROPERTY = "specifiedType"; //$NON-NLS-1$
+
String getSpecifiedType();
+
void setSpecifiedType(String type);
- String SPECIFIED_TYPE_PROPERTY = "specifiedType"; //$NON-NLS-1$
- String DEFAULT_TYPE = "javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT"; //$NON-NLS-1$
-
+
+ String DEFAULT_TYPE_PROPERTY = "defaultType"; //$NON-NLS-1$
+
+ String getDefaultType();
+
+ String DEFAULT_TYPE = "javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT"; //$NON-NLS-1$
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRegistry.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRegistry.java
index 7b6e6e582b..33b17de687 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRegistry.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,7 +9,8 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
+
/**
* Represents a JAXB registry
@@ -24,18 +25,19 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
* @version 3.0
* @since 3.0
*/
-public interface JaxbRegistry extends JaxbType {
-
- /**
- * covariant override
- */
- JavaResourceType getJavaResourceType();
-
-
- /********** element factory methods **********/
-
+public interface XmlRegistry
+ extends JavaContextNode {
+
+ // ***** element factory methods ******
+
+ String ELEMENT_FACTORY_METHODS_COLLECTION = "elementFactoryMethods"; //$NON-NLS-1$
+
Iterable<JaxbElementFactoryMethod> getElementFactoryMethods();
+
int getElementFactoryMethodsSize();
- String ELEMENT_FACTORY_METHODS_COLLECTION = "elementFactoryMethods"; //$NON-NLS-1$
-
+
+
+ // ***** misc *****
+
+ JaxbPackage getJaxbPackage();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRootElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRootElement.java
index 78b619c001..9c57969d97 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRootElement.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlRootElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -27,7 +27,7 @@ import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
public interface XmlRootElement
extends JavaContextNode {
- JaxbPersistentType getPersistentType();
+ JaxbTypeMapping getTypeMapping();
JaxbQName getQName();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSeeAlso.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSeeAlso.java
index 7a02e5f6d9..f291894fd8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSeeAlso.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSeeAlso.java
@@ -45,5 +45,9 @@ public interface XmlSeeAlso
// **************** misc **************************************************
- Iterable<String> getDirectlyReferencedTypeNames();
+ /**
+ * Return all directly referenced types, fully qualified.
+ * (Used for constructing Jaxb context)
+ */
+ Iterable<String> getReferencedXmlTypeNames();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlValueMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlValueMapping.java
index 49b7509633..3ed188f52b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlValueMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlValueMapping.java
@@ -23,6 +23,6 @@ package org.eclipse.jpt.jaxb.core.context;
* @since 3.0
*/
public interface XmlValueMapping
- extends JaxbAttributeMapping, XmlAdaptable {
+ extends JaxbAttributeMapping, XmlAdaptableMapping {
} \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
index 6193ddbf5d..2bfd9edc6e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
@@ -24,17 +24,17 @@ import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JaxbProject.Config;
import org.eclipse.jpt.jaxb.core.context.Accessor;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
@@ -43,20 +43,21 @@ import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.context.XmlSchema;
import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
import org.eclipse.jpt.jaxb.core.internal.context.GenericContextRoot;
import org.eclipse.jpt.jaxb.core.internal.context.GenericPackage;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaClassMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaElementFactoryMethod;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaEnumConstant;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaEnumMapping;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaJaxbClass;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaJaxbEnum;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaNullAttributeMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPackageInfo;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentClass;
-import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentEnum;
-import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaRegistry;
-import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaTransientClass;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAttributeMapping;
@@ -65,6 +66,7 @@ import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementRefM
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementRefsMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementsMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlNs;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlRegistry;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlRootElement;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlSchema;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlTransientMapping;
@@ -106,57 +108,57 @@ public abstract class AbstractJaxbFactory
}
- // ********** Java context nodes **********
+ // ***** Java context nodes *****
public JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage) {
return new GenericJavaPackageInfo(parent, resourcePackage);
}
- public JaxbRegistry buildRegistry(JaxbContextRoot parent, JavaResourceType resourceType) {
- return new GenericJavaRegistry(parent, resourceType);
+ public XmlSchema buildJavaXmlSchema(JaxbPackageInfo parent) {
+ return new GenericJavaXmlSchema(parent);
}
- public JaxbTransientClass buildJavaTransientClass(JaxbContextRoot parent, JavaResourceType resourceType) {
- return new GenericJavaTransientClass(parent, resourceType);
+ public XmlNs buildJavaXmlNs(XmlSchema parent, XmlNsAnnotation xmlNsAnnotation) {
+ return new GenericJavaXmlNs(parent, xmlNsAnnotation);
}
- public JaxbPersistentClass buildJavaPersistentClass(JaxbContextRoot parent, JavaResourceType resourceType) {
- return new GenericJavaPersistentClass(parent, resourceType);
+ public JaxbClass buildJaxbClass(JaxbContextRoot parent, JavaResourceType resourceType) {
+ return new GenericJavaJaxbClass(parent, resourceType);
}
- public JaxbPersistentEnum buildJavaPersistentEnum(JaxbContextRoot parent, JavaResourceEnum resourceEnum) {
- return new GenericJavaPersistentEnum(parent, resourceEnum);
+ public JaxbEnum buildJaxbEnum(JaxbContextRoot parent, JavaResourceEnum resourceEnum) {
+ return new GenericJavaJaxbEnum(parent, resourceEnum);
}
- public XmlSchema buildJavaXmlSchema(JaxbPackageInfo parent) {
- return new GenericJavaXmlSchema(parent);
+ public JaxbClassMapping buildJaxbClassMapping(JaxbClass parent) {
+ return new GenericJavaClassMapping(parent);
}
- public JaxbEnumConstant buildJavaEnumConstant(JaxbPersistentEnum parent, JavaResourceEnumConstant resourceEnumConstant) {
- return new GenericJavaEnumConstant(parent, resourceEnumConstant);
+ public JaxbEnumMapping buildJaxbEnumMapping(JaxbEnum parent) {
+ return new GenericJavaEnumMapping(parent);
}
- public XmlNs buildJavaXmlNs(XmlSchema parent, XmlNsAnnotation xmlNsAnnotation) {
- return new GenericJavaXmlNs(parent, xmlNsAnnotation);
+ public XmlRegistry buildXmlRegistry(JaxbClass parent) {
+ return new GenericJavaXmlRegistry(parent);
}
- public XmlRootElement buildJavaXmlRootElement(JaxbPersistentType parent, XmlRootElementAnnotation xmlRootElementAnnotation) {
- return new GenericJavaXmlRootElement(parent, xmlRootElementAnnotation);
+ public JaxbElementFactoryMethod buildJavaElementFactoryMethod(XmlRegistry parent, JavaResourceMethod resourceMethod) {
+ return new GenericJavaElementFactoryMethod(parent, resourceMethod);
}
- public JaxbElementFactoryMethod buildJavaElementFactoryMethod(JaxbRegistry parent, JavaResourceMethod resourceMethod) {
- return new GenericJavaElementFactoryMethod(parent, resourceMethod);
+ public XmlRootElement buildJavaXmlRootElement(JaxbTypeMapping parent, XmlRootElementAnnotation xmlRootElementAnnotation) {
+ return new GenericJavaXmlRootElement(parent, xmlRootElementAnnotation);
}
- public JaxbPersistentAttribute buildJavaPersistentAttribute(JaxbPersistentClass parent, Accessor accessor) {
+ public JaxbPersistentAttribute buildJavaPersistentAttribute(JaxbClassMapping parent, Accessor accessor) {
return new GenericJavaPersistentAttribute(parent, accessor);
}
- public JaxbPersistentAttribute buildJavaPersistentField(JaxbPersistentClass parent, JavaResourceField resourceField) {
+ public JaxbPersistentAttribute buildJavaPersistentField(JaxbClassMapping parent, JavaResourceField resourceField) {
return GenericJavaPersistentAttribute.buildPersistentField(parent, resourceField);
}
- public JaxbPersistentAttribute buildJavaPersistentProperty(JaxbPersistentClass parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) {
+ public JaxbPersistentAttribute buildJavaPersistentProperty(JaxbClassMapping parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) {
return GenericJavaPersistentAttribute.buildPersistentProperty(parent, resourceGetter, resourceSetter);
}
@@ -199,4 +201,8 @@ public abstract class AbstractJaxbFactory
public XmlValueMapping buildJavaXmlValueMapping(JaxbPersistentAttribute parent) {
return new GenericJavaXmlValueMapping(parent);
}
+
+ public JaxbEnumConstant buildJavaEnumConstant(JaxbEnumMapping parent, JavaResourceEnumConstant resourceEnumConstant) {
+ return new GenericJavaEnumConstant(parent, resourceEnumConstant);
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextRoot.java
index dc4c8ab0e3..26a40bc247 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextRoot.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextRoot.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jaxb.core.internal.context;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -30,13 +31,13 @@ import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.jaxbindex.JaxbIndexResource;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -93,16 +94,8 @@ public class AbstractJaxbContextRoot
this.packages.put(pkg, buildPackage(pkg));
}
- // process registry classes before other classes (they are completely determined by annotation)
- for (JavaResourceType registryResourceType : calculateRegistries()) {
- String className = registryResourceType.getQualifiedName();
- totalTypes.add(className);
- typesToScan.add(className);
- addType_(buildRegistry(registryResourceType));
- }
-
- // calculate initial set of persistent types (annotated with @XmlType or listed in jaxb.index files)
- final Set<JavaResourceAbstractType> resourceTypesToProcess = calculateInitialPersistentTypes();
+ // calculate initial types (annotated or listed in jaxb.index files)
+ final Set<JavaResourceAbstractType> resourceTypesToProcess = calculateInitialTypes();
// while there are resource types to process or types to scan, continue to do so
while (! resourceTypesToProcess.isEmpty() || ! typesToScan.isEmpty()) {
@@ -110,15 +103,14 @@ public class AbstractJaxbContextRoot
String className = resourceType.getQualifiedName();
totalTypes.add(className);
typesToScan.add(className);
- JaxbType.Kind jaxbTypeKind = calculateJaxbTypeKind(resourceType);
- addType_(buildType(jaxbTypeKind, resourceType));
+ addType_(buildType(resourceType));
resourceTypesToProcess.remove(resourceType);
}
for (String typeToScan : new SnapshotCloneIterable<String>(typesToScan)) {
JaxbType jaxbType = getType(typeToScan);
if (jaxbType != null) {
- for (String referencedTypeName : jaxbType.getDirectlyReferencedTypeNames()) {
+ for (String referencedTypeName : jaxbType.getReferencedXmlTypeNames()) {
if (! totalTypes.contains(referencedTypeName)) {
JavaResourceAbstractType referencedType = getJaxbProject().getJavaResourceType(referencedTypeName);
if (referencedType != null) {
@@ -179,28 +171,11 @@ public class AbstractJaxbContextRoot
}
}
- // process registry classes before other classes (they are completely determined by annotation)
- for (JavaResourceType registryResourceType : calculateRegistries()) {
- String className = registryResourceType.getQualifiedName();
- typesToRemove.remove(className);
- totalTypes.add(className);
- typesToScan.add(className);
- if (this.types.containsKey(className)) {
- if (this.types.get(className).getKind() == JaxbType.Kind.REGISTRY) {
- typesToUpdate.add(className);
- }
- else {
- this.removeType(className); // this will remove a type of another kind
- this.addType(buildRegistry(registryResourceType));
- }
- }
- else {
- this.addType(buildRegistry(registryResourceType));
- }
- }
+ // calculate initial types (annotated or listed in jaxb.index files)
+ final Set<JavaResourceAbstractType> resourceTypesToProcess = calculateInitialTypes();
- // calculate initial set of persistent types (annotated with @XmlType or listed in jaxb.index files)
- final Set<JavaResourceAbstractType> resourceTypesToProcess = calculateInitialPersistentTypes();
+ // store set of types that are referenced (and should therefore be default mapped)
+ final Set<JavaResourceAbstractType> referencedTypes = new HashSet<JavaResourceAbstractType>();
// while there are resource types to process or types to scan, continue to do so
while (! resourceTypesToProcess.isEmpty() || ! typesToScan.isEmpty()) {
@@ -209,18 +184,19 @@ public class AbstractJaxbContextRoot
typesToRemove.remove(className);
totalTypes.add(className);
typesToScan.add(className);
- processType(resourceType, typesToUpdate);
+ processType(resourceType, typesToUpdate, referencedTypes.contains(resourceType));
resourceTypesToProcess.remove(resourceType);
}
for (String typeToScan : new SnapshotCloneIterable<String>(typesToScan)) {
JaxbType jaxbType = getType(typeToScan);
if (jaxbType != null) {
- for (String referencedTypeName : jaxbType.getDirectlyReferencedTypeNames()) {
+ for (String referencedTypeName : jaxbType.getReferencedXmlTypeNames()) {
if (! StringTools.stringIsEmpty(referencedTypeName) && ! totalTypes.contains(referencedTypeName)) {
JavaResourceAbstractType referencedType = getJaxbProject().getJavaResourceType(referencedTypeName);
if (referencedType != null) {
resourceTypesToProcess.add(referencedType);
+ referencedTypes.add(referencedType);
}
}
}
@@ -286,34 +262,32 @@ public class AbstractJaxbContextRoot
}
/*
- * Calculate set of registries
- * (this should be all resource types with the @XmlRegistry annotation)
- */
- protected Set<JavaResourceType> calculateRegistries() {
- return CollectionTools.set(
- new SubIterableWrapper<JavaResourceAbstractType, JavaResourceType>(
- new FilteringIterable<JavaResourceAbstractType>(
- getJaxbProject().getJavaSourceResourceTypes()) {
- @Override
- protected boolean accept(JavaResourceAbstractType o) {
- return o.getKind() == JavaResourceAbstractType.Kind.TYPE
- && o.getAnnotation(JAXB.XML_REGISTRY) != null;
- }
- }));
- }
-
- /*
- * Calculate set of resource types annotated with @XmlType (and not @XmlRegistry)
- * plus those referred to in jaxb.index files
+ * Calculate set of initial types
+ * This should be:
+ * - all resource types with @XmlType, @XmlRootElement, or @XmlJavaTypeAdapter
+ * - all resource classes with @XmlRegistry
+ * - all resource enums with @XmlEnum
+ * - all types listed in jaxb.index files.
*/
- protected Set<JavaResourceAbstractType> calculateInitialPersistentTypes() {
+ protected Set<JavaResourceAbstractType> calculateInitialTypes() {
Set<JavaResourceAbstractType> set = CollectionTools.set(
- new FilteringIterable<JavaResourceAbstractType>(getJaxbProject().getJavaSourceResourceTypes()) {
+ new FilteringIterable<JavaResourceAbstractType>(
+ getJaxbProject().getJavaSourceResourceTypes()) {
@Override
protected boolean accept(JavaResourceAbstractType o) {
- return (o.getAnnotation(JAXB.XML_TYPE) != null
- || o.getAnnotation(JAXB.XML_ROOT_ELEMENT) != null)
- && o.getAnnotation(JAXB.XML_REGISTRY) == null;
+ if (o.getKind() == JavaResourceAbstractType.Kind.TYPE) {
+ if (o.getAnnotation(JAXB.XML_REGISTRY) != null) {
+ return true;
+ }
+ }
+ if (o.getKind() == JavaResourceAbstractType.Kind.ENUM) {
+ if (o.getAnnotation(JAXB.XML_ENUM) != null) {
+ return true;
+ }
+ }
+ return o.getAnnotation(JAXB.XML_TYPE) != null
+ || o.getAnnotation(JAXB.XML_ROOT_ELEMENT) != null
+ || o.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER) != null;
}
});
CollectionTools.addAll(
@@ -336,13 +310,15 @@ public class AbstractJaxbContextRoot
return set;
}
- protected void processType(JavaResourceAbstractType resourceType, Set<String> typesToUpdate) {
+ protected void processType(JavaResourceAbstractType resourceType, Set<String> typesToUpdate, boolean defaultMapped) {
JaxbType.Kind jaxbTypeKind = calculateJaxbTypeKind(resourceType);
String className = resourceType.getQualifiedName();
if (this.types.containsKey(className)) {
- if (this.types.get(className).getKind() == jaxbTypeKind) {
+ JaxbType type = this.types.get(className);
+ if (type.getKind() == jaxbTypeKind) {
typesToUpdate.add(className);
+ type.setDefaultMapped(defaultMapped);
return;
}
else {
@@ -350,42 +326,33 @@ public class AbstractJaxbContextRoot
}
}
- this.addType(buildType(jaxbTypeKind, resourceType));
+ JaxbType type = buildType(resourceType);
+ type.setDefaultMapped(defaultMapped);
+ this.addType(type);
}
protected JaxbType.Kind calculateJaxbTypeKind(JavaResourceAbstractType resourceType) {
if (resourceType.getKind() == JavaResourceAbstractType.Kind.ENUM) {
- return JaxbType.Kind.PERSISTENT_ENUM;
+ return JaxbType.Kind.ENUM;
}
// else is of kind TYPE
- else if (resourceType.getAnnotation(JAXB.XML_REGISTRY) != null) {
- return JaxbType.Kind.REGISTRY;
- }
- else if (resourceType.getAnnotation(JAXB.XML_TRANSIENT) != null) {
- return JaxbType.Kind.TRANSIENT;
- }
else {
- return JaxbType.Kind.PERSISTENT_CLASS;
+ return JaxbType.Kind.CLASS;
}
}
- protected JaxbType buildType(JaxbType.Kind jaxbTypeKind, JavaResourceAbstractType resourceType) {
- if (jaxbTypeKind == JaxbType.Kind.PERSISTENT_ENUM) {
- return buildPersistentEnum((JavaResourceEnum) resourceType);
- }
- else if (jaxbTypeKind == JaxbType.Kind.REGISTRY) {
- return buildRegistry((JavaResourceType) resourceType);
- }
- else if (jaxbTypeKind == JaxbType.Kind.TRANSIENT) {
- return buildTransientClass((JavaResourceType) resourceType);
+ protected JaxbType buildType(JavaResourceAbstractType resourceType) {
+ JaxbType.Kind kind = calculateJaxbTypeKind(resourceType);
+ if (kind == JaxbType.Kind.ENUM) {
+ return buildJaxbEnum((JavaResourceEnum) resourceType);
}
else {
- return buildPersistentClass((JavaResourceType) resourceType);
+ return buildJaxbClass((JavaResourceType) resourceType);
}
}
- // ********** AbstractJaxbNode overrides **********
+ // ***** AbstractJaxbNode overrides *****
@Override
public JaxbProject getJaxbProject() {
@@ -402,7 +369,7 @@ public class AbstractJaxbContextRoot
}
- // ************* packages ***************
+ // ***** packages *****
public Iterable<JaxbPackage> getPackages() {
return new LiveCloneIterable<JaxbPackage>(this.packages.values());
@@ -451,7 +418,7 @@ public class AbstractJaxbContextRoot
}
- // ********** types ***********
+ // ***** types *****
public Iterable<JaxbType> getTypes() {
return new LiveCloneIterable<JaxbType>(this.types.values());
@@ -498,140 +465,78 @@ public class AbstractJaxbContextRoot
};
}
-
- // ********** registries **********
-
- public Iterable<JaxbRegistry> getRegistries() {
- return new SubIterableWrapper<JaxbType, JaxbRegistry>(
+ public Iterable<JaxbClass> getClasses() {
+ return new SubIterableWrapper<JaxbType, JaxbClass>(
new FilteringIterable<JaxbType>(getTypes()) {
@Override
protected boolean accept(JaxbType o) {
- return o.getKind() == JaxbType.Kind.REGISTRY;
+ return o.getKind() == JaxbType.Kind.CLASS;
}
});
}
- protected JaxbRegistry buildRegistry(JavaResourceType resourceType) {
- return this.getFactory().buildRegistry(this, resourceType);
- }
-
- public Iterable<JaxbRegistry> getRegistries(final JaxbPackage jaxbPackage) {
- return new FilteringIterable<JaxbRegistry>(getRegistries()) {
- @Override
- protected boolean accept(JaxbRegistry o) {
- return o.getPackageName().equals(jaxbPackage.getName());
- }
- };
+ public Iterable<JaxbClass> getClasses(JaxbPackage jaxbPackage) {
+ return new SubIterableWrapper<JaxbType, JaxbClass>(
+ new FilteringIterable<JaxbType>(getTypes(jaxbPackage)) {
+ @Override
+ protected boolean accept(JaxbType o) {
+ return o.getKind() == JaxbType.Kind.CLASS;
+ }
+ });
}
-
-
- // ********** transient types **********
- public Iterable<JaxbTransientClass> getTransientClasses() {
- return new SubIterableWrapper<JaxbType, JaxbTransientClass>(
+ public Iterable<JaxbEnum> getEnums() {
+ return new SubIterableWrapper<JaxbType, JaxbEnum>(
new FilteringIterable<JaxbType>(getTypes()) {
@Override
protected boolean accept(JaxbType o) {
- return o.getKind() == JaxbType.Kind.TRANSIENT;
+ return o.getKind() == JaxbType.Kind.ENUM;
}
});
}
- protected JaxbTransientClass buildTransientClass(JavaResourceType resourceType) {
- return this.getFactory().buildJavaTransientClass(this, resourceType);
- }
-
- public Iterable<JaxbTransientClass> getTransientClasses(final JaxbPackage jaxbPackage) {
- return new FilteringIterable<JaxbTransientClass>(getTransientClasses()) {
- @Override
- protected boolean accept(JaxbTransientClass o) {
- return o.getPackageName().equals(jaxbPackage.getName());
- }
- };
- }
-
- public JaxbTransientClass getTransientClass(String className) {
- for (JaxbTransientClass jaxbClass : this.getTransientClasses()) {
- if (StringTools.stringsAreEqual(jaxbClass.getFullyQualifiedName(), className)) {
- return jaxbClass;
- }
- }
- return null;
- }
-
- // ********** persistent classes **********
-
- public Iterable<JaxbPersistentClass> getPersistentClasses() {
- return new SubIterableWrapper<JaxbType, JaxbPersistentClass>(
- new FilteringIterable<JaxbType>(getTypes()) {
+ public Iterable<JaxbEnum> getEnums(JaxbPackage jaxbPackage) {
+ return new SubIterableWrapper<JaxbType, JaxbEnum>(
+ new FilteringIterable<JaxbType>(getTypes(jaxbPackage)) {
@Override
protected boolean accept(JaxbType o) {
- return o.getKind() == JaxbType.Kind.PERSISTENT_CLASS;
+ return o.getKind() == JaxbType.Kind.ENUM;
}
});
}
- protected JaxbPersistentClass buildPersistentClass(JavaResourceType resourceType) {
- return this.getFactory().buildJavaPersistentClass(this, resourceType);
- }
- public Iterable<JaxbPersistentClass> getPersistentClasses(final JaxbPackage jaxbPackage) {
- return new FilteringIterable<JaxbPersistentClass>(getPersistentClasses()) {
- @Override
- protected boolean accept(JaxbPersistentClass o) {
- return o.getPackageName().equals(jaxbPackage.getName());
- }
- };
- }
-
- public JaxbPersistentClass getPersistentClass(String className) {
- for (JaxbPersistentClass jaxbClass : this.getPersistentClasses()) {
- if (StringTools.stringsAreEqual(jaxbClass.getFullyQualifiedName(), className)) {
- return jaxbClass;
- }
- }
- return null;
+ protected JaxbClass buildJaxbClass(JavaResourceType resourceType) {
+ return this.getFactory().buildJaxbClass(this, resourceType);
}
-
- public JaxbClass getClass(String fullyQualifiedTypeName) {
- JaxbPersistentClass jaxbClass= this.getPersistentClass(fullyQualifiedTypeName);
- return jaxbClass != null ? jaxbClass : this.getTransientClass(fullyQualifiedTypeName);
+
+ protected JaxbEnum buildJaxbEnum(JavaResourceEnum resourceEnum) {
+ return this.getFactory().buildJaxbEnum(this, resourceEnum);
}
-
- // ********** persistent enums **********
- public Iterable<JaxbPersistentEnum> getPersistentEnums() {
- return new SubIterableWrapper<JaxbType, JaxbPersistentEnum>(
- new FilteringIterable<JaxbType>(getTypes()) {
+ public Iterable<XmlRegistry> getXmlRegistries(JaxbPackage jaxbPackage) {
+ return new FilteringIterable<XmlRegistry>(
+ new TransformationIterable<JaxbClass, XmlRegistry>(getClasses(jaxbPackage)) {
@Override
- protected boolean accept(JaxbType o) {
- return o.getKind() == JaxbType.Kind.PERSISTENT_ENUM;
+ protected XmlRegistry transform(JaxbClass o) {
+ return o.getXmlRegistry();
}
- });
+ },
+ NotNullFilter.INSTANCE);
}
- protected JaxbPersistentEnum buildPersistentEnum(JavaResourceEnum resourceEnum) {
- return this.getFactory().buildJavaPersistentEnum(this, resourceEnum);
+ public JaxbTypeMapping getTypeMapping(String typeName) {
+ JaxbType type = getType(typeName);
+ return (type == null) ? null : type.getMapping();
}
- public Iterable<JaxbPersistentEnum> getPersistentEnums(final JaxbPackage jaxbPackage) {
- return new FilteringIterable<JaxbPersistentEnum>(getPersistentEnums()) {
- @Override
- protected boolean accept(JaxbPersistentEnum o) {
- return o.getPackageName().equals(jaxbPackage.getName());
- }
- };
- }
-
- public JaxbPersistentEnum getPersistentEnum(String enumName) {
- for (JaxbPersistentEnum jaxbEnum : this.getPersistentEnums()) {
- if (StringTools.stringsAreEqual(jaxbEnum.getFullyQualifiedName(), enumName)) {
- return jaxbEnum;
- }
- }
- return null;
+ public JaxbClassMapping getClassMapping(String typeName) {
+ JaxbType type = getType(typeName);
+ return (type == null || (type.getKind() != JaxbType.Kind.CLASS)) ?
+ null : ((JaxbClass) type).getMapping();
}
-
+
+
@Override
public void stateChanged() {
super.stateChanged();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java
index 4828557c13..353c688860 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java
@@ -15,8 +15,8 @@ import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
import org.eclipse.jpt.jaxb.core.context.XmlNsForm;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
import org.eclipse.jpt.jaxb.core.xsd.XsdSchema;
@@ -100,8 +100,8 @@ public class GenericPackage
return getPackageInfo() == null && getRegistry() == null;
}
- public JaxbRegistry getRegistry() {
- Iterable<JaxbRegistry> registries = getContextRoot().getRegistries(this);
+ public XmlRegistry getRegistry() {
+ Iterable<XmlRegistry> registries = getContextRoot().getXmlRegistries(this);
if (CollectionTools.isEmpty(registries)) {
return null;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
index 99373b6ad3..addcc0ca8a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaAttributeMapping.java
@@ -15,9 +15,9 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
public abstract class AbstractJavaAttributeMapping<A extends Annotation>
extends AbstractJavaContextNode
@@ -102,19 +102,25 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation>
return (JaxbPersistentAttribute) super.getParent();
}
- public JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ public JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
}
public JaxbPackage getJaxbPackage() {
- return getPersistentClass().getJaxbPackage();
+ return getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
public JavaResourceAttribute getJavaResourceAttribute() {
return this.getPersistentAttribute().getJavaResourceAttribute();
}
- public Iterable<String> getDirectlyReferencedTypeNames() {
- return new SingleElementIterable(getPersistentAttribute().getJavaResourceAttributeBaseTypeName());
+
+
+ public String getValueTypeName() {
+ return getPersistentAttribute().getJavaResourceAttributeBaseTypeName();
+ }
+
+ public Iterable<String> getReferencedXmlTypeNames() {
+ return new SingleElementIterable(getValueTypeName());
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaElementQName.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaElementQName.java
index 2a3f118c82..26c510c6ed 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaElementQName.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaElementQName.java
@@ -13,9 +13,9 @@ import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
import org.eclipse.jpt.jaxb.core.context.XmlNsForm;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
@@ -42,12 +42,12 @@ public abstract class AbstractJavaElementQName
protected abstract JaxbPersistentAttribute getPersistentAttribute();
- protected JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ protected JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
}
protected JaxbPackage getJaxbPackage() {
- return getPersistentClass().getJaxbPackage();
+ return getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
protected abstract XmlElementWrapper getElementWrapper();
@@ -59,7 +59,7 @@ public abstract class AbstractJavaElementQName
@Override
public Iterable<String> getNameProposals(Filter<String> filter) {
- XsdTypeDefinition xsdType = getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition xsdType = getJaxbClassMapping().getXsdTypeDefinition();
if (xsdType == null) {
return EmptyIterable.instance();
}
@@ -82,7 +82,7 @@ public abstract class AbstractJavaElementQName
@Override
public String getDefaultNamespace() {
return (getJaxbPackage().getElementFormDefault() == XmlNsForm.QUALIFIED) ?
- getPersistentClass().getQName().getNamespace() : "";
+ getJaxbClassMapping().getQName().getNamespace() : "";
}
@Override
@@ -93,7 +93,7 @@ public abstract class AbstractJavaElementQName
@Override
protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- XsdTypeDefinition xsdType = getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition xsdType = getJaxbClassMapping().getXsdTypeDefinition();
if (xsdType == null) {
return;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaPersistentType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaPersistentType.java
deleted file mode 100644
index 089f9b26ef..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaPersistentType.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.context.java;
-
-import java.beans.Introspector;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-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.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType;
-import org.eclipse.jpt.jaxb.core.context.JaxbQName;
-import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
-import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
-import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
-import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
-import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.QNameAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.xsd.XsdElementDeclaration;
-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;
-
-public abstract class AbstractJavaPersistentType
- extends AbstractJavaType
- implements JaxbPersistentType {
-
- protected final JaxbQName qName;
-
- protected String factoryClass;
-
- protected String factoryMethod;
-
- protected final ListContainer<String, String> propOrderContainer;
-
- protected XmlRootElement rootElement;
-
-
- public AbstractJavaPersistentType(JaxbContextRoot parent, JavaResourceAbstractType resourceType) {
- super(parent, resourceType);
- this.qName = buildQName();
- this.factoryClass = this.getResourceFactoryClass();
- this.factoryMethod = this.getResourceFactoryMethod();
- this.propOrderContainer = this.buildPropOrderContainer();
- this.rootElement = this.buildRootElement();
- }
-
-
- protected JaxbQName buildQName() {
- return new XmlTypeQName(this);
- }
-
- @Override
- public JaxbContextRoot getParent() {
- return (JaxbContextRoot) super.getParent();
- }
-
- protected JaxbPackageInfo getPackageInfo() {
- JaxbPackage jaxbPackage = getParent().getPackage(this.getPackageName());
- return jaxbPackage == null ? null : jaxbPackage.getPackageInfo();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.qName.synchronizeWithResourceModel();
- this.setFactoryClass_(getResourceFactoryClass());
- this.setFactoryMethod_(getResourceFactoryMethod());
- this.syncPropOrder();
- this.syncRootElement();
- }
-
- @Override
- public void update() {
- super.update();
- this.qName.update();
- }
-
-
- // ********** xml type annotation **********
-
- protected XmlTypeAnnotation getXmlTypeAnnotation() {
- return (XmlTypeAnnotation) this.getJavaResourceType().getNonNullAnnotation(JAXB.XML_TYPE);
- }
-
-
- // ***** schema type ref *****
-
- public JaxbQName getQName() {
- return this.qName;
- }
-
-
- // ********** factory class **********
-
- public String getFactoryClass() {
- return this.factoryClass;
- }
-
- public void setFactoryClass(String factoryClass) {
- this.getXmlTypeAnnotation().setFactoryClass(factoryClass);
- this.setFactoryClass_(factoryClass);
- }
-
- protected void setFactoryClass_(String factoryClass) {
- String old = this.factoryClass;
- this.factoryClass = factoryClass;
- this.firePropertyChanged(FACTORY_CLASS_PROPERTY, old, factoryClass);
- }
-
- protected String getResourceFactoryClass() {
- return this.getXmlTypeAnnotation().getFactoryClass();
- }
-
-
- // ********** factory method **********
-
- public String getFactoryMethod() {
- return this.factoryMethod;
- }
-
- public void setFactoryMethod(String factoryMethod) {
- this.getXmlTypeAnnotation().setFactoryMethod(factoryMethod);
- this.setFactoryMethod_(factoryMethod);
- }
-
- protected void setFactoryMethod_(String factoryMethod) {
- String old = this.factoryMethod;
- this.factoryMethod = factoryMethod;
- this.firePropertyChanged(FACTORY_METHOD_PROPERTY, old, factoryMethod);
- }
-
- protected String getResourceFactoryMethod() {
- return this.getXmlTypeAnnotation().getFactoryMethod();
- }
-
-
- // ********** prop order **********
-
- public ListIterable<String> getPropOrder() {
- return this.propOrderContainer.getContextElements();
- }
-
- public int getPropOrderSize() {
- return this.propOrderContainer.getContextElementsSize();
- }
-
- public void addProp(int index, String prop) {
- getXmlTypeAnnotation().addProp(index, prop);
- this.propOrderContainer.addContextElement(index, prop);
- }
-
- public void removeProp(String prop) {
- this.removeProp(this.propOrderContainer.indexOfContextElement(prop));
- }
-
- public void removeProp(int index) {
- this.getXmlTypeAnnotation().removeProp(index);
- this.propOrderContainer.removeContextElement(index);
- }
-
- public void moveProp(int targetIndex, int sourceIndex) {
- this.getXmlTypeAnnotation().moveProp(targetIndex, sourceIndex);
- this.propOrderContainer.moveContextElement(targetIndex, sourceIndex);
- }
-
- protected void syncPropOrder() {
- this.propOrderContainer.synchronizeWithResourceModel();
- }
-
- protected ListIterable<String> getResourcePropOrder() {
- return this.getXmlTypeAnnotation().getPropOrder();
- }
-
- protected ListContainer<String, String> buildPropOrderContainer() {
- PropOrderContainer container = new PropOrderContainer();
- container.initialize();
- return container;
- }
-
-
- // *************** root element *********************
-
- public XmlRootElement getRootElement() {
- return this.rootElement;
- }
-
- public boolean isRootElement() {
- return this.rootElement != null;
- }
-
- public XmlRootElement setRootElement(String name) {
- if (name == null) {
- this.getJavaResourceType().removeAnnotation(JAXB.XML_ROOT_ELEMENT);
- this.setRootElement_(null);
- return null;
- }
- XmlRootElementAnnotation resourceRootElement = (XmlRootElementAnnotation) getJavaResourceType().addAnnotation(JAXB.XML_ROOT_ELEMENT);
- resourceRootElement.setName(name);
- XmlRootElement contextRootElement = this.buildRootElement(resourceRootElement);
- this.setRootElement_(contextRootElement);
- return contextRootElement;
- }
-
- protected void setRootElement_(XmlRootElement rootElement) {
- XmlRootElement old = this.rootElement;
- this.rootElement = rootElement;
- this.firePropertyChanged(ROOT_ELEMENT, old, rootElement);
- }
-
- protected XmlRootElement buildRootElement() {
- XmlRootElementAnnotation resourceRootElement = this.getRootElementAnnotation();
- return resourceRootElement == null ? null : this.buildRootElement(resourceRootElement);
- }
-
- protected XmlRootElement buildRootElement(XmlRootElementAnnotation resourceRootElement) {
- return getFactory().buildJavaXmlRootElement(this, resourceRootElement);
- }
-
- protected void syncRootElement() {
- XmlRootElementAnnotation resourceRootElement = this.getRootElementAnnotation();
- if (resourceRootElement != null) {
- if (this.rootElement != null) {
- this.rootElement.synchronizeWithResourceModel();
- }
- else {
- this.setRootElement_(this.buildRootElement(resourceRootElement));
- }
- }
- else if (this.rootElement != null) {
- this.setRootElement_(null);
- }
- }
-
- protected XmlRootElementAnnotation getRootElementAnnotation() {
- return (XmlRootElementAnnotation) this.getJavaResourceType().getAnnotation(JAXB.XML_ROOT_ELEMENT);
- }
-
-
- // **************** content assist ****************************************
-
- @Override
- public Iterable<String> getJavaCompletionProposals(
- int pos, Filter<String> filter, CompilationUnit astRoot) {
-
- getJaxbProject().getSchemaLibrary().refreshSchema(getJaxbPackage().getNamespace());
-
- Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot);
- if (! CollectionTools.isEmpty(result)) {
- return result;
- }
-
- result = this.qName.getJavaCompletionProposals(pos, filter, astRoot);
- if (! CollectionTools.isEmpty(result)) {
- return result;
- }
-
- if (this.rootElement != null) {
- result = this.rootElement.getJavaCompletionProposals(pos, filter, astRoot);
- if (! CollectionTools.isEmpty(result)) {
- return result;
- }
- }
-
- return EmptyIterable.instance();
- }
-
-
- // **************** validation ********************************************
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = getXmlTypeAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : super.getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- this.qName.validate(messages, reporter, astRoot);
-
- if (this.rootElement != null) {
- this.rootElement.validate(messages, reporter, astRoot);
- }
- }
-
-
- // **************** misc **************************************************
-
- public XsdTypeDefinition getXsdTypeDefinition() {
- XsdSchema xsdSchema = getJaxbPackage().getXsdSchema();
- if (xsdSchema == null) {
- return null;
- }
-
- if (! StringTools.stringIsEmpty(this.qName.getName())) {
- return xsdSchema.getTypeDefinition(this.qName.getNamespace(), this.qName.getName());
- }
-
- if (this.rootElement != null) {
- XsdElementDeclaration xsdElement = xsdSchema.getElementDeclaration(this.rootElement.getQName().getNamespace(), this.rootElement.getQName().getName());
- if (xsdElement != null) {
- return xsdElement.getType();
- }
- }
-
- return null;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.getFullyQualifiedName());
- }
-
-
- protected class XmlTypeQName
- extends AbstractJavaQName {
-
- protected XmlTypeQName(JavaContextNode parent) {
- super(parent, new QNameAnnotationProxy());
- }
-
-
- @Override
- public String getDefaultNamespace() {
- return AbstractJavaPersistentType.this.getJaxbPackage().getNamespace();
- }
-
- @Override
- public String getDefaultName() {
- return Introspector.decapitalize(AbstractJavaPersistentType.this.getSimpleName());
- }
-
- @Override
- protected Iterable<String> getNamespaceProposals(Filter<String> filter) {
- XsdSchema schema = AbstractJavaPersistentType.this.getJaxbPackage().getXsdSchema();
- if (schema == null) {
- return EmptyIterable.instance();
- }
- return schema.getNamespaceProposals(filter);
- }
-
- @Override
- protected Iterable<String> getNameProposals(Filter<String> filter) {
- XsdSchema schema = AbstractJavaPersistentType.this.getJaxbPackage().getXsdSchema();
- if (schema == null) {
- return EmptyIterable.instance();
- }
- return schema.getTypeNameProposals(getNamespace(), filter);
- }
-
- @Override
- public String getReferencedComponentTypeDescription() {
- return JptJaxbCoreMessages.XML_TYPE_DESC;
- }
-
- @Override
- protected void validateName(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- // do not call super... - it is not an error if the name is ""
- // if name is absent (""), namespace cannot be different from package namespace
- if ("".equals(getName())
- && ! StringTools.stringsAreEqual(
- getNamespace(),
- AbstractJavaPersistentType.this.getJaxbPackage().getNamespace())) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE,
- this,
- getXmlTypeAnnotation().getNamespaceTextRange(astRoot)));
- }
- }
-
- @Override
- protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- // if name is not absent (""), type must be from schema associated with this package
- String name = getName();
- String namespace = getNamespace();
-
- if (! StringTools.stringIsEmpty(name)) {
- XsdSchema schema = AbstractJavaPersistentType.this.getJaxbPackage().getXsdSchema();
-
- if (schema != null) {
- XsdTypeDefinition schemaType = schema.getTypeDefinition(namespace, name);
- if (schemaType == null) {
- messages.add(getUnresolveSchemaComponentMessage(astRoot));
- }
- }
- }
- }
- }
-
-
- protected class QNameAnnotationProxy
- extends AbstractJavaQName.AbstractQNameAnnotationProxy {
-
- @Override
- protected QNameAnnotation getAnnotation(boolean createIfNull) {
- return AbstractJavaPersistentType.this.getXmlTypeAnnotation();
- }
- }
-
-
- /**
- * xml prop order container
- */
- protected class PropOrderContainer
- extends ListContainer<String, String> {
-
- @Override
- protected String getContextElementsPropertyName() {
- return PROP_ORDER_LIST;
- }
-
- @Override
- protected String buildContextElement(String resourceElement) {
- return resourceElement;
- }
-
- @Override
- protected ListIterable<String> getResourceElements() {
- return AbstractJavaPersistentType.this.getResourcePropOrder();
- }
-
- @Override
- protected String getResourceElement(String contextElement) {
- return contextElement;
- }
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
index 80f33e2989..f9d8d3ed83 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaType.java
@@ -17,9 +17,16 @@ import org.eclipse.jpt.common.core.internal.resource.java.source.SourceNode;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlTransientAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -30,16 +37,23 @@ public abstract class AbstractJavaType
implements JaxbType {
protected final JavaResourceAbstractType resourceType;
-
- protected AbstractJavaType(JaxbContextRoot parent, JavaResourceAbstractType resourceType) {
+ protected JaxbTypeMapping mapping;
+
+ protected boolean defaultMapped = false;
+
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
+
+
+ protected AbstractJavaType(JaxbContextNode parent, JavaResourceAbstractType resourceType) {
super(parent);
this.resourceType = resourceType;
-
+ initMapping();
+ initXmlJavaTypeAdapter();
}
- // **************** AbstractJaxbNode impl *********************************
+ // ***** overrides *****
@Override
public IResource getResource() {
@@ -47,14 +61,175 @@ public abstract class AbstractJavaType
}
- // *********** JaxbType impl ***********
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncMapping();
+ syncXmlJavaTypeAdapter();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ updateMapping();
+ updateXmlJavaTypeAdapter();
+ }
+
+
+ // ***** mapping *****
+
+ public JaxbTypeMapping getMapping() {
+ return this.mapping;
+ }
+
+ protected void setMapping_(JaxbTypeMapping newMapping) {
+ JaxbTypeMapping old = this.mapping;
+ this.mapping = newMapping;
+ firePropertyChanged(MAPPING_PROPERTY, old, newMapping);
+ }
+
+ protected abstract JaxbTypeMapping buildMapping();
+
+ protected void initMapping() {
+ if (isDefaultMapped() || isSpecifiedMapped()) {
+ this.mapping = buildMapping();
+ }
+ }
+
+ protected void syncMapping() {
+ if (this.mapping != null) {
+ this.mapping.synchronizeWithResourceModel();
+ }
+ }
+
+ protected void updateMapping() {
+ boolean isMapped = isDefaultMapped() || isSpecifiedMapped();
+ if (isMapped) {
+ if (this.mapping != null) {
+ this.mapping.update();
+ }
+ else {
+ setMapping_(buildMapping());
+ }
+ }
+ else if (this.mapping != null) {
+ setMapping_(null);
+ }
+ }
+
+ /*
+ * Return true if the annotations on this type indicate it should have a mapping
+ */
+ protected boolean isSpecifiedMapped() {
+ return getXmlTypeAnnotation() != null
+ || getXmlRootElementAnnotation() != null
+ || getXmlTransientAnnotation() != null;
+ }
+
+ protected XmlTypeAnnotation getXmlTypeAnnotation() {
+ return (XmlTypeAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_TYPE);
+ }
+
+ protected XmlRootElementAnnotation getXmlRootElementAnnotation() {
+ return (XmlRootElementAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_ROOT_ELEMENT);
+ }
+
+ protected XmlTransientAnnotation getXmlTransientAnnotation() {
+ return (XmlTransientAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_TRANSIENT);
+ }
+
+
+ // ***** default mapped *****
+
+ public boolean isDefaultMapped() {
+ return this.defaultMapped;
+ }
+
+ public void setDefaultMapped(boolean newValue) {
+ boolean old = this.defaultMapped;
+ this.defaultMapped = newValue;
+ firePropertyChanged(DEFAULT_MAPPED_PROPERTY, old, newValue);
+ }
+
+
+ // ***** XmlJavaTypeAdapter *****
+
+ public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
+ return this.xmlJavaTypeAdapter;
+ }
+
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
+ }
+
+ public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation
+ = (XmlJavaTypeAdapterAnnotation) getJavaResourceType().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
+ }
+
+ public void removeXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceType().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
+ }
+
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceType().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
+ return new GenericJavaTypeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
+ }
+
+ protected void initXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
+
+ // ***** JaxbType misc *****
public JavaResourceAbstractType getJavaResourceType() {
return this.resourceType;
}
- public String getFullyQualifiedName() {
- return this.resourceType.getQualifiedName();
+ public String getSimpleName() {
+ return this.resourceType.getName();
}
public String getTypeQualifiedName() {
@@ -62,8 +237,8 @@ public abstract class AbstractJavaType
return (packageName.length() == 0) ? getFullyQualifiedName() : getFullyQualifiedName().substring(packageName.length() + 1);
}
- public String getSimpleName() {
- return this.resourceType.getName();
+ public String getFullyQualifiedName() {
+ return this.resourceType.getQualifiedName();
}
public String getPackageName() {
@@ -74,19 +249,22 @@ public abstract class AbstractJavaType
return getContextRoot().getPackage(getPackageName());
}
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
+ if (this.mapping != null) {
+ return this.mapping.getReferencedXmlTypeNames();
+ }
return EmptyIterable.instance();
}
- // **************** misc **************************************************
+ // ***** misc *****
protected CompilationUnit buildASTRoot() {
return this.resourceType.getJavaResourceCompilationUnit().buildASTRoot();
}
- // **************** validation ********************************************
+ // ***** validation *****
/**
* Override as needed
@@ -113,4 +291,13 @@ public abstract class AbstractJavaType
this.validate(messages, reporter, this.buildASTRoot());
}
}
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java
new file mode 100644
index 0000000000..7687e31f0e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaTypeMapping.java
@@ -0,0 +1,475 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import java.beans.Introspector;
+import java.util.List;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+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.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbQName;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
+import org.eclipse.jpt.jaxb.core.context.XmlSeeAlso;
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
+import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
+import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.QNameAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlTransientAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
+import org.eclipse.jpt.jaxb.core.xsd.XsdElementDeclaration;
+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;
+
+
+public abstract class AbstractJavaTypeMapping
+ extends AbstractJavaContextNode
+ implements JaxbTypeMapping {
+
+ protected boolean xmlTransient;
+
+ protected final JaxbQName qName;
+
+ protected XmlRootElement xmlRootElement;
+
+ protected XmlSeeAlso xmlSeeAlso;
+
+
+ protected AbstractJavaTypeMapping(JaxbType parent) {
+ super(parent);
+ initXmlTransient();
+ this.qName = buildQName();
+ initXmlRootElement();
+ initializeXmlSeeAlso();
+ }
+
+
+ public JaxbType getJaxbType() {
+ return (JaxbType) getParent();
+ }
+
+ protected JavaResourceAbstractType getJavaResourceType() {
+ return getJaxbType().getJavaResourceType();
+ }
+
+ protected JaxbPackage getJaxbPackage() {
+ return getJaxbType().getJaxbPackage();
+ }
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncXmlTransient();
+ this.qName.synchronizeWithResourceModel();
+ syncXmlRootElement();
+ syncXmlSeeAlso();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.qName.update();
+ updateXmlRootElement();
+ updateXmlSeeAlso();
+ }
+
+
+ // ***** XmlTransient *****
+
+ public boolean isXmlTransient() {
+ return this.xmlTransient;
+ }
+
+ public void setXmlTransient(boolean newValue) {
+ getJavaResourceType().addAnnotation(JAXB.XML_TRANSIENT);
+ setXmlTransient_(newValue);
+ }
+
+ protected void setXmlTransient_(boolean newValue) {
+ boolean old = this.xmlTransient;
+ this.xmlTransient = newValue;
+ firePropertyChanged(XML_TRANSIENT_PROPERTY, old, newValue);
+ }
+
+ protected XmlTransientAnnotation getXmlTransientAnnotation() {
+ return (XmlTransientAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_TRANSIENT);
+ }
+
+ protected void initXmlTransient() {
+ this.xmlTransient = getXmlTransientAnnotation() != null;
+ }
+
+ protected void syncXmlTransient() {
+ setXmlTransient_(getXmlTransientAnnotation() != null);
+ }
+
+
+ // ***** XmlType.name and namespace *****
+
+ public JaxbQName getQName() {
+ return this.qName;
+ }
+
+ protected JaxbQName buildQName() {
+ return new XmlTypeQName(this);
+ }
+
+ protected XmlTypeAnnotation getXmlTypeAnnotation() {
+ return (XmlTypeAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_TYPE);
+ }
+
+
+ // ***** XmlRootElement *****
+
+ public XmlRootElement getXmlRootElement() {
+ return this.xmlRootElement;
+ }
+
+ protected void setXmlRootElement_(XmlRootElement rootElement) {
+ XmlRootElement old = this.xmlRootElement;
+ this.xmlRootElement = rootElement;
+ this.firePropertyChanged(XML_ROOT_ELEMENT_PROPERTY, old, rootElement);
+ }
+
+ public XmlRootElement addXmlRootElement() {
+ if (this.xmlRootElement != null) {
+ throw new IllegalStateException();
+ }
+
+ XmlRootElementAnnotation annotation
+ = (XmlRootElementAnnotation) getJavaResourceType().addAnnotation(JAXB.XML_ROOT_ELEMENT);
+
+ XmlRootElement xmlRootElement = buildXmlRootElement(annotation);
+ setXmlRootElement_(xmlRootElement);
+ return xmlRootElement;
+ }
+
+ public void removeXmlRootElement() {
+ if (this.xmlRootElement == null) {
+ throw new IllegalStateException();
+ }
+
+ getJavaResourceType().removeAnnotation(JAXB.XML_ROOT_ELEMENT);
+ setXmlRootElement_(null);
+ }
+
+ protected XmlRootElementAnnotation getXmlRootElementAnnotation() {
+ return (XmlRootElementAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_ROOT_ELEMENT);
+ }
+
+ protected XmlRootElement buildXmlRootElement() {
+ XmlRootElementAnnotation annotation = getXmlRootElementAnnotation();
+ return annotation == null ? null : buildXmlRootElement(annotation);
+ }
+
+ protected XmlRootElement buildXmlRootElement(XmlRootElementAnnotation resourceRootElement) {
+ return getFactory().buildJavaXmlRootElement(this, resourceRootElement);
+ }
+
+ protected void initXmlRootElement() {
+ this.xmlRootElement = this.buildXmlRootElement();
+ }
+
+ protected void syncXmlRootElement() {
+ XmlRootElementAnnotation annotation = getXmlRootElementAnnotation();
+ if (annotation != null) {
+ if (this.xmlRootElement != null) {
+ this.xmlRootElement.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlRootElement_(buildXmlRootElement(annotation));
+ }
+ }
+ else if (this.xmlRootElement != null) {
+ setXmlRootElement_(null);
+ }
+ }
+
+ protected void updateXmlRootElement() {
+ if (this.xmlRootElement != null) {
+ this.xmlRootElement.update();
+ }
+ }
+
+
+ // ***** XmlSeeAlso *****
+
+ public XmlSeeAlso getXmlSeeAlso() {
+ return this.xmlSeeAlso;
+ }
+
+ protected void setXmlSeeAlso_(XmlSeeAlso xmlSeeAlso) {
+ XmlSeeAlso old = this.xmlSeeAlso;
+ this.xmlSeeAlso = xmlSeeAlso;
+ firePropertyChanged(XML_SEE_ALSO_PROPERTY, old, xmlSeeAlso);
+ }
+
+ public XmlSeeAlso addXmlSeeAlso() {
+ if (this.xmlSeeAlso != null) {
+ throw new IllegalStateException();
+ }
+ XmlSeeAlsoAnnotation annotation
+ = (XmlSeeAlsoAnnotation) getJavaResourceType().addAnnotation(JAXB.XML_SEE_ALSO);
+
+ XmlSeeAlso xmlSeeAlso = buildXmlSeeAlso(annotation);
+ setXmlSeeAlso_(xmlSeeAlso);
+ return xmlSeeAlso;
+ }
+
+ public void removeXmlSeeAlso() {
+ if (this.xmlSeeAlso == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceType().removeAnnotation(JAXB.XML_SEE_ALSO);
+ setXmlSeeAlso_(null);
+ }
+
+ protected XmlSeeAlsoAnnotation getXmlSeeAlsoAnnotation() {
+ return (XmlSeeAlsoAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_SEE_ALSO);
+ }
+
+ protected XmlSeeAlso buildXmlSeeAlso(XmlSeeAlsoAnnotation annotation) {
+ return new GenericJavaXmlSeeAlso(this, annotation);
+ }
+
+ protected void initializeXmlSeeAlso() {
+ XmlSeeAlsoAnnotation annotation = getXmlSeeAlsoAnnotation();
+ this.xmlSeeAlso = (annotation == null) ?
+ null
+ : buildXmlSeeAlso(annotation);
+ }
+
+ protected void syncXmlSeeAlso() {
+ XmlSeeAlsoAnnotation annotation = getXmlSeeAlsoAnnotation();
+ if (annotation != null) {
+ if (this.xmlSeeAlso != null) {
+ this.xmlSeeAlso.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlSeeAlso_(buildXmlSeeAlso(annotation));
+ }
+ }
+ else {
+ setXmlSeeAlso_(null);
+ }
+ }
+
+ protected void updateXmlSeeAlso() {
+ if (this.xmlSeeAlso != null) {
+ this.xmlSeeAlso.update();
+ }
+ }
+
+
+ // ***** misc *****
+
+ public final Iterable<String> getReferencedXmlTypeNames() {
+ if (! this.xmlTransient) {
+ return getNonTransientReferencedXmlTypeNames();
+ }
+ return EmptyIterable.instance();
+ }
+
+ protected Iterable<String> getNonTransientReferencedXmlTypeNames() {
+ if (this.xmlSeeAlso != null) {
+ return this.xmlSeeAlso.getReferencedXmlTypeNames();
+ }
+ return EmptyIterable.instance();
+ }
+
+
+ // ***** content assist *****
+
+ @Override
+ public Iterable<String> getJavaCompletionProposals(
+ int pos, Filter<String> filter, CompilationUnit astRoot) {
+
+ getJaxbProject().getSchemaLibrary().refreshSchema(getJaxbPackage().getNamespace());
+
+ Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+
+ result = this.qName.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+
+ if (this.xmlRootElement != null) {
+ result = this.xmlRootElement.getJavaCompletionProposals(pos, filter, astRoot);
+ if (! CollectionTools.isEmpty(result)) {
+ return result;
+ }
+ }
+
+ return EmptyIterable.instance();
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ TextRange textRange = getXmlTypeAnnotation().getTextRange(astRoot);
+ return (textRange != null) ? textRange : getJaxbType().getValidationTextRange(astRoot);
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+
+ // TODO - validation for xml transient and anything else
+
+ if (! this.xmlTransient) {
+ this.qName.validate(messages, reporter, astRoot);
+
+ if (this.xmlRootElement != null) {
+ this.xmlRootElement.validate(messages, reporter, astRoot);
+ }
+ }
+ }
+
+
+ // ***** misc *****
+
+ public XsdTypeDefinition getXsdTypeDefinition() {
+ XsdSchema xsdSchema = getJaxbPackage().getXsdSchema();
+ if (xsdSchema == null) {
+ return null;
+ }
+
+ if (! StringTools.stringIsEmpty(this.qName.getName())) {
+ return xsdSchema.getTypeDefinition(this.qName.getNamespace(), this.qName.getName());
+ }
+
+ if (this.xmlRootElement != null) {
+ XsdElementDeclaration xsdElement
+ = xsdSchema.getElementDeclaration(
+ this.xmlRootElement.getQName().getNamespace(),
+ this.xmlRootElement.getQName().getName());
+ if (xsdElement != null) {
+ return xsdElement.getType();
+ }
+ }
+
+ return null;
+ }
+
+ public boolean hasRootElementInHierarchy() {
+ return this.xmlRootElement != null;
+ }
+
+
+ protected class XmlTypeQName
+ extends AbstractJavaQName {
+
+ protected XmlTypeQName(JavaContextNode parent) {
+ super(parent, new QNameAnnotationProxy());
+ }
+
+
+ @Override
+ public String getDefaultNamespace() {
+ return AbstractJavaTypeMapping.this.getJaxbType().getJaxbPackage().getNamespace();
+ }
+
+ @Override
+ public String getDefaultName() {
+ return Introspector.decapitalize(AbstractJavaTypeMapping.this.getJaxbType().getSimpleName());
+ }
+
+ @Override
+ protected Iterable<String> getNamespaceProposals(Filter<String> filter) {
+ XsdSchema schema = AbstractJavaTypeMapping.this.getJaxbType().getJaxbPackage().getXsdSchema();
+ if (schema == null) {
+ return EmptyIterable.instance();
+ }
+ return schema.getNamespaceProposals(filter);
+ }
+
+ @Override
+ protected Iterable<String> getNameProposals(Filter<String> filter) {
+ XsdSchema schema = AbstractJavaTypeMapping.this.getJaxbType().getJaxbPackage().getXsdSchema();
+ if (schema == null) {
+ return EmptyIterable.instance();
+ }
+ return schema.getTypeNameProposals(getNamespace(), filter);
+ }
+
+ @Override
+ public String getReferencedComponentTypeDescription() {
+ return JptJaxbCoreMessages.XML_TYPE_DESC;
+ }
+
+ @Override
+ protected void validateName(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ // do not call super... - it is not an error if the name is ""
+ // if name is absent (""), namespace cannot be different from package namespace
+ if ("".equals(getName())
+ && ! StringTools.stringsAreEqual(
+ getNamespace(),
+ AbstractJavaTypeMapping.this.getJaxbType().getJaxbPackage().getNamespace())) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_TYPE_UNMATCHING_NAMESPACE_FOR_ANONYMOUS_TYPE,
+ this,
+ getXmlTypeAnnotation().getNamespaceTextRange(astRoot)));
+ }
+ }
+
+ @Override
+ protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ // if name is not absent (""), type must be from schema associated with this package
+ String name = getName();
+ String namespace = getNamespace();
+
+ if (! StringTools.stringIsEmpty(name)) {
+ XsdSchema schema = AbstractJavaTypeMapping.this.getJaxbType().getJaxbPackage().getXsdSchema();
+
+ if (schema != null) {
+ XsdTypeDefinition schemaType = schema.getTypeDefinition(namespace, name);
+ if (schemaType == null) {
+ messages.add(getUnresolveSchemaComponentMessage(astRoot));
+ }
+ }
+ }
+ }
+ }
+
+
+ protected class QNameAnnotationProxy
+ extends AbstractJavaQName.AbstractQNameAnnotationProxy {
+
+ @Override
+ protected QNameAnnotation getAnnotation(boolean createIfNull) {
+ return AbstractJavaTypeMapping.this.getXmlTypeAnnotation();
+ }
+ }
+
+
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaXmlJavaTypeAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaXmlJavaTypeAdapter.java
index 9bc4790c04..4fc5ada700 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaXmlJavaTypeAdapter.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/AbstractJavaXmlJavaTypeAdapter.java
@@ -10,121 +10,193 @@
package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+import org.eclipse.jpt.jaxb.core.context.XmlAdapter;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
public abstract class AbstractJavaXmlJavaTypeAdapter
- extends AbstractJavaContextNode
- implements XmlJavaTypeAdapter
-{
-
- protected final XmlJavaTypeAdapterAnnotation resourceXmlJavaTypeAdapter;
-
+ extends AbstractJavaContextNode
+ implements XmlJavaTypeAdapter {
+
+ protected final XmlJavaTypeAdapterAnnotation annotation;
+
protected String value;
-
+
+ protected XmlAdapter xmlAdapter;
+
protected String specifiedType;
-
+
protected String defaultType;
-
- protected AbstractJavaXmlJavaTypeAdapter(JaxbContextNode parent, XmlJavaTypeAdapterAnnotation resource) {
+
+
+ protected AbstractJavaXmlJavaTypeAdapter(JaxbContextNode parent, XmlJavaTypeAdapterAnnotation annotation) {
super(parent);
- this.resourceXmlJavaTypeAdapter = resource;
- this.value = this.getResourceValue();
- this.specifiedType = this.getResourceTypeString();
- this.defaultType = this.buildDefaultType();
- }
-
-
- // ********** synchronize/update **********
-
+ this.annotation = annotation;
+ this.value = getResourceValue();
+ initializeXmlAdapter();
+ this.specifiedType = getResourceTypeString();
+ this.defaultType = buildDefaultType();
+ }
+
+
+ public XmlJavaTypeAdapterAnnotation getAnnotation() {
+ return this.annotation;
+ }
+
+
+ // ***** synchronize/update *****
+
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.setValue_(this.getResourceValue());
- this.setSpecifiedType_(this.getResourceTypeString());
- this.setDefaultType(this.buildDefaultType());
+ setValue_(getResourceValue());
+ syncXmlAdapter();
+ setSpecifiedType_(getResourceTypeString());
+ setDefaultType(buildDefaultType());
}
-
-
- // ********** xml java type adapter annotation **********
-
- public XmlJavaTypeAdapterAnnotation getResourceXmlJavaTypeAdapter() {
- return this.resourceXmlJavaTypeAdapter;
- }
-
- // ********** value **********
-
+
+ @Override
+ public void update() {
+ super.update();
+ updateXmlAdapter();
+ }
+
+
+ // ***** value *****
+
public String getValue() {
return this.value;
}
-
+
public void setValue(String value) {
- this.resourceXmlJavaTypeAdapter.setValue(value);
+ this.annotation.setValue(value);
this.setValue_(value);
}
-
+
protected void setValue_(String value) {
String old = this.value;
this.value = value;
this.firePropertyChanged(VALUE_PROPERTY, old, value);
}
-
+
protected String getResourceValue() {
- return this.resourceXmlJavaTypeAdapter.getValue();
- }
-
-
- // ********** type **********
-
+ return this.annotation.getValue();
+ }
+
+ public String getFullyQualifiedValue() {
+ return this.annotation.getFullyQualifiedValue();
+ }
+
+
+ // ***** xmlAdapter *****
+
+ public XmlAdapter getXmlAdapter() {
+ return this.xmlAdapter;
+ }
+
+ protected void setXmlAdapter_(XmlAdapter xmlAdapter) {
+ XmlAdapter old = this.xmlAdapter;
+ this.xmlAdapter = xmlAdapter;
+ firePropertyChanged(XML_ADAPTER_PROPERTY, old, xmlAdapter);
+ }
+
+ protected JavaResourceType getXmlAdapterResourceType() {
+ String xmlAdapterName = getFullyQualifiedValue();
+ return (JavaResourceType) getJaxbProject().getJavaResourceType(xmlAdapterName, JavaResourceAbstractType.Kind.TYPE);
+ }
+
+ protected XmlAdapter buildXmlAdapter(JavaResourceType xmlAdapterResourceType) {
+ return new GenericJavaXmlAdapter(this, xmlAdapterResourceType);
+ }
+
+ protected void initializeXmlAdapter() {
+ JavaResourceType xmlAdapterResourceType = getXmlAdapterResourceType();
+ if (xmlAdapterResourceType != null) {
+ this.xmlAdapter = buildXmlAdapter(xmlAdapterResourceType);
+ }
+ }
+
+ protected void syncXmlAdapter() {
+ if (this.xmlAdapter != null) {
+ this.xmlAdapter.synchronizeWithResourceModel();
+ }
+ }
+
+ protected void updateXmlAdapter() {
+ JavaResourceType newResourceType = getXmlAdapterResourceType();
+ if (newResourceType == null) {
+ setXmlAdapter_(null);
+ }
+ else {
+ if (this.xmlAdapter == null) {
+ setXmlAdapter_(buildXmlAdapter(newResourceType));
+ }
+ else {
+ JavaResourceType currentResourceType = this.xmlAdapter.getJavaResourceType();
+ if (currentResourceType == null || ! currentResourceType.equals(newResourceType)) {
+ setXmlAdapter_(buildXmlAdapter(newResourceType));
+ }
+ else {
+ this.xmlAdapter.update();
+ }
+ }
+ }
+ }
+
+
+ // ***** type *****
+
public String getType() {
return this.specifiedTypeNotSet() ? this.getDefaultType() : this.getSpecifiedType();
}
-
+
/**
* @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT
*/
protected boolean specifiedTypeNotSet() {
return getSpecifiedType() == null || getSpecifiedType().equals(DEFAULT_TYPE);
}
-
+
public String getDefaultType() {
return this.defaultType;
}
-
+
protected void setDefaultType(String defaultType) {
String oldDefaultType = this.defaultType;
this.defaultType = defaultType;
firePropertyChanged(DEFAULT_TYPE_PROPERTY, oldDefaultType, defaultType);
}
-
+
protected abstract String buildDefaultType();
-
+
public String getSpecifiedType() {
return this.specifiedType;
}
-
+
public void setSpecifiedType(String location) {
- this.resourceXmlJavaTypeAdapter.setType(location);
+ this.annotation.setType(location);
this.setSpecifiedType_(location);
}
-
+
protected void setSpecifiedType_(String type) {
String old = this.specifiedType;
this.specifiedType = type;
this.firePropertyChanged(SPECIFIED_TYPE_PROPERTY, old, type);
}
-
+
protected String getResourceTypeString() {
- return this.resourceXmlJavaTypeAdapter.getType();
+ return this.annotation.getType();
}
-
-
- // ********** validation **********
-
+
+
+ // ***** validation *****
+
@Override
public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getResourceXmlJavaTypeAdapter().getTextRange(astRoot);
+ return this.annotation.getTextRange(astRoot);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/FieldAccessor.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/FieldAccessor.java
index f4b45792da..d351834091 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/FieldAccessor.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/FieldAccessor.java
@@ -15,7 +15,7 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jaxb.core.context.Accessor;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
public class FieldAccessor
extends AbstractJavaContextNode
@@ -24,7 +24,7 @@ public class FieldAccessor
protected final JavaResourceField resourceField;
- public FieldAccessor(JaxbPersistentClass parent, JavaResourceField resourceField) {
+ public FieldAccessor(JaxbClassMapping parent, JavaResourceField resourceField) {
super(parent);
this.resourceField = resourceField;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeMappingXmlSchemaType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeMappingXmlSchemaType.java
index ebbd013752..dc3fda16bc 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeMappingXmlSchemaType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeMappingXmlSchemaType.java
@@ -10,9 +10,9 @@
package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
public class GenericJavaAttributeMappingXmlSchemaType
@@ -35,12 +35,12 @@ public class GenericJavaAttributeMappingXmlSchemaType
return getAttributeMapping().getPersistentAttribute();
}
- protected JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ protected JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
}
@Override
protected JaxbPackage getJaxbPackage() {
- return this.getPersistentClass().getJaxbPackage();
+ return this.getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapter.java
index 0541e48350..8d751b01ad 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapter.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapter.java
@@ -56,7 +56,7 @@ public class GenericJavaAttributeXmlJavaTypeAdapter
IMessage.HIGH_SEVERITY,
JaxbValidationMessages.ATTRIBUTE_MAPPING_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_DEFINED,
this,
- getResourceXmlJavaTypeAdapter().getTypeTextRange(astRoot)));
+ getAnnotation().getTypeTextRange(astRoot)));
}
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributesContainer.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributesContainer.java
index 018cefef64..3b210a13f4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributesContainer.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaAttributesContainer.java
@@ -28,8 +28,8 @@ import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributesContainer;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -44,18 +44,18 @@ public class GenericJavaAttributesContainer
protected final Vector<JaxbPersistentAttribute> attributes = new Vector<JaxbPersistentAttribute>();
- public GenericJavaAttributesContainer(JaxbPersistentClass parent, JaxbAttributesContainer.Owner owner, JavaResourceType resourceType) {
+ public GenericJavaAttributesContainer(JaxbClassMapping parent, JaxbAttributesContainer.Owner owner, JavaResourceType resourceType) {
super(parent);
this.javaResourceType = resourceType;
this.owner = owner;
this.initializeAttributes();
}
-
- @Override
- public JaxbPersistentClass getParent() {
- return (JaxbPersistentClass) super.getParent();
+
+
+ public JaxbClassMapping getJaxbClassMapping() {
+ return (JaxbClassMapping) getParent();
}
-
+
public boolean isFor(JavaResourceType javaResourceType) {
return this.javaResourceType == javaResourceType;
}
@@ -105,11 +105,11 @@ public class GenericJavaAttributesContainer
}
protected JaxbPersistentAttribute buildField(JavaResourceField resourceField) {
- return getFactory().buildJavaPersistentField(getParent(), resourceField);
+ return getFactory().buildJavaPersistentField(getJaxbClassMapping(), resourceField);
}
protected JaxbPersistentAttribute buildProperty(JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) {
- return getFactory().buildJavaPersistentProperty(getParent(), resourceGetter, resourceSetter);
+ return getFactory().buildJavaPersistentProperty(getJaxbClassMapping(), resourceGetter, resourceSetter);
}
protected void initializeAttributes() {
@@ -645,6 +645,6 @@ public class GenericJavaAttributesContainer
@Override
public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getParent().getValidationTextRange(astRoot);
+ return getJaxbClassMapping().getValidationTextRange(astRoot);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaBasicMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaBasicMapping.java
index 0a4d017542..ade3aa0cd3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaBasicMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaBasicMapping.java
@@ -11,13 +11,11 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbBasicMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlAttachmentRef;
import org.eclipse.jpt.jaxb.core.context.XmlID;
import org.eclipse.jpt.jaxb.core.context.XmlIDREF;
@@ -39,7 +37,7 @@ public abstract class GenericJavaBasicMapping<A extends JaxbBasicSchemaComponent
extends AbstractJavaAttributeMapping<A>
implements JaxbBasicMapping {
- protected final XmlAdaptable xmlAdaptable;
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
protected XmlSchemaType xmlSchemaType;
@@ -54,71 +52,117 @@ public abstract class GenericJavaBasicMapping<A extends JaxbBasicSchemaComponent
public GenericJavaBasicMapping(JaxbPersistentAttribute parent) {
super(parent);
- this.xmlAdaptable = buildXmlAdaptable();
- this.initializeXmlSchemaType();
- this.initializeXmlList();
- this.initializeXmlID();
- this.initializeXmlIDREF();
- this.initializeXmlAttachmentRef();
+ initializeXmlJavaTypeAdapter();
+ initializeXmlSchemaType();
+ initializeXmlList();
+ initializeXmlID();
+ initializeXmlIDREF();
+ initializeXmlAttachmentRef();
}
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
- this.syncXmlSchemaType();
- this.syncXmlList();
- this.syncXmlID();
- this.syncXmlIDREF();
- this.syncXmlAttachmentRef();
+ syncXmlJavaTypeAdapter();
+ syncXmlSchemaType();
+ syncXmlList();
+ syncXmlID();
+ syncXmlIDREF();
+ syncXmlAttachmentRef();
}
@Override
public void update() {
super.update();
- this.xmlAdaptable.update();
- this.updateXmlSchemaType();
- this.updateXmlList();
- this.updateXmlID();
- this.updateXmlIDREF();
- this.updateXmlAttachmentRef();
+ updateXmlJavaTypeAdapter();
+ updateXmlSchemaType();
+ updateXmlList();
+ updateXmlID();
+ updateXmlIDREF();
+ updateXmlAttachmentRef();
}
- //****************** XmlJavaTypeAdapter *********************
-
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaBasicMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaBasicMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
- }
-
+ // ***** XmlJavaTypeAdapter *****
+
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
}
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
+ }
+
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
-
+
+ public void removeXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
+ }
+
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
-
- public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
}
-
- //****************** XmlSchemaType *********************
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
+
+ // ***** XmlAdapter *****
+
+// public XmlAdapter getXmlAdapter() {
+// if (this.xmlJavaTypeAdapter != null) {
+// return this.xmlJavaTypeAdapter.getXmlAdapter();
+// }
+// JaxbPersistentClass referenceClass
+// }
+
+
+ // ***** XmlSchemaType *****
public XmlSchemaType getXmlSchemaType() {
return this.xmlSchemaType;
@@ -460,7 +504,17 @@ public abstract class GenericJavaBasicMapping<A extends JaxbBasicSchemaComponent
}
- // **************** content assist **************
+ // ***** misc *****
+
+ @Override
+ public String getValueTypeName() {
+ return (this.xmlJavaTypeAdapter == null || this.xmlJavaTypeAdapter.getXmlAdapter() == null) ?
+ super.getValueTypeName()
+ : this.xmlJavaTypeAdapter.getXmlAdapter().getValueType();
+ }
+
+
+ // ***** content assist *****
@Override
public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
@@ -480,13 +534,15 @@ public abstract class GenericJavaBasicMapping<A extends JaxbBasicSchemaComponent
}
- // ********** validation **********
+ // ***** validation *****
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
- this.xmlAdaptable.validate(messages, reporter, astRoot);
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
if (this.xmlSchemaType != null) {
this.xmlSchemaType.validate(messages, reporter, astRoot);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
new file mode 100644
index 0000000000..12a3dedb7b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaClassMapping.java
@@ -0,0 +1,846 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.JDTTools;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
+import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributesContainer;
+import org.eclipse.jpt.jaxb.core.context.JaxbBasicMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
+import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
+import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.omg.CORBA.PUBLIC_MEMBER;
+
+
+public class GenericJavaClassMapping
+ extends AbstractJavaTypeMapping
+ implements JaxbClassMapping {
+
+ protected String factoryClass;
+
+ protected String factoryMethod;
+
+ protected final PropOrderContainer propOrderContainer;
+
+ protected JaxbClassMapping superclass;
+
+ protected XmlAccessType defaultAccessType;
+ protected XmlAccessType specifiedAccessType;
+
+ protected XmlAccessOrder defaultAccessOrder;
+ protected XmlAccessOrder specifiedAccessOrder;
+
+ protected boolean hasRootElementInHierarchy_loaded = false;
+ protected boolean hasRootElementInHierarchy = false;
+
+ protected final JaxbAttributesContainer attributesContainer;
+
+ protected final Map<JaxbClassMapping, JaxbAttributesContainer> inheritedAttributesContainers;
+
+ public GenericJavaClassMapping(JaxbClass parent) {
+ super(parent);
+ this.inheritedAttributesContainers = new HashMap<JaxbClassMapping, JaxbAttributesContainer>();
+ this.propOrderContainer = new PropOrderContainer();
+
+ initFactoryClass();
+ initFactoryMethod();
+ initPropOrder();
+ initSpecifiedAccessType();
+ initDefaultAccessType();
+ initSpecifiedAccessOrder();
+ initDefaultAccessOrder();
+ this.attributesContainer = new GenericJavaAttributesContainer(this, buildAttributesContainerOwner(), getJavaResourceType());
+ initInheritedAttributes();
+ }
+
+
+ @Override
+ public JavaResourceType getJavaResourceType() {
+ return (JavaResourceType) super.getJavaResourceType();
+ }
+
+ @Override
+ public JaxbClass getJaxbType() {
+ return (JaxbClass) super.getJaxbType();
+ }
+
+ protected JaxbPackageInfo getPackageInfo() {
+ JaxbPackage jaxbPackage = getJaxbPackage();
+ // jaxb package may be null during initialization/update
+ return (jaxbPackage == null) ? null : jaxbPackage.getPackageInfo();
+ }
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncFactoryClass();
+ syncFactoryMethod();
+ syncPropOrder();
+ syncSpecifiedAccessType();
+ syncSpecifiedAccessOrder();
+ this.attributesContainer.synchronizeWithResourceModel();
+ syncInheritedAttributes();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ updateSuperclass();
+ updateDefaultAccessType();
+ updateDefaultAccessOrder();
+ this.hasRootElementInHierarchy_loaded = false; // triggers that the value must be recalculated on next request
+ this.attributesContainer.update();
+ updateInheritedAttributes();
+ }
+
+
+ // ***** factory class *****
+
+ public String getFactoryClass() {
+ return this.factoryClass;
+ }
+
+ public void setFactoryClass(String factoryClass) {
+ getXmlTypeAnnotation().setFactoryClass(factoryClass);
+ setFactoryClass_(factoryClass);
+ }
+
+ protected void setFactoryClass_(String factoryClass) {
+ String old = this.factoryClass;
+ this.factoryClass = factoryClass;
+ firePropertyChanged(FACTORY_CLASS_PROPERTY, old, factoryClass);
+ }
+
+ protected String getResourceFactoryClass() {
+ return getXmlTypeAnnotation().getFactoryClass();
+ }
+
+ protected void initFactoryClass() {
+ this.factoryClass = getResourceFactoryClass();
+ }
+
+ protected void syncFactoryClass() {
+ setFactoryClass_(getResourceFactoryClass());
+ }
+
+
+ // ***** factory method *****
+
+ public String getFactoryMethod() {
+ return this.factoryMethod;
+ }
+
+ public void setFactoryMethod(String factoryMethod) {
+ getXmlTypeAnnotation().setFactoryMethod(factoryMethod);
+ setFactoryMethod_(factoryMethod);
+ }
+
+ protected void setFactoryMethod_(String factoryMethod) {
+ String old = this.factoryMethod;
+ this.factoryMethod = factoryMethod;
+ firePropertyChanged(FACTORY_METHOD_PROPERTY, old, factoryMethod);
+ }
+
+ protected String getResourceFactoryMethod() {
+ return getXmlTypeAnnotation().getFactoryMethod();
+ }
+
+ protected void initFactoryMethod() {
+ this.factoryMethod = getResourceFactoryMethod();
+ }
+
+ protected void syncFactoryMethod() {
+ setFactoryMethod_(getResourceFactoryMethod());
+ }
+
+
+ // ***** prop order *****
+
+ public ListIterable<String> getPropOrder() {
+ return this.propOrderContainer.getContextElements();
+ }
+
+ public int getPropOrderSize() {
+ return this.propOrderContainer.getContextElementsSize();
+ }
+
+ public void addProp(int index, String prop) {
+ getXmlTypeAnnotation().addProp(index, prop);
+ this.propOrderContainer.addContextElement(index, prop);
+ }
+
+ public void removeProp(String prop) {
+ this.removeProp(this.propOrderContainer.indexOfContextElement(prop));
+ }
+
+ public void removeProp(int index) {
+ this.getXmlTypeAnnotation().removeProp(index);
+ this.propOrderContainer.removeContextElement(index);
+ }
+
+ public void moveProp(int targetIndex, int sourceIndex) {
+ this.getXmlTypeAnnotation().moveProp(targetIndex, sourceIndex);
+ this.propOrderContainer.moveContextElement(targetIndex, sourceIndex);
+ }
+
+ protected void initPropOrder() {
+ this.propOrderContainer.initialize();
+ }
+
+ protected void syncPropOrder() {
+ this.propOrderContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<String> getResourcePropOrder() {
+ return this.getXmlTypeAnnotation().getPropOrder();
+ }
+
+
+ // ***** XmlAccessorType *****
+
+ public XmlAccessType getAccessType() {
+ return (this.specifiedAccessType != null) ? this.specifiedAccessType : this.defaultAccessType;
+ }
+
+ public XmlAccessType getDefaultAccessType() {
+ return this.defaultAccessType;
+ }
+
+ protected void setDefaultAccessType_(XmlAccessType access) {
+ XmlAccessType old = this.defaultAccessType;
+ this.defaultAccessType = access;
+ firePropertyChanged(DEFAULT_ACCESS_TYPE_PROPERTY, old, access);
+ }
+
+ public XmlAccessType getSpecifiedAccessType() {
+ return this.specifiedAccessType;
+ }
+
+ public void setSpecifiedAccessType(XmlAccessType access) {
+ getXmlAccessorTypeAnnotation().setValue(XmlAccessType.toJavaResourceModel(access));
+ setSpecifiedAccessType_(access);
+ }
+
+ protected void setSpecifiedAccessType_(XmlAccessType access) {
+ XmlAccessType old = this.specifiedAccessType;
+ this.specifiedAccessType = access;
+ firePropertyChanged(SPECIFIED_ACCESS_TYPE_PROPERTY, old, access);
+ }
+
+ protected void initDefaultAccessType() {
+ this.defaultAccessType = buildDefaultAccessType();
+ }
+
+ protected void updateDefaultAccessType() {
+ setDefaultAccessType_(buildDefaultAccessType());
+ }
+
+ /**
+ * Default access type is determined by the following, in order of precedence:
+ * - @XmlAccessorType annotation on a mapped super class
+ * - @XmlAccessorType annotation on the package
+ * - default access type of {@link PUBLIC_MEMBER}
+ */
+ protected XmlAccessType buildDefaultAccessType() {
+ XmlAccessType accessType = getSuperclassAccessType();
+ if (accessType != null) {
+ return accessType;
+ }
+ accessType = getPackageAccessType();
+ if (accessType != null) {
+ return accessType;
+ }
+ return XmlAccessType.PUBLIC_MEMBER;
+ }
+
+ protected XmlAccessType getSuperclassAccessType() {
+ return this.superclass == null ? null : this.superclass.getSpecifiedAccessType();
+ }
+
+ protected XmlAccessType getPackageAccessType() {
+ JaxbPackageInfo packageInfo = getPackageInfo();
+ return (packageInfo == null) ? null : packageInfo.getAccessType();
+ }
+
+ protected XmlAccessorTypeAnnotation getXmlAccessorTypeAnnotation() {
+ return (XmlAccessorTypeAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_TYPE);
+ }
+
+ protected XmlAccessType getResourceAccessType() {
+ return XmlAccessType.fromJavaResourceModel(getXmlAccessorTypeAnnotation().getValue());
+ }
+
+ protected void initSpecifiedAccessType() {
+ this.specifiedAccessType = getResourceAccessType();
+ }
+
+ protected void syncSpecifiedAccessType() {
+ setSpecifiedAccessType_(getResourceAccessType());
+ }
+
+
+ // ***** XmlAccessorOrder *****
+
+ public XmlAccessOrder getAccessOrder() {
+ return (this.specifiedAccessOrder != null) ? this.specifiedAccessOrder : this.defaultAccessOrder;
+ }
+
+ public XmlAccessOrder getDefaultAccessOrder() {
+ return this.defaultAccessOrder;
+ }
+
+ protected void setDefaultAccessOrder_(XmlAccessOrder accessOrder) {
+ XmlAccessOrder old = this.defaultAccessOrder;
+ this.defaultAccessOrder = accessOrder;
+ firePropertyChanged(DEFAULT_ACCESS_ORDER_PROPERTY, old, accessOrder);
+ }
+
+ public XmlAccessOrder getSpecifiedAccessOrder() {
+ return this.specifiedAccessOrder;
+ }
+
+ public void setSpecifiedAccessOrder(XmlAccessOrder accessOrder) {
+ getXmlAccessorOrderAnnotation().setValue(XmlAccessOrder.toJavaResourceModel(accessOrder));
+ setSpecifiedAccessOrder_(accessOrder);
+ }
+
+ protected void setSpecifiedAccessOrder_(XmlAccessOrder accessOrder) {
+ XmlAccessOrder old = this.specifiedAccessOrder;
+ this.specifiedAccessOrder = accessOrder;
+ firePropertyChanged(SPECIFIED_ACCESS_ORDER_PROPERTY, old, accessOrder);
+ }
+
+ protected void initDefaultAccessOrder() {
+ this.defaultAccessOrder = buildDefaultAccessOrder();
+ }
+
+ protected void updateDefaultAccessOrder() {
+ setDefaultAccessOrder_(buildDefaultAccessOrder());
+ }
+
+ /**
+ * Default access order is determined by the following, in order of precedence:
+ * - @XmlAccessorOrder annotation on a mapped super class
+ * - @XmlAccessorOrder annotation on the package
+ * - default access order of {@link UNDEFINED}
+ */
+ protected XmlAccessOrder buildDefaultAccessOrder() {
+ XmlAccessOrder accessOrder = getSuperclassAccessOrder();
+ if (accessOrder != null) {
+ return accessOrder;
+ }
+ accessOrder = getPackageAccessOrder();
+ if (accessOrder != null) {
+ return accessOrder;
+ }
+ return XmlAccessOrder.UNDEFINED;
+ }
+
+ protected XmlAccessOrder getSuperclassAccessOrder() {
+ JaxbClassMapping superclass = this.superclass;
+ while (superclass != null) {
+ XmlAccessOrder accessOrder = superclass.getSpecifiedAccessOrder();
+ if (accessOrder != null) {
+ return accessOrder;
+ }
+ superclass = superclass.getSuperclass();
+ }
+ return null;
+ }
+
+ protected XmlAccessOrder getPackageAccessOrder() {
+ JaxbPackageInfo packageInfo = getPackageInfo();
+ return packageInfo == null ? null : packageInfo.getAccessOrder();
+ }
+
+ protected XmlAccessorOrderAnnotation getXmlAccessorOrderAnnotation() {
+ return (XmlAccessorOrderAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_ORDER);
+ }
+
+ protected XmlAccessOrder getResourceAccessOrder() {
+ return XmlAccessOrder.fromJavaResourceModel(getXmlAccessorOrderAnnotation().getValue());
+ }
+
+ protected void initSpecifiedAccessOrder() {
+ this.specifiedAccessOrder = getResourceAccessOrder();
+ }
+
+ protected void syncSpecifiedAccessOrder() {
+ setSpecifiedAccessOrder_(getResourceAccessOrder());
+ }
+
+
+ // ********** super class **********
+
+ public JaxbClassMapping getSuperclass() {
+ return this.superclass;
+ }
+
+ protected void setSuperclass_(JaxbClassMapping superclass) {
+ JaxbClassMapping old = this.superclass;
+ this.superclass = superclass;
+ this.firePropertyChanged(SUPERCLASS_PROPERTY, old, superclass);
+ }
+
+ protected void updateSuperclass() {
+ setSuperclass_(findSuperclass());
+ }
+
+ protected JaxbClassMapping findSuperclass() {
+ JavaResourceType resourceType = getSuperclass(getJavaResourceType());
+ while (resourceType != null && resourceType != this) {
+ JaxbType jaxbType = getJaxbProject().getContextRoot().getType(resourceType.getQualifiedName());
+
+ // if the superclass is not a class, return null
+ if (jaxbType == null || jaxbType.getKind() != JaxbType.Kind.CLASS) {
+ return null;
+ }
+
+ JaxbClassMapping jaxbClassMapping = ((JaxbClass) jaxbType).getMapping();
+ // rare for a non-null superclass to not be mapped, but potentially possible mid-update
+ if (jaxbClassMapping != null) {
+ return jaxbClassMapping;
+ }
+ else {
+ resourceType = getSuperclass(resourceType);
+ }
+ }
+ return null;
+ }
+
+ protected JavaResourceType getSuperclass(JavaResourceType resourceType) {
+ String superclassName = resourceType.getSuperclassQualifiedName();
+ if (superclassName == null) {
+ return null;
+ }
+
+ return (JavaResourceType) getJaxbProject().getJavaResourceType(
+ superclassName, JavaResourceType.Kind.TYPE);
+ }
+
+
+ // ***** attributes *****
+
+ public Iterable<JaxbPersistentAttribute> getAttributes() {
+ return this.attributesContainer.getAttributes();
+ }
+
+ public int getAttributesSize() {
+ return this.attributesContainer.getAttributesSize();
+ }
+
+ protected JaxbAttributesContainer.Owner buildAttributesContainerOwner() {
+ return new JaxbAttributesContainer.Owner() {
+ public XmlAccessType getAccessType() {
+ return GenericJavaClassMapping.this.getAccessType();
+ }
+
+ public void fireAttributeAdded(JaxbPersistentAttribute attribute) {
+ GenericJavaClassMapping.this.fireItemAdded(ATTRIBUTES_COLLECTION, attribute);
+ }
+
+ public void fireAttributeRemoved(JaxbPersistentAttribute attribute) {
+ GenericJavaClassMapping.this.fireItemRemoved(ATTRIBUTES_COLLECTION, attribute);
+ }
+ };
+ }
+
+
+ // ***** inherited attributes *****
+
+ public Iterable<JaxbPersistentAttribute> getInheritedAttributes() {
+ return new CompositeIterable<JaxbPersistentAttribute>(getInheritedAttributeSets());
+ }
+
+ protected Iterable<Iterable<JaxbPersistentAttribute>> getInheritedAttributeSets() {
+ return new TransformationIterable<JaxbAttributesContainer, Iterable<JaxbPersistentAttribute>>(
+ getInheritedAttributesContainers()) {
+ @Override
+ protected Iterable<JaxbPersistentAttribute> transform(JaxbAttributesContainer attributesContainer) {
+ return attributesContainer.getAttributes();
+ }
+ };
+ }
+
+ protected Iterable<JaxbAttributesContainer> getInheritedAttributesContainers() {
+ return new LiveCloneIterable<JaxbAttributesContainer>(this.inheritedAttributesContainers.values()); // read-only
+ }
+
+ public int getInheritedAttributesSize() {
+ int size = 0;
+ for (JaxbAttributesContainer attributesContainer : getInheritedAttributesContainers()) {
+ size += attributesContainer.getAttributesSize();
+ }
+ return size;
+ }
+
+ protected void initInheritedAttributes() {
+ JaxbClassMapping superclass = this.superclass;
+ // only add inherited attributes for superclasses up until a mapped class is encountered
+ while (superclass != null && superclass.isXmlTransient()) {
+ this.inheritedAttributesContainers.put(superclass, buildInheritedAttributesContainer(superclass));
+ superclass = superclass.getSuperclass();
+ }
+ }
+
+ protected void syncInheritedAttributes() {
+ for (JaxbAttributesContainer attributesContainer : this.inheritedAttributesContainers.values()) {
+ attributesContainer.synchronizeWithResourceModel();
+ }
+ }
+
+ protected void updateInheritedAttributes() {
+ HashSet<JaxbClassMapping> oldSuperclasses
+ = CollectionTools.set(this.inheritedAttributesContainers.keySet());
+ Set<JaxbPersistentAttribute> oldAttributes = CollectionTools.set(getInheritedAttributes());
+ JaxbClassMapping superclass = this.superclass;
+ // only add inherited attributes for superclasses up until a mapped class is encountered
+ while (superclass != null && superclass.isXmlTransient()) {
+ if (this.inheritedAttributesContainers.containsKey(superclass)) {
+ this.inheritedAttributesContainers.get(superclass).update();
+ oldSuperclasses.remove(superclass);
+ }
+ else {
+ this.inheritedAttributesContainers.put(superclass, buildInheritedAttributesContainer(superclass));
+ }
+ superclass = superclass.getSuperclass();
+ }
+
+ for (JaxbClassMapping oldSuperclass : oldSuperclasses) {
+ this.inheritedAttributesContainers.remove(oldSuperclass);
+ }
+
+ Set<JaxbPersistentAttribute> newAttributes = CollectionTools.set(getInheritedAttributes());
+ if (CollectionTools.elementsAreDifferent(oldAttributes, newAttributes)) {
+ fireCollectionChanged(INHERITED_ATTRIBUTES_COLLECTION, newAttributes);
+ }
+ }
+
+ protected JaxbAttributesContainer buildInheritedAttributesContainer(JaxbClassMapping jaxbClassMapping) {
+ return new GenericJavaAttributesContainer(this, buildInheritedAttributesContainerOwner(), jaxbClassMapping.getJaxbType().getJavaResourceType());
+ }
+
+ protected JaxbAttributesContainer.Owner buildInheritedAttributesContainerOwner() {
+ return new JaxbAttributesContainer.Owner() {
+ public XmlAccessType getAccessType() {
+ return GenericJavaClassMapping.this.getAccessType();
+ }
+
+ public void fireAttributeAdded(JaxbPersistentAttribute attribute) {
+ GenericJavaClassMapping.this.fireItemAdded(INHERITED_ATTRIBUTES_COLLECTION, attribute);
+ }
+
+ public void fireAttributeRemoved(JaxbPersistentAttribute attribute) {
+ GenericJavaClassMapping.this.fireItemRemoved(INHERITED_ATTRIBUTES_COLLECTION, attribute);
+ }
+ };
+ }
+
+ public boolean isInherited(JaxbPersistentAttribute attribute) {
+ if (attribute.getParent() != this) {
+ throw new IllegalArgumentException("The attribute is not owned by this JaxbClassMapping"); //$NON-NLS-1$
+ }
+ return ! CollectionTools.contains(this.getAttributes(), attribute);
+ }
+
+ public String getJavaResourceAttributeOwningTypeName(JaxbPersistentAttribute attribute) {
+ if (attribute.getParent() != this) {
+ throw new IllegalArgumentException("The attribute is not owned by this JaxbClassMapping"); //$NON-NLS-1$
+ }
+ for (JaxbClassMapping superclass : this.inheritedAttributesContainers.keySet()) {
+ if (CollectionTools.contains(this.inheritedAttributesContainers.get(superclass).getAttributes(), attribute)) {
+ return superclass.getJaxbType().getSimpleName();
+ }
+ }
+ throw new IllegalArgumentException("The attribute is not an inherited attribute"); //$NON-NLS-1$
+ }
+
+
+ // ***** subClasses *****
+
+ @Override
+ public boolean hasRootElementInHierarchy() {
+ if (! this.hasRootElementInHierarchy_loaded) {
+ this.hasRootElementInHierarchy = calculateHasRootElementInHierarchy();
+ this.hasRootElementInHierarchy_loaded = true;
+ }
+ return this.hasRootElementInHierarchy;
+ }
+
+ protected boolean calculateHasRootElementInHierarchy() {
+ if (this.getXmlRootElement() != null) {
+ return true;
+ }
+
+ for (JaxbType jaxbType : getJaxbProject().getContextRoot().getTypes()) {
+ if (jaxbType.getMapping() != null
+ && ! jaxbType.getMapping().isXmlTransient()
+ && jaxbType.getMapping().getXmlRootElement() != null
+ && JDTTools.typeIsSubType(
+ getJaxbProject().getJavaProject(),
+ jaxbType.getFullyQualifiedName(), getJaxbType().getFullyQualifiedName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ // ***** misc *****
+
+ @Override
+ protected Iterable<String> getNonTransientReferencedXmlTypeNames() {
+ return new CompositeIterable<String>(
+ super.getNonTransientReferencedXmlTypeNames(),
+ new SingleElementIterable(getJavaResourceType().getSuperclassQualifiedName()),
+ new CompositeIterable<String>(
+ new TransformationIterable<JaxbPersistentAttribute, Iterable<String>>(getAttributes()) {
+ @Override
+ protected Iterable<String> transform(JaxbPersistentAttribute o) {
+ return o.getMapping().getReferencedXmlTypeNames();
+ }
+ }));
+ }
+
+ public boolean containsXmlId() {
+ return ! CollectionTools.isEmpty(getBasicMappingsWithXmlID());
+ }
+
+ protected Iterable<JaxbBasicMapping> getBasicMappingsWithXmlID(){
+ return new FilteringIterable<JaxbBasicMapping>(getBasicMappings()){
+ @Override
+ protected boolean accept(JaxbBasicMapping basicMapping) {
+ return basicMapping.getXmlID() != null;
+ }
+ };
+ }
+
+ protected Iterable<JaxbBasicMapping> getBasicMappings() {
+ return new SubIterableWrapper<JaxbAttributeMapping, JaxbBasicMapping>(getBasicMappings_());
+ }
+
+ protected Iterable<JaxbAttributeMapping> getBasicMappings_(){
+ return new FilteringIterable<JaxbAttributeMapping>(getAttributeMappings()){
+ @Override
+ protected boolean accept(JaxbAttributeMapping attributeMapping) {
+ return (attributeMapping.getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY
+ || attributeMapping.getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
+ }
+ };
+ }
+
+ protected Iterable<? extends JaxbAttributeMapping> getAttributeMappings() {
+ return new TransformationIterable<JaxbPersistentAttribute, JaxbAttributeMapping>(getAttributes()) {
+ @Override
+ protected JaxbAttributeMapping transform(JaxbPersistentAttribute attribute) {
+ return attribute.getMapping();
+ }
+ };
+ }
+
+
+ // ***** content assist *****
+
+ @Override
+ 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;
+ }
+
+ // TODO - factory methods?
+
+ for (JaxbPersistentAttribute attribute : this.getAttributes()) {
+ result = attribute.getJavaCompletionProposals(pos, filter, astRoot);
+ if (!CollectionTools.isEmpty(result)) {
+ return result;
+ }
+ }
+
+ return EmptyIterable.instance();
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+
+ // TODO - factory method?
+
+ validateXmlAnyAttributeMapping(messages, astRoot);
+ validateXmlAnyElementMapping(messages, astRoot);
+ validateXmlValueMapping(messages, astRoot);
+ validateXmlIDs(messages, astRoot);
+
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ attribute.validate(messages, reporter, astRoot);
+ }
+ }
+
+ protected void validateXmlValueMapping(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlValueMapping = null;
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getMappingKey() == MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY) {
+ if (xmlValueMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_VALUE_MAPPINGS_DEFINED,
+ new String[] {attribute.getName(), xmlValueMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlValueMapping = attribute.getName();
+ }
+ }
+ }
+ if (xmlValueMapping != null) {
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getName() != xmlValueMapping) {
+ if (attribute.getMappingKey() != MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY
+ && attribute.getMappingKey() != MappingKeys.XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_VALUE_MAPPING_WITH_NON_XML_ATTRIBUTE_MAPPING_DEFINED,
+ new String[] {attribute.getName(), xmlValueMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ }
+ }
+ }
+ }
+
+ protected void validateXmlAnyAttributeMapping(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlAnyAttributeMapping = null;
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getMappingKey() == MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY) {
+ if (xmlAnyAttributeMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_ANY_ATTRIBUTE_MAPPINGS_DEFINED,
+ new String[] {attribute.getName(), xmlAnyAttributeMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlAnyAttributeMapping = attribute.getName();
+ }
+ }
+ }
+ }
+
+ protected void validateXmlAnyElementMapping(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlAnyElementMapping = null;
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getMappingKey() == MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY) {
+ if (xmlAnyElementMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_ANY_ELEMENT_MAPPINGS_DEFINED,
+ new String[] {attribute.getName(), xmlAnyElementMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlAnyElementMapping = attribute.getName();
+ }
+ }
+ }
+ }
+
+ protected void validateXmlIDs(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlIdMapping = null;
+ for (JaxbBasicMapping containmentMapping : getBasicMappingsWithXmlID()) {
+ if (xmlIdMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_IDS_DEFINED,
+ new String[] { containmentMapping.getPersistentAttribute().getName(), xmlIdMapping },
+ containmentMapping,
+ containmentMapping.getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlIdMapping = containmentMapping.getPersistentAttribute().getName();
+ }
+ }
+ }
+
+
+ /**
+ * xml prop order container
+ */
+ protected class PropOrderContainer
+ extends ListContainer<String, String> {
+
+ @Override
+ protected String getContextElementsPropertyName() {
+ return PROP_ORDER_LIST;
+ }
+
+ @Override
+ protected String buildContextElement(String resourceElement) {
+ return resourceElement;
+ }
+
+ @Override
+ protected ListIterable<String> getResourceElements() {
+ return GenericJavaClassMapping.this.getResourcePropOrder();
+ }
+
+ @Override
+ protected String getResourceElement(String contextElement) {
+ return contextElement;
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java
index a45a23a10e..375ff625d3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaElementFactoryMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -20,9 +20,9 @@ import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbQName;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
@@ -50,7 +50,7 @@ public class GenericJavaElementFactoryMethod
protected String defaultValue;
- public GenericJavaElementFactoryMethod(JaxbRegistry parent, JavaResourceMethod resourceMethod) {
+ public GenericJavaElementFactoryMethod(XmlRegistry parent, JavaResourceMethod resourceMethod) {
super(parent);
this.resourceMethod = resourceMethod;
this.scope = getResourceScope();
@@ -68,8 +68,8 @@ public class GenericJavaElementFactoryMethod
return new XmlElementDeclSubstitutionHeadQName(this);
}
- protected JaxbRegistry getRegistry() {
- return (JaxbRegistry) getParent();
+ protected XmlRegistry getRegistry() {
+ return (XmlRegistry) getParent();
}
public JavaResourceMethod getResourceMethod() {
@@ -252,10 +252,10 @@ public class GenericJavaElementFactoryMethod
public Iterable<String> getNameProposals(Filter<String> filter) {
if (! GenericJavaElementFactoryMethod.this.isGlobalScope()) {
String fqScope = GenericJavaElementFactoryMethod.this.getFullyQualifiedScope();
- JaxbPersistentClass scopeClass =
- GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getPersistentClass(fqScope);
- if (scopeClass != null) {
- XsdTypeDefinition xsdType = scopeClass.getXsdTypeDefinition();
+ JaxbTypeMapping scopeTypeMapping =
+ GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getTypeMapping(fqScope);
+ if (scopeTypeMapping != null) {
+ XsdTypeDefinition xsdType = scopeTypeMapping.getXsdTypeDefinition();
if (xsdType != null) {
return xsdType.getElementNameProposals(getNamespace(), filter, true);
}
@@ -285,10 +285,10 @@ public class GenericJavaElementFactoryMethod
protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
if (! GenericJavaElementFactoryMethod.this.isGlobalScope()) {
String fqScope = GenericJavaElementFactoryMethod.this.getFullyQualifiedScope();
- JaxbPersistentClass scopeClass =
- GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getPersistentClass(fqScope);
- if (scopeClass != null) {
- XsdTypeDefinition xsdType = scopeClass.getXsdTypeDefinition();
+ JaxbTypeMapping scopeTypeMapping =
+ GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getTypeMapping(fqScope);
+ if (scopeTypeMapping != null) {
+ XsdTypeDefinition xsdType = scopeTypeMapping.getXsdTypeDefinition();
if (xsdType == null) {
return;
}
@@ -341,10 +341,10 @@ public class GenericJavaElementFactoryMethod
@Override
public Iterable<String> getNameProposals(Filter<String> filter) {
String fqScope = GenericJavaElementFactoryMethod.this.getFullyQualifiedScope();
- JaxbPersistentClass scopeClass =
- GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getPersistentClass(fqScope);
- if (scopeClass != null) {
- XsdTypeDefinition xsdType = scopeClass.getXsdTypeDefinition();
+ JaxbTypeMapping scopeTypeMapping =
+ GenericJavaElementFactoryMethod.this.getJaxbProject().getContextRoot().getTypeMapping(fqScope);
+ if (scopeTypeMapping != null) {
+ XsdTypeDefinition xsdType = scopeTypeMapping.getXsdTypeDefinition();
if (xsdType != null) {
return xsdType.getElementNameProposals(getNamespace(), filter);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumConstant.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumConstant.java
index 6261fc0148..ff13847fd1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumConstant.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumConstant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,7 +11,7 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
@@ -24,7 +24,7 @@ public class GenericJavaEnumConstant
protected String specifiedValue;
- public GenericJavaEnumConstant(JaxbPersistentEnum parent, JavaResourceEnumConstant resourceEnumConstant) {
+ public GenericJavaEnumConstant(JaxbEnumMapping parent, JavaResourceEnumConstant resourceEnumConstant) {
super(parent);
this.resourceEnumConstant = resourceEnumConstant;
this.specifiedValue = this.getResourceEnumValue();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumMapping.java
index 2579f5b9eb..ffec69e7ca 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentEnum.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaEnumMapping.java
@@ -1,94 +1,99 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
-public class GenericJavaPersistentEnum
- extends AbstractJavaPersistentType
- implements JaxbPersistentEnum {
+public class GenericJavaEnumMapping
+ extends AbstractJavaTypeMapping
+ implements JaxbEnumMapping {
+
protected String enumType;
- protected final ContextCollectionContainer<JaxbEnumConstant, JavaResourceEnumConstant> enumConstantContainer;
+ protected final EnumConstantContainer enumConstantContainer;
- public GenericJavaPersistentEnum(JaxbContextRoot parent, JavaResourceEnum resourceEnum) {
- super(parent, resourceEnum);
- this.enumType = this.getResourceEnumType();
- this.enumConstantContainer = this.buildEnumConstantContainer();
+
+ public GenericJavaEnumMapping(JaxbEnum parent) {
+ super(parent);
+ this.enumConstantContainer = new EnumConstantContainer();
+
+ initEnumType();
+ initEnumConstants();
}
-
+
+
@Override
public JavaResourceEnum getJavaResourceType() {
return (JavaResourceEnum) super.getJavaResourceType();
}
-
-
- // ********** JaxbType impl **********
-
- public Kind getKind() {
- return Kind.PERSISTENT_ENUM;
- }
-
-
- // ********** synchronize/update **********
-
+
+
+ // ********** sync/update **********
+
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.setEnumType_(this.getResourceEnumType());
- this.enumConstantContainer.synchronizeWithResourceModel();
+ syncEnumType();
+ syncEnumConstants();
}
-
+
@Override
public void update() {
super.update();
- this.enumConstantContainer.update();
- }
-
- // ********** xml enum annotation **********
-
- protected XmlEnumAnnotation getXmlEnumAnnotation() {
- return (XmlEnumAnnotation) this.getJavaResourceType().getNonNullAnnotation(JAXB.XML_ENUM);
+ updateEnumConstants();
}
+
-
- // ********** JaxbPersistentEnum impl **********
-
- // ********** enum type **********
-
+ // ***** XmlEnum.value *****
+
public String getEnumType() {
return this.enumType;
}
-
+
public void setEnumType(String enumType) {
- this.getXmlEnumAnnotation().setValue(enumType);
- this.setEnumType_(enumType);
+ getXmlEnumAnnotation().setValue(enumType);
+ setEnumType_(enumType);
}
-
+
protected void setEnumType_(String enumType) {
String old = this.enumType;
this.enumType = enumType;
- this.firePropertyChanged(ENUM_TYPE_PROPERTY, old, enumType);
+ firePropertyChanged(ENUM_TYPE_PROPERTY, old, enumType);
}
-
+
+ protected XmlEnumAnnotation getXmlEnumAnnotation() {
+ return (XmlEnumAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ENUM);
+ }
+
protected String getResourceEnumType() {
- return this.getXmlEnumAnnotation().getValue();
+ return getXmlEnumAnnotation().getValue();
}
-
+
+ protected void initEnumType() {
+ this.enumType = getResourceEnumType();
+ }
+
+ protected void syncEnumType() {
+ setEnumType_(getResourceEnumType());
+ }
+
+
+ // ***** enum constants *****
+
public Iterable<JaxbEnumConstant> getEnumConstants() {
return this.enumConstantContainer.getContextElements();
}
@@ -96,43 +101,52 @@ public class GenericJavaPersistentEnum
public int getEnumConstantsSize() {
return this.enumConstantContainer.getContextElementsSize();
}
-
- private Iterable<JavaResourceEnumConstant> getResourceEnumConstants() {
+
+ protected void initEnumConstants() {
+ this.enumConstantContainer.initialize();
+ }
+
+ protected void syncEnumConstants() {
+ this.enumConstantContainer.synchronizeWithResourceModel();
+ }
+
+ protected void updateEnumConstants() {
+ this.enumConstantContainer.update();
+ }
+
+ protected Iterable<JavaResourceEnumConstant> getResourceEnumConstants() {
return getJavaResourceType().getEnumConstants();
}
private JaxbEnumConstant buildEnumConstant(JavaResourceEnumConstant resourceEnumConstant) {
return getFactory().buildJavaEnumConstant(this, resourceEnumConstant);
}
-
- protected ContextCollectionContainer<JaxbEnumConstant, JavaResourceEnumConstant> buildEnumConstantContainer() {
- EnumConstantContainer container = new EnumConstantContainer();
- container.initialize();
- return container;
- }
-
+
+
/**
* enum constant container adapter
*/
protected class EnumConstantContainer
- extends ContextCollectionContainer<JaxbEnumConstant, JavaResourceEnumConstant>
- {
+ extends ContextCollectionContainer<JaxbEnumConstant, JavaResourceEnumConstant> {
+
@Override
protected String getContextElementsPropertyName() {
return ENUM_CONSTANTS_COLLECTION;
}
+
@Override
protected JaxbEnumConstant buildContextElement(JavaResourceEnumConstant resourceElement) {
- return GenericJavaPersistentEnum.this.buildEnumConstant(resourceElement);
+ return GenericJavaEnumMapping.this.buildEnumConstant(resourceElement);
}
+
@Override
protected Iterable<JavaResourceEnumConstant> getResourceElements() {
- return GenericJavaPersistentEnum.this.getResourceEnumConstants();
+ return GenericJavaEnumMapping.this.getResourceEnumConstants();
}
+
@Override
protected JavaResourceEnumConstant getResourceElement(JaxbEnumConstant contextElement) {
return contextElement.getResourceEnumConstant();
}
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbClass.java
new file mode 100644
index 0000000000..05a0a9d496
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbClass.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import java.util.List;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlRegistryAnnotation;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+public class GenericJavaJaxbClass
+ extends AbstractJavaType
+ implements JaxbClass {
+
+ protected XmlRegistry xmlRegistry;
+
+
+ public GenericJavaJaxbClass(JaxbContextNode parent, JavaResourceType resourceType) {
+ super(parent, resourceType);
+ initXmlRegistry();
+ }
+
+
+ @Override
+ public JavaResourceType getJavaResourceType() {
+ return (JavaResourceType) super.getJavaResourceType();
+ }
+
+ public Kind getKind() {
+ return JaxbType.Kind.CLASS;
+ }
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncXmlRegistry();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ updateXmlRegistry();
+ }
+
+
+ // ***** mapping *****
+
+ @Override
+ public JaxbClassMapping getMapping() {
+ return (JaxbClassMapping) super.getMapping();
+ }
+
+ @Override
+ protected JaxbClassMapping buildMapping() {
+ return getFactory().buildJaxbClassMapping(this);
+ }
+
+ @Override
+ protected boolean isSpecifiedMapped() {
+ return getXmlTypeAnnotation() != null
+ || getXmlRootElementAnnotation() != null
+ || getXmlTransientAnnotation() != null;
+ }
+
+
+ // ***** XmlRegistry *****
+
+ public XmlRegistry getXmlRegistry() {
+ return this.xmlRegistry;
+ }
+
+ protected void setXmlRegistry_(XmlRegistry xmlRegistry) {
+ XmlRegistry old = this.xmlRegistry;
+ this.xmlRegistry = xmlRegistry;
+ firePropertyChanged(XML_REGISTRY_PROPERTY, old, xmlRegistry);
+ }
+
+ protected XmlRegistryAnnotation getXmlRegistryAnnotation() {
+ return (XmlRegistryAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_REGISTRY);
+ }
+
+ protected XmlRegistry buildXmlRegistry() {
+ return getFactory().buildXmlRegistry(this);
+ }
+
+ protected void initXmlRegistry() {
+ if (getXmlRegistryAnnotation() != null) {
+ this.xmlRegistry = buildXmlRegistry();
+ }
+ }
+
+ protected void syncXmlRegistry() {
+ XmlRegistryAnnotation annotation = getXmlRegistryAnnotation();
+ if (annotation != null) {
+ if (this.xmlRegistry != null) {
+ this.xmlRegistry.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlRegistry_(buildXmlRegistry());
+ }
+ }
+ else if (this.xmlRegistry != null) {
+ setXmlRegistry_(null);
+ }
+ }
+
+ protected void updateXmlRegistry() {
+ if (this.xmlRegistry != null) {
+ this.xmlRegistry.update();
+ }
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+
+ if (this.xmlRegistry != null) {
+ this.xmlRegistry.validate(messages, reporter, astRoot);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbEnum.java
new file mode 100644
index 0000000000..3cf53874dc
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaJaxbEnum.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
+
+
+public class GenericJavaJaxbEnum
+ extends AbstractJavaType
+ implements JaxbEnum {
+
+ public GenericJavaJaxbEnum(JaxbContextNode parent, JavaResourceEnum resourceType) {
+ super(parent, resourceType);
+ }
+
+
+ @Override
+ public JavaResourceEnum getJavaResourceType() {
+ return (JavaResourceEnum) super.getJavaResourceType();
+ }
+
+ public Kind getKind() {
+ return JaxbType.Kind.ENUM;
+ }
+
+
+ // ***** mapping *****
+
+ @Override
+ public JaxbEnumMapping getMapping() {
+ return (JaxbEnumMapping) super.getMapping();
+ }
+
+ @Override
+ protected JaxbEnumMapping buildMapping() {
+ return getFactory().buildJaxbEnumMapping(this);
+ }
+
+ @Override
+ protected boolean isSpecifiedMapped() {
+ return super.isSpecifiedMapped()
+ || getXmlEnumAnnotation() != null;
+ }
+
+ protected XmlEnumAnnotation getXmlEnumAnnotation() {
+ return (XmlEnumAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_ENUM);
+ }
+}
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 c9cd81bd36..cf02703f94 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
@@ -389,23 +389,26 @@ public class GenericJavaPackageInfo
* xml java type adapter container
*/
protected class XmlJavaTypeAdapterContainer
- extends ContextListContainer<XmlJavaTypeAdapter, XmlJavaTypeAdapterAnnotation>
- {
+ extends ContextListContainer<XmlJavaTypeAdapter, XmlJavaTypeAdapterAnnotation> {
+
@Override
protected String getContextElementsPropertyName() {
return XML_JAVA_TYPE_ADAPTERS_LIST;
}
+
@Override
protected XmlJavaTypeAdapter buildContextElement(XmlJavaTypeAdapterAnnotation resourceElement) {
return GenericJavaPackageInfo.this.buildXmlJavaTypeAdapter(resourceElement);
}
+
@Override
protected ListIterable<XmlJavaTypeAdapterAnnotation> getResourceElements() {
return GenericJavaPackageInfo.this.getXmlJavaTypeAdapterAnnotations();
}
+
@Override
protected XmlJavaTypeAdapterAnnotation getResourceElement(XmlJavaTypeAdapter contextElement) {
- return contextElement.getResourceXmlJavaTypeAdapter();
+ return contextElement.getAnnotation();
}
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageXmlJavaTypeAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageXmlJavaTypeAdapter.java
index 14f9daf4ab..f4ee9e71f5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageXmlJavaTypeAdapter.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageXmlJavaTypeAdapter.java
@@ -42,7 +42,7 @@ public class GenericJavaPackageXmlJavaTypeAdapter
IMessage.HIGH_SEVERITY,
JaxbValidationMessages.PACKAGE_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_SPECIFIED,
this,
- getResourceXmlJavaTypeAdapter().getTypeTextRange(astRoot)));
+ getAnnotation().getTypeTextRange(astRoot)));
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentAttribute.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentAttribute.java
index 9a9d718aaa..1b0caee2f3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentAttribute.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentAttribute.java
@@ -22,8 +22,8 @@ import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jaxb.core.context.Accessor;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
@@ -40,39 +40,42 @@ public class GenericJavaPersistentAttribute
protected String defaultMappingKey;
protected final Accessor accessor;
-
+
+
public static JaxbPersistentAttribute buildPersistentProperty(
- JaxbPersistentClass parent,
+ JaxbClassMapping parent,
JavaResourceMethod resourceGetter,
JavaResourceMethod resourceSetter) {
return new GenericJavaPersistentAttribute(parent, new PropertyAccessor(parent, resourceGetter, resourceSetter));
}
public static JaxbPersistentAttribute buildPersistentField(
- JaxbPersistentClass parent,
+ JaxbClassMapping parent,
JavaResourceField resourceField) {
return new GenericJavaPersistentAttribute(parent, new FieldAccessor(parent, resourceField));
}
-
- public GenericJavaPersistentAttribute(JaxbPersistentClass parent, Accessor accessor) {
+
+
+ public GenericJavaPersistentAttribute(JaxbClassMapping parent, Accessor accessor) {
super(parent);
this.accessor = accessor;
// keep non-null at all times
this.mapping = this.buildMapping();
}
- public JaxbPersistentClass getPersistentClass() {
- return (JaxbPersistentClass) super.getParent();
+ public JaxbClassMapping getJaxbClassMapping() {
+ return (JaxbClassMapping) super.getParent();
}
public boolean isInherited() {
- return getPersistentClass().isInherited(this);
+ return getJaxbClassMapping().isInherited(this);
}
public String getInheritedJavaResourceAttributeOwningTypeName() {
- return getPersistentClass().getJavaResourceAttributeOwningTypeName(this);
+ return getJaxbClassMapping().getJavaResourceAttributeOwningTypeName(this);
}
-
+
+
// ********** synchronize/update **********
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
deleted file mode 100644
index 665b4326d4..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
+++ /dev/null
@@ -1,811 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.context.java;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ChainIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.jaxb.core.MappingKeys;
-import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
-import org.eclipse.jpt.jaxb.core.context.JaxbAttributesContainer;
-import org.eclipse.jpt.jaxb.core.context.JaxbBasicMapping;
-import org.eclipse.jpt.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-import org.eclipse.jpt.jaxb.core.context.XmlSeeAlso;
-import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
-import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * To support inherited attributes in the Generic case I have made some assumptions
- * based on the JAXB RIs interpretation of the spec. Any superclass that is
- * marked as @XmlTransient will have a corresponding JaxbAttributesContainer for its JaxbClass.
- * If that XmlTransient class has no access type specified, the access type will be determined
- * by this JaxbPersistentClass's access type. If the XmlTransient class specified an access
- * type it will only be used in the case where this class does not specify an access type.
- * It will be this class's default access type. The spec states that you are not allowed
- * to use other annotations along with XmlTransient, but it appears the reference implementation
- * has made an exception for @XmlAccessorType and @XmlAccessorOrder. This is subject to change
- * pending a discussion with Blaise and the developers of the RI
- *
- */
-public class GenericJavaPersistentClass
- extends AbstractJavaPersistentType
- implements JaxbPersistentClass {
-
- protected JaxbClass superClass;
-
- protected boolean hasRootElementInHierarchy_loaded = false;
- protected boolean hasRootElementInHierarchy = false;
-
- protected XmlAccessType defaultAccessType;
- protected XmlAccessType specifiedAccessType;
-
- protected XmlAccessOrder defaultAccessOrder;
- protected XmlAccessOrder specifiedAccessOrder;
-
- protected final XmlAdaptable xmlAdaptable;
-
- protected XmlSeeAlso xmlSeeAlso;
-
- protected final JaxbAttributesContainer attributesContainer;
-
- protected final Map<JaxbClass, JaxbAttributesContainer> inheritedAttributesContainers = new HashMap<JaxbClass, JaxbAttributesContainer>();
-
- public GenericJavaPersistentClass(JaxbContextRoot parent, JavaResourceType resourceType) {
- super(parent, resourceType);
- this.superClass = this.buildSuperClass();
- this.specifiedAccessType = this.getResourceAccessType();
- this.specifiedAccessOrder = this.getResourceAccessOrder();
- this.defaultAccessType = this.buildDefaultAccessType();
- this.defaultAccessOrder = this.buildDefaultAccessOrder();
- this.xmlAdaptable = this.buildXmlAdaptable();
- initXmlSeeAlso();
- this.attributesContainer = new GenericJavaAttributesContainer(this, buildAttributesContainerOwner(), resourceType);
- this.initializeInheritedAttributes();
- }
-
-
- @Override
- public JavaResourceType getJavaResourceType() {
- return (JavaResourceType) super.getJavaResourceType();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedAccessType_(this.getResourceAccessType());
- this.setSpecifiedAccessOrder_(this.getResourceAccessOrder());
- this.xmlAdaptable.synchronizeWithResourceModel();
- syncXmlSeeAlso();
- this.attributesContainer.synchronizeWithResourceModel();
- this.syncInheritedAttributes();
- }
-
- @Override
- public void update() {
- super.update();
- setSuperClass(buildSuperClass());
- this.hasRootElementInHierarchy_loaded = false; // triggers that the value must be recalculated on next request
- setDefaultAccessType(buildDefaultAccessType());
- setDefaultAccessOrder(buildDefaultAccessOrder());
- this.xmlAdaptable.update();
- updateXmlSeeAlso();
- this.attributesContainer.update();
- updateInheritedAttributes();
- }
-
-
- // ********** JaxbType impl **********
-
- public Kind getKind() {
- return Kind.PERSISTENT_CLASS;
- }
-
- @Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
- return new CompositeIterable<String>(
- new SingleElementIterable(getJavaResourceType().getSuperclassQualifiedName()),
- new CompositeIterable<String>(
- new TransformationIterable<JaxbPersistentAttribute, Iterable<String>>(getAttributes()) {
- @Override
- protected Iterable<String> transform(JaxbPersistentAttribute o) {
- return o.getMapping().getDirectlyReferencedTypeNames();
- }
- }),
- getXmlSeeAlsoClasses());
- }
-
- protected Iterable<String> getXmlSeeAlsoClasses() {
- return (this.xmlSeeAlso == null) ?
- EmptyIterable.<String>instance()
- : getXmlSeeAlso().getDirectlyReferencedTypeNames();
- }
-
-
- // ********** super class **********
-
- public JaxbClass getSuperClass() {
- return this.superClass;
- }
-
- protected void setSuperClass(JaxbClass superClass) {
- JaxbClass old = this.superClass;
- this.superClass = superClass;
- this.firePropertyChanged(SUPER_CLASS_PROPERTY, old, superClass);
- }
-
- protected JaxbClass buildSuperClass() {
- HashSet<JavaResourceType> visited = new HashSet<JavaResourceType>();
- visited.add(this.getJavaResourceType());
- JaxbClass spc = this.getSuperClass(this.getJavaResourceType().getSuperclassQualifiedName(), visited);
- if (spc == null) {
- return null;
- }
- if (CollectionTools.contains(spc.getInheritanceHierarchy(), this)) {
- return null; // short-circuit in this case, we have circular inheritance
- }
- return spc;
- }
-
- /**
- * The JPA spec allows non-persistent types in a persistent type's
- * inheritance hierarchy. We check for a persistent type with the
- * specified name in the persistence unit. If it is not found we use
- * resource persistent type and look for *its* super type.
- *
- * The 'visited' collection is used to detect a cycle in the *resource* type
- * inheritance hierarchy and prevent the resulting stack overflow.
- * Any cycles in the *context* type inheritance hierarchy are handled in
- * #buildSuperPersistentType().
- */
- protected JaxbClass getSuperClass(String typeName, Collection<JavaResourceType> visited) {
- if (typeName == null) {
- return null;
- }
- JavaResourceType resourceType = (JavaResourceType) this.getJaxbProject().getJavaResourceType(typeName, JavaResourceAbstractType.Kind.TYPE);
- if ((resourceType == null) || visited.contains(resourceType)) {
- return null;
- }
- visited.add(resourceType);
- JaxbClass spc = this.getClass(typeName);
- return (spc != null) ? spc : this.getSuperClass(resourceType.getSuperclassQualifiedName(), visited); // recurse
- }
-
- protected JaxbClass getClass(String fullyQualifiedTypeName) {
- return this.getParent().getClass(fullyQualifiedTypeName);
- }
-
-
- // ***** subClasses *****
-
- public boolean hasRootElementInHierarchy() {
- if (! this.hasRootElementInHierarchy_loaded) {
- this.hasRootElementInHierarchy = calculateHasRootElementInHierarchy();
- this.hasRootElementInHierarchy_loaded = true;
- }
- return this.hasRootElementInHierarchy;
- }
-
- protected boolean calculateHasRootElementInHierarchy() {
- if (this.getRootElement() != null) {
- return true;
- }
-
- for (JaxbPersistentClass persistentClass : getJaxbProject().getContextRoot().getPersistentClasses()) {
- if (persistentClass.getRootElement() != null
- && JDTTools.typeIsSubType(getJaxbProject().getJavaProject(),
- persistentClass.getFullyQualifiedName(), getFullyQualifiedName())) {
- return true;
- }
- }
-
- return false;
- }
-
-
- // ********** inheritance **********
-
- public Iterable<JaxbClass> getInheritanceHierarchy() {
- return this.getInheritanceHierarchyOf(this);
- }
-
- public Iterable<JaxbClass> getAncestors() {
- return this.getInheritanceHierarchyOf(this.superClass);
- }
-
- protected Iterable<JaxbClass> getInheritanceHierarchyOf(JaxbClass start) {
- // using a chain iterator to traverse up the inheritance tree
- return new ChainIterable<JaxbClass>(start) {
- @Override
- protected JaxbClass nextLink(JaxbClass jaxbClass) {
- return jaxbClass.getSuperClass();
- }
- };
- }
-
- // ********** access type **********
-
- public XmlAccessType getAccessType() {
- return (this.specifiedAccessType != null) ? this.specifiedAccessType : this.defaultAccessType;
- }
-
- public XmlAccessType getSpecifiedAccessType() {
- return this.specifiedAccessType;
- }
-
- public void setSpecifiedAccessType(XmlAccessType access) {
- this.getAccessorTypeAnnotation().setValue(XmlAccessType.toJavaResourceModel(access));
- this.setSpecifiedAccessType_(access);
- }
-
- protected void setSpecifiedAccessType_(XmlAccessType access) {
- XmlAccessType old = this.specifiedAccessType;
- this.specifiedAccessType = access;
- this.firePropertyChanged(SPECIFIED_ACCESS_TYPE_PROPERTY, old, access);
- }
-
- public XmlAccessType getDefaultAccessType() {
- return this.defaultAccessType;
- }
-
- protected void setDefaultAccessType(XmlAccessType access) {
- XmlAccessType old = this.defaultAccessType;
- this.defaultAccessType = access;
- this.firePropertyChanged(DEFAULT_ACCESS_TYPE_PROPERTY, old, access);
- }
-
- protected XmlAccessType getResourceAccessType() {
- return XmlAccessType.fromJavaResourceModel(this.getAccessorTypeAnnotation().getValue());
- }
-
- protected XmlAccessorTypeAnnotation getAccessorTypeAnnotation() {
- return (XmlAccessorTypeAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_TYPE);
- }
-
- /**
- * If there is a @XmlAccessorType on a class, then it is used.
- * Otherwise, if a @XmlAccessorType exists on one of its super classes, then it is inherited.
- * Otherwise, the @XmlAccessorType on a package is inherited.
- */
- protected XmlAccessType buildDefaultAccessType() {
- XmlAccessType superAccessType = this.getSuperClassAccessType();
- if (superAccessType != null) {
- return superAccessType;
- }
- XmlAccessType packageAccessType = getPackageAccessType();
- if (packageAccessType != null) {
- return packageAccessType;
- }
- return XmlAccessType.PUBLIC_MEMBER;
- }
-
- protected XmlAccessType getSuperClassAccessType() {
- JaxbClass superClass = this.getSuperClass();
- return superClass == null ? null : superClass.getSpecifiedAccessType();
- }
-
- protected XmlAccessType getPackageAccessType() {
- JaxbPackageInfo packageInfo = this.getPackageInfo();
- return packageInfo == null ? null : packageInfo.getAccessType();
- }
-
-
- // ********** access order **********
-
- public XmlAccessOrder getAccessOrder() {
- return (this.specifiedAccessOrder != null) ? this.specifiedAccessOrder : this.defaultAccessOrder;
- }
-
- public XmlAccessOrder getSpecifiedAccessOrder() {
- return this.specifiedAccessOrder;
- }
-
- public void setSpecifiedAccessOrder(XmlAccessOrder accessOrder) {
- this.getAccessorOrderAnnotation().setValue(XmlAccessOrder.toJavaResourceModel(accessOrder));
- this.setSpecifiedAccessOrder_(accessOrder);
- }
-
- protected void setSpecifiedAccessOrder_(XmlAccessOrder accessOrder) {
- XmlAccessOrder old = this.specifiedAccessOrder;
- this.specifiedAccessOrder = accessOrder;
- this.firePropertyChanged(SPECIFIED_ACCESS_ORDER_PROPERTY, old, accessOrder);
- }
-
- public XmlAccessOrder getDefaultAccessOrder() {
- return this.defaultAccessOrder;
- }
-
- protected void setDefaultAccessOrder(XmlAccessOrder accessOrder) {
- XmlAccessOrder old = this.defaultAccessOrder;
- this.defaultAccessOrder = accessOrder;
- this.firePropertyChanged(DEFAULT_ACCESS_ORDER_PROPERTY, old, accessOrder);
- }
-
- protected XmlAccessOrder getResourceAccessOrder() {
- return XmlAccessOrder.fromJavaResourceModel(this.getAccessorOrderAnnotation().getValue());
- }
-
- protected XmlAccessorOrderAnnotation getAccessorOrderAnnotation() {
- return (XmlAccessorOrderAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_ORDER);
- }
-
- /**
- * If there is a @XmlAccessorOrder on a class, then it is used.
- * Otherwise, if a @XmlAccessorOrder exists on one of its super classes, then it is inherited (by the virtue of Inherited)
- * Otherwise, the @XmlAccessorOrder on the package of the class is used, if it's there.
- * Otherwise XmlAccessOrder.UNDEFINED.
- */
- protected XmlAccessOrder buildDefaultAccessOrder() {
- XmlAccessOrder superAccessOrder = this.getSuperClassAccessOrder();
- if (superAccessOrder != null) {
- return superAccessOrder;
- }
- XmlAccessOrder packageAccessOrder = getPackageAccessOrder();
- if (packageAccessOrder != null) {
- return packageAccessOrder;
- }
- return XmlAccessOrder.UNDEFINED;
- }
-
- protected XmlAccessOrder getSuperClassAccessOrder() {
- JaxbClass superClass = this.getSuperClass();
- return superClass == null ? null : superClass.getSpecifiedAccessOrder();
- }
-
- protected XmlAccessOrder getPackageAccessOrder() {
- JaxbPackageInfo packageInfo = this.getPackageInfo();
- return packageInfo == null ? null : packageInfo.getAccessOrder();
- }
-
-
- //****************** XmlJavaTypeAdapter *********************
-
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceType();
- }
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaPersistentClass.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaPersistentClass.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
- }
-
- public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
- }
-
- public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
- }
-
- protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
- return new GenericJavaTypeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
- }
-
- public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
- }
-
-
- // **************** xml see also ******************************************
-
- protected XmlSeeAlsoAnnotation getXmlSeeAlsoAnnotation() {
- return (XmlSeeAlsoAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_SEE_ALSO);
- }
-
- protected void initXmlSeeAlso() {
- XmlSeeAlsoAnnotation annotation = getXmlSeeAlsoAnnotation();
- this.xmlSeeAlso = (annotation == null) ?
- null
- : buildXmlSeeAlso(annotation);
- }
-
- protected XmlSeeAlso buildXmlSeeAlso(XmlSeeAlsoAnnotation annotation) {
- return new GenericJavaXmlSeeAlso(this, annotation);
- }
-
- public XmlSeeAlso getXmlSeeAlso() {
- return this.xmlSeeAlso;
- }
-
- public XmlSeeAlso addXmlSeeAlso() {
- if (this.xmlSeeAlso != null) {
- throw new IllegalStateException();
- }
- XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) getJavaResourceType().addAnnotation(JAXB.XML_SEE_ALSO);
-
- XmlSeeAlso xmlSeeAlso = buildXmlSeeAlso(annotation);
- setXmlSeeAlso_(xmlSeeAlso);
- return xmlSeeAlso;
- }
-
- protected void setXmlSeeAlso_(XmlSeeAlso xmlSeeAlso) {
- XmlSeeAlso old = this.xmlSeeAlso;
- this.xmlSeeAlso = xmlSeeAlso;
- firePropertyChanged(XML_SEE_ALSO_PROPERTY, old, xmlSeeAlso);
- }
-
- public void removeXmlSeeAlso() {
- if (this.xmlSeeAlso == null) {
- throw new IllegalStateException();
- }
- getJavaResourceType().removeAnnotation(JAXB.XML_SEE_ALSO);
- setXmlSeeAlso_(null);
- }
-
- protected void syncXmlSeeAlso() {
- XmlSeeAlsoAnnotation annotation = getXmlSeeAlsoAnnotation();
- if (annotation != null) {
- if (this.xmlSeeAlso != null) {
- this.xmlSeeAlso.synchronizeWithResourceModel();
- }
- else {
- setXmlSeeAlso_(buildXmlSeeAlso(annotation));
- }
- }
- else {
- setXmlSeeAlso_(null);
- }
- }
-
- protected void updateXmlSeeAlso() {
- if (this.xmlSeeAlso != null) {
- this.xmlSeeAlso.update();
- }
- }
-
-
- // ********** attributes **********
-
- public Iterable<JaxbPersistentAttribute> getAttributes() {
- return this.attributesContainer.getAttributes();
- }
-
- public int getAttributesSize() {
- return this.attributesContainer.getAttributesSize();
- }
-
- protected JaxbAttributesContainer.Owner buildAttributesContainerOwner() {
- return new JaxbAttributesContainer.Owner() {
- public XmlAccessType getAccessType() {
- return GenericJavaPersistentClass.this.getAccessType();
- }
-
- public void fireAttributeAdded(JaxbPersistentAttribute attribute) {
- GenericJavaPersistentClass.this.fireItemAdded(ATTRIBUTES_COLLECTION, attribute);
- }
-
- public void fireAttributeRemoved(JaxbPersistentAttribute attribute) {
- GenericJavaPersistentClass.this.fireItemRemoved(ATTRIBUTES_COLLECTION, attribute);
- }
- };
- }
-
-
- // ********** inherited attributes **********
-
- public Iterable<JaxbPersistentAttribute> getInheritedAttributes() {
- return new CompositeIterable<JaxbPersistentAttribute>(this.getInheritedAttributeSets());
- }
-
- protected Iterable<Iterable<JaxbPersistentAttribute>> getInheritedAttributeSets() {
- return new TransformationIterable<JaxbAttributesContainer, Iterable<JaxbPersistentAttribute>>(this.getInheritedAttributesContainers()) {
- @Override
- protected Iterable<JaxbPersistentAttribute> transform(JaxbAttributesContainer attributesContainer) {
- return attributesContainer.getAttributes();
- }
- };
- }
-
- protected Iterable<JaxbAttributesContainer> getInheritedAttributesContainers() {
- return new LiveCloneIterable<JaxbAttributesContainer>(this.inheritedAttributesContainers.values()); // read-only
- }
-
- public int getInheritedAttributesSize() {
- int size = 0;
- for (JaxbAttributesContainer attributesContainer : getInheritedAttributesContainers()) {
- size += attributesContainer.getAttributesSize();
- }
- return size;
- }
-
- protected void initializeInheritedAttributes() {
- this.addInheritedAttributesContainer(this.getSuperClass());
- }
-
- protected void addInheritedAttributesContainer(JaxbClass superClass) {
- if (superClass != null) {
- if (superClass.getKind() == Kind.TRANSIENT) {
- this.inheritedAttributesContainers.put(superClass, this.buildInheritedAttributesContainer(superClass));
- this.addInheritedAttributesContainer(superClass.getSuperClass());
- }
- }
- }
-
- protected JaxbAttributesContainer buildInheritedAttributesContainer(JaxbClass jaxbClass) {
- return new GenericJavaAttributesContainer(this, buildInheritedAttributesContainerOwner(), jaxbClass.getJavaResourceType());
- }
-
- protected JaxbAttributesContainer.Owner buildInheritedAttributesContainerOwner() {
- return new JaxbAttributesContainer.Owner() {
- public XmlAccessType getAccessType() {
- return GenericJavaPersistentClass.this.getAccessType();
- }
-
- public void fireAttributeAdded(JaxbPersistentAttribute attribute) {
- GenericJavaPersistentClass.this.fireItemAdded(INHERITED_ATTRIBUTES_COLLECTION, attribute);
- }
-
- public void fireAttributeRemoved(JaxbPersistentAttribute attribute) {
- GenericJavaPersistentClass.this.fireItemRemoved(INHERITED_ATTRIBUTES_COLLECTION, attribute);
- }
- };
- }
-
- protected void syncInheritedAttributes() {
- for (JaxbAttributesContainer attributesContainer : this.inheritedAttributesContainers.values()) {
- attributesContainer.synchronizeWithResourceModel();
- }
- }
-
- /**
- * The attributes are synchronized during the <em>update</em> because
- * the list of resource attributes is determined by the access type
- * which can be controlled in a number of different places....
- */
- protected void updateInheritedAttributes() {
- HashSet<JaxbClass> contextSuperclasses = CollectionTools.set(this.inheritedAttributesContainers.keySet());
- for (JaxbClass superClass : getAncestors()) {
- if (superClass.getKind() == Kind.TRANSIENT) {
- boolean match = false;
- for (Iterator<JaxbClass> stream = contextSuperclasses.iterator(); stream.hasNext(); ) {
- JaxbClass contextSuperclass = stream.next();
- if (contextSuperclass == superClass) {
- stream.remove();
- this.inheritedAttributesContainers.get(contextSuperclass).update();
- match = true;
- break;
- }
- }
- if ( ! match) {
- JaxbAttributesContainer container = this.buildInheritedAttributesContainer(superClass);
- this.inheritedAttributesContainers.put(superClass, container);
- this.fireItemsAdded(INHERITED_ATTRIBUTES_COLLECTION, CollectionTools.collection(container.getAttributes()));
- }
- }
- }
-
- for (JaxbClass superClass : contextSuperclasses) {
- JaxbAttributesContainer container = this.inheritedAttributesContainers.remove(superClass);
- this.fireItemsRemoved(INHERITED_ATTRIBUTES_COLLECTION, CollectionTools.collection(container.getAttributes()));
- }
- }
-
- public boolean isInherited(JaxbPersistentAttribute attribute) {
- if (attribute.getParent() != this) {
- throw new IllegalArgumentException("The attribute is not owned by this GenericJavaPersistentClass"); //$NON-NLS-1$
- }
- return !CollectionTools.contains(this.getAttributes(), attribute);
- }
-
- public String getJavaResourceAttributeOwningTypeName(JaxbPersistentAttribute attribute) {
- if (attribute.getParent() != this) {
- throw new IllegalArgumentException("The attribute is not owned by this GenericJavaPersistentClass"); //$NON-NLS-1$
- }
- for (JaxbClass inheritedClass : this.inheritedAttributesContainers.keySet()) {
- if (CollectionTools.contains(this.inheritedAttributesContainers.get(inheritedClass).getAttributes(), attribute)) {
- return inheritedClass.getSimpleName();
- }
- }
- throw new IllegalArgumentException("The attribute is not an inherited attribute"); //$NON-NLS-1$
- }
-
-
- // ********** content assist **********
-
- @Override
- 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;
- }
- for (JaxbPersistentAttribute attribute : this.getAttributes()) {
- result = attribute.getJavaCompletionProposals(pos, filter, astRoot);
- if (!CollectionTools.isEmpty(result)) {
- return result;
- }
- }
- return EmptyIterable.instance();
- }
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.xmlAdaptable.validate(messages, reporter, astRoot);
- this.validateXmlAnyAttributeMapping(messages, astRoot);
- this.validateXmlAnyElementMapping(messages, astRoot);
- this.validateXmlValueMapping(messages, astRoot);
- this.validateXmlIDs(messages, astRoot);
- for (JaxbPersistentAttribute attribute : getAttributes()) {
- attribute.validate(messages, reporter, astRoot);
- }
- }
-
- protected void validateXmlValueMapping(List<IMessage> messages, CompilationUnit astRoot) {
- String xmlValueMapping = null;
- for (JaxbPersistentAttribute attribute : getAttributes()) {
- if (attribute.getMappingKey() == MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY) {
- if (xmlValueMapping != null) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.MULTIPLE_XML_VALUE_MAPPINGS_DEFINED,
- new String[] {attribute.getName(), xmlValueMapping},
- attribute.getMapping(),
- attribute.getMapping().getValidationTextRange(astRoot)));
- }
- else {
- xmlValueMapping = attribute.getName();
- }
- }
- }
- if (xmlValueMapping != null) {
- for (JaxbPersistentAttribute attribute : getAttributes()) {
- if (attribute.getName() != xmlValueMapping) {
- if (attribute.getMappingKey() != MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY
- && attribute.getMappingKey() != MappingKeys.XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.XML_VALUE_MAPPING_WITH_NON_XML_ATTRIBUTE_MAPPING_DEFINED,
- new String[] {attribute.getName(), xmlValueMapping},
- attribute.getMapping(),
- attribute.getMapping().getValidationTextRange(astRoot)));
- }
- }
- }
- }
- }
-
- protected void validateXmlAnyAttributeMapping(List<IMessage> messages, CompilationUnit astRoot) {
- String xmlAnyAttributeMapping = null;
- for (JaxbPersistentAttribute attribute : getAttributes()) {
- if (attribute.getMappingKey() == MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY) {
- if (xmlAnyAttributeMapping != null) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.MULTIPLE_XML_ANY_ATTRIBUTE_MAPPINGS_DEFINED,
- new String[] {attribute.getName(), xmlAnyAttributeMapping},
- attribute.getMapping(),
- attribute.getMapping().getValidationTextRange(astRoot)));
- }
- else {
- xmlAnyAttributeMapping = attribute.getName();
- }
- }
- }
- }
-
- protected void validateXmlAnyElementMapping(List<IMessage> messages, CompilationUnit astRoot) {
- String xmlAnyElementMapping = null;
- for (JaxbPersistentAttribute attribute : getAttributes()) {
- if (attribute.getMappingKey() == MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY) {
- if (xmlAnyElementMapping != null) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.MULTIPLE_XML_ANY_ELEMENT_MAPPINGS_DEFINED,
- new String[] {attribute.getName(), xmlAnyElementMapping},
- attribute.getMapping(),
- attribute.getMapping().getValidationTextRange(astRoot)));
- }
- else {
- xmlAnyElementMapping = attribute.getName();
- }
- }
- }
- }
-
- protected void validateXmlIDs(List<IMessage> messages, CompilationUnit astRoot) {
- String xmlIdMapping = null;
- for (JaxbBasicMapping containmentMapping : getBasicMappingsWithXmlID()) {
- if (xmlIdMapping != null) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.MULTIPLE_XML_IDS_DEFINED,
- new String[] { containmentMapping.getPersistentAttribute().getName(), xmlIdMapping },
- containmentMapping,
- containmentMapping.getValidationTextRange(astRoot)));
- }
- else {
- xmlIdMapping = containmentMapping.getPersistentAttribute().getName();
- }
- }
- }
-
- protected Iterable<JaxbBasicMapping> getBasicMappingsWithXmlID(){
- return new FilteringIterable<JaxbBasicMapping>(this.getBasicMappings()){
- @Override
- protected boolean accept(JaxbBasicMapping basicMapping) {
- return basicMapping.getXmlID() != null;
- }
- };
- }
-
- protected Iterable<JaxbBasicMapping> getBasicMappings() {
- return new SubIterableWrapper<JaxbAttributeMapping, JaxbBasicMapping>(this.getBasicMappings_());
- }
-
- protected Iterable<JaxbAttributeMapping> getBasicMappings_(){
- return new FilteringIterable<JaxbAttributeMapping>(this.getAttributeMappings()){
- @Override
- protected boolean accept(JaxbAttributeMapping attributeMapping) {
- return (attributeMapping.getKey() == MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY
- || attributeMapping.getKey() == MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- }
- };
- }
-
- private Iterable<? extends JaxbAttributeMapping> getAttributeMappings() {
- return new TransformationIterable<JaxbPersistentAttribute, JaxbAttributeMapping>(this.getAttributes()) {
- @Override
- protected JaxbAttributeMapping transform(JaxbPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public boolean containsXmlId() {
- return !CollectionTools.isEmpty(getBasicMappingsWithXmlID());
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientClass.java
deleted file mode 100644
index 98e1148fe0..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientClass.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.context.java;
-
-import java.util.Collection;
-import java.util.HashSet;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ChainIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
-import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlTransientAnnotation;
-
-
-public class GenericJavaTransientClass
- extends AbstractJavaType
- implements JaxbTransientClass {
-
- protected JaxbClass superClass;
-
- protected XmlAccessType specifiedAccessType;
-
- protected XmlAccessOrder specifiedAccessOrder;
-
- public GenericJavaTransientClass(JaxbContextRoot parent, JavaResourceType resourceType) {
- super(parent, resourceType);
- this.superClass = this.buildSuperClass();
- this.specifiedAccessType = this.getResourceAccessType();
- this.specifiedAccessOrder = this.getResourceAccessOrder();
- }
-
- @Override
- public JavaResourceType getJavaResourceType() {
- return (JavaResourceType) super.getJavaResourceType();
- }
-
- @Override
- public JaxbContextRoot getParent() {
- return (JaxbContextRoot) super.getParent();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedAccessType_(this.getResourceAccessType());
- this.setSpecifiedAccessOrder_(this.getResourceAccessOrder());
- }
-
- @Override
- public void update() {
- super.update();
- this.setSuperClass(this.buildSuperClass());
- }
-
-
- // ********** xml transient annotation **********
-
- protected XmlTransientAnnotation getXmlTransientAnnotation() {
- return (XmlTransientAnnotation) this.getJavaResourceType().getAnnotation(JAXB.XML_TRANSIENT);
- }
-
-
- // ********** JaxbType impl **********
-
- public Kind getKind() {
- return Kind.TRANSIENT;
- }
-
-
- // ********** super class **********
-
- public JaxbClass getSuperClass() {
- return this.superClass;
- }
-
- protected void setSuperClass(JaxbClass superClass) {
- JaxbClass old = this.superClass;
- this.superClass = superClass;
- this.firePropertyChanged(SUPER_CLASS_PROPERTY, old, superClass);
- }
-
- protected JaxbClass buildSuperClass() {
- HashSet<JavaResourceType> visited = new HashSet<JavaResourceType>();
- visited.add(this.getJavaResourceType());
- JaxbClass spc = this.getSuperClass(this.getJavaResourceType().getSuperclassQualifiedName(), visited);
- if (spc == null) {
- return null;
- }
- if (CollectionTools.contains(spc.getInheritanceHierarchy(), this)) {
- return null; // short-circuit in this case, we have circular inheritance
- }
- return spc;
- }
-
- /**
- * The JPA spec allows non-persistent types in a persistent type's
- * inheritance hierarchy. We check for a persistent type with the
- * specified name in the persistence unit. If it is not found we use
- * resource persistent type and look for *its* super type.
- *
- * The 'visited' collection is used to detect a cycle in the *resource* type
- * inheritance hierarchy and prevent the resulting stack overflow.
- * Any cycles in the *context* type inheritance hierarchy are handled in
- * #buildSuperPersistentType().
- */
- protected JaxbClass getSuperClass(String typeName, Collection<JavaResourceType> visited) {
- if (typeName == null) {
- return null;
- }
- JavaResourceType resourceType = (JavaResourceType) getJaxbProject().getJavaResourceType(typeName, JavaResourceAbstractType.Kind.TYPE);
- if ((resourceType == null) || visited.contains(resourceType)) {
- return null;
- }
- visited.add(resourceType);
- JaxbClass spc = this.getClass(typeName);
- return (spc != null) ? spc : this.getSuperClass(resourceType.getSuperclassQualifiedName(), visited); // recurse
- }
-
- protected JaxbClass getClass(String fullyQualifiedTypeName) {
- return this.getParent().getClass(fullyQualifiedTypeName);
- }
-
-
- // ********** inheritance **********
-
- public Iterable<JaxbClass> getInheritanceHierarchy() {
- return this.getInheritanceHierarchyOf(this);
- }
-
- public Iterable<JaxbClass> getAncestors() {
- return this.getInheritanceHierarchyOf(this.superClass);
- }
-
- protected Iterable<JaxbClass> getInheritanceHierarchyOf(JaxbClass start) {
- // using a chain iterator to traverse up the inheritance tree
- return new ChainIterable<JaxbClass>(start) {
- @Override
- protected JaxbClass nextLink(JaxbClass jaxbClass) {
- return jaxbClass.getSuperClass();
- }
- };
- }
-
-
- // ********** access type **********
-
- public XmlAccessType getAccessType() {
- return (this.specifiedAccessType != null) ? this.specifiedAccessType : this.getDefaultAccessType();
- }
-
- public XmlAccessType getSpecifiedAccessType() {
- return this.specifiedAccessType;
- }
-
- public void setSpecifiedAccessType(XmlAccessType access) {
- this.getAccessorTypeAnnotation().setValue(XmlAccessType.toJavaResourceModel(access));
- this.setSpecifiedAccessType_(access);
- }
-
- protected void setSpecifiedAccessType_(XmlAccessType access) {
- XmlAccessType old = this.specifiedAccessType;
- this.specifiedAccessType = access;
- this.firePropertyChanged(SPECIFIED_ACCESS_TYPE_PROPERTY, old, access);
- }
-
- public XmlAccessType getDefaultAccessType() {
- return null;
- }
-
- protected XmlAccessType getResourceAccessType() {
- return XmlAccessType.fromJavaResourceModel(this.getAccessorTypeAnnotation().getValue());
- }
-
- protected XmlAccessorTypeAnnotation getAccessorTypeAnnotation() {
- return (XmlAccessorTypeAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_TYPE);
- }
-
-
- // ********** access order **********
-
- public XmlAccessOrder getAccessOrder() {
- return (this.specifiedAccessOrder != null) ? this.specifiedAccessOrder : this.getDefaultAccessOrder();
- }
-
- public XmlAccessOrder getSpecifiedAccessOrder() {
- return this.specifiedAccessOrder;
- }
-
- public void setSpecifiedAccessOrder(XmlAccessOrder accessOrder) {
- this.getAccessorOrderAnnotation().setValue(XmlAccessOrder.toJavaResourceModel(accessOrder));
- this.setSpecifiedAccessOrder_(accessOrder);
- }
-
- protected void setSpecifiedAccessOrder_(XmlAccessOrder accessOrder) {
- XmlAccessOrder old = this.specifiedAccessOrder;
- this.specifiedAccessOrder = accessOrder;
- this.firePropertyChanged(SPECIFIED_ACCESS_ORDER_PROPERTY, old, accessOrder);
- }
-
- public XmlAccessOrder getDefaultAccessOrder() {
- return null;
- }
-
- protected XmlAccessOrder getResourceAccessOrder() {
- return XmlAccessOrder.fromJavaResourceModel(this.getAccessorOrderAnnotation().getValue());
- }
-
- protected XmlAccessorOrderAnnotation getAccessorOrderAnnotation() {
- return (XmlAccessorOrderAnnotation) getJavaResourceType().getNonNullAnnotation(JAXB.XML_ACCESSOR_ORDER);
- }
-
- // **************** validation ********************************************
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getXmlTransientAnnotation().getTextRange(astRoot);
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTypeXmlJavaTypeAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTypeXmlJavaTypeAdapter.java
index 4932837849..10a874665f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTypeXmlJavaTypeAdapter.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTypeXmlJavaTypeAdapter.java
@@ -9,20 +9,20 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
public class GenericJavaTypeXmlJavaTypeAdapter
extends AbstractJavaXmlJavaTypeAdapter
{
- public GenericJavaTypeXmlJavaTypeAdapter(JaxbPersistentClass parent, XmlJavaTypeAdapterAnnotation resource) {
+ public GenericJavaTypeXmlJavaTypeAdapter(JaxbType parent, XmlJavaTypeAdapterAnnotation resource) {
super(parent, resource);
}
@Override
- public JaxbPersistentClass getParent() {
- return (JaxbPersistentClass) super.getParent();
+ public JaxbType getParent() {
+ return (JaxbType) super.getParent();
}
// ********** type **********
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdaptable.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdaptable.java
deleted file mode 100644
index 09eb40ac12..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdaptable.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jaxb.core.JaxbNode;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
-import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-class GenericJavaXmlAdaptable
- extends AbstractJavaContextNode
- implements XmlAdaptable {
-
- protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
-
- protected XmlAdaptable.Owner owner;
-
- GenericJavaXmlAdaptable(JaxbNode parent, XmlAdaptable.Owner owner) {
- super(parent);
- this.owner = owner;
- this.initializeXmlJavaTypeAdapter();
- }
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncXmlJavaTypeAdapter();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateXmlJavaTypeAdapter();
- }
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.xmlJavaTypeAdapter == null ? this.owner.getResource().getTextRange(astRoot) : this.xmlJavaTypeAdapter.getResourceXmlJavaTypeAdapter().getTextRange(astRoot);
- }
-
- public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlJavaTypeAdapter;
- }
-
- public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- if (this.xmlJavaTypeAdapter != null) {
- throw new IllegalStateException();
- }
- XmlJavaTypeAdapterAnnotation annotation = (XmlJavaTypeAdapterAnnotation) this.owner.getResource().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
-
- XmlJavaTypeAdapter xmlJavaTypeAdapter = this.buildXmlJavaTypeAdapter(annotation);
- this.setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
- return xmlJavaTypeAdapter;
- }
-
- protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
- return this.owner.buildXmlJavaTypeAdapter(xmlJavaTypeAdapterAnnotation);
- }
-
- public void removeXmlJavaTypeAdapter() {
- if (this.xmlJavaTypeAdapter == null) {
- throw new IllegalStateException();
- }
- this.owner.getResource().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- this.setXmlJavaTypeAdapter_(null);
- }
-
- protected void initializeXmlJavaTypeAdapter() {
- XmlJavaTypeAdapterAnnotation annotation = this.getXmlJavaTypeAdapterAnnotation();
- if (annotation != null) {
- this.xmlJavaTypeAdapter = this.buildXmlJavaTypeAdapter(annotation);
- }
- }
-
- protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
- return (XmlJavaTypeAdapterAnnotation) this.owner.getResource().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- protected void syncXmlJavaTypeAdapter() {
- XmlJavaTypeAdapterAnnotation annotation = this.getXmlJavaTypeAdapterAnnotation();
- if (annotation != null) {
- if (this.getXmlJavaTypeAdapter() != null) {
- this.getXmlJavaTypeAdapter().synchronizeWithResourceModel();
- }
- else {
- this.setXmlJavaTypeAdapter_(this.buildXmlJavaTypeAdapter(annotation));
- }
- }
- else {
- this.setXmlJavaTypeAdapter_(null);
- }
- }
-
- protected void updateXmlJavaTypeAdapter() {
- if (this.getXmlJavaTypeAdapter() != null) {
- this.getXmlJavaTypeAdapter().update();
- }
- }
-
- protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
- XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
- this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
- this.owner.fireXmlAdapterChanged(oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- if (getXmlJavaTypeAdapter() != null) {
- this.getXmlJavaTypeAdapter().validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdapter.java
new file mode 100644
index 0000000000..b71db30e34
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAdapter.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jaxb.core.context.XmlAdapter;
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
+
+
+public class GenericJavaXmlAdapter
+ extends AbstractJavaContextNode
+ implements XmlAdapter {
+
+ protected final JavaResourceType resourceType;
+
+ protected String boundType;
+
+ protected String valueType;
+
+
+ public GenericJavaXmlAdapter(JavaContextNode parent, JavaResourceType resourceType) {
+ super(parent);
+ this.resourceType = resourceType;
+ initBoundAndValueTypes();
+ }
+
+
+ public JavaResourceType getJavaResourceType() {
+ return this.resourceType;
+ }
+
+
+ // ***** overrides *****
+
+ @Override
+ public IResource getResource() {
+ return this.resourceType.getFile();
+ }
+
+
+ // ***** sync/update *****
+
+ protected void initBoundAndValueTypes() {
+ String[] types = findBoundAndValueTypes(getJavaResourceType());
+ this.boundType = types[0];
+ this.valueType = types[1];
+ }
+
+
+ @Override
+ public void update() {
+ super.update();
+ // these are in update, since their values may depend on other classes
+ updateBoundAndValueTypes();
+ }
+
+ protected void updateBoundAndValueTypes() {
+ String[] types = findBoundAndValueTypes(getJavaResourceType());
+ setBoundType_(types[0]);
+ setValueType_(types[1]);
+ }
+
+ protected String[] findBoundAndValueTypes(JavaResourceType resourceType) {
+ for (JavaResourceMethod resourceMethod : resourceType.getMethods()) {
+ if (MARSHAL_METHOD_NAME.equals(resourceMethod.getName()) && resourceMethod.getParametersSize() == 1) {
+ String valueType = resourceMethod.getTypeName();
+ String boundType = resourceMethod.getParameterTypeName(0);
+ return new String[] { boundType, valueType };
+ }
+ }
+
+ String superResourceTypeName = resourceType.getSuperclassQualifiedName();
+ if (! StringTools.stringIsEmpty(superResourceTypeName)) {
+ JavaResourceType superResourceType
+ = (JavaResourceType) getJaxbProject().getJavaResourceType(superResourceTypeName, JavaResourceAbstractType.Kind.TYPE);
+ if (superResourceType != null) {
+ return findBoundAndValueTypes(superResourceType);
+ }
+ }
+
+ String objectTypeName = Object.class.getName();
+ return new String[] { objectTypeName, objectTypeName };
+ }
+
+
+ // ***** bound type *****
+
+ public String getBoundType() {
+ return this.boundType;
+ }
+
+ protected void setBoundType_(String newType) {
+ String oldType = this.boundType;
+ this.boundType = newType;
+ firePropertyChanged(BOUND_TYPE_PROPERTY, oldType, newType);
+ }
+
+
+ // ***** value type *****
+
+ public String getValueType() {
+ return this.valueType;
+ }
+
+ protected void setValueType_(String newType) {
+ String oldType = this.valueType;
+ this.valueType = newType;
+ firePropertyChanged(VALUE_TYPE_PROPERTY, oldType, newType);
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return getJavaResourceType().getNameTextRange(astRoot);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java
index 25c633dcc1..96b04b23ca 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java
@@ -12,10 +12,8 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import java.util.Map;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
@@ -27,76 +25,119 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class GenericJavaXmlAnyAttributeMapping
- extends AbstractJavaAttributeMapping<XmlAnyAttributeAnnotation>
- implements XmlAnyAttributeMapping
-{
-
- protected final XmlAdaptable xmlAdaptable;
-
-
+ extends AbstractJavaAttributeMapping<XmlAnyAttributeAnnotation>
+ implements XmlAnyAttributeMapping {
+
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
+
+
public GenericJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) {
super(parent);
- this.xmlAdaptable = buildXmlAdaptable();
- }
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.xmlAdaptable.update();
+ initializeXmlJavaTypeAdapter();
}
-
+
+
public String getKey() {
return MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY;
}
-
+
@Override
protected String getAnnotationName() {
return JAXB.XML_ANY_ATTRIBUTE;
}
-
- //****************** XmlJavaTypeAdapter *********************
-
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlAnyAttributeMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlAnyAttributeMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
}
-
+
+ @Override
+ public void update() {
+ super.update();
+ updateXmlJavaTypeAdapter();
+ }
+
+
+ // ***** XmlJavaTypeAdapter *****
+
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
}
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
+ }
+
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
-
+
+ public void removeXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
+ }
+
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
-
- public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
}
-
- //************* validation ****************
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
+
+ // ***** validation *****
+
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
- if (!getPersistentAttribute().isJavaResourceAttributeTypeSubTypeOf(Map.class.getName())) {
+
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
+
+ if (! getPersistentAttribute().isJavaResourceAttributeTypeSubTypeOf(Map.class.getName())) {
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -105,5 +146,4 @@ public class GenericJavaXmlAnyAttributeMapping
getValidationTextRange(astRoot)));
}
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java
index ce2f11cd0e..274aeec37d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java
@@ -11,7 +11,6 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -22,7 +21,6 @@ import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterab
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefs;
@@ -50,10 +48,10 @@ public class GenericJavaXmlAnyElementMapping
protected String specifiedValue;
- protected final XmlAdaptable xmlAdaptable;
-
protected final XmlElementRefs xmlElementRefs;
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
+
protected XmlElementWrapper xmlElementWrapper;
protected XmlMixed xmlMixed;
@@ -63,8 +61,8 @@ public class GenericJavaXmlAnyElementMapping
super(parent);
this.specifiedLax = buildSpecifiedLax();
this.specifiedValue = getResourceValueString();
- this.xmlAdaptable = buildXmlAdaptable();
this.xmlElementRefs = buildXmlElementRefs();
+ initializeXmlJavaTypeAdapter();
initializeXmlElementWrapper();
this.initializeXmlMixed();
}
@@ -73,7 +71,7 @@ public class GenericJavaXmlAnyElementMapping
public String getKey() {
return MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY;
}
-
+
@Override
protected String getAnnotationName() {
return JAXB.XML_ANY_ELEMENT;
@@ -87,8 +85,8 @@ public class GenericJavaXmlAnyElementMapping
super.synchronizeWithResourceModel();
setSpecifiedLax_(buildSpecifiedLax());
setSpecifiedValue_(getResourceValueString());
- this.xmlAdaptable.synchronizeWithResourceModel();
this.xmlElementRefs.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
syncXmlElementWrapper();
syncXmlMixed();
}
@@ -96,8 +94,8 @@ public class GenericJavaXmlAnyElementMapping
@Override
public void update() {
super.update();
- this.xmlAdaptable.update();
this.xmlElementRefs.update();
+ updateXmlJavaTypeAdapter();
updateXmlElementWrapper();
updateXmlMixed();
}
@@ -163,50 +161,82 @@ public class GenericJavaXmlAnyElementMapping
}
+ // ***** XmlElementRefs *****
+
+ public XmlElementRefs getXmlElementRefs() {
+ return this.xmlElementRefs;
+ }
+
+ protected XmlElementRefs buildXmlElementRefs() {
+ return new GenericJavaXmlElementRefs(this, new XmlElementRefsContext());
+ }
+
+
// ***** XmlJavaTypeAdapter *****
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
+ }
+
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
}
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
}
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
-
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
-
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlAnyElementMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
-
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlAnyElementMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
}
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
- // ***** XmlElementRefs *****
-
- public XmlElementRefs getXmlElementRefs() {
- return this.xmlElementRefs;
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
}
- protected XmlElementRefs buildXmlElementRefs() {
- return new GenericJavaXmlElementRefs(this, new XmlElementRefsContext());
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
}
@@ -349,8 +379,8 @@ public class GenericJavaXmlAnyElementMapping
// ***** misc *****
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
- return this.xmlElementRefs.getDirectlyReferencedTypeNames();
+ public Iterable<String> getReferencedXmlTypeNames() {
+ return this.xmlElementRefs.getReferencedXmlTypeNames();
}
@@ -401,7 +431,9 @@ public class GenericJavaXmlAnyElementMapping
}
}
- this.xmlAdaptable.validate(messages, reporter, astRoot);
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
if (this.xmlElementWrapper != null) {
this.xmlElementWrapper.validate(messages, reporter, astRoot);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java
index 6b140c3591..6545feedb3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java
@@ -168,14 +168,14 @@ public class GenericJavaXmlAttributeMapping
@Override
public Iterable<String> getNameProposals(Filter<String> filter) {
- XsdTypeDefinition xsdType = GenericJavaXmlAttributeMapping.this.getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition xsdType = GenericJavaXmlAttributeMapping.this.getJaxbClassMapping().getXsdTypeDefinition();
return (xsdType == null) ? EmptyIterable.instance() : xsdType.getAttributeNameProposals(getNamespace(), filter);
}
@Override
public String getDefaultNamespace() {
return (GenericJavaXmlAttributeMapping.this.getJaxbPackage().getAttributeFormDefault() == XmlNsForm.QUALIFIED) ?
- GenericJavaXmlAttributeMapping.this.getPersistentClass().getQName().getNamespace() : "";
+ GenericJavaXmlAttributeMapping.this.getJaxbClassMapping().getQName().getNamespace() : "";
}
@Override
@@ -186,7 +186,7 @@ public class GenericJavaXmlAttributeMapping
@Override
protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- XsdTypeDefinition type = getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition type = getJaxbClassMapping().getXsdTypeDefinition();
if (type != null) {
if (type.getAttribute(getNamespace(), getName()) == null) {
messages.add(getUnresolveSchemaComponentMessage(astRoot));
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
index 0d301bb030..4132ce5c5e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
@@ -19,9 +19,9 @@ import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbQName;
import org.eclipse.jpt.jaxb.core.context.XmlElement;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
@@ -99,12 +99,12 @@ public class GenericJavaXmlElement
return getContext().getAttributeMapping().getPersistentAttribute();
}
- protected JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ protected JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
}
protected JaxbPackage getJaxbPackage() {
- return getPersistentClass().getJaxbPackage();
+ return getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
public XmlElementAnnotation getAnnotation(boolean createIfNull) {
@@ -266,9 +266,11 @@ public class GenericJavaXmlElement
// ***** misc *****
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
// only return the specified type - the default type should already be included
- return (this.specifiedType == null) ? EmptyIterable.<String>instance() : new SingleElementIterable(getFullyQualifiedType());
+ return (this.specifiedType == null) ?
+ EmptyIterable.<String>instance()
+ : new SingleElementIterable(getFullyQualifiedType());
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
index c7cdd5b9fa..55d24fc653 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java
@@ -88,21 +88,21 @@ public class GenericJavaXmlElementMapping
return this.xmlElementWrapper;
}
+ protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) {
+ return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation);
+ }
+
public XmlElementWrapper addXmlElementWrapper() {
if (this.xmlElementWrapper != null) {
throw new IllegalStateException();
}
XmlElementWrapperAnnotation annotation =
- (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER);
- XmlElementWrapper xmlElementWrapper = this.buildXmlElementWrapper(annotation);
+ (XmlElementWrapperAnnotation) getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER);
+ XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(annotation);
this.setXmlElementWrapper_(xmlElementWrapper);
return xmlElementWrapper;
}
- protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) {
- return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation);
- }
-
public void removeXmlElementWrapper() {
if (this.xmlElementWrapper == null) {
throw new IllegalStateException();
@@ -161,10 +161,10 @@ public class GenericJavaXmlElementMapping
// ***** misc *****
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
return new CompositeIterable<String>(
- super.getDirectlyReferencedTypeNames(),
- this.xmlElement.getDirectlyReferencedTypeNames());
+ super.getReferencedXmlTypeNames(),
+ this.xmlElement.getReferencedXmlTypeNames());
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java
index 721c06a7d1..9a4bd162d9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRef.java
@@ -20,14 +20,15 @@ import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbQName;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
@@ -92,12 +93,12 @@ public class GenericJavaXmlElementRef
return getContext().getAttributeMapping().getPersistentAttribute();
}
- protected JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ protected JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
}
protected JaxbPackage getJaxbPackage() {
- return getPersistentClass().getJaxbPackage();
+ return getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
public XmlElementRefAnnotation getAnnotation() {
@@ -192,7 +193,7 @@ public class GenericJavaXmlElementRef
// ***** misc *****
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
// only return the specified type - the default type should already be included
if (this.specifiedType != null) {
String fqType = getFullyQualifiedType();
@@ -268,8 +269,8 @@ public class GenericJavaXmlElementRef
}
// if type is a persistent class, check that it or a subclass has a root element specified
- JaxbPersistentClass persistentClass = getJaxbProject().getContextRoot().getPersistentClass(fqType);
- if (persistentClass != null && ! persistentClass.hasRootElementInHierarchy()) {
+ JaxbTypeMapping typeMapping = getJaxbProject().getContextRoot().getTypeMapping(fqType);
+ if (typeMapping != null && ! typeMapping.hasRootElementInHierarchy()) {
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -299,9 +300,9 @@ public class GenericJavaXmlElementRef
return JAXB.JAXB_ELEMENT.equals(GenericJavaXmlElementRef.this.getFullyQualifiedType());
}
- protected JaxbPersistentClass getReferencedPersistentClass() {
+ protected JaxbTypeMapping getReferencedTypeMapping() {
String fqTypeName = GenericJavaXmlElementRef.this.getFullyQualifiedType();
- return getJaxbProject().getContextRoot().getPersistentClass(fqTypeName);
+ return getJaxbProject().getContextRoot().getTypeMapping(fqTypeName);
}
@Override
@@ -315,9 +316,9 @@ public class GenericJavaXmlElementRef
return super.getDefaultName();
}
- JaxbPersistentClass referencedClass = getReferencedPersistentClass();
- if (referencedClass != null) {
- XmlRootElement rootElement = referencedClass.getRootElement();
+ JaxbTypeMapping referencedTypeMapping = getReferencedTypeMapping();
+ if (referencedTypeMapping != null) {
+ XmlRootElement rootElement = referencedTypeMapping.getXmlRootElement();
if (rootElement != null) {
return rootElement.getQName().getName();
}
@@ -328,9 +329,9 @@ public class GenericJavaXmlElementRef
@Override
public String getDefaultNamespace() {
- JaxbPersistentClass referencedClass = getReferencedPersistentClass();
- if (referencedClass != null) {
- XmlRootElement rootElement = referencedClass.getRootElement();
+ JaxbTypeMapping referencedTypeMapping = getReferencedTypeMapping();
+ if (referencedTypeMapping != null) {
+ XmlRootElement rootElement = referencedTypeMapping.getXmlRootElement();
if (rootElement != null) {
return rootElement.getQName().getNamespace();
}
@@ -356,7 +357,7 @@ public class GenericJavaXmlElementRef
return;
}
- JaxbRegistry registry = getJaxbPackage().getRegistry();
+ XmlRegistry registry = getJaxbPackage().getRegistry();
if (registry == null) {
messages.add(
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
index 55adfbe289..f3debc6ed3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
@@ -11,15 +11,12 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
@@ -40,7 +37,7 @@ public class GenericJavaXmlElementRefMapping
protected final XmlElementRef xmlElementRef;
- protected final XmlAdaptable xmlAdaptable;
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
protected XmlElementWrapper xmlElementWrapper;
@@ -50,7 +47,7 @@ public class GenericJavaXmlElementRefMapping
public GenericJavaXmlElementRefMapping(JaxbPersistentAttribute parent) {
super(parent);
this.xmlElementRef = buildXmlElementRef();
- this.xmlAdaptable = buildXmlAdaptable();
+ initializeXmlJavaTypeAdapter();
initializeXmlElementWrapper();
initializeXmlMixed();
}
@@ -69,7 +66,7 @@ public class GenericJavaXmlElementRefMapping
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.xmlElementRef.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
syncXmlElementWrapper();
syncXmlMixed();
}
@@ -78,7 +75,7 @@ public class GenericJavaXmlElementRefMapping
public void update() {
super.update();
this.xmlElementRef.update();
- this.xmlAdaptable.update();
+ updateXmlJavaTypeAdapter();
updateXmlElementWrapper();
updateXmlMixed();
}
@@ -96,37 +93,72 @@ public class GenericJavaXmlElementRefMapping
// ***** XmlJavaTypeAdapter *****
-
+
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
}
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
+ }
+
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
-
+
public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
}
-
- protected XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlElementRefMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
+
+ protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
+ return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
+ }
+
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
}
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlElementRefMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
}
- });
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
}
-
- protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
- return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
}
-
+
// ***** XmlElementWrapper *****
@@ -267,11 +299,8 @@ public class GenericJavaXmlElementRefMapping
// ***** misc *****
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
- String typeName = this.xmlElementRef.getFullyQualifiedType();
- return (JAXB.JAXB_ELEMENT.equals(typeName)) ?
- EmptyIterable.<String>instance()
- : new SingleElementIterable(typeName);
+ public Iterable<String> getReferencedXmlTypeNames() {
+ return this.xmlElementRef.getReferencedXmlTypeNames();
}
@@ -308,7 +337,9 @@ public class GenericJavaXmlElementRefMapping
this.xmlElementRef.validate(messages, reporter, astRoot);
- this.xmlAdaptable.validate(messages, reporter, astRoot);
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
if (this.xmlElementWrapper != null) {
this.xmlElementWrapper.validate(messages, reporter, astRoot);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefs.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefs.java
index 631a5093ae..c7e0f48e47 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefs.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefs.java
@@ -194,12 +194,12 @@ public class GenericJavaXmlElementRefs
// ***** misc *****
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
return new CompositeIterable<String>(
new TransformationIterable<XmlElementRef, Iterable<String>>(getXmlElementRefs()) {
@Override
protected Iterable<String> transform(XmlElementRef xmlElementRef) {
- return xmlElementRef.getDirectlyReferencedTypeNames();
+ return xmlElementRef.getReferencedXmlTypeNames();
}
});
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
index fa46a3354c..8357755fa5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
@@ -11,7 +11,6 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -20,7 +19,6 @@ import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefs;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
@@ -44,7 +42,7 @@ public class GenericJavaXmlElementRefsMapping
protected final XmlElementRefs xmlElementRefs;
- protected final XmlAdaptable xmlAdaptable;
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
protected XmlElementWrapper xmlElementWrapper;
@@ -54,7 +52,7 @@ public class GenericJavaXmlElementRefsMapping
public GenericJavaXmlElementRefsMapping(JaxbPersistentAttribute parent) {
super(parent);
this.xmlElementRefs = buildXmlElementRefs();
- this.xmlAdaptable = buildXmlAdaptable();
+ initializeXmlJavaTypeAdapter();
initializeXmlElementWrapper();
initializeXmlMixed();
}
@@ -76,7 +74,7 @@ public class GenericJavaXmlElementRefsMapping
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.xmlElementRefs.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
syncXmlElementWrapper();
syncXmlMixed();
}
@@ -85,7 +83,7 @@ public class GenericJavaXmlElementRefsMapping
public void update() {
super.update();
this.xmlElementRefs.update();
- this.xmlAdaptable.update();
+ updateXmlJavaTypeAdapter();
updateXmlElementWrapper();
updateXmlMixed();
}
@@ -105,39 +103,70 @@ public class GenericJavaXmlElementRefsMapping
// ***** XmlJavaTypeAdapter *****
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
+ }
+
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
}
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
- }
-
- protected XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(
- this,
- new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
-
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlElementRefsMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
-
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlElementRefsMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
}
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
// ***** XmlElementWrapper *****
@@ -278,8 +307,8 @@ public class GenericJavaXmlElementRefsMapping
// ***** misc *****
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
- return this.xmlElementRefs.getDirectlyReferencedTypeNames();
+ public Iterable<String> getReferencedXmlTypeNames() {
+ return this.xmlElementRefs.getReferencedXmlTypeNames();
}
@@ -316,7 +345,9 @@ public class GenericJavaXmlElementRefsMapping
this.xmlElementRefs.validate(messages, reporter, astRoot);
- this.xmlAdaptable.validate(messages, reporter, astRoot);
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
if (this.xmlElementWrapper != null) {
this.xmlElementWrapper.validate(messages, reporter, astRoot);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java
index 8f58b5c2c4..cd7bc49491 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java
@@ -16,8 +16,9 @@ import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbQName;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
import org.eclipse.jpt.jaxb.core.context.XmlNsForm;
@@ -72,8 +73,12 @@ public class GenericJavaXmlElementWrapper
return getAttributeMapping().getPersistentAttribute();
}
- protected JaxbPersistentClass getPersistentClass() {
- return getPersistentAttribute().getPersistentClass();
+ protected JaxbClassMapping getJaxbClassMapping() {
+ return getPersistentAttribute().getJaxbClassMapping();
+ }
+
+ protected JaxbPackage getJaxbPackage() {
+ return getJaxbClassMapping().getJaxbType().getJaxbPackage();
}
@@ -164,7 +169,7 @@ public class GenericJavaXmlElementWrapper
// **************** misc **************************************************
public XsdElementDeclaration getXsdElementDeclaration() {
- XsdTypeDefinition xsdType = getPersistentAttribute().getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition xsdType = getPersistentAttribute().getJaxbClassMapping().getXsdTypeDefinition();
return (xsdType == null) ? null : xsdType.getElement(this.qName.getNamespace(), this.qName.getName());
}
@@ -224,19 +229,19 @@ public class GenericJavaXmlElementWrapper
@Override
public String getDefaultNamespace() {
- return (GenericJavaXmlElementWrapper.this.getPersistentClass().getJaxbPackage().getElementFormDefault() == XmlNsForm.QUALIFIED) ?
- GenericJavaXmlElementWrapper.this.getPersistentClass().getQName().getNamespace() : "";
+ return (GenericJavaXmlElementWrapper.this.getJaxbPackage().getElementFormDefault() == XmlNsForm.QUALIFIED) ?
+ GenericJavaXmlElementWrapper.this.getJaxbClassMapping().getQName().getNamespace() : "";
}
@Override
public Iterable<String> getNameProposals(Filter<String> filter) {
- XsdTypeDefinition xsdType = GenericJavaXmlElementWrapper.this.getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition xsdType = GenericJavaXmlElementWrapper.this.getJaxbClassMapping().getXsdTypeDefinition();
return (xsdType == null) ? EmptyIterable.instance() : xsdType.getElementNameProposals(getNamespace(), filter);
}
@Override
public Iterable<String> getNamespaceProposals(Filter<String> filter) {
- XsdSchema schema = GenericJavaXmlElementWrapper.this.getPersistentClass().getJaxbPackage().getXsdSchema();
+ XsdSchema schema = GenericJavaXmlElementWrapper.this.getJaxbPackage().getXsdSchema();
return (schema == null) ? EmptyIterable.<String>instance() : schema.getNamespaceProposals(filter);
}
@@ -247,7 +252,7 @@ public class GenericJavaXmlElementWrapper
@Override
protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- XsdTypeDefinition type = getPersistentClass().getXsdTypeDefinition();
+ XsdTypeDefinition type = getJaxbClassMapping().getXsdTypeDefinition();
if (type == null) {
return;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
index c9b186f6ec..b58eecb968 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import javax.xml.namespace.QName;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.Bag;
@@ -26,7 +25,6 @@ import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlElement;
import org.eclipse.jpt.jaxb.core.context.XmlElementWrapper;
import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
@@ -51,7 +49,7 @@ public class GenericJavaXmlElementsMapping
protected final ContextListContainer<XmlElement, XmlElementAnnotation> xmlElementContainer;
- protected final XmlAdaptable xmlAdaptable;
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
protected XmlElementWrapper xmlElementWrapper;
@@ -61,7 +59,7 @@ public class GenericJavaXmlElementsMapping
public GenericJavaXmlElementsMapping(JaxbPersistentAttribute parent) {
super(parent);
this.xmlElementContainer = this.buildXmlElementContainer();
- this.xmlAdaptable = buildXmlAdaptable();
+ initializeXmlJavaTypeAdapter();
initializeXmlElementWrapper();
initializeXmlIDREF();
}
@@ -83,7 +81,7 @@ public class GenericJavaXmlElementsMapping
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.xmlElementContainer.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
syncXmlElementWrapper();
syncXmlIDREF();
}
@@ -92,7 +90,7 @@ public class GenericJavaXmlElementsMapping
public void update() {
super.update();
this.xmlElementContainer.update();
- this.xmlAdaptable.update();
+ updateXmlJavaTypeAdapter();
updateXmlElementWrapper();
updateXmlIDREF();
}
@@ -138,39 +136,71 @@ public class GenericJavaXmlElementsMapping
// ***** XmlJavaTypeAdapter *****
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
-
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
-
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlElementsMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
-
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlElementsMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
- }
-
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
+ }
+
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
}
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
}
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
// ***** XmlElementWrapper *****
@@ -315,14 +345,14 @@ public class GenericJavaXmlElementsMapping
// ***** misc *****
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
return new CompositeIterable<String>(
- super.getDirectlyReferencedTypeNames(),
+ super.getReferencedXmlTypeNames(),
new CompositeIterable<String>(
new TransformationIterable<XmlElement, Iterable<String>>(getXmlElements()) {
@Override
protected Iterable<String> transform(XmlElement o) {
- return o.getDirectlyReferencedTypeNames();
+ return o.getReferencedXmlTypeNames();
}
}));
}
@@ -367,7 +397,9 @@ public class GenericJavaXmlElementsMapping
xmlElement.validate(messages, reporter, astRoot);
}
- this.xmlAdaptable.validate(messages, reporter, astRoot);
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
if (this.xmlElementWrapper != null) {
this.xmlElementWrapper.validate(messages, reporter, astRoot);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlIDREF.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlIDREF.java
index a4dad0971e..30f1419e37 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlIDREF.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlIDREF.java
@@ -15,8 +15,8 @@ import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlIDREF;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
@@ -68,8 +68,8 @@ public class GenericJavaXmlIDREF
continue;
}
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(typeName);
- if (persistentClass == null || ! persistentClass.containsXmlId()) {
+ JaxbClassMapping classMapping = getContextRoot().getClassMapping(typeName);
+ if (classMapping == null || ! classMapping.containsXmlId()) {
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaRegistry.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java
index 3eb0b2d82d..63b7b64d1d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaRegistry.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java
@@ -24,9 +24,10 @@ import org.eclipse.jpt.common.utility.internal.HashBag;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
@@ -37,33 +38,35 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-public class GenericJavaRegistry
- extends AbstractJavaType
- implements JaxbRegistry {
+public class GenericJavaXmlRegistry
+ extends AbstractJavaContextNode
+ implements XmlRegistry {
- protected final ContextCollectionContainer<JaxbElementFactoryMethod, JavaResourceMethod> elementFactoryMethodContainer;
+ protected final ElementFactoryMethodContainer elementFactoryMethodContainer;
- public GenericJavaRegistry(JaxbContextRoot parent, JavaResourceType resourceType) {
- super(parent, resourceType);
- this.elementFactoryMethodContainer = this.buildElementFactoryMethodContainer();
+ public GenericJavaXmlRegistry(JaxbClass parent) {
+ super(parent);
+ this.elementFactoryMethodContainer = new ElementFactoryMethodContainer();
+
+ initElementFactoryMethods();
}
- @Override
+ public JaxbClass getJaxbClass() {
+ return (JaxbClass) getParent();
+ }
+
public JavaResourceType getJavaResourceType() {
- return (JavaResourceType) super.getJavaResourceType();
+ return getJaxbClass().getJavaResourceType();
}
protected XmlRegistryAnnotation getAnnotation() {
return (XmlRegistryAnnotation) getJavaResourceType().getAnnotation(JAXB.XML_REGISTRY);
}
-
- // ***** JaxbType impl *****
-
- public Kind getKind() {
- return Kind.REGISTRY;
+ public JaxbPackage getJaxbPackage() {
+ return getJaxbClass().getJaxbPackage();
}
@@ -72,15 +75,18 @@ public class GenericJavaRegistry
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.elementFactoryMethodContainer.synchronizeWithResourceModel();
+ syncElementFactoryMethods();
}
@Override
public void update() {
super.update();
- this.elementFactoryMethodContainer.update();
+ updateElementFactoryMethods();
}
+
+ // ***** element factory methods *****
+
public Iterable<JaxbElementFactoryMethod> getElementFactoryMethods() {
return this.elementFactoryMethodContainer.getContextElements();
}
@@ -89,6 +95,18 @@ public class GenericJavaRegistry
return this.elementFactoryMethodContainer.getContextElementsSize();
}
+ protected void initElementFactoryMethods() {
+ this.elementFactoryMethodContainer.initialize();
+ }
+
+ protected void syncElementFactoryMethods() {
+ this.elementFactoryMethodContainer.synchronizeWithResourceModel();
+ }
+
+ protected void updateElementFactoryMethods() {
+ this.elementFactoryMethodContainer.update();
+ }
+
private JaxbElementFactoryMethod buildElementFactoryMethod(JavaResourceMethod resourceMethod) {
return getFactory().buildJavaElementFactoryMethod(this, resourceMethod);
}
@@ -114,12 +132,6 @@ public class GenericJavaRegistry
protected static boolean methodReturnTypeIsJAXBElement(JavaResourceMethod method) {
return method.typeIsSubTypeOf(JAXB.XML_ELEMENT);
}
-
- protected ContextCollectionContainer<JaxbElementFactoryMethod, JavaResourceMethod> buildElementFactoryMethodContainer() {
- ElementFactoryMethodContainer container = new ElementFactoryMethodContainer();
- container.initialize();
- return container;
- }
// ***** content assist *****
@@ -147,7 +159,7 @@ public class GenericJavaRegistry
@Override
public TextRange getValidationTextRange(CompilationUnit astRoot) {
TextRange textRange = getAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : super.getValidationTextRange(astRoot);
+ return (textRange != null) ? textRange : getJaxbClass().getValidationTextRange(astRoot);
}
@Override
@@ -205,17 +217,17 @@ public class GenericJavaRegistry
@Override
protected String getContextElementsPropertyName() {
- return JaxbRegistry.ELEMENT_FACTORY_METHODS_COLLECTION;
+ return XmlRegistry.ELEMENT_FACTORY_METHODS_COLLECTION;
}
@Override
protected JaxbElementFactoryMethod buildContextElement(JavaResourceMethod resourceElement) {
- return GenericJavaRegistry.this.buildElementFactoryMethod(resourceElement);
+ return GenericJavaXmlRegistry.this.buildElementFactoryMethod(resourceElement);
}
@Override
protected Iterable<JavaResourceMethod> getResourceElements() {
- return GenericJavaRegistry.this.getResourceElementFactoryMethods();
+ return GenericJavaXmlRegistry.this.getResourceElementFactoryMethods();
}
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRootElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRootElement.java
index d220863716..891c9ea630 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRootElement.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRootElement.java
@@ -16,8 +16,10 @@ 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.iterables.EmptyIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbQName;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
@@ -40,7 +42,7 @@ public class GenericJavaXmlRootElement
protected JaxbQName qName;
- public GenericJavaXmlRootElement(JaxbPersistentType parent, XmlRootElementAnnotation resourceXmlRootElementAnnotation) {
+ public GenericJavaXmlRootElement(JaxbTypeMapping parent, XmlRootElementAnnotation resourceXmlRootElementAnnotation) {
super(parent);
this.annotation = resourceXmlRootElementAnnotation;
this.qName = buildQName();
@@ -51,8 +53,16 @@ public class GenericJavaXmlRootElement
return new XmlRootElementQName(this);
}
- public JaxbPersistentType getPersistentType() {
- return (JaxbPersistentType) super.getParent();
+ public JaxbTypeMapping getTypeMapping() {
+ return (JaxbTypeMapping) getParent();
+ }
+
+ protected JaxbType getJaxbType() {
+ return getTypeMapping().getJaxbType();
+ }
+
+ protected JaxbPackage getJaxbPackage() {
+ return getJaxbType().getJaxbPackage();
}
@@ -130,17 +140,17 @@ public class GenericJavaXmlRootElement
@Override
public String getDefaultNamespace() {
- return GenericJavaXmlRootElement.this.getPersistentType().getJaxbPackage().getNamespace();
+ return GenericJavaXmlRootElement.this.getJaxbPackage().getNamespace();
}
@Override
public String getDefaultName() {
- return Introspector.decapitalize(GenericJavaXmlRootElement.this.getPersistentType().getSimpleName());
+ return Introspector.decapitalize(GenericJavaXmlRootElement.this.getJaxbType().getSimpleName());
}
@Override
protected Iterable<String> getNamespaceProposals(Filter<String> filter) {
- XsdSchema schema = GenericJavaXmlRootElement.this.getPersistentType().getJaxbPackage().getXsdSchema();
+ XsdSchema schema = GenericJavaXmlRootElement.this.getJaxbPackage().getXsdSchema();
if (schema == null) {
return EmptyIterable.instance();
}
@@ -149,7 +159,7 @@ public class GenericJavaXmlRootElement
@Override
protected Iterable<String> getNameProposals(Filter<String> filter) {
- XsdSchema schema = GenericJavaXmlRootElement.this.getPersistentType().getJaxbPackage().getXsdSchema();
+ XsdSchema schema = GenericJavaXmlRootElement.this.getJaxbPackage().getXsdSchema();
if (schema == null) {
return EmptyIterable.instance();
}
@@ -165,7 +175,7 @@ public class GenericJavaXmlRootElement
protected void validateReference(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
String name = getName();
String namespace = getNamespace();
- XsdSchema schema = GenericJavaXmlRootElement.this.getPersistentType().getJaxbPackage().getXsdSchema();
+ XsdSchema schema = GenericJavaXmlRootElement.this.getJaxbPackage().getXsdSchema();
if (schema != null) {
// element must resolve
@@ -175,7 +185,7 @@ public class GenericJavaXmlRootElement
}
else {
// element type must agree with parent's schema type
- XsdTypeDefinition schemaType = GenericJavaXmlRootElement.this.getPersistentType().getXsdTypeDefinition();
+ XsdTypeDefinition schemaType = GenericJavaXmlRootElement.this.getTypeMapping().getXsdTypeDefinition();
if (schemaType != null) {
if (! schemaType.equals(schemaElement.getType())) {
messages.add(
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSeeAlso.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSeeAlso.java
index ba3c150501..d4216aa54f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSeeAlso.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSeeAlso.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbTypeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlSeeAlso;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
@@ -25,17 +25,13 @@ public class GenericJavaXmlSeeAlso
protected final ListContainer<String, String> valueContainer;
- public GenericJavaXmlSeeAlso(JaxbPersistentClass parent, XmlSeeAlsoAnnotation annotation) {
+ public GenericJavaXmlSeeAlso(JaxbTypeMapping parent, XmlSeeAlsoAnnotation annotation) {
super(parent);
this.annotation = annotation;
this.valueContainer = this.buildValueContainer();
}
- public JaxbPersistentClass getPersistentClass() {
- return (JaxbPersistentClass) getParent();
- }
-
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
@@ -65,7 +61,7 @@ public class GenericJavaXmlSeeAlso
this.valueContainer.moveContextElement(targetIndex, sourceIndex);
}
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
return this.annotation.getFullyQualifiedClasses();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
index b47485d6dc..eb9efe3671 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlTransientMapping.java
@@ -32,7 +32,7 @@ public class GenericJavaXmlTransientMapping
}
@Override
- public Iterable<String> getDirectlyReferencedTypeNames() {
+ public Iterable<String> getReferencedXmlTypeNames() {
return EmptyIterable.instance();
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
index c80f55db77..d2d9fea7e5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
@@ -9,78 +9,132 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
+import java.util.List;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlValueAnnotation;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class GenericJavaXmlValueMapping
- extends AbstractJavaAttributeMapping<XmlValueAnnotation>
- implements XmlValueMapping
-{
- protected final XmlAdaptable xmlAdaptable;
-
-
+ extends AbstractJavaAttributeMapping<XmlValueAnnotation>
+ implements XmlValueMapping {
+
+ protected XmlJavaTypeAdapter xmlJavaTypeAdapter;
+
+
public GenericJavaXmlValueMapping(JaxbPersistentAttribute parent) {
super(parent);
- this.xmlAdaptable = buildXmlAdaptable();
- }
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.xmlAdaptable.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.xmlAdaptable.update();
+ initializeXmlJavaTypeAdapter();
}
-
+
+
public String getKey() {
return MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY;
}
-
+
@Override
protected String getAnnotationName() {
return JAXB.XML_VALUE;
}
-
- //****************** XmlJavaTypeAdapter *********************
-
- public XmlAdaptable buildXmlAdaptable() {
- return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
- public JavaResourceAnnotatedElement getResource() {
- return getJavaResourceAttribute();
- }
- public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
- return GenericJavaXmlValueMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
- }
- public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
- GenericJavaXmlValueMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
- }
- });
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncXmlJavaTypeAdapter();
}
-
+
+ @Override
+ public void update() {
+ super.update();
+ updateXmlJavaTypeAdapter();
+ }
+
+
+ // ***** XmlJavaTypeAdapter *****
+
public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
- return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ return this.xmlJavaTypeAdapter;
}
+ protected void setXmlJavaTypeAdapter_(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ XmlJavaTypeAdapter oldXmlJavaTypeAdapter = this.xmlJavaTypeAdapter;
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldXmlJavaTypeAdapter, xmlJavaTypeAdapter);
+ }
+
public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
- return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ if (this.xmlJavaTypeAdapter != null) {
+ throw new IllegalStateException();
+ }
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().addAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ setXmlJavaTypeAdapter_(xmlJavaTypeAdapter);
+ return xmlJavaTypeAdapter;
}
-
+
+ public void removeXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ setXmlJavaTypeAdapter_(null);
+ }
+
protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
}
-
- public void removeXmlJavaTypeAdapter() {
- this.xmlAdaptable.removeXmlJavaTypeAdapter();
+
+ protected XmlJavaTypeAdapterAnnotation getXmlJavaTypeAdapterAnnotation() {
+ return (XmlJavaTypeAdapterAnnotation) getJavaResourceAttribute().getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ protected void initializeXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ this.xmlJavaTypeAdapter = buildXmlJavaTypeAdapter(annotation);
+ }
+ }
+
+ protected void syncXmlJavaTypeAdapter() {
+ XmlJavaTypeAdapterAnnotation annotation = getXmlJavaTypeAdapterAnnotation();
+ if (annotation != null) {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.synchronizeWithResourceModel();
+ }
+ else {
+ setXmlJavaTypeAdapter_(buildXmlJavaTypeAdapter(annotation));
+ }
+ }
+ else {
+ setXmlJavaTypeAdapter_(null);
+ }
+ }
+
+ protected void updateXmlJavaTypeAdapter() {
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.update();
+ }
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+
+ if (this.xmlJavaTypeAdapter != null) {
+ this.xmlJavaTypeAdapter.validate(messages, reporter, astRoot);
+ }
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/PropertyAccessor.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/PropertyAccessor.java
index 95800e76f5..125950698e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/PropertyAccessor.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/PropertyAccessor.java
@@ -15,7 +15,7 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jaxb.core.context.Accessor;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
public class PropertyAccessor
extends AbstractJavaContextNode
@@ -26,7 +26,7 @@ public class PropertyAccessor
protected final JavaResourceMethod resourceSetter;
- public PropertyAccessor(JaxbPersistentClass parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) {
+ public PropertyAccessor(JaxbClassMapping parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) {
super(parent);
this.resourceGetter = resourceGetter;
this.resourceSetter = resourceSetter;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_class.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_class.gif
index baac236770..baac236770 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_class.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_class.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_enum.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_enum.gif
index c73ed28e70..c73ed28e70 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_enum.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_enum.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_registry.gif
index 719e6057b3..719e6057b3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_registry.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/transient_class.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_transient_class.gif
index 066461be61..066461be61 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/transient_class.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/jaxb_transient_class.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java
index d89b9c0605..693c3ec187 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java
@@ -17,10 +17,11 @@ public class JptJaxbUiIcons {
public static final String JAXB_CONTENT = "full/obj16/jaxb_content";
public static final String PACKAGE = "full/obj16/package";
- public static final String PERSISTENT_CLASS = "full/obj16/persistent_class";
- public static final String PERSISTENT_ENUM = "full/obj16/persistent_enum";
- public static final String TRANSIENT_CLASS = "full/obj16/transient_class";
- public static final String REGISTRY = "full/obj16/registry";
+ public static final String JAXB_CLASS = "full/obj16/jaxb_class";
+ public static final String JAXB_ENUM = "full/obj16/jaxb_enum";
+ public static final String JAXB_TRANSIENT_CLASS = "full/obj16/jaxb_transient_class";
+ public static final String JAXB_TRANSIENT_ENUM = "full/obj16/jaxb_transient_enum";
+ public static final String JAXB_REGISTRY = "full/obj16/jaxb_registry";
public static final String XML_ANY_ATTRIBUTE = "full/obj16/xml-any-attribute";
public static final String XML_ANY_ELEMENT = "full/obj16/xml-any-element";
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java
index dbb1274798..7e6c6bb8a3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java
@@ -12,14 +12,12 @@ package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory
@@ -51,17 +49,11 @@ public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory
else if (item instanceof JaxbPackage) {
return new JaxbPackageItemLabelProvider((JaxbPackage) item, contentAndLabelProvider);
}
- else if (item instanceof JaxbRegistry) {
- return new JaxbRegistryItemLabelProvider((JaxbRegistry) item, contentAndLabelProvider);
+ else if (item instanceof JaxbClass) {
+ return new JaxbClassItemLabelProvider((JaxbClass) item, contentAndLabelProvider);
}
- else if (item instanceof JaxbPersistentClass) {
- return new JaxbPersistentClassItemLabelProvider((JaxbPersistentClass) item, contentAndLabelProvider);
- }
- else if (item instanceof JaxbPersistentEnum) {
- return new JaxbPersistentEnumItemLabelProvider((JaxbPersistentEnum) item, contentAndLabelProvider);
- }
- else if (item instanceof JaxbTransientClass) {
- return new JaxbTransientClassItemLabelProvider((JaxbTransientClass) item, contentAndLabelProvider);
+ else if (item instanceof JaxbEnum) {
+ return new JaxbEnumItemLabelProvider((JaxbEnum) item, contentAndLabelProvider);
}
else if (item instanceof JaxbPersistentAttribute) {
return new JaxbPersistentAttributeItemLabelProvider((JaxbPersistentAttribute) item, contentAndLabelProvider);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java
index 2b053849fb..57a6265e1a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,11 +13,10 @@ import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelPro
import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider;
import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
public class GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory
@@ -52,14 +51,11 @@ public class GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory
else if (item instanceof JaxbPackage) {
return new JaxbPackageItemContentProvider((JaxbPackage) item, treeContentAndLabelProvider);
}
- else if (item instanceof JaxbPersistentClass) {
- return new JaxbPersistentClassItemContentProvider((JaxbPersistentClass) item, treeContentAndLabelProvider);
+ else if (item instanceof JaxbClass) {
+ return new JaxbClassItemContentProvider((JaxbClass) item, treeContentAndLabelProvider);
}
- else if (item instanceof JaxbPersistentEnum) {
- return new JaxbPersistentEnumItemContentProvider((JaxbPersistentEnum) item, treeContentAndLabelProvider);
- }
- else if (item instanceof JaxbRegistry) {
- return new JaxbRegistryItemContentProvider((JaxbRegistry) item, treeContentAndLabelProvider);
+ else if (item instanceof JaxbEnum) {
+ return new JaxbEnumItemContentProvider((JaxbEnum) item, treeContentAndLabelProvider);
}
return null;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemContentProvider.java
index dfcf97e383..3436965b21 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemContentProvider.java
@@ -9,31 +9,31 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider;
import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-public class JaxbPersistentClassItemContentProvider
+public class JaxbClassItemContentProvider
extends AbstractTreeItemContentProvider<JaxbPersistentAttribute> {
- public JaxbPersistentClassItemContentProvider(
- JaxbPersistentClass jaxbPersistentClass, DelegatingTreeContentAndLabelProvider contentProvider) {
-
- super(jaxbPersistentClass, contentProvider);
+ public JaxbClassItemContentProvider(
+ JaxbClass jaxbClass, DelegatingTreeContentAndLabelProvider contentProvider) {
+ super(jaxbClass, contentProvider);
}
@Override
- public JaxbPersistentClass getModel() {
- return (JaxbPersistentClass) super.getModel();
+ public JaxbClass getModel() {
+ return (JaxbClass) super.getModel();
}
@Override
@@ -43,15 +43,25 @@ public class JaxbPersistentClassItemContentProvider
@Override
protected CollectionValueModel<JaxbPersistentAttribute> buildChildrenModel() {
- List<CollectionValueModel<JaxbPersistentAttribute>> list = new ArrayList<CollectionValueModel<JaxbPersistentAttribute>>();
- list.add(buildAttributesModel());
- list.add(buildInheritedAttributesModel());
- return new CompositeCollectionValueModel<CollectionValueModel<JaxbPersistentAttribute>, JaxbPersistentAttribute>(list);
+ PropertyValueModel<JaxbClassMapping> mappingModel = buildMappingModel();
+ return new CompositeCollectionValueModel<CollectionValueModel<JaxbPersistentAttribute>, JaxbPersistentAttribute>(
+ buildAttributesModel(mappingModel),
+ buildInheritedAttributesModel(mappingModel));
}
-
- protected CollectionValueModel<JaxbPersistentAttribute> buildAttributesModel() {
- return new CollectionAspectAdapter<JaxbPersistentClass, JaxbPersistentAttribute>(
- JaxbPersistentClass.ATTRIBUTES_COLLECTION, getModel()) {
+
+ protected PropertyValueModel<JaxbClassMapping> buildMappingModel() {
+ return new PropertyAspectAdapter<JaxbClass, JaxbClassMapping>(JaxbClass.MAPPING_PROPERTY, getModel()) {
+ @Override
+ protected JaxbClassMapping buildValue_() {
+ return this.subject.getMapping();
+ }
+ };
+ }
+
+ protected CollectionValueModel<JaxbPersistentAttribute> buildAttributesModel(
+ PropertyValueModel<JaxbClassMapping> mappingModel) {
+ return new CollectionAspectAdapter<JaxbClassMapping, JaxbPersistentAttribute>(
+ mappingModel, JaxbClassMapping.ATTRIBUTES_COLLECTION) {
@Override
protected Iterable<JaxbPersistentAttribute> getIterable() {
return this.subject.getAttributes();
@@ -59,9 +69,10 @@ public class JaxbPersistentClassItemContentProvider
};
}
- protected CollectionValueModel<JaxbPersistentAttribute> buildInheritedAttributesModel() {
- return new CollectionAspectAdapter<JaxbPersistentClass, JaxbPersistentAttribute>(
- JaxbPersistentClass.INHERITED_ATTRIBUTES_COLLECTION, getModel()) {
+ protected CollectionValueModel<JaxbPersistentAttribute> buildInheritedAttributesModel(
+ PropertyValueModel<JaxbClassMapping> mappingModel) {
+ return new CollectionAspectAdapter<JaxbClassMapping, JaxbPersistentAttribute>(
+ mappingModel, JaxbClassMapping.INHERITED_ATTRIBUTES_COLLECTION) {
@Override
protected Iterable<JaxbPersistentAttribute> getIterable() {
return this.subject.getInheritedAttributes();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemLabelProvider.java
new file mode 100644
index 0000000000..bfb87c8d68
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbClassItemLabelProvider.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
+
+import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
+import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
+import org.eclipse.swt.graphics.Image;
+
+
+public class JaxbClassItemLabelProvider
+ extends JaxbTypeItemLabelProvider {
+
+ public JaxbClassItemLabelProvider(
+ JaxbClass jaxbPersistentClass, DelegatingContentAndLabelProvider labelProvider) {
+
+ super(jaxbPersistentClass, labelProvider);
+ }
+
+
+ @Override
+ public JaxbClass getModel() {
+ return (JaxbClass) super.getModel();
+ }
+
+ @Override
+ protected PropertyValueModel<Image> buildImageModel() {
+ return new JaxbClassImageModel(getModel());
+ }
+
+
+ protected class JaxbClassImageModel
+ extends AspectPropertyValueModelAdapter<JaxbClass, Image> {
+
+ protected final PropertyValueModel<Boolean> isXmlRegistryModel;
+
+ protected final PropertyValueModel<JaxbClassMapping> mappingModel;
+
+ protected final PropertyValueModel<Boolean> isXmlTransientModel;
+
+ protected final PropertyChangeListener propertyChangeListener;
+
+
+ public JaxbClassImageModel(JaxbClass subject) {
+ super(new StaticPropertyValueModel(subject));
+ this.isXmlRegistryModel = buildIsXmlRegistryModel();
+ this.mappingModel = buildMappingModel();
+ this.isXmlTransientModel = buildIsXmlTransientModel();
+ this.propertyChangeListener = buildPropertyChangeListener();
+ }
+
+
+ protected PropertyValueModel<Boolean> buildIsXmlRegistryModel() {
+ return new PropertyAspectAdapter<JaxbClass, Boolean>(JaxbClass.XML_REGISTRY_PROPERTY, JaxbClassItemLabelProvider.this.getModel()) {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.getXmlRegistry() != null;
+ }
+ };
+ }
+
+ protected PropertyValueModel<JaxbClassMapping> buildMappingModel() {
+ return new PropertyAspectAdapter<JaxbClass, JaxbClassMapping> (JaxbClass.MAPPING_PROPERTY, JaxbClassItemLabelProvider.this.getModel()) {
+ @Override
+ protected JaxbClassMapping buildValue_() {
+ return this.subject.getMapping();
+ }
+ };
+ }
+
+ protected PropertyValueModel<Boolean> buildIsXmlTransientModel() {
+ return new PropertyAspectAdapter<JaxbClassMapping, Boolean>(this.mappingModel, JaxbClassMapping.XML_TRANSIENT_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.isXmlTransient();
+ }
+ };
+ }
+
+ protected PropertyChangeListener buildPropertyChangeListener() {
+ // transform the subject's property change events into VALUE property change events
+ return new PropertyChangeListener() {
+ public void propertyChanged(PropertyChangeEvent event) {
+ JaxbClassImageModel.this.propertyChanged();
+ }
+ };
+ }
+
+ @Override
+ protected Image buildValue_() {
+ if (this.mappingModel.getValue() != null) {
+ if (this.isXmlTransientModel.getValue() == Boolean.TRUE) {
+ return JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_TRANSIENT_CLASS);
+ }
+ }
+ else if (this.isXmlRegistryModel.getValue() == Boolean.TRUE) {
+ return JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_REGISTRY);
+ }
+ return JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_CLASS);
+ }
+
+ @Override
+ protected void engageSubject_() {
+ this.isXmlRegistryModel.addPropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.mappingModel.addPropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.isXmlTransientModel.addPropertyChangeListener(VALUE, this.propertyChangeListener);
+ }
+
+ @Override
+ protected void disengageSubject_() {
+ this.isXmlRegistryModel.removePropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.mappingModel.removePropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.isXmlTransientModel.removePropertyChangeListener(VALUE, this.propertyChangeListener);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemContentProvider.java
index 5e7620866e..8ada32297a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -12,25 +12,28 @@ package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider;
import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
-public class JaxbPersistentEnumItemContentProvider
+public class JaxbEnumItemContentProvider
extends AbstractTreeItemContentProvider<JaxbEnumConstant> {
- public JaxbPersistentEnumItemContentProvider(
- JaxbPersistentEnum jaxbPersistentEnum, DelegatingTreeContentAndLabelProvider contentProvider) {
+ public JaxbEnumItemContentProvider(
+ JaxbEnum jaxbEnum, DelegatingTreeContentAndLabelProvider contentProvider) {
- super(jaxbPersistentEnum, contentProvider);
+ super(jaxbEnum, contentProvider);
}
@Override
- public JaxbPersistentEnum getModel() {
- return (JaxbPersistentEnum) super.getModel();
+ public JaxbEnum getModel() {
+ return (JaxbEnum) super.getModel();
}
@Override
@@ -38,10 +41,19 @@ public class JaxbPersistentEnumItemContentProvider
return (JaxbContextRoot) getModel().getParent();
}
+ protected PropertyValueModel<JaxbEnumMapping> buildMappingModel() {
+ return new PropertyAspectAdapter<JaxbEnum, JaxbEnumMapping>(JaxbEnum.MAPPING_PROPERTY, getModel()) {
+ @Override
+ protected JaxbEnumMapping buildValue_() {
+ return this.subject.getMapping();
+ }
+ };
+ }
+
@Override
protected CollectionValueModel<JaxbEnumConstant> buildChildrenModel() {
- return new CollectionAspectAdapter<JaxbPersistentEnum, JaxbEnumConstant>(
- JaxbPersistentEnum.ENUM_CONSTANTS_COLLECTION, getModel()) {
+ return new CollectionAspectAdapter<JaxbEnumMapping, JaxbEnumConstant>(
+ buildMappingModel(), JaxbEnumMapping.ENUM_CONSTANTS_COLLECTION) {
@Override
protected Iterable<JaxbEnumConstant> getIterable() {
return this.subject.getEnumConstants();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemLabelProvider.java
new file mode 100644
index 0000000000..8dbdacd834
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumItemLabelProvider.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
+
+import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
+import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
+import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
+import org.eclipse.swt.graphics.Image;
+
+
+public class JaxbEnumItemLabelProvider
+ extends JaxbTypeItemLabelProvider {
+
+ public JaxbEnumItemLabelProvider(
+ JaxbEnum jaxbEnum, DelegatingContentAndLabelProvider labelProvider) {
+ super(jaxbEnum, labelProvider);
+ }
+
+
+ @Override
+ public JaxbEnum getModel() {
+ return (JaxbEnum) super.getModel();
+ }
+
+ @Override
+ protected PropertyValueModel<Image> buildImageModel() {
+ return new JaxbEnumImageModel(getModel());
+ }
+
+
+ protected class JaxbEnumImageModel
+ extends AspectPropertyValueModelAdapter<JaxbEnum, Image> {
+
+ protected final PropertyValueModel<JaxbEnumMapping> mappingModel;
+
+ protected final PropertyValueModel<Boolean> isXmlTransientModel;
+
+ protected final PropertyChangeListener propertyChangeListener;
+
+
+ public JaxbEnumImageModel(JaxbEnum subject) {
+ super(new StaticPropertyValueModel(subject));
+ this.mappingModel = buildMappingModel();
+ this.isXmlTransientModel = buildIsXmlTransientModel();
+ this.propertyChangeListener = buildPropertyChangeListener();
+ }
+
+
+ protected PropertyValueModel<JaxbEnumMapping> buildMappingModel() {
+ return new PropertyAspectAdapter<JaxbEnum, JaxbEnumMapping> (JaxbEnum.MAPPING_PROPERTY, JaxbEnumItemLabelProvider.this.getModel()) {
+ @Override
+ protected JaxbEnumMapping buildValue_() {
+ return this.subject.getMapping();
+ }
+ };
+ }
+
+ protected PropertyValueModel<Boolean> buildIsXmlTransientModel() {
+ return new PropertyAspectAdapter<JaxbEnumMapping, Boolean>(this.mappingModel, JaxbEnumMapping.XML_TRANSIENT_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.isXmlTransient();
+ }
+ };
+ }
+
+ protected PropertyChangeListener buildPropertyChangeListener() {
+ // transform the subject's property change events into VALUE property change events
+ return new PropertyChangeListener() {
+ public void propertyChanged(PropertyChangeEvent event) {
+ JaxbEnumImageModel.this.propertyChanged();
+ }
+ };
+ }
+
+ @Override
+ protected Image buildValue_() {
+ if (this.mappingModel.getValue() != null) {
+ if (this.isXmlTransientModel.getValue() == Boolean.TRUE) {
+ return JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_TRANSIENT_ENUM);
+ }
+ }
+ return JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_ENUM);
+ }
+
+ @Override
+ protected void engageSubject_() {
+ this.mappingModel.addPropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.isXmlTransientModel.addPropertyChangeListener(VALUE, this.propertyChangeListener);
+ }
+
+ @Override
+ protected void disengageSubject_() {
+ this.mappingModel.removePropertyChangeListener(VALUE, this.propertyChangeListener);
+ this.isXmlTransientModel.removePropertyChangeListener(VALUE, this.propertyChangeListener);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java
deleted file mode 100644
index d13e1c3664..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
-
-import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
-import org.eclipse.swt.graphics.Image;
-
-
-public class JaxbPersistentClassItemLabelProvider
- extends JaxbTypeItemLabelProvider {
-
- public JaxbPersistentClassItemLabelProvider(
- JaxbPersistentClass jaxbPersistentClass, DelegatingContentAndLabelProvider labelProvider) {
-
- super(jaxbPersistentClass, labelProvider);
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_CLASS));
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java
deleted file mode 100644
index 36e6c40455..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
-
-import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
-import org.eclipse.swt.graphics.Image;
-
-
-public class JaxbPersistentEnumItemLabelProvider
- extends JaxbTypeItemLabelProvider {
-
- public JaxbPersistentEnumItemLabelProvider(
- JaxbPersistentEnum jaxbEnum, DelegatingContentAndLabelProvider labelProvider) {
-
- super(jaxbEnum, labelProvider);
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_ENUM));
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java
index 940db5e8c4..846e5b97e2 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,22 +13,22 @@ import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider;
import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
public class JaxbRegistryItemContentProvider
extends AbstractTreeItemContentProvider<JaxbElementFactoryMethod> {
public JaxbRegistryItemContentProvider(
- JaxbRegistry jaxbRegistry, DelegatingTreeContentAndLabelProvider contentProvider) {
+ XmlRegistry jaxbRegistry, DelegatingTreeContentAndLabelProvider contentProvider) {
super(jaxbRegistry, contentProvider);
}
@Override
- public JaxbRegistry getModel() {
- return (JaxbRegistry) super.getModel();
+ public XmlRegistry getModel() {
+ return (XmlRegistry) super.getModel();
}
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java
deleted file mode 100644
index 4d897515e1..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
-
-import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
-import org.eclipse.swt.graphics.Image;
-
-
-public class JaxbRegistryItemLabelProvider
- extends JaxbTypeItemLabelProvider {
-
- public JaxbRegistryItemLabelProvider(
- JaxbRegistry jaxbRegistry, DelegatingContentAndLabelProvider labelProvider) {
-
- super(jaxbRegistry, labelProvider);
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.REGISTRY));
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java
deleted file mode 100644
index 5f79b33805..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.ui.internal.jaxb21;
-
-import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
-import org.eclipse.swt.graphics.Image;
-
-
-public class JaxbTransientClassItemLabelProvider
- extends JaxbTypeItemLabelProvider {
-
- public JaxbTransientClassItemLabelProvider(
- JaxbTransientClass jaxbTransientType, DelegatingContentAndLabelProvider labelProvider) {
-
- super(jaxbTransientType, labelProvider);
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.TRANSIENT_CLASS));
- }
-}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
index 6249397302..855a5ef20c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/GenericContextRootTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -34,10 +34,10 @@ import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.JaxbType;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
@@ -55,7 +55,7 @@ public class GenericContextRootTests
JAXB.XML_ACCESS_ORDER, JAXB.XML_ACCESSOR_ORDER);
}
- private ICompilationUnit createAnnotatedPersistentClassWithSuperclassNamed(final String superclassName) throws Exception {
+ private ICompilationUnit createClassWithXmlTypeAndSuperclassNamed(final String superclassName) throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -72,7 +72,7 @@ public class GenericContextRootTests
});
}
- private ICompilationUnit createAnnotatedPersistentClassWithAttributeAndTypeNamed(
+ private ICompilationUnit createClassWithXmlTypeAndAttribute(
final String attributeName, final String typeName) throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
@@ -91,7 +91,7 @@ public class GenericContextRootTests
});
}
- private ICompilationUnit createAnnotatedPersistentClassWithAttributeAndElementTypeNamed(
+ private ICompilationUnit createClassWithXmlTypeAndListAttribute(
final String attributeName, final String typeName) throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
@@ -192,18 +192,16 @@ public class GenericContextRootTests
}
public void testGetRegistries() throws Exception {
- createAnnotatedRegistry();
- Iterator<JaxbRegistry> registries = getContextRoot().getRegistries().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, registries.next().getFullyQualifiedName());
- assertFalse(registries.hasNext());
+ createClassWithXmlRegistry();
+ Iterable<JaxbType> types = getContextRoot().getTypes();
+ assertEquals(1, CollectionTools.size(types));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)).getXmlRegistry());
//add an unannotated class and make sure it's not added to the context root
createUnannotatedClassNamed("Foo");
- registries = getContextRoot().getRegistries().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, registries.next().getFullyQualifiedName());
- assertFalse(registries.hasNext());
+ types = getContextRoot().getTypes();
+ assertEquals(1, CollectionTools.size(types));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)).getXmlRegistry());
//annotate the class with @XmlRegistry and test it's added to the root context node
JavaResourceAbstractType fooResourceType = getJaxbProject().getJavaResourceType("test.Foo");
@@ -215,17 +213,10 @@ public class GenericContextRootTests
}
});
- Iterable<String> registryNames =
- new TransformationIterable<JaxbRegistry, String>(
- getContextRoot().getRegistries()) {
- @Override
- protected String transform(JaxbRegistry o) {
- return o.getFullyQualifiedName();
- }
- };
- assertEquals(2, CollectionTools.size(getContextRoot().getRegistries()));
- assertTrue(CollectionTools.contains(registryNames, "test.Foo"));
- assertTrue(CollectionTools.contains(registryNames, FULLY_QUALIFIED_TYPE_NAME));
+ types = getContextRoot().getTypes();
+ assertEquals(2, CollectionTools.size(types));
+ assertNotNull(((JaxbClass) getContextRoot().getType("test.Foo")).getXmlRegistry());
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)).getXmlRegistry());
//remove the annotation from the class and test it's removed from the context root
annotatedElement.edit(
@@ -235,26 +226,21 @@ public class GenericContextRootTests
}
});
- registries = getContextRoot().getRegistries().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, registries.next().getFullyQualifiedName());
- assertFalse(registries.hasNext());
+ types = getContextRoot().getTypes();
+ assertEquals(1, CollectionTools.size(types));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)).getXmlRegistry());
}
- public void testGetPersistentClasses() throws Exception {
- this.createAnnotatedPersistentClass();
- Iterator<JaxbPersistentClass> persistentClasses = this.getContextRoot().getPersistentClasses().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentClasses.next().getFullyQualifiedName());
- assertFalse(persistentClasses.hasNext());
+ public void testGetTypes() throws Exception {
+ createClassWithXmlType();
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
//add an unannotated class and make sure it's not added to the context root
createUnannotatedClassNamed("Foo");
- persistentClasses = this.getContextRoot().getPersistentClasses().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentClasses.next().getFullyQualifiedName());
- assertFalse(persistentClasses.hasNext());
-
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+
//annotate the class with @XmlType and test it's added to the context root
JavaResourceAbstractType fooResourceType = getJaxbProject().getJavaResourceType("test.Foo");
AnnotatedElement annotatedElement = annotatedElement(fooResourceType);
@@ -265,18 +251,10 @@ public class GenericContextRootTests
}
});
- Iterable<String> persistentClassNames =
- new TransformationIterable<JaxbPersistentClass, String>(
- getContextRoot().getPersistentClasses()) {
- @Override
- protected String transform(JaxbPersistentClass o) {
- return o.getFullyQualifiedName();
- }
- };
- assertEquals(2, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertTrue(CollectionTools.contains(persistentClassNames, "test.Foo"));
- assertTrue(CollectionTools.contains(persistentClassNames, FULLY_QUALIFIED_TYPE_NAME));
-
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNotNull(((JaxbClass) getContextRoot().getType("test.Foo")));
+
//remove the annotation from the class and test it's removed from the root context node
annotatedElement.edit(
new Member.Editor() {
@@ -285,26 +263,22 @@ public class GenericContextRootTests
}
});
- persistentClasses = getContextRoot().getPersistentClasses().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentClasses.next().getFullyQualifiedName());
- assertFalse(persistentClasses.hasNext());
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNull(((JaxbClass) getContextRoot().getType("test.Foo")));
}
-
- public void testGetPersistentEnums() throws Exception {
- this.createAnnotatedPersistentEnum();
- Iterator<JaxbPersistentEnum> persistentEnums = this.getContextRoot().getPersistentEnums().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentEnums()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentEnums.next().getFullyQualifiedName());
- assertFalse(persistentEnums.hasNext());
+
+ public void testGetTypes2() throws Exception {
+ createEnumWithXmlType();
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbEnum) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
//add an unannotated class and make sure it's not added to the context root
createUnannotatedEnumNamed("Foo");
- persistentEnums = this.getContextRoot().getPersistentEnums().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentEnums()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentEnums.next().getFullyQualifiedName());
- assertFalse(persistentEnums.hasNext());
-
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbEnum) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNull(((JaxbEnum) getContextRoot().getType("test.Foo")));
+
//annotate the class with @XmlEnum and test it's added to the context root
JavaResourceEnum fooResourceType = (JavaResourceEnum) getJaxbProject().getJavaResourceType("test.Foo", JavaResourceAbstractType.Kind.ENUM);
AnnotatedElement annotatedElement = annotatedElement(fooResourceType);
@@ -315,73 +289,21 @@ public class GenericContextRootTests
}
});
- Iterable<String> persistentEnumNames =
- new TransformationIterable<JaxbPersistentEnum, String>(
- getContextRoot().getPersistentEnums()) {
- @Override
- protected String transform(JaxbPersistentEnum o) {
- return o.getFullyQualifiedName();
- }
- };
- assertEquals(2, CollectionTools.size(getContextRoot().getPersistentEnums()));
- assertTrue(CollectionTools.contains(persistentEnumNames, "test.Foo"));
- assertTrue(CollectionTools.contains(persistentEnumNames, FULLY_QUALIFIED_TYPE_NAME));
-
- //remove the annotation from the class and test it's removed from the root context node
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- removeAnnotation(declaration, JAXB.XML_TYPE);
- }
- });
-
- persistentEnums = getContextRoot().getPersistentEnums().iterator();
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentEnums()));
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, persistentEnums.next().getFullyQualifiedName());
- assertFalse(persistentEnums.hasNext());
- }
-
- public void testChangeTypeKind() throws Exception {
- createAnnotatedRegistry();
- createUnannotatedClassNamed("Foo");
- JavaResourceAbstractType fooResourceType = getJaxbProject().getJavaResourceType("test.Foo");
- AnnotatedElement annotatedElement = annotatedElement(fooResourceType);
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_REGISTRY);
- }
- });
-
- assertEquals(2, getContextRoot().getTypesSize());
- assertEquals(2, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(0, CollectionTools.size(getContextRoot().getPersistentClasses()));
-
- // remove the @XmlRegistry annotation and add an @XmlType annotation
- annotatedElement.edit(
- new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- removeAnnotation(declaration, JAXB.XML_REGISTRY);
- addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- }
- });
-
- assertEquals(2, getContextRoot().getTypesSize());
- assertEquals(1, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbEnum) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNotNull(((JaxbEnum) getContextRoot().getType("test.Foo")));
- // remove the @XmlType annotation and add an @XmlRegistry annotation
+ //remove the annotation from the class and test it's removed from the root context node
annotatedElement.edit(
new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
removeAnnotation(declaration, JAXB.XML_TYPE);
- addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_REGISTRY);
}
});
- assertEquals(2, getContextRoot().getTypesSize());
- assertEquals(2, CollectionTools.size(getContextRoot().getRegistries()));
- assertEquals(0, CollectionTools.size(getContextRoot().getPersistentClasses()));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbEnum) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNull(((JaxbEnum) getContextRoot().getType("test.Foo")));
}
public void testDirectReferencedSuperclass() throws Exception {
@@ -390,22 +312,21 @@ public class GenericContextRootTests
createUnannotatedClassNamed(superclassName);
// make sure unannotated superclass is not in context
- assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
+
+ createClassWithXmlTypeAndSuperclassNamed(superclassName);
- createAnnotatedPersistentClassWithSuperclassNamed(superclassName);
- Iterable<JaxbPersistentClass> persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(2, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqSuperclassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNotNull(((JaxbClass) getContextRoot().getType(fqSuperclassName)));
// remove annotated class - both classes removed from context
- IFile file = (IFile) getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME).getResource();
+ IFile file = (IFile) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME).getResource();
file.delete(true, null);
- persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(0, CollectionTools.size(persistentClasses));
- assertNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNull(getContextRoot().getPersistentClass(fqSuperclassName));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
+ assertNull(((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME)));
+ assertNull(((JaxbClass) getContextRoot().getType(fqSuperclassName)));
}
public void testDirectReferencedAttribute() throws Exception {
@@ -415,17 +336,16 @@ public class GenericContextRootTests
createUnannotatedClassNamed(otherClassName);
// make sure unannotated other class is not in context
- assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
- createAnnotatedPersistentClassWithAttributeAndTypeNamed(attributeName, otherClassName);
+ createClassWithXmlTypeAndAttribute(attributeName, otherClassName);
JavaResourceType thisType = (JavaResourceType) getJaxbProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourceAttribute attribute = getFieldNamed(thisType, attributeName);
AnnotatedElement annotatedAttribute = annotatedElement(attribute);
- Iterable<JaxbPersistentClass> persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(2, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// add an @XmlElement
annotatedAttribute.edit(
@@ -435,10 +355,9 @@ public class GenericContextRootTests
}
});
- persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(2, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// change to @XmlTransient
annotatedAttribute.edit(
@@ -449,10 +368,9 @@ public class GenericContextRootTests
}
});
- persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(1, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNull(getContextRoot().getType(fqOtherClassName));
}
public void testDirectReferencedListAttribute() throws Exception {
@@ -462,17 +380,16 @@ public class GenericContextRootTests
createUnannotatedClassNamed(otherClassName);
// make sure unannotated other class is not in context
- assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
- createAnnotatedPersistentClassWithAttributeAndElementTypeNamed(attributeName, otherClassName);
+ createClassWithXmlTypeAndListAttribute(attributeName, otherClassName);
JavaResourceType thisType = (JavaResourceType) getJaxbProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourceAttribute attribute = getFieldNamed(thisType, attributeName);
AnnotatedElement annotatedAttribute = annotatedElement(attribute);
- Iterable<JaxbPersistentClass> persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(2, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// add an @XmlElement
annotatedAttribute.edit(
@@ -482,10 +399,9 @@ public class GenericContextRootTests
}
});
- persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(2, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// change to @XmlTransient
annotatedAttribute.edit(
@@ -496,10 +412,9 @@ public class GenericContextRootTests
}
});
- persistentClasses = this.getContextRoot().getPersistentClasses();
- assertEquals(1, CollectionTools.size(persistentClasses));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNull(getContextRoot().getType(fqOtherClassName));
}
public void testDirectReferencedSeeAlso() throws Exception {
@@ -511,15 +426,15 @@ public class GenericContextRootTests
createUnannotatedClassNamed(otherClassName2);
// make sure unannotated other classes are not in context
- assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
JavaResourceType thisType = (JavaResourceType) getJaxbProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME);
AnnotatedElement annotatedType = annotatedElement(thisType);
// make sure unannotated other classes are not in context
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
// add an @XmlSeeAlso with one class
annotatedType.edit(
@@ -529,9 +444,9 @@ public class GenericContextRootTests
}
});
- assertEquals(2, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// change to @XmlSeeAlso with two classes
annotatedType.edit(
@@ -542,10 +457,10 @@ public class GenericContextRootTests
}
});
- assertEquals(3, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName2));
+ assertEquals(3, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
+ assertNotNull(getContextRoot().getType(fqOtherClassName2));
// remove the @XmlSeeAlso annotation
annotatedType.edit(
@@ -555,8 +470,8 @@ public class GenericContextRootTests
}
});
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
}
public void testJaxbIndex() throws Exception {
@@ -568,35 +483,35 @@ public class GenericContextRootTests
createUnannotatedClassNamed(otherClassName2);
// make sure unannotated other classes are not in context
- assertTrue(CollectionTools.isEmpty(getContextRoot().getPersistentClasses()));
+ assertTrue(CollectionTools.isEmpty(getContextRoot().getTypes()));
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
// make sure unannotated other classes are not in context
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
// add a jaxb.index with one class
IFile jaxbIndex = getJavaProject().getProject().getFile(new Path("src/test/jaxb.index"));
InputStream stream = new ByteArrayInputStream(otherClassName.getBytes());
jaxbIndex.create(stream, true, null);
- assertEquals(2, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
+ assertEquals(2, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
// change to jaxb.index with two classes
jaxbIndex.setContents(new ByteArrayInputStream((otherClassName + CR + otherClassName2).getBytes()), true, false, null);
- assertEquals(3, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName));
- assertNotNull(getContextRoot().getPersistentClass(fqOtherClassName2));
+ assertEquals(3, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(getContextRoot().getType(fqOtherClassName));
+ assertNotNull(getContextRoot().getType(fqOtherClassName2));
// clear the jaxb.index
jaxbIndex.setContents(new ByteArrayInputStream(new byte[0]), true, false, null);
- assertEquals(1, CollectionTools.size(getContextRoot().getPersistentClasses()));
- assertNotNull(getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME));
+ assertEquals(1, CollectionTools.size(getContextRoot().getTypes()));
+ assertNotNull(getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME));
}
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
index 2b94840f9b..9eeb39279b 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -49,7 +49,7 @@ public abstract class JaxbContextModelTestCase
return createTestPackageInfo(packageName);
}
- protected ICompilationUnit createAnnotatedPersistentClass() throws Exception {
+ protected ICompilationUnit createClassWithXmlType() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -62,11 +62,24 @@ public abstract class JaxbContextModelTestCase
});
}
+ protected ICompilationUnit createClassWithXmlRegistry() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_REGISTRY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlRegistry");
+ }
+ });
+ }
+
protected ICompilationUnit createUnannotatedClassNamed(String typeName) throws Exception {
return this.createTestType(PACKAGE_NAME, typeName + ".java", typeName, new DefaultAnnotationWriter());
}
- protected ICompilationUnit createAnnotatedPersistentEnum() throws Exception {
+ protected ICompilationUnit createEnumWithXmlType() throws Exception {
return this.createTestEnum(new DefaultEnumAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -82,17 +95,4 @@ public abstract class JaxbContextModelTestCase
protected ICompilationUnit createUnannotatedEnumNamed(String enumName) throws Exception {
return this.createTestEnum(PACKAGE_NAME, enumName + ".java", enumName, new DefaultEnumAnnotationWriter());
}
-
- protected ICompilationUnit createAnnotatedRegistry() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_REGISTRY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlRegistry");
- }
- });
- }
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java
index 221e8855a9..3d2a980510 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaAttributeXmlJavaTypeAdapterTests.java
@@ -19,6 +19,8 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
@@ -34,7 +36,7 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
super(name);
}
- private ICompilationUnit createTypeWithXmlTypeWithXmlJavaTypeAdapter() throws Exception {
+ private ICompilationUnit createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -53,11 +55,14 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
}
public void testModifyValue() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- XmlAttributeMapping contextAttributeMapping = (XmlAttributeMapping) CollectionTools.get(CollectionTools.get(getContextRoot().getPersistentClasses(), 0).getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextAttributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = contextAttributeMapping.getJavaResourceAttribute();
-
+ createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
+
assertNull(contextXmlJavaTypeAdapter.getValue());
contextXmlJavaTypeAdapter.setValue("foo");
@@ -73,11 +78,14 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
}
public void testUpdateValue() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- XmlAttributeMapping contextAttributeMapping = (XmlAttributeMapping) CollectionTools.get(CollectionTools.get(getContextRoot().getPersistentClasses(), 0).getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextAttributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = contextAttributeMapping.getJavaResourceAttribute();
-
+ createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
+
assertNull(contextXmlJavaTypeAdapter.getValue());
//add a value member value pair
@@ -94,15 +102,18 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
GenericJavaAttributeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
}
});
- assertNull(contextAttributeMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
}
-
+
public void testModifyType() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- XmlAttributeMapping contextAttributeMapping = (XmlAttributeMapping) CollectionTools.get(CollectionTools.get(getContextRoot().getPersistentClasses(), 0).getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextAttributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = contextAttributeMapping.getJavaResourceAttribute();
-
+ createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
+
assertEquals("int", contextXmlJavaTypeAdapter.getType());
assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
@@ -122,11 +133,14 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
}
public void testUpdateType() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- XmlAttributeMapping contextAttributeMapping = (XmlAttributeMapping) CollectionTools.get(CollectionTools.get(getContextRoot().getPersistentClasses(), 0).getAttributes(), 0).getMapping();
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextAttributeMapping.getXmlJavaTypeAdapter();
- JavaResourceAttribute resourceAttribute = contextAttributeMapping.getJavaResourceAttribute();
-
+ createClassWithXmlTypeAndAttributeXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlAttributeMapping attributeMapping = (XmlAttributeMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = attributeMapping.getXmlJavaTypeAdapter();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getJavaResourceAttribute();
+
assertEquals("int", contextXmlJavaTypeAdapter.getType());
assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
assertEquals("int", contextXmlJavaTypeAdapter.getDefaultType());
@@ -147,7 +161,7 @@ public class GenericJavaAttributeXmlJavaTypeAdapterTests extends JaxbContextMode
GenericJavaAttributeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
}
});
- assertNull(contextAttributeMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
}
protected void addXmlJavaTypeAdapterTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java
index 29bad05e04..660856ced4 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaClassMappingTests.java
@@ -34,16 +34,16 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.ReflectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
import org.eclipse.jpt.jaxb.core.internal.context.java.PropertyAccessor;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
@@ -51,10 +51,10 @@ import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase
@SuppressWarnings("nls")
-public class GenericJavaPersistentClassTests
+public class GenericJavaClassMappingTests
extends JaxbContextModelTestCase {
- public GenericJavaPersistentClassTests(String name) {
+ public GenericJavaClassMappingTests(String name) {
super(name);
}
@@ -261,325 +261,333 @@ public class GenericJavaPersistentClassTests
}
public void testModifyFactoryClass() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getFactoryClass());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertNull(classMapping.getFactoryClass());
- persistentClass.setFactoryClass("foo");
+ classMapping.setFactoryClass("foo");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getFactoryClass());
- assertEquals("foo", persistentClass.getFactoryClass());
+ assertEquals("foo", classMapping.getFactoryClass());
- persistentClass.setFactoryClass(null);
+ classMapping.setFactoryClass(null);
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertNull(xmlTypeAnnotation.getFactoryClass());
- assertNull(persistentClass.getFactoryClass());
+ assertNull(classMapping.getFactoryClass());
//add another annotation so that the context model does not get blown away
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
resourceType.removeAnnotation(JAXB.XML_TYPE);
//set factoryClass again, this time starting with no XmlType annotation
- persistentClass.setFactoryClass("foo");
+ classMapping.setFactoryClass("foo");
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getFactoryClass());
- assertEquals("foo", persistentClass.getFactoryClass());
+ assertEquals("foo", classMapping.getFactoryClass());
}
public void testUpdateFactoryClass() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getFactoryClass());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+ assertNull(classMapping.getFactoryClass());
//add a factoryClass member value pair
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addXmlTypeTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_CLASS, "Foo");
+ GenericJavaClassMappingTests.this.addXmlTypeTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_CLASS, "Foo");
}
});
- assertEquals("Foo", persistentClass.getFactoryClass());
+ assertEquals("Foo", classMapping.getFactoryClass());
//remove the factoryClass member value pair
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentClassTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentClassTests.this.values(xmlTypeAnnotation).remove(0);
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
}
});
- assertNull(persistentClass.getFactoryClass());
+ assertNull(classMapping.getFactoryClass());
}
public void testModifyFactoryMethod() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getFactoryMethod());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertNull(classMapping.getFactoryMethod());
- persistentClass.setFactoryMethod("foo");
+ classMapping.setFactoryMethod("foo");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", persistentClass.getFactoryMethod());
+ assertEquals("foo", classMapping.getFactoryMethod());
- persistentClass.setFactoryMethod(null);
+ classMapping.setFactoryMethod(null);
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertNull(xmlTypeAnnotation.getFactoryMethod());
- assertNull(persistentClass.getFactoryMethod());
+ assertNull(classMapping.getFactoryMethod());
//add another annotation so that the context model does not get blown away
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
resourceType.removeAnnotation(JAXB.XML_TYPE);
//set factoryMethod again, this time starting with no XmlType annotation
- persistentClass.setFactoryMethod("foo");
+ classMapping.setFactoryMethod("foo");
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", persistentClass.getFactoryMethod());
+ assertEquals("foo", classMapping.getFactoryMethod());
}
public void testUpdateFactoryMethod() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getFactoryMethod());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+ assertNull(classMapping.getFactoryMethod());
//add a factoryMethod member value pair
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_METHOD, "foo");
+ GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_METHOD, "foo");
}
});
- assertEquals("foo", persistentClass.getFactoryMethod());
+ assertEquals("foo", classMapping.getFactoryMethod());
//remove the factoryMethod member value pair
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentClassTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentClassTests.this.values(xmlTypeAnnotation).remove(0);
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
}
});
- assertNull(persistentClass.getFactoryMethod());
+ assertNull(classMapping.getFactoryMethod());
}
public void testModifySchemaTypeName() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
- assertNull(persistentClass.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getName());
+ assertNull(classMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getDefaultName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
- persistentClass.getQName().setSpecifiedName("foo");
+ classMapping.getQName().setSpecifiedName("foo");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", persistentClass.getQName().getSpecifiedName());
- assertEquals("foo", persistentClass.getQName().getName());
+ assertEquals("foo", classMapping.getQName().getSpecifiedName());
+ assertEquals("foo", classMapping.getQName().getName());
- persistentClass.getQName().setSpecifiedName(null);
+ classMapping.getQName().setSpecifiedName(null);
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertNull(xmlTypeAnnotation.getName());
- assertNull(persistentClass.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getName());
+ assertNull(classMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
//add another annotation so that the context model does not get blown away
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
resourceType.removeAnnotation(JAXB.XML_TYPE);
//set name again, this time starting with no XmlType annotation
- persistentClass.getQName().setSpecifiedName("foo");
+ classMapping.getQName().setSpecifiedName("foo");
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", persistentClass.getQName().getSpecifiedName());
- assertEquals("foo", persistentClass.getQName().getName());
+ assertEquals("foo", classMapping.getQName().getSpecifiedName());
+ assertEquals("foo", classMapping.getQName().getName());
}
public void testUpdateSchemaTypeName() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
- assertNull(persistentClass.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getName());
+ assertNull(classMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getDefaultName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
//add a namespace member value pair
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
+ GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
}
});
- assertEquals("foo", persistentClass.getQName().getSpecifiedName());
- assertEquals("foo", persistentClass.getQName().getName());
+ assertEquals("foo", classMapping.getQName().getSpecifiedName());
+ assertEquals("foo", classMapping.getQName().getName());
//remove the namespace member value pair
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentClassTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentClassTests.this.values(xmlTypeAnnotation).remove(0);
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
}
});
- assertNull(persistentClass.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, persistentClass.getQName().getName());
+ assertNull(classMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, classMapping.getQName().getName());
}
public void testModifyNamespace() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- assertNull(persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("", persistentClass.getQName().getDefaultNamespace());
- assertEquals("", persistentClass.getQName().getNamespace());
+ assertNull(classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", classMapping.getQName().getDefaultNamespace());
+ assertEquals("", classMapping.getQName().getNamespace());
- persistentClass.getQName().setSpecifiedNamespace("foo");
+ classMapping.getQName().setSpecifiedNamespace("foo");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("foo", persistentClass.getQName().getNamespace());
+ assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", classMapping.getQName().getNamespace());
- persistentClass.getQName().setSpecifiedNamespace(null);
+ classMapping.getQName().setSpecifiedNamespace(null);
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertNull(xmlTypeAnnotation.getNamespace());
- assertNull(persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("", persistentClass.getQName().getNamespace());
+ assertNull(classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", classMapping.getQName().getNamespace());
//add another annotation so that the context model does not get blown away
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
resourceType.removeAnnotation(JAXB.XML_TYPE);
//set namespace again, this time starting with no XmlType annotation
- persistentClass.getQName().setSpecifiedNamespace("foo");
+ classMapping.getQName().setSpecifiedNamespace("foo");
xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("foo", persistentClass.getQName().getNamespace());
+ assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", classMapping.getQName().getNamespace());
}
public void testUpdateNamespace() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
- assertNull(persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("", persistentClass.getQName().getDefaultNamespace());
- assertEquals("", persistentClass.getQName().getNamespace());
+ assertNull(classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", classMapping.getQName().getDefaultNamespace());
+ assertEquals("", classMapping.getQName().getNamespace());
//add a namespace member value pair
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
+ GenericJavaClassMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
}
});
- assertEquals("foo", persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("foo", persistentClass.getQName().getNamespace());
+ assertEquals("foo", classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", classMapping.getQName().getNamespace());
//remove the namespace member value pair
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentClassTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentClassTests.this.values(xmlTypeAnnotation).remove(0);
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaClassMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaClassMappingTests.this.values(xmlTypeAnnotation).remove(0);
}
});
- assertNull(persistentClass.getQName().getSpecifiedNamespace());
- assertEquals("", persistentClass.getQName().getNamespace());
+ assertNull(classMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", classMapping.getQName().getNamespace());
}
public void testModifyAccessType() throws Exception {
createXmlTypeWithAccessorType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertEquals(XmlAccessType.PROPERTY, persistentClass.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, persistentClass.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getDefaultAccessType());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertEquals(XmlAccessType.PROPERTY, classMapping.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PROPERTY, classMapping.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
XmlAccessorTypeAnnotation accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.FIELD, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.FIELD, classMapping.getAccessType());
- persistentClass.setSpecifiedAccessType(XmlAccessType.PUBLIC_MEMBER);
+ classMapping.setSpecifiedAccessType(XmlAccessType.PUBLIC_MEMBER);
assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
- persistentClass.setSpecifiedAccessType(XmlAccessType.NONE);
+ classMapping.setSpecifiedAccessType(XmlAccessType.NONE);
assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE, accessorTypeAnnotation.getValue());
- assertEquals(XmlAccessType.NONE, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.NONE, classMapping.getAccessType());
- persistentClass.setSpecifiedAccessType(null);
+ classMapping.setSpecifiedAccessType(null);
accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_TYPE);
assertNull(accessorTypeAnnotation.getValue());
- assertNull(persistentClass.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getDefaultAccessType());
+ assertNull(classMapping.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
}
public void testUpdateAccessType() throws Exception {
createXmlTypeWithAccessorType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertEquals(XmlAccessType.PROPERTY, persistentClass.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PROPERTY, persistentClass.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getDefaultAccessType());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertEquals(XmlAccessType.PROPERTY, classMapping.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PROPERTY, classMapping.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
//set the accesser type value to FIELD
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__FIELD);
+ GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__FIELD);
}
});
- assertEquals(XmlAccessType.FIELD, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.FIELD, classMapping.getAccessType());
//set the accesser type value to PUBLIC_MEMBER
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
}
});
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
//set the accesser type value to NONE
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__NONE);
+ GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, JAXB.XML_ACCESS_TYPE__NONE);
}
});
- assertEquals(XmlAccessType.NONE, persistentClass.getAccessType());
+ assertEquals(XmlAccessType.NONE, classMapping.getAccessType());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_TYPE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_TYPE);
}
});
- assertNull(persistentClass.getSpecifiedAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getAccessType());
- assertEquals(XmlAccessType.PUBLIC_MEMBER, persistentClass.getDefaultAccessType());
+ assertNull(classMapping.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, classMapping.getDefaultAccessType());
}
/**
@@ -588,118 +596,130 @@ public class GenericJavaPersistentClassTests
* Otherwise, the @XmlAccessorType on a package is inherited.
*/
public void testGetDefaultAccessType() throws Exception {
- this.createAnnotatedPersistentClass();
- this.createTestSubType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentClass childPersistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
-
- assertEquals(XmlAccessType.PUBLIC_MEMBER, childPersistentClass.getDefaultAccessType());
+ createClassWithXmlType();
+ createTestSubType();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbClass childJaxbClass = (JaxbClass) getContextRoot().getType("test.AnnotationTestTypeChild");
+ JaxbClassMapping childClassMapping = childJaxbClass.getMapping();
+
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, childClassMapping.getDefaultAccessType());
this.createPackageInfoWithAccessorType();
- assertEquals(XmlAccessType.PROPERTY, childPersistentClass.getDefaultAccessType());
+ assertEquals(XmlAccessType.PROPERTY, childClassMapping.getDefaultAccessType());
- persistentClass.setSpecifiedAccessType(XmlAccessType.FIELD);
- assertEquals(XmlAccessType.PROPERTY, childPersistentClass.getDefaultAccessType());
+ classMapping.setSpecifiedAccessType(XmlAccessType.FIELD);
+ assertEquals(XmlAccessType.FIELD, childClassMapping.getDefaultAccessType());
JaxbPackageInfo contextPackageInfo = CollectionTools.get(getContextRoot().getPackages(), 0).getPackageInfo();
- persistentClass.setSpecifiedAccessType(null);
- assertEquals(XmlAccessType.PROPERTY, childPersistentClass.getDefaultAccessType());
+ classMapping.setSpecifiedAccessType(null);
+ assertEquals(XmlAccessType.PROPERTY, childClassMapping.getDefaultAccessType());
contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
- assertEquals(XmlAccessType.FIELD, childPersistentClass.getDefaultAccessType());
+ assertEquals(XmlAccessType.FIELD, childClassMapping.getDefaultAccessType());
contextPackageInfo.setSpecifiedAccessType(XmlAccessType.NONE);
- assertEquals(XmlAccessType.NONE, childPersistentClass.getDefaultAccessType());
+ assertEquals(XmlAccessType.NONE, childClassMapping.getDefaultAccessType());
contextPackageInfo.setSpecifiedAccessType(null);
- assertEquals(XmlAccessType.PUBLIC_MEMBER, childPersistentClass.getDefaultAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, childClassMapping.getDefaultAccessType());
}
public void testGetSuperPersistentClass() throws Exception {
- this.createAnnotatedPersistentClass();
- this.createTestSubType();
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- JaxbPersistentClass childPersistentClass = getContextRoot().getPersistentClass(PACKAGE_NAME + ".AnnotationTestTypeChild");
-
- assertEquals(persistentClass, childPersistentClass.getSuperClass());
+ createClassWithXmlType();
+ createTestSubType();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbClass childJaxbClass = (JaxbClass) getContextRoot().getType("test.AnnotationTestTypeChild");
+ JaxbClassMapping childClassMapping = childJaxbClass.getMapping();
+
+ assertEquals(classMapping, childClassMapping.getSuperclass());
//test that the superClass is not null even when it is unannotated
- AnnotatedElement annotatedElement = this.annotatedElement(persistentClass.getJavaResourceType());
+ AnnotatedElement annotatedElement = this.annotatedElement(jaxbClass.getJavaResourceType());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_TYPE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_TYPE);
}
});
- assertEquals(persistentClass, childPersistentClass.getSuperClass());
+ assertEquals(classMapping, childClassMapping.getSuperclass());
}
public void testModifyAccessOrder() throws Exception {
createXmlTypeWithAccessorOrder();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getDefaultAccessOrder());
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
- persistentClass.setSpecifiedAccessOrder(XmlAccessOrder.UNDEFINED);
+ classMapping.setSpecifiedAccessOrder(XmlAccessOrder.UNDEFINED);
XmlAccessorOrderAnnotation accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED, accessorOrderAnnotation.getValue());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
- persistentClass.setSpecifiedAccessOrder(null);
+ classMapping.setSpecifiedAccessOrder(null);
accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourceType.getAnnotation(JAXB.XML_ACCESSOR_ORDER);
assertNull(accessorOrderAnnotation.getValue());
- assertNull(persistentClass.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getDefaultAccessOrder());
+ assertNull(classMapping.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
}
public void testUpdateAccessOrder() throws Exception {
createXmlTypeWithAccessorOrder();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getDefaultAccessOrder());
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.ALPHABETICAL, classMapping.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
//set the access order value to UNDEFINED
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_ORDER, JAXB.XML_ACCESS_ORDER__UNDEFINED);
+ GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_ORDER, JAXB.XML_ACCESS_ORDER__UNDEFINED);
}
});
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_ORDER);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ACCESSOR_ORDER);
}
});
- assertNull(persistentClass.getSpecifiedAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getAccessOrder());
- assertEquals(XmlAccessOrder.UNDEFINED, persistentClass.getDefaultAccessOrder());
+ assertNull(classMapping.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, classMapping.getDefaultAccessOrder());
}
public void testGetPropOrder() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- ListIterator<String> props = persistentClass.getPropOrder().iterator();
+ this.createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ ListIterator<String> props = classMapping.getPropOrder().iterator();
assertFalse(props.hasNext());
//add 2 prop orders
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentClassTests.this.addProp(declaration, 1, "foo");
+ GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
+ GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertEquals("bar", props.next());
assertEquals("foo", props.next());
assertFalse(props.hasNext());
@@ -710,31 +730,35 @@ public class GenericJavaPersistentClassTests
}
public void testGetPropOrderSize() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertEquals(0, persistentClass.getPropOrderSize());
+ this.createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertEquals(0, classMapping.getPropOrderSize());
//add 2 prop orders
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentClassTests.this.addProp(declaration, 1, "foo");
+ GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
+ GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
}
});
- assertEquals(2, persistentClass.getPropOrderSize());
+ assertEquals(2, classMapping.getPropOrderSize());
}
public void testAddProp() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- persistentClass.addProp(0, "bar");
- persistentClass.addProp(0, "foo");
- persistentClass.addProp(0, "baz");
+ this.createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ classMapping.addProp(0, "bar");
+ classMapping.addProp(0, "foo");
+ classMapping.addProp(0, "baz");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
@@ -746,13 +770,15 @@ public class GenericJavaPersistentClassTests
}
public void testAddProp2() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- persistentClass.addProp(0, "bar");
- persistentClass.addProp(1, "foo");
- persistentClass.addProp(0, "baz");
+ createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ classMapping.addProp(0, "bar");
+ classMapping.addProp(1, "foo");
+ classMapping.addProp(0, "baz");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
@@ -764,48 +790,52 @@ public class GenericJavaPersistentClassTests
}
public void testRemoveProp() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- persistentClass.addProp(0, "bar");
- persistentClass.addProp(1, "foo");
- persistentClass.addProp(2, "baz");
+ createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ classMapping.addProp(0, "bar");
+ classMapping.addProp(1, "foo");
+ classMapping.addProp(2, "baz");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
- persistentClass.removeProp(1);
+ classMapping.removeProp(1);
ListIterator<String> resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
assertEquals("bar", resourceProps.next());
assertEquals("baz", resourceProps.next());
assertFalse(resourceProps.hasNext());
- persistentClass.removeProp(1);
+ classMapping.removeProp(1);
resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
assertEquals("bar", resourceProps.next());
assertFalse(resourceProps.hasNext());
- persistentClass.removeProp(0);
+ classMapping.removeProp(0);
resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
assertFalse(resourceProps.hasNext());
}
public void testMoveProp() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- persistentClass.addProp(0, "bar");
- persistentClass.addProp(1, "foo");
- persistentClass.addProp(2, "baz");
+ createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ classMapping.addProp(0, "bar");
+ classMapping.addProp(1, "foo");
+ classMapping.addProp(2, "baz");
XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceType.getAnnotation(JAXB.XML_TYPE);
assertEquals(3, xmlTypeAnnotation.getPropOrderSize());
- persistentClass.moveProp(2, 0);
- ListIterator<String> props = persistentClass.getPropOrder().iterator();
+ classMapping.moveProp(2, 0);
+ ListIterator<String> props = classMapping.getPropOrder().iterator();
assertEquals("foo", props.next());
assertEquals("baz", props.next());
assertEquals("bar", props.next());
@@ -815,10 +845,9 @@ public class GenericJavaPersistentClassTests
assertEquals("foo", resourceProps.next());
assertEquals("baz", resourceProps.next());
assertEquals("bar", resourceProps.next());
-
-
- persistentClass.moveProp(0, 1);
- props = persistentClass.getPropOrder().iterator();
+
+ classMapping.moveProp(0, 1);
+ props = classMapping.getPropOrder().iterator();
assertEquals("baz", props.next());
assertEquals("foo", props.next());
assertEquals("bar", props.next());
@@ -830,25 +859,27 @@ public class GenericJavaPersistentClassTests
assertEquals("bar", resourceProps.next());
}
- public void testSyncXmlNsPrefixes() throws Exception {
- this.createAnnotatedPersistentClass();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- ListIterator<String> props = persistentClass.getPropOrder().iterator();
+ public void testSyncProps() throws Exception {
+ createClassWithXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ ListIterator<String> props = classMapping.getPropOrder().iterator();
assertFalse(props.hasNext());
//add 3 prop orders
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentClassTests.this.addProp(declaration, 1, "foo");
- GenericJavaPersistentClassTests.this.addProp(declaration, 2, "baz");
+ GenericJavaClassMappingTests.this.addProp(declaration, 0, "bar");
+ GenericJavaClassMappingTests.this.addProp(declaration, 1, "foo");
+ GenericJavaClassMappingTests.this.addProp(declaration, 2, "baz");
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertTrue(props.hasNext());
assertEquals("bar", props.next());
assertEquals("foo", props.next());
@@ -858,11 +889,11 @@ public class GenericJavaPersistentClassTests
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.moveProp(declaration, 2, 0);
+ GenericJavaClassMappingTests.this.moveProp(declaration, 2, 0);
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertTrue(props.hasNext());
assertEquals("foo", props.next());
assertEquals("baz", props.next());
@@ -872,11 +903,11 @@ public class GenericJavaPersistentClassTests
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.moveProp(declaration, 0, 1);
+ GenericJavaClassMappingTests.this.moveProp(declaration, 0, 1);
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertTrue(props.hasNext());
assertEquals("baz", props.next());
assertEquals("foo", props.next());
@@ -886,11 +917,11 @@ public class GenericJavaPersistentClassTests
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeProp(declaration, 1);
+ GenericJavaClassMappingTests.this.removeProp(declaration, 1);
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertTrue(props.hasNext());
assertEquals("baz", props.next());
assertEquals("bar", props.next());
@@ -899,11 +930,11 @@ public class GenericJavaPersistentClassTests
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeProp(declaration, 1);
+ GenericJavaClassMappingTests.this.removeProp(declaration, 1);
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertTrue(props.hasNext());
assertEquals("baz", props.next());
assertFalse(props.hasNext());
@@ -911,11 +942,11 @@ public class GenericJavaPersistentClassTests
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeProp(declaration, 0);
+ GenericJavaClassMappingTests.this.removeProp(declaration, 0);
}
});
- props = persistentClass.getPropOrder().iterator();
+ props = classMapping.getPropOrder().iterator();
assertFalse(props.hasNext());
}
@@ -943,904 +974,899 @@ public class GenericJavaPersistentClassTests
}
public void testModifyXmlRootElement() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getRootElement());
- assertFalse(persistentClass.isRootElement());
-
- persistentClass.setRootElement("foo");
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+
+ assertNull(classMapping.getXmlRootElement());
+
+ classMapping.addXmlRootElement().getQName().setSpecifiedName("foo");
XmlRootElementAnnotation xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
assertEquals("foo", xmlRootElementAnnotation.getName());
- assertEquals("foo", persistentClass.getRootElement().getQName().getName());
- assertTrue(persistentClass.isRootElement());
-
- persistentClass.setRootElement(null);
+ assertEquals("foo", classMapping.getXmlRootElement().getQName().getName());
+
+ classMapping.removeXmlRootElement();
xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceType.getAnnotation(JAXB.XML_ROOT_ELEMENT);
assertNull(xmlRootElementAnnotation);
- assertNull(persistentClass.getRootElement());
- assertFalse(persistentClass.isRootElement());
+ assertNull(classMapping.getXmlRootElement());
}
public void testUpdateXmlRootElement() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- assertNull(persistentClass.getRootElement());
- assertFalse(persistentClass.isRootElement());
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
+ assertNull(classMapping.getXmlRootElement());
//add a XmlRootElement annotation
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = GenericJavaPersistentClassTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
- GenericJavaPersistentClassTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
+ NormalAnnotation annotation = GenericJavaClassMappingTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
+ GenericJavaClassMappingTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
}
});
- assertEquals("foo", persistentClass.getRootElement().getQName().getName());
- assertTrue(persistentClass.isRootElement());
-
+ assertEquals("foo", classMapping.getXmlRootElement().getQName().getName());
+
//remove the XmlRootElement annotation
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
}
});
- assertNull(persistentClass.getRootElement());
- assertFalse(persistentClass.isRootElement());
+ assertNull(classMapping.getXmlRootElement());
}
-
-
+
public void testUpdateFieldAttributes() throws Exception {
this.createTestXmlTypeWithFieldAndPublicMemberAccess();
-
- JaxbPersistentClass contextClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
//public int foo;
- this.publicFieldTest(contextClass);
-
+ publicFieldTest(classMapping);
+
//public transient int foo;
- this.publicTransientFieldTest(contextClass);
-
+ publicTransientFieldTest(classMapping);
+
//public static int foo;
- this.publicStaticFieldTest(contextClass);
-
+ publicStaticFieldTest(classMapping);
+
//public final int foo;
- this.publicFinalFieldTest(contextClass);
-
+ publicFinalFieldTest(classMapping);
+
//public static final int foo;
- this.publicStaticFinalFieldTest(contextClass);
-
+ publicStaticFinalFieldTest(classMapping);
+
//private int foo;
- this.privateFieldTest(contextClass);
-
+ privateFieldTest(classMapping);
+
// private transient int foo;
- this.privateTransientFieldTest(contextClass);
-
+ privateTransientFieldTest(classMapping);
+
// @XmlAttribute
// private static int foo; //persistent
- this.privateStaticFieldTest(contextClass);
-
+ privateStaticFieldTest(classMapping);
+
// @XmlAttribute
// private static final int foo; //persistent
- this.privateStaticFinalFieldTest(contextClass);
+ privateStaticFinalFieldTest(classMapping);
}
-
- protected void publicFieldTest(JaxbPersistentClass contextClass) {
+
+ protected void publicFieldTest(JaxbClassMapping classMapping) {
//public int foo; PUBLIC_MEMBER access - persistent
- assertEquals(1, contextClass.getAttributesSize());
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//public int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//public int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
-
+
//add @XmlTransient annotation and test each access type
- JavaResourceField resourceField = (JavaResourceField) contextClass.getAttributes().iterator().next().getJavaResourceAttribute();
+ JavaResourceField resourceField = (JavaResourceField) classMapping.getAttributes().iterator().next().getJavaResourceAttribute();
AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TRANSIENT);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TRANSIENT);
}
});
//@XmlTransient
//public int foo; //PROPERTY access - not "persistent", but comes in to our context model because it is "mapped"
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlTransient
//public int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlTransient
//public int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlTransient
//public int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_TRANSIENT);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_TRANSIENT);
}
});
}
- protected void publicTransientFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void publicTransientFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
//public transient int foo; PUBLIC_MEMBER access - not persistent
this.addModifiers(resourceField, ModifierKeyword.TRANSIENT_KEYWORD);
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//public transient int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//public transient int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public transient int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public transient int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
this.removeModifiers(resourceField, ModifierKeyword.TRANSIENT_KEYWORD);
}
- protected void publicStaticFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void publicStaticFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
//public static int foo; PUBLIC_MEMBER access - not persistent
this.addModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD);
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//public static int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
this.removeModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD);
}
- protected void publicFinalFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void publicFinalFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
//public final int foo; PUBLIC_MEMBER access - persistent
this.addModifiers(resourceField, ModifierKeyword.FINAL_KEYWORD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//public final int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public final int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
this.removeModifiers(resourceField, ModifierKeyword.FINAL_KEYWORD);
}
- protected void publicStaticFinalFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void publicStaticFinalFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
//public static final int foo; PUBLIC_MEMBER access - not persistent
this.addModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//public static final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//public static final int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public static final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public static final int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
this.removeModifiers(resourceField, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
}
- protected void privateFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void privateFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD);
//private int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//private int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//private int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//private int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//private int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//private int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
}
- protected void privateTransientFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void privateTransientFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.TRANSIENT_KEYWORD);
//private transient int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//private transient int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//private transient int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//private transient int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//private transient int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//private transient int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private transient int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private transient int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private transient int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.TRANSIENT_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
}
- protected void privateStaticFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void privateStaticFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD);
//private static int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//private static int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//private static int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//private static int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//private static int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//private static int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
removeModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
}
- protected void privateStaticFinalFieldTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void privateStaticFinalFieldTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
JavaResourceField resourceField = (JavaResourceField) attributes.next().getJavaResourceAttribute();
removeModifiers(resourceField, ModifierKeyword.PUBLIC_KEYWORD);
addModifiers(resourceField, ModifierKeyword.PRIVATE_KEYWORD, ModifierKeyword.STATIC_KEYWORD, ModifierKeyword.FINAL_KEYWORD);
//private static final int foo; PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//private static final int foo; //PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//private static final int foo; //FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//private static final int foo; //NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//private static final int foo; PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceField);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//private static final int foo; //PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static final int foo; //FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static final int foo; //NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private static final int foo; PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
}
public void testUpdatePropertyAttributes() throws Exception {
- this.createTestXmlTypeWithPropertyAndPublicMemberAccess();
-
- JaxbPersistentClass contextClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
-
+ createTestXmlTypeWithPropertyAndPublicMemberAccess();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+
//public int getFoo();, public void setFoo(int);
- this.publicGetterSetterTest(contextClass);
-
+ publicGetterSetterTest(classMapping);
+
//public static int getFoo();, public static void setFoo(int);
- this.publicStaticGetterSetterTest(contextClass);
-
+ publicStaticGetterSetterTest(classMapping);
+
//private int getFoo();, private void setFoo(int);
- this.privateGetterSetterTest(contextClass);
+ privateGetterSetterTest(classMapping);
}
-
+
public void testUpdateGetterPropertyAttributes() throws Exception {
- this.createTestXmlTypeWithPropertyGetterAndPublicMemberAccess();
-
- JaxbPersistentClass contextClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
-
+ createTestXmlTypeWithPropertyGetterAndPublicMemberAccess();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+
//public int getFoo(); PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
-
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int getFoo(); PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int getFoo(); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int getFoo(); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public int getFoo(); PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
-
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
+
//add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = contextClass.getJavaResourceType().getMethods().iterator().next();
+ JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//public int getFoo(); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public int getFoo(); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//@XmlAttribute
//public int getFoo(); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//@XmlAttribute
//public int getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
}
-
+
public void testUpdateSetterPropertyAttributes() throws Exception {
- this.createTestXmlTypeWithPropertySetterAndPublicMemberAccess();
-
- JaxbPersistentClass contextClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
-
+ createTestXmlTypeWithPropertySetterAndPublicMemberAccess();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+
//public void setFoo(int foo); PUBLIC_MEMBER access - not persistent
- assertEquals(0, contextClass.getAttributesSize());
-
+ assertEquals(0, classMapping.getAttributesSize());
+
//public void setFoo(int foo); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public void setFoo(int foo); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public void setFoo(int foo); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
+
//public void setFoo(int foo); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
-
-
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
+
//add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = contextClass.getJavaResourceType().getMethods().iterator().next();
+ JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//public void setFoo(int foo);; PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//@XmlAttribute
//public void setFoo(int foo); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public void setFoo(int foo); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
//@XmlAttribute
//public void setFoo(int foo); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
+
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
}
-
+
public void testUpdateGetterListPropertyAttributes() throws Exception {
this.createTestXmlTypeWithPropertyGetterListAndPublicMemberAccess();
-
- JaxbPersistentClass contextClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
-
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+
//public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public List<?> getFoo(); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public List<?> getFoo(); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public List<?> getFoo(); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
-
//add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = contextClass.getJavaResourceType().getMethods().iterator().next();
+ JavaResourceMethod resourceMethod = classMapping.getJaxbType().getJavaResourceType().getMethods().iterator().next();
AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//public List<?> getFoo(); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- attributes = contextClass.getAttributes().iterator();
- assertEquals(1, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ attributes = classMapping.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public List<?> getFoo(); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public List<?> getFoo(); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public List<?> getFoo(); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
}
- protected void publicGetterSetterTest(JaxbPersistentClass contextClass) {
+ protected void publicGetterSetterTest(JaxbClassMapping classMapping) {
//public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- assertEquals(1, contextClass.getAttributesSize());
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ assertEquals(1, classMapping.getAttributesSize());
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public int getFoo();, public void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//public int getFoo();, public void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public int getFoo();, public void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//add @XmlAttribute annotation and test each access type
- JavaResourceMethod resourceMethod = (JavaResourceMethod) contextClass.getAttributes().iterator().next().getJavaResourceAttribute();
+ JavaResourceMethod resourceMethod = (JavaResourceMethod) classMapping.getAttributes().iterator().next().getJavaResourceAttribute();
AnnotatedElement annotatedElement = this.annotatedElement(resourceMethod);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//public int getFoo();, public void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public int getFoo();, public void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public int getFoo();, public void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public int getFoo();, public void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
}
- protected void publicStaticGetterSetterTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void publicStaticGetterSetterTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
PropertyAccessor propertyAccessor = (PropertyAccessor) ReflectionTools.getFieldValue(attributes.next(), "accessor");
JavaResourceMethod resourceGetter = propertyAccessor.getResourceGetterMethod();
JavaResourceMethod resourceSetter = propertyAccessor.getResourceSetterMethod();
@@ -1848,76 +1874,76 @@ public class GenericJavaPersistentClassTests
//public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - not persistent
this.addModifiers(resourceGetter, ModifierKeyword.STATIC_KEYWORD);
this.addModifiers(resourceSetter, ModifierKeyword.STATIC_KEYWORD);
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//public static int getFoo();, public static void setFoo(int); PROPERTY access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int getFoo();, public static void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int getFoo();, public static void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceGetter);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//public static int getFoo();, public static void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public static int getFoo();, public static void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public static int getFoo();, public static void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//public static int getFoo();, public static void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
this.removeModifiers(resourceGetter, ModifierKeyword.STATIC_KEYWORD);
this.removeModifiers(resourceSetter, ModifierKeyword.STATIC_KEYWORD);
}
- protected void privateGetterSetterTest(JaxbPersistentClass contextClass) {
- Iterator<JaxbPersistentAttribute> attributes = contextClass.getAttributes().iterator();
+ protected void privateGetterSetterTest(JaxbClassMapping classMapping) {
+ Iterator<JaxbPersistentAttribute> attributes = classMapping.getAttributes().iterator();
PropertyAccessor propertyAccessor = (PropertyAccessor) ReflectionTools.getFieldValue(attributes.next(), "accessor");
JavaResourceMethod resourceGetter = propertyAccessor.getResourceGetterMethod();
JavaResourceMethod resourceSetter = propertyAccessor.getResourceSetterMethod();
@@ -1927,71 +1953,71 @@ public class GenericJavaPersistentClassTests
this.removeModifiers(resourceSetter, ModifierKeyword.PUBLIC_KEYWORD);
this.addModifiers(resourceGetter, ModifierKeyword.PRIVATE_KEYWORD);
this.addModifiers(resourceSetter, ModifierKeyword.PRIVATE_KEYWORD);
- assertEquals(0, contextClass.getAttributesSize());
+ assertEquals(0, classMapping.getAttributesSize());
//private int getFoo();, private void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//private int getFoo();, private void setFoo(int); FIELD access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(0, classMapping.getAttributesSize());
//private int getFoo();, private void setFoo(int); NONE access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(0, classMapping.getAttributesSize());
//private int getFoo();, private void setFoo(int); PUBLIC_MEMBER access - not persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(0, contextClass.getAttributesSize());
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(0, classMapping.getAttributesSize());
//add @XmlAttribute annotation and test each access type
AnnotatedElement annotatedElement = this.annotatedElement(resourceGetter);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ATTRIBUTE);
}
});
//@XmlAttribute
//private int getFoo();, private void setFoo(int); PROPERTY access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PROPERTY);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PROPERTY);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int getFoo();, private void setFoo(int); FIELD access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__FIELD);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__FIELD);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int getFoo();, private void setFoo(int); NONE access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__NONE);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__NONE);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
//@XmlAttribute
//private int getFoo();, private void setFoo(int); PUBLIC_MEMBER access - persistent
- this.setAccessTypeInJavaSource(contextClass, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
- assertEquals(1, contextClass.getAttributesSize());
- attributes = contextClass.getAttributes().iterator();
+ this.setAccessTypeInJavaSource(classMapping, JAXB.XML_ACCESS_TYPE__PUBLIC_MEMBER);
+ assertEquals(1, classMapping.getAttributesSize());
+ attributes = classMapping.getAttributes().iterator();
assertEquals("foo", attributes.next().getName());
assertFalse(attributes.hasNext());
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_ATTRIBUTE);
}
});
this.removeModifiers(resourceGetter, ModifierKeyword.PRIVATE_KEYWORD);
@@ -1999,110 +2025,60 @@ public class GenericJavaPersistentClassTests
this.addModifiers(resourceGetter, ModifierKeyword.PUBLIC_KEYWORD);
this.addModifiers(resourceSetter, ModifierKeyword.PUBLIC_KEYWORD);
}
-
- public void testModifyXmlJavaTypeAdapter() throws Exception {
- createAnnotatedPersistentClass();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(persistentClass.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
- persistentClass.addXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(persistentClass.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- persistentClass.removeXmlJavaTypeAdapter();
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
-
- public void testUpdateXmlJavaTypeAdapter() throws Exception {
- createAnnotatedPersistentClass();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(persistentClass.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
-
-
- //add an XmlJavaTypeAdapter annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(persistentClass.getXmlJavaTypeAdapter());
- assertNotNull(xmlJavaTypeAdapterAnnotation);
-
- //remove the XmlJavaTypeAdapter annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_JAVA_TYPE_ADAPTER);
- }
- });
- xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceType.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(persistentClass.getXmlJavaTypeAdapter());
- assertNull(xmlJavaTypeAdapterAnnotation);
- }
public void testModifyXmlSeeAlso() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(persistentClass.getXmlSeeAlso());
+ assertNull(classMapping.getXmlSeeAlso());
assertNull(annotation);
- persistentClass.addXmlSeeAlso();
+ classMapping.addXmlSeeAlso();
annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNotNull(persistentClass.getXmlSeeAlso());
+ assertNotNull(classMapping.getXmlSeeAlso());
assertNotNull(annotation);
- persistentClass.removeXmlSeeAlso();
+ classMapping.removeXmlSeeAlso();
annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(persistentClass.getXmlSeeAlso());
+ assertNull(classMapping.getXmlSeeAlso());
assertNull(annotation);
}
public void testUpdateXmlSeeAlso() throws Exception {
- createAnnotatedPersistentClass();
+ createClassWithXmlType();
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
XmlSeeAlsoAnnotation annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(persistentClass.getXmlSeeAlso());
+ assertNull(classMapping.getXmlSeeAlso());
assertNull(annotation);
AnnotatedElement annotatedElement = this.annotatedElement(resourceType);
annotatedElement.edit(
new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SEE_ALSO);
+ GenericJavaClassMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_SEE_ALSO);
}
});
annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNotNull(persistentClass.getXmlSeeAlso());
+ assertNotNull(classMapping.getXmlSeeAlso());
assertNotNull(annotation);
annotatedElement.edit(
new Member.Editor() {
public void edit(
ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeAnnotation(declaration, JAXB.XML_SEE_ALSO);
+ GenericJavaClassMappingTests.this.removeAnnotation(declaration, JAXB.XML_SEE_ALSO);
}
});
annotation = (XmlSeeAlsoAnnotation) resourceType.getAnnotation(JAXB.XML_SEE_ALSO);
- assertNull(persistentClass.getXmlSeeAlso());
+ assertNull(classMapping.getXmlSeeAlso());
assertNull(annotation);
}
@@ -2110,7 +2086,7 @@ public class GenericJavaPersistentClassTests
AnnotatedElement annotatedElement = this.annotatedElement(resourceMember);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.addModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
+ GenericJavaClassMappingTests.this.addModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
}
});
}
@@ -2119,7 +2095,7 @@ public class GenericJavaPersistentClassTests
AnnotatedElement annotatedElement = this.annotatedElement(resourceMember);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.removeModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
+ GenericJavaClassMappingTests.this.removeModifiers((BodyDeclaration) declaration.getDeclaration(), modifiers);
}
});
}
@@ -2149,12 +2125,12 @@ public class GenericJavaPersistentClassTests
return bodyDeclaration.modifiers();
}
- protected void setAccessTypeInJavaSource(JaxbPersistentClass contextClass, final String accessType) {
- JavaResourceType resourceClass = contextClass.getJavaResourceType();
+ protected void setAccessTypeInJavaSource(JaxbClassMapping classMapping, final String accessType) {
+ JavaResourceType resourceClass = classMapping.getJaxbType().getJavaResourceType();
AnnotatedElement annotatedElement = this.annotatedElement(resourceClass);
annotatedElement.edit(new Member.Editor() {
public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentClassTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, accessType);
+ GenericJavaClassMappingTests.this.setEnumMemberValuePair(declaration, JAXB.XML_ACCESSOR_TYPE, accessType);
}
});
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java
index e7a7d8d0fe..e6e8f7640b 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaElementFactoryMethodTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,24 +17,24 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementDeclAnnotation;
import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
@SuppressWarnings("nls")
-public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCase
-{
+public class GenericJavaElementFactoryMethodTests
+ extends JaxbContextModelTestCase {
public GenericJavaElementFactoryMethodTests(String name) {
super(name);
}
- private ICompilationUnit createTypeWithXmlRegistry() throws Exception {
+ protected ICompilationUnit createClassWithXmlRegistryAndCreateMethods() throws Exception {
return this.createTestType(PACKAGE_NAME, "ObjectFactory.java", "ObjectFactory", new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -57,26 +57,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
});
}
- private ICompilationUnit createTypeWithXmlType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- }
- });
- }
-
public void testModifyElementName() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getQName().getName());
@@ -94,13 +82,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateElementName() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getQName().getName());
@@ -119,16 +108,17 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
public void testModifyDefaultValue() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getDefaultValue());
@@ -146,13 +136,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateDefaultValue() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getDefaultValue());
@@ -171,16 +162,17 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
public void testModifyScope() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getScope());
@@ -206,13 +198,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateScope() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getScope());
@@ -233,16 +226,17 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
public void testModifySubstitutionHeadName() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getSubstitutionHeadQName().getName());
@@ -260,13 +254,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateSubstitutionHeadName() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertNull(elementFactoryMethod.getSubstitutionHeadQName().getName());
@@ -285,16 +280,17 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
public void testModifySubstitutionHeadNamespace() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertEquals("", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
@@ -312,13 +308,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateSubstitutionHeadNamespace() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertEquals("", elementFactoryMethod.getSubstitutionHeadQName().getNamespace());
@@ -337,16 +334,17 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
public void testModifyNamespace() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertEquals("", elementFactoryMethod.getQName().getNamespace());
@@ -364,13 +362,14 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
}
public void testUpdateNamespace() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
-
- assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
- Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry xmlRegistry = jaxbClass.getXmlRegistry();
+
+ assertEquals(2, xmlRegistry.getElementFactoryMethodsSize());
+ Iterator<JaxbElementFactoryMethod> elementFactoryMethods = xmlRegistry.getElementFactoryMethods().iterator();
JaxbElementFactoryMethod elementFactoryMethod = elementFactoryMethods.next();
JavaResourceMethod resourceMethod = elementFactoryMethod.getResourceMethod();
assertEquals("", elementFactoryMethod.getQName().getNamespace());
@@ -389,7 +388,7 @@ public class GenericJavaElementFactoryMethodTests extends JaxbContextModelTestCa
GenericJavaElementFactoryMethodTests.this.removeXmlElementDeclAnnotation(declaration);
}
});
- assertEquals(1, contextRegistry.getElementFactoryMethodsSize());
+ assertEquals(1, xmlRegistry.getElementFactoryMethodsSize());
}
protected void addXmlElementDeclMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java
index e9c3d9a693..59b975eeec 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumConstantTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -20,8 +20,9 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
@@ -51,10 +52,11 @@ public class GenericJavaEnumConstantTests extends JaxbContextModelTestCase
public void testUpdateName() throws Exception {
createEnumWithXmlEnum();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(contextEnum.getEnumConstants(), 1);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
assertEquals("MONDAY", contextEnumConstant.getName());
@@ -65,18 +67,18 @@ public class GenericJavaEnumConstantTests extends JaxbContextModelTestCase
GenericJavaEnumConstantTests.this.changeEnumConstantName((EnumDeclaration) declaration.getDeclaration(), "MONDAY", "MONDAY2");
}
});
- contextEnumConstant = CollectionTools.get(contextEnum.getEnumConstants(), 1);
- assertEquals(2, contextEnum.getEnumConstantsSize());
+ contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
+ assertEquals(2, enumMapping.getEnumConstantsSize());
assertEquals("MONDAY2", contextEnumConstant.getName());
}
public void testModifyValue() throws Exception {
createEnumWithXmlEnum();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(contextEnum.getEnumConstants(), 1);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
- JavaResourceEnumConstant resourceEnumConstant = CollectionTools.get(resourceEnum.getEnumConstants(), 1);
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
+ JavaResourceEnumConstant resourceEnumConstant = contextEnumConstant.getResourceEnumConstant();
assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
assertEquals("MONDAY", contextEnumConstant.getValue());
@@ -100,10 +102,10 @@ public class GenericJavaEnumConstantTests extends JaxbContextModelTestCase
public void testUpdateValue() throws Exception {
createEnumWithXmlEnum();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JaxbEnumConstant contextEnumConstant = CollectionTools.get(contextEnum.getEnumConstants(), 1);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
- JavaResourceEnumConstant resourceEnumConstant = CollectionTools.get(resourceEnum.getEnumConstants(), 1);
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JaxbEnumConstant contextEnumConstant = CollectionTools.get(enumMapping.getEnumConstants(), 1);
+ JavaResourceEnumConstant resourceEnumConstant = contextEnumConstant.getResourceEnumConstant();
assertEquals("MONDAY", contextEnumConstant.getDefaultValue());
assertEquals("MONDAY", contextEnumConstant.getValue());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java
new file mode 100644
index 0000000000..bcb23fbab1
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaEnumMappingTests.java
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.tests.internal.context.java;
+
+import java.beans.Introspector;
+import java.util.Iterator;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.MarkerAnnotation;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.Member;
+import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnum;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
+import org.eclipse.jpt.jaxb.core.context.JaxbEnumMapping;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
+import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
+
+
+@SuppressWarnings("nls")
+public class GenericJavaEnumMappingTests
+ extends JaxbContextModelTestCase {
+
+ public GenericJavaEnumMappingTests(String name) {
+ super(name);
+ }
+
+
+ protected void addXmlTypeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
+ this.addMemberValuePair((MarkerAnnotation) this.getXmlTypeAnnotation(declaration), name, value);
+ }
+
+ protected void addXmlTypeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
+ this.addMemberValuePair(
+ (MarkerAnnotation) this.getXmlTypeAnnotation(declaration),
+ name,
+ this.newTypeLiteral(declaration.getAst(), typeName));
+ }
+
+ protected void addXmlEnumTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
+ this.addMemberValuePair(
+ (MarkerAnnotation) this.getXmlEnumAnnotation(declaration),
+ name,
+ this.newTypeLiteral(declaration.getAst(), typeName));
+ }
+
+ protected Annotation getXmlTypeAnnotation(ModifiedDeclaration declaration) {
+ return declaration.getAnnotationNamed(JAXB.XML_TYPE);
+ }
+
+ protected Annotation getXmlEnumAnnotation(ModifiedDeclaration declaration) {
+ return declaration.getAnnotationNamed(JAXB.XML_ENUM);
+ }
+
+ public void testModifySchemaTypeName() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+ String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
+
+ assertNull(enumMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getDefaultName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
+
+ enumMapping.getQName().setSpecifiedName("foo");
+ XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertEquals("foo", xmlTypeAnnotation.getName());
+ assertEquals("foo", enumMapping.getQName().getSpecifiedName());
+ assertEquals("foo", enumMapping.getQName().getName());
+
+ enumMapping.getQName().setSpecifiedName(null);
+ xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertNull(xmlTypeAnnotation.getName());
+ assertNull(enumMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
+
+ resourceEnum.removeAnnotation(JAXB.XML_TYPE);
+
+ //set name again, this time starting with no XmlType annotation
+ enumMapping.getQName().setSpecifiedName("foo");
+ xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertEquals("foo", xmlTypeAnnotation.getName());
+ assertEquals("foo", enumMapping.getQName().getSpecifiedName());
+ assertEquals("foo", enumMapping.getQName().getName());
+ }
+
+ public void testUpdateSchemaTypeName() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+ String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
+
+ assertNull(enumMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getDefaultName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
+
+ //add a namespace member value pair
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
+ GenericJavaEnumMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
+ }
+ });
+ assertEquals("foo", enumMapping.getQName().getSpecifiedName());
+ assertEquals("foo", enumMapping.getQName().getName());
+
+ //remove the namespace member value pair
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaEnumMappingTests.this.values(xmlTypeAnnotation).remove(0);
+ }
+ });
+ assertNull(enumMapping.getQName().getSpecifiedName());
+ assertEquals(defaultXmlTypeName, enumMapping.getQName().getName());
+ }
+
+ public void testModifyNamespace() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", enumMapping.getQName().getDefaultNamespace());
+ assertEquals("", enumMapping.getQName().getNamespace());
+
+ enumMapping.getQName().setSpecifiedNamespace("foo");
+ XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertEquals("foo", xmlTypeAnnotation.getNamespace());
+ assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", enumMapping.getQName().getNamespace());
+
+ enumMapping.getQName().setSpecifiedNamespace(null);
+ xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertNull(xmlTypeAnnotation.getNamespace());
+ assertNull(enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", enumMapping.getQName().getNamespace());
+
+ resourceEnum.removeAnnotation(JAXB.XML_TYPE);
+
+ //set namespace again, this time starting with no XmlType annotation
+ enumMapping.getQName().setSpecifiedNamespace("foo");
+ xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
+ assertEquals("foo", xmlTypeAnnotation.getNamespace());
+ assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", enumMapping.getQName().getNamespace());
+ }
+
+ public void testUpdateNamespace() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", enumMapping.getQName().getDefaultNamespace());
+ assertEquals("", enumMapping.getQName().getNamespace());
+
+ //add a namespace member value pair
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
+ GenericJavaEnumMappingTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
+ }
+ });
+ assertEquals("foo", enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("foo", enumMapping.getQName().getNamespace());
+
+ //remove the namespace member value pair
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlTypeAnnotation(declaration);
+ GenericJavaEnumMappingTests.this.values(xmlTypeAnnotation).remove(0);
+ }
+ });
+ assertNull(enumMapping.getQName().getSpecifiedNamespace());
+ assertEquals("", enumMapping.getQName().getNamespace());
+ }
+
+ public void testModifyXmlRootElement() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getXmlRootElement());
+
+ enumMapping.addXmlRootElement().getQName().setSpecifiedName("foo");
+ XmlRootElementAnnotation xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
+ assertEquals("foo", xmlRootElementAnnotation.getName());
+ assertEquals("foo", enumMapping.getXmlRootElement().getQName().getName());
+
+ enumMapping.removeXmlRootElement();
+ xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
+ assertNull(xmlRootElementAnnotation);
+ assertNull(enumMapping.getXmlRootElement());
+ }
+
+ public void testUpdateXmlRootElement() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getXmlRootElement());
+
+ //add a XmlRootElement annotation
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ NormalAnnotation annotation = GenericJavaEnumMappingTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
+ GenericJavaEnumMappingTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
+ }
+ });
+ assertEquals("foo", enumMapping.getXmlRootElement().getQName().getName());
+
+ //remove the XmlRootElement annotation
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
+ }
+ });
+ assertNull(enumMapping.getXmlRootElement());
+ }
+
+ public void testModifyEnumType() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getEnumType());
+
+ enumMapping.setEnumType("Integer");
+ XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
+ assertEquals("Integer", xmlEnumAnnotation.getValue());
+ assertEquals("Integer", enumMapping.getEnumType());
+
+ enumMapping.setEnumType(null);
+ xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
+ assertNull(xmlEnumAnnotation.getValue());
+ assertNull(enumMapping.getEnumType());
+
+ resourceEnum.addAnnotation(JAXB.XML_TYPE);
+ resourceEnum.removeAnnotation(JAXB.XML_ENUM);
+ enumMapping = ((JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
+ assertNull(enumMapping.getEnumType());
+ }
+
+ public void testUpdateEnumType() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertNull(enumMapping.getEnumType());
+
+ //add a factoryClass member value pair
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_ENUM);
+ GenericJavaEnumMappingTests.this.addXmlEnumTypeMemberValuePair(declaration, JAXB.XML_ENUM__VALUE, "String");
+ }
+ });
+ assertEquals("String", enumMapping.getEnumType());
+
+ //remove the factoryClass member value pair
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ NormalAnnotation xmlEnumAnnotation = (NormalAnnotation) GenericJavaEnumMappingTests.this.getXmlEnumAnnotation(declaration);
+ GenericJavaEnumMappingTests.this.values(xmlEnumAnnotation).remove(0);
+ }
+ });
+ assertNull(enumMapping.getEnumType());
+ }
+
+ public void testUpdateEnumConstants() throws Exception {
+ createEnumWithXmlType();
+
+ JaxbEnum jaxbEnum = (JaxbEnum) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbEnumMapping enumMapping = jaxbEnum.getMapping();
+ JavaResourceEnum resourceEnum = jaxbEnum.getJavaResourceType();
+
+ assertEquals(2, enumMapping.getEnumConstantsSize());
+ Iterator<JaxbEnumConstant> enumConstants = enumMapping.getEnumConstants().iterator();
+ JaxbEnumConstant enumConstant = enumConstants.next();
+ assertEquals("SUNDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("MONDAY", enumConstant.getName());
+ assertFalse(enumConstants.hasNext());
+
+
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
+ GenericJavaEnumMappingTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
+ }
+ });
+ assertEquals(4, enumMapping.getEnumConstantsSize());
+ enumConstants = enumMapping.getEnumConstants().iterator();
+ enumConstant = enumConstants.next();
+ assertEquals("SUNDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("MONDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("TUESDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("WEDNESDAY", enumConstant.getName());
+ assertFalse(enumConstants.hasNext());
+
+
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "SUNDAY");
+ }
+ });
+ assertEquals(3, enumMapping.getEnumConstantsSize());
+ enumConstants = enumMapping.getEnumConstants().iterator();
+ enumConstant = enumConstants.next();
+ assertEquals("MONDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("TUESDAY", enumConstant.getName());
+ enumConstant = enumConstants.next();
+ assertEquals("WEDNESDAY", enumConstant.getName());
+ assertFalse(enumConstants.hasNext());
+
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
+ GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "MONDAY");
+ }
+ });
+ assertEquals(1, enumMapping.getEnumConstantsSize());
+ enumConstants = enumMapping.getEnumConstants().iterator();
+ enumConstant = enumConstants.next();
+ assertEquals("WEDNESDAY", enumConstant.getName());
+ assertFalse(enumConstants.hasNext());
+
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ GenericJavaEnumMappingTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
+ }
+ });
+ assertEquals(0, enumMapping.getEnumConstantsSize());
+ assertFalse(enumMapping.getEnumConstants().iterator().hasNext());
+ }
+} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java
index 138e99e9f5..13bf4b00f7 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentAttributeTests.java
@@ -12,8 +12,9 @@ package org.eclipse.jpt.jaxb.core.tests.internal.context.java;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
@@ -56,55 +57,55 @@ public class GenericJavaPersistentAttributeTests
public void testJavaResourceType() throws Exception {
createXmlTypeWithVariousAttributes();
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(PACKAGE_NAME_ + TEST_CLASS_NAME);
+ JaxbClassMapping classMapping = ((JaxbClass) getContextRoot().getType(PACKAGE_NAME_ + TEST_CLASS_NAME)).getMapping();
// String string
- JaxbPersistentAttribute att = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbPersistentAttribute att = CollectionTools.get(classMapping.getAttributes(), 0);
assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
assertEquals(false, att.isJavaResourceAttributeCollectionType());
// List<String> stringList
- att = CollectionTools.get(persistentClass.getAttributes(), 1);
+ att = CollectionTools.get(classMapping.getAttributes(), 1);
assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
// String[] stringArray
- att = CollectionTools.get(persistentClass.getAttributes(), 2);
+ att = CollectionTools.get(classMapping.getAttributes(), 2);
assertEquals("java.lang.String", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
// String[][] stringDoubleArray
- att = CollectionTools.get(persistentClass.getAttributes(), 3);
+ att = CollectionTools.get(classMapping.getAttributes(), 3);
assertEquals("java.lang.String[][]", att.getJavaResourceAttributeBaseTypeName());
assertEquals(false, att.isJavaResourceAttributeCollectionType());
// T generic
- att = CollectionTools.get(persistentClass.getAttributes(), 4);
+ att = CollectionTools.get(classMapping.getAttributes(), 4);
assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
assertEquals(false, att.isJavaResourceAttributeCollectionType());
// List<T> genericList
- att = CollectionTools.get(persistentClass.getAttributes(), 5);
+ att = CollectionTools.get(classMapping.getAttributes(), 5);
assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
// T[] genericArray
- att = CollectionTools.get(persistentClass.getAttributes(), 6);
+ att = CollectionTools.get(classMapping.getAttributes(), 6);
assertEquals("java.lang.Number", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
// List<?> wildcardList
- att = CollectionTools.get(persistentClass.getAttributes(), 7);
+ att = CollectionTools.get(classMapping.getAttributes(), 7);
assertEquals("java.lang.Object", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
// byte[] byteArray
- att = CollectionTools.get(persistentClass.getAttributes(), 8);
+ att = CollectionTools.get(classMapping.getAttributes(), 8);
assertEquals("byte[]", att.getJavaResourceAttributeBaseTypeName());
assertEquals(false, att.isJavaResourceAttributeCollectionType());
// List list
- att = CollectionTools.get(persistentClass.getAttributes(), 9);
+ att = CollectionTools.get(classMapping.getAttributes(), 9);
assertEquals("java.lang.Object", att.getJavaResourceAttributeBaseTypeName());
assertEquals(true, att.isJavaResourceAttributeCollectionType());
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentEnumTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentEnumTests.java
deleted file mode 100644
index 80a161f521..0000000000
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentEnumTests.java
+++ /dev/null
@@ -1,740 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.tests.internal.context.java;
-
-import java.beans.Introspector;
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
-import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class GenericJavaPersistentEnumTests extends JaxbContextModelTestCase
-{
-
- public GenericJavaPersistentEnumTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createEnumWithXmlType() throws Exception {
- return createTestEnum(new DefaultEnumAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_ENUM);
- }
- @Override
- public void appendEnumAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType @XmlEnum");
- }
- });
- }
-
- public void testModifyFactoryClass() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getFactoryClass());
-
- contextEnum.setFactoryClass("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryClass());
- assertEquals("foo", contextEnum.getFactoryClass());
-
- contextEnum.setFactoryClass(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getFactoryClass());
- assertNull(contextEnum.getFactoryClass());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
- assertNull(contextEnum.getFactoryClass());
- }
-
- public void testUpdateFactoryClass() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getFactoryClass());
-
-
- //add a factoryClass member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaPersistentEnumTests.this.addXmlTypeTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_CLASS, "Foo");
- }
- });
- assertEquals("Foo", contextEnum.getFactoryClass());
-
- //remove the factoryClass member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentEnumTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentEnumTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(contextEnum.getFactoryClass());
- }
-
- public void testModifyFactoryMethod() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getFactoryMethod());
-
- contextEnum.setFactoryMethod("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", contextEnum.getFactoryMethod());
-
- contextEnum.setFactoryMethod(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getFactoryMethod());
- assertNull(contextEnum.getFactoryMethod());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
-
- //set factoryMethod again, this time starting with no XmlType annotation
- contextEnum.setFactoryMethod("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getFactoryMethod());
- assertEquals("foo", contextEnum.getFactoryMethod());
- }
-
- public void testUpdateFactoryMethod() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getFactoryMethod());
-
-
- //add a factoryMethod member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaPersistentEnumTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__FACTORY_METHOD, "foo");
- }
- });
- assertEquals("foo", contextEnum.getFactoryMethod());
-
- //remove the factoryMethod member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentEnumTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentEnumTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(contextEnum.getFactoryMethod());
- }
-
- public void testModifySchemaTypeName() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(contextEnum.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getName());
-
- contextEnum.getQName().setSpecifiedName("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", contextEnum.getQName().getSpecifiedName());
- assertEquals("foo", contextEnum.getQName().getName());
-
- contextEnum.getQName().setSpecifiedName(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getName());
- assertNull(contextEnum.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getName());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
-
- //set name again, this time starting with no XmlType annotation
- contextEnum.getQName().setSpecifiedName("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getName());
- assertEquals("foo", contextEnum.getQName().getSpecifiedName());
- assertEquals("foo", contextEnum.getQName().getName());
- }
-
- public void testUpdateSchemaTypeName() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
- String defaultXmlTypeName = Introspector.decapitalize(TYPE_NAME);
-
- assertNull(contextEnum.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getDefaultName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getName());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaPersistentEnumTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAME, "foo");
- }
- });
- assertEquals("foo", contextEnum.getQName().getSpecifiedName());
- assertEquals("foo", contextEnum.getQName().getName());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentEnumTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentEnumTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(contextEnum.getQName().getSpecifiedName());
- assertEquals(defaultXmlTypeName, contextEnum.getQName().getName());
- }
-
- public void testModifyNamespace() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("", contextEnum.getQName().getDefaultNamespace());
- assertEquals("", contextEnum.getQName().getNamespace());
-
- contextEnum.getQName().setSpecifiedNamespace("foo");
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextEnum.getQName().getNamespace());
-
- contextEnum.getQName().setSpecifiedNamespace(null);
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertNull(xmlTypeAnnotation.getNamespace());
- assertNull(contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("", contextEnum.getQName().getNamespace());
-
- resourceEnum.removeAnnotation(JAXB.XML_TYPE);
-
- //set namespace again, this time starting with no XmlType annotation
- contextEnum.getQName().setSpecifiedNamespace("foo");
- xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- assertEquals("foo", xmlTypeAnnotation.getNamespace());
- assertEquals("foo", contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextEnum.getQName().getNamespace());
- }
-
- public void testUpdateNamespace() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("", contextEnum.getQName().getDefaultNamespace());
- assertEquals("", contextEnum.getQName().getNamespace());
-
- //add a namespace member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addMarkerAnnotation(declaration.getDeclaration(), JAXB.XML_TYPE);
- GenericJavaPersistentEnumTests.this.addXmlTypeMemberValuePair(declaration, JAXB.XML_TYPE__NAMESPACE, "foo");
- }
- });
- assertEquals("foo", contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("foo", contextEnum.getQName().getNamespace());
-
- //remove the namespace member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlTypeAnnotation = (NormalAnnotation) GenericJavaPersistentEnumTests.this.getXmlTypeAnnotation(declaration);
- GenericJavaPersistentEnumTests.this.values(xmlTypeAnnotation).remove(0);
- }
- });
- assertNull(contextEnum.getQName().getSpecifiedNamespace());
- assertEquals("", contextEnum.getQName().getNamespace());
- }
-
- public void testGetPropOrder() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- ListIterator<String> props = contextEnum.getPropOrder().iterator();
- assertFalse(props.hasNext());
-
- //add 2 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentEnumTests.this.addProp(declaration, 1, "foo");
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertFalse(props.hasNext());
- }
-
- protected void addProp(ModifiedDeclaration declaration, int index, String prop) {
- this.addArrayElement(declaration, JAXB.XML_TYPE, index, JAXB.XML_TYPE__PROP_ORDER, this.newStringLiteral(declaration.getAst(), prop));
- }
-
- public void testGetPropOrderSize() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertEquals(0, contextEnum.getPropOrderSize());
-
- //add 2 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentEnumTests.this.addProp(declaration, 1, "foo");
- }
- });
- assertEquals(2, contextEnum.getPropOrderSize());
- }
-
- public void testAddProp() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- contextEnum.addProp(0, "bar");
- contextEnum.addProp(0, "foo");
- contextEnum.addProp(0, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
-
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
- }
-
- public void testAddProp2() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- contextEnum.addProp(0, "bar");
- contextEnum.addProp(1, "foo");
- contextEnum.addProp(0, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
- ListIterator<String> props = xmlTypeAnnotation.getPropOrder().iterator();
-
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertFalse(props.hasNext());
- }
-
- public void testRemoveProp() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- contextEnum.addProp(0, "bar");
- contextEnum.addProp(1, "foo");
- contextEnum.addProp(2, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
-
- contextEnum.removeProp(1);
-
- ListIterator<String> resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("bar", resourceProps.next());
- assertEquals("baz", resourceProps.next());
- assertFalse(resourceProps.hasNext());
-
- contextEnum.removeProp(1);
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("bar", resourceProps.next());
- assertFalse(resourceProps.hasNext());
-
- contextEnum.removeProp(0);
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertFalse(resourceProps.hasNext());
- }
-
- public void testMoveProp() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- contextEnum.addProp(0, "bar");
- contextEnum.addProp(1, "foo");
- contextEnum.addProp(2, "baz");
-
- XmlTypeAnnotation xmlTypeAnnotation = (XmlTypeAnnotation) resourceEnum.getAnnotation(JAXB.XML_TYPE);
-
- assertEquals(3, xmlTypeAnnotation.getPropOrderSize());
-
- contextEnum.moveProp(2, 0);
- ListIterator<String> props = contextEnum.getPropOrder().iterator();
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
- ListIterator<String> resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("foo", resourceProps.next());
- assertEquals("baz", resourceProps.next());
- assertEquals("bar", resourceProps.next());
-
-
- contextEnum.moveProp(0, 1);
- props = contextEnum.getPropOrder().iterator();
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
- resourceProps = xmlTypeAnnotation.getPropOrder().iterator();
- assertEquals("baz", resourceProps.next());
- assertEquals("foo", resourceProps.next());
- assertEquals("bar", resourceProps.next());
- }
-
- public void testSyncXmlNsPrefixes() throws Exception {
- this.createEnumWithXmlType();
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- ListIterator<String> props = contextEnum.getPropOrder().iterator();
- assertFalse(props.hasNext());
-
- //add 3 prop orders
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addProp(declaration, 0, "bar");
- GenericJavaPersistentEnumTests.this.addProp(declaration, 1, "foo");
- GenericJavaPersistentEnumTests.this.addProp(declaration, 2, "baz");
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("bar", props.next());
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.moveProp(declaration, 2, 0);
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("foo", props.next());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.moveProp(declaration, 0, 1);
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertEquals("foo", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeProp(declaration, 1);
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertEquals("bar", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeProp(declaration, 1);
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertTrue(props.hasNext());
- assertEquals("baz", props.next());
- assertFalse(props.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeProp(declaration, 0);
- }
- });
-
- props = contextEnum.getPropOrder().iterator();
- assertFalse(props.hasNext());
- }
-
- protected void addXmlTypeMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
- this.addMemberValuePair((MarkerAnnotation) this.getXmlTypeAnnotation(declaration), name, value);
- }
-
- protected void addXmlTypeTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlTypeAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected void addXmlEnumTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
- this.addMemberValuePair(
- (MarkerAnnotation) this.getXmlEnumAnnotation(declaration),
- name,
- this.newTypeLiteral(declaration.getAst(), typeName));
- }
-
- protected Annotation getXmlTypeAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_TYPE);
- }
-
- protected Annotation getXmlEnumAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(JAXB.XML_ENUM);
- }
-
- protected void moveProp(ModifiedDeclaration declaration, int targetIndex, int sourceIndex) {
- this.moveArrayElement((NormalAnnotation) getXmlTypeAnnotation(declaration), JAXB.XML_TYPE__PROP_ORDER, targetIndex, sourceIndex);
- }
-
- protected void removeProp(ModifiedDeclaration declaration, int index) {
- this.removeArrayElement((NormalAnnotation) getXmlTypeAnnotation(declaration), JAXB.XML_TYPE__PROP_ORDER, index);
- }
-
- public void testModifyXmlRootElement() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getRootElement());
- assertFalse(contextEnum.isRootElement());
-
- contextEnum.setRootElement("foo");
- XmlRootElementAnnotation xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertEquals("foo", xmlRootElementAnnotation.getName());
- assertEquals("foo", contextEnum.getRootElement().getQName().getName());
- assertTrue(contextEnum.isRootElement());
-
- contextEnum.setRootElement(null);
- xmlRootElementAnnotation = (XmlRootElementAnnotation) resourceEnum.getAnnotation(JAXB.XML_ROOT_ELEMENT);
- assertNull(xmlRootElementAnnotation);
- assertNull(contextEnum.getRootElement());
- assertFalse(contextEnum.isRootElement());
- }
-
- public void testUpdateXmlRootElement() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getRootElement());
- assertFalse(contextEnum.isRootElement());
-
-
- //add a XmlRootElement annotation
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = GenericJavaPersistentEnumTests.this.addNormalAnnotation(declaration.getDeclaration(), JAXB.XML_ROOT_ELEMENT);
- GenericJavaPersistentEnumTests.this.addMemberValuePair(annotation, JAXB.XML_ROOT_ELEMENT__NAME, "foo");
- }
- });
- assertEquals("foo", contextEnum.getRootElement().getQName().getName());
- assertTrue(contextEnum.isRootElement());
-
- //remove the XmlRootElement annotation
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
- }
- });
- assertNull(contextEnum.getRootElement());
- assertFalse(contextEnum.isRootElement());
- }
-
- public void testModifyEnumType() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getEnumType());
-
- contextEnum.setEnumType("Integer");
- XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
- assertEquals("Integer", xmlEnumAnnotation.getValue());
- assertEquals("Integer", contextEnum.getEnumType());
-
- contextEnum.setEnumType(null);
- xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
- assertNull(xmlEnumAnnotation.getValue());
- assertNull(contextEnum.getEnumType());
-
- resourceEnum.addAnnotation(JAXB.XML_TYPE);
- resourceEnum.removeAnnotation(JAXB.XML_ENUM);
- contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- assertNull(contextEnum.getEnumType());
- }
-
- public void testUpdateEnumType() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertNull(contextEnum.getEnumType());
-
-
- //add a factoryClass member value pair
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addXmlEnumTypeMemberValuePair(declaration, JAXB.XML_ENUM__VALUE, "String");
- }
- });
- assertEquals("String", contextEnum.getEnumType());
-
- //remove the factoryClass member value pair
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NormalAnnotation xmlEnumAnnotation = (NormalAnnotation) GenericJavaPersistentEnumTests.this.getXmlEnumAnnotation(declaration);
- GenericJavaPersistentEnumTests.this.values(xmlEnumAnnotation).remove(0);
- }
- });
- assertNull(contextEnum.getEnumType());
- }
-
- public void testUpdateEnumConstants() throws Exception {
- createEnumWithXmlType();
-
- JaxbPersistentEnum contextEnum = CollectionTools.get(getContextRoot().getPersistentEnums(), 0);
- JavaResourceEnum resourceEnum = contextEnum.getJavaResourceType();
-
- assertEquals(2, contextEnum.getEnumConstantsSize());
- Iterator<JaxbEnumConstant> enumConstants = contextEnum.getEnumConstants().iterator();
- JaxbEnumConstant enumConstant = enumConstants.next();
- assertEquals("SUNDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
-
- AnnotatedElement annotatedElement = this.annotatedElement(resourceEnum);
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
- GenericJavaPersistentEnumTests.this.addEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
- }
- });
- assertEquals(4, contextEnum.getEnumConstantsSize());
- enumConstants = contextEnum.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("SUNDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("TUESDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "SUNDAY");
- }
- });
- assertEquals(3, contextEnum.getEnumConstantsSize());
- enumConstants = contextEnum.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("MONDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("TUESDAY", enumConstant.getName());
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "TUESDAY");
- GenericJavaPersistentEnumTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "MONDAY");
- }
- });
- assertEquals(1, contextEnum.getEnumConstantsSize());
- enumConstants = contextEnum.getEnumConstants().iterator();
- enumConstant = enumConstants.next();
- assertEquals("WEDNESDAY", enumConstant.getName());
- assertFalse(enumConstants.hasNext());
-
- annotatedElement.edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- GenericJavaPersistentEnumTests.this.removeEnumConstant((EnumDeclaration) declaration.getDeclaration(), "WEDNESDAY");
- }
- });
- assertEquals(0, contextEnum.getEnumConstantsSize());
- assertFalse(contextEnum.getEnumConstants().iterator().hasNext());
-
- }
-} \ No newline at end of file
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java
index 2271abc200..b01ba097ef 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaRegistryTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -24,10 +24,10 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
-import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
@@ -39,8 +39,8 @@ public class GenericJavaRegistryTests extends JaxbContextModelTestCase
public GenericJavaRegistryTests(String name) {
super(name);
}
-
- private ICompilationUnit createTypeWithXmlRegistry() throws Exception {
+
+ protected ICompilationUnit createClassWithXmlRegistryAndCreateMethods() throws Exception {
return this.createTestType(PACKAGE_NAME, "ObjectFactory.java", "ObjectFactory", new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
@@ -62,20 +62,7 @@ public class GenericJavaRegistryTests extends JaxbContextModelTestCase
}
});
}
-
- private ICompilationUnit createTypeWithXmlType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
- }
- });
- }
-
+
protected void addElementFactoryMethod(TypeDeclaration typeDeclaration, String methodName) {
AST ast = typeDeclaration.getAST();
@@ -126,11 +113,12 @@ public class GenericJavaRegistryTests extends JaxbContextModelTestCase
}
public void testUpdateElementFactoryMethods() throws Exception {
- createTypeWithXmlType();
- createTypeWithXmlRegistry();
-
- JaxbRegistry contextRegistry = CollectionTools.get(getContextRoot().getRegistries(), 0);
- JavaResourceType resourceType = contextRegistry.getJavaResourceType();
+ createClassWithXmlType();
+ createClassWithXmlRegistryAndCreateMethods();
+
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType("test.ObjectFactory");
+ XmlRegistry contextRegistry = jaxbClass.getXmlRegistry();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
assertEquals(2, contextRegistry.getElementFactoryMethodsSize());
Iterator<JaxbElementFactoryMethod> elementFactoryMethods = contextRegistry.getElementFactoryMethods().iterator();
@@ -206,4 +194,4 @@ public class GenericJavaRegistryTests extends JaxbContextModelTestCase
assertEquals(0, contextRegistry.getElementFactoryMethodsSize());
assertFalse(contextRegistry.getElementFactoryMethods().iterator().hasNext());
}
-} \ No newline at end of file
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java
index 5bf9d2f794..6df5f7d855 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaTypeXmlJavaTypeAdapterTests.java
@@ -19,7 +19,7 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
@@ -34,25 +34,25 @@ public class GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTest
super(name);
}
- private ICompilationUnit createTypeWithXmlTypeWithXmlJavaTypeAdapter() throws Exception {
+ private ICompilationUnit createTypeWithXmlJavaTypeAdapter() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
- return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_JAVA_TYPE_ADAPTER);
+ return new ArrayIterator<String>(JAXB.XML_JAVA_TYPE_ADAPTER);
}
@Override
public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@XmlType").append(CR);
sb.append("@XmlJavaTypeAdapter");
}
});
}
public void testModifyValue() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- JaxbPersistentClass contextPersistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPersistentClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
+ createTypeWithXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
assertNull(contextXmlJavaTypeAdapter.getValue());
@@ -69,11 +69,12 @@ public class GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTest
}
public void testUpdateValue() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- JaxbPersistentClass contextPersistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPersistentClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
-
+ createTypeWithXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
+
assertNull(contextXmlJavaTypeAdapter.getValue());
//add a value member value pair
@@ -90,14 +91,15 @@ public class GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTest
GenericJavaTypeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
}
});
- assertNull(contextPersistentClass.getXmlJavaTypeAdapter());
+ assertNull(jaxbClass.getXmlJavaTypeAdapter());
}
-
+
public void testModifyType() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- JaxbPersistentClass contextPersistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPersistentClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
+ createTypeWithXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getType());
assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
@@ -118,10 +120,11 @@ public class GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTest
}
public void testUpdateType() throws Exception {
- this.createTypeWithXmlTypeWithXmlJavaTypeAdapter();
- JaxbPersistentClass contextPersistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlJavaTypeAdapter contextXmlJavaTypeAdapter = contextPersistentClass.getXmlJavaTypeAdapter();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
+ createTypeWithXmlJavaTypeAdapter();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ XmlJavaTypeAdapter contextXmlJavaTypeAdapter = jaxbClass.getXmlJavaTypeAdapter();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
assertEquals(FULLY_QUALIFIED_TYPE_NAME, contextXmlJavaTypeAdapter.getType());
assertNull(contextXmlJavaTypeAdapter.getSpecifiedType());
@@ -143,7 +146,7 @@ public class GenericJavaTypeXmlJavaTypeAdapterTests extends JaxbContextModelTest
GenericJavaTypeXmlJavaTypeAdapterTests.this.removeXmlJavaTypeAdapterAnnotation(declaration);
}
});
- assertNull(contextPersistentClass.getXmlJavaTypeAdapter());
+ assertNull(jaxbClass.getXmlJavaTypeAdapter());
}
protected void addXmlJavaTypeAdapterTypeMemberValuePair(ModifiedDeclaration declaration, String name, String typeName) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java
new file mode 100644
index 0000000000..8e79e10763
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAdapterTests.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.tests.internal.context.java;
+
+import java.util.Iterator;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.XmlAdapter;
+import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
+
+
+public class GenericJavaXmlAdapterTests
+ extends JaxbContextModelTestCase {
+
+ public GenericJavaXmlAdapterTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createXmlType() throws Exception {
+ return this.createTestType(
+ new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_TYPE);
+ }
+
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlType");
+ }
+ });
+ }
+
+ private void createObjObjXmlAdapter() throws CoreException {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import " + JAXB.XML_ADAPTER + ";").append(CR);
+ sb.append(CR);
+ sb.append("public class ObjObjAdapter extends XmlAdapter<Object, Object> {").append(CR);
+ sb.append(" public Object marshal(Object obj) { return null; }").append(CR);
+ sb.append(" public Object unmarshal(Object obj) { return null; }").append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "ObjObjAdapter.java", sourceWriter);
+ }
+
+ private void createMapCalendarXmlAdapter() throws CoreException {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import " + JAXB.XML_ADAPTER + ";").append(CR);
+ sb.append("import java.util.Map;").append(CR);
+ sb.append("import java.util.GregorianCalendar;").append(CR);
+ sb.append(CR);
+ sb.append("public class MapCalendarAdapter extends XmlAdapter<GregorianCalendar, Map<String, String>> {").append(CR);
+ sb.append(" public GregorianCalendar marshal(Map<String, String> obj) { return null; }").append(CR);
+ sb.append(" public GregorianCalendar marshal(Object obj) { return null; }").append(CR);
+ sb.append(" public Map<String, String> unmarshal(Gregorian Calendar obj) { return null; }").append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "MapCalendarAdapter.java", sourceWriter);
+ }
+
+
+ public void testBoundAndValueTypes() throws Exception {
+ createXmlType();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping attributeMapping = (XmlElementMapping) persistentAttribute.getMapping();
+
+ XmlJavaTypeAdapter xmlJavaTypeAdapter = attributeMapping.addXmlJavaTypeAdapter();
+ xmlJavaTypeAdapter.setValue("test.ObjObjAdapter");
+
+ assertEquals("test.ObjObjAdapter", xmlJavaTypeAdapter.getValue());
+ assertEquals("test.ObjObjAdapter", xmlJavaTypeAdapter.getFullyQualifiedValue());
+ assertNull(xmlJavaTypeAdapter.getXmlAdapter());
+
+ createObjObjXmlAdapter();
+ XmlAdapter xmlAdapter = xmlJavaTypeAdapter.getXmlAdapter();
+ assertNotNull(xmlAdapter);
+ assertEquals("java.lang.Object", xmlAdapter.getBoundType());
+ assertEquals("java.lang.Object", xmlAdapter.getValueType());
+
+ createMapCalendarXmlAdapter();
+ xmlJavaTypeAdapter.setValue("test.MapCalendarAdapter");
+ xmlAdapter = xmlJavaTypeAdapter.getXmlAdapter();
+ assertNotNull(xmlAdapter);
+ assertEquals("java.util.Map", xmlAdapter.getBoundType());
+ assertEquals("java.util.GregorianCalendar", xmlAdapter.getValueType());
+ }
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java
index 21d715cd0b..e82e700eb3 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyAttributeMappingTests.java
@@ -18,8 +18,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
@@ -55,13 +56,14 @@ public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTest
public void testChangeMappingType() throws Exception {
createTypeWithXmlAnyAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyAttributeMapping xmlAnyAttributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlAnyAttributeMapping);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE));
persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
@@ -71,8 +73,8 @@ public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTest
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- xmlAnyAttributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAnyAttributeMapping);
+ attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
@@ -84,43 +86,45 @@ public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTest
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
- xmlAnyAttributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAnyAttributeMapping);
+ attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
}
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAnyAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyAttributeMapping xmlAnyAttributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyAttributeMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
- xmlAnyAttributeMapping.addXmlJavaTypeAdapter();
+ attributeMapping.addXmlJavaTypeAdapter();
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAnyAttributeMapping.getXmlJavaTypeAdapter());
+ assertNotNull(attributeMapping.getXmlJavaTypeAdapter());
assertNotNull(xmlJavaTypeAdapterAnnotation);
- xmlAnyAttributeMapping.removeXmlJavaTypeAdapter();
+ attributeMapping.removeXmlJavaTypeAdapter();
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
}
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAnyAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyAttributeMapping xmlAnyAttributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyAttributeMapping attributeMapping = (XmlAnyAttributeMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyAttributeMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
@@ -132,7 +136,7 @@ public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTest
}
});
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAnyAttributeMapping.getXmlJavaTypeAdapter());
+ assertNotNull(attributeMapping.getXmlJavaTypeAdapter());
assertNotNull(xmlJavaTypeAdapterAnnotation);
//remove the XmlJavaTypeAdapter annotation
@@ -142,7 +146,7 @@ public class GenericJavaXmlAnyAttributeMappingTests extends JaxbContextModelTest
}
});
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyAttributeMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java
index 40e77a4713..392f95d821 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAnyElementMappingTests.java
@@ -21,8 +21,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
@@ -63,13 +64,14 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
public void testChangeMappingType() throws Exception {
createTypeWithXmlAnyElement();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNotNull(xmlAnyElementMapping);
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
persistentAttribute.setMappingKey(MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY);
@@ -79,8 +81,8 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAnyElementMapping);
+ attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE));
@@ -92,8 +94,8 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
persistentAttribute.setMappingKey(MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY);
- xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- assertNotNull(xmlAnyElementMapping);
+ attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ assertNotNull(attributeMapping);
assertNotNull(resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
}
@@ -101,34 +103,36 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAnyElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyElementMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
- xmlAnyElementMapping.addXmlJavaTypeAdapter();
+ attributeMapping.addXmlJavaTypeAdapter();
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAnyElementMapping.getXmlJavaTypeAdapter());
+ assertNotNull(attributeMapping.getXmlJavaTypeAdapter());
assertNotNull(xmlJavaTypeAdapterAnnotation);
- xmlAnyElementMapping.removeXmlJavaTypeAdapter();
+ attributeMapping.removeXmlJavaTypeAdapter();
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
}
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAnyElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyElementMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
@@ -140,7 +144,7 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
}
});
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNotNull(xmlAnyElementMapping.getXmlJavaTypeAdapter());
+ assertNotNull(attributeMapping.getXmlJavaTypeAdapter());
assertNotNull(xmlJavaTypeAdapterAnnotation);
//remove the XmlJavaTypeAdapter annotation
@@ -150,45 +154,49 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
}
});
xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
- assertNull(xmlAnyElementMapping.getXmlJavaTypeAdapter());
+ assertNull(attributeMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
}
public void testModifyLax() throws Exception {
createTypeWithXmlAnyElement();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(false, xmlAnyElementMapping.isLax());
+ assertNull(attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(false, attributeMapping.isLax());
- xmlAnyElementMapping.setSpecifiedLax(Boolean.TRUE);
+ attributeMapping.setSpecifiedLax(Boolean.TRUE);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertEquals(Boolean.TRUE, xmlAnyElementAnnotation.getLax());
- assertEquals(Boolean.TRUE, xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(true, xmlAnyElementMapping.isLax());
+ assertEquals(Boolean.TRUE, attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(true, attributeMapping.isLax());
- xmlAnyElementMapping.setSpecifiedLax(null);
+ attributeMapping.setSpecifiedLax(null);
xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertNull(xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(false, xmlAnyElementMapping.isLax());
+ assertNull(attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(false, attributeMapping.isLax());
}
public void testUpdateLax() throws Exception {
createTypeWithXmlAnyElement();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(false, xmlAnyElementMapping.isLax());
+ assertNull(attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(false, attributeMapping.isLax());
//add a nillable member value pair
@@ -198,9 +206,9 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
GenericJavaXmlAnyElementMappingTests.this.addXmlAnyElementMemberValuePair(declaration, JAXB.XML_ANY_ELEMENT__LAX, true);
}
});
- assertEquals(Boolean.TRUE, xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(true, xmlAnyElementMapping.isLax());
+ assertEquals(Boolean.TRUE, attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(true, attributeMapping.isLax());
//remove the lax member value pair
annotatedElement.edit(new Member.Editor() {
@@ -209,39 +217,43 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
GenericJavaXmlAnyElementMappingTests.this.values(xmlElementAnnotation).remove(0);
}
});
- assertNull(xmlAnyElementMapping.getSpecifiedLax());
- assertEquals(false, xmlAnyElementMapping.isDefaultLax());
- assertEquals(false, xmlAnyElementMapping.isLax());
+ assertNull(attributeMapping.getSpecifiedLax());
+ assertEquals(false, attributeMapping.isDefaultLax());
+ assertEquals(false, attributeMapping.isLax());
}
public void testModifyValue() throws Exception {
createTypeWithXmlAnyElement();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAnyElementMapping.getSpecifiedValue());
+ assertNull(attributeMapping.getSpecifiedValue());
- xmlAnyElementMapping.setSpecifiedValue("Foo");
+ attributeMapping.setSpecifiedValue("Foo");
XmlAnyElementAnnotation xmlElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
- assertEquals("Foo", xmlAnyElementMapping.getSpecifiedValue());
- assertEquals("Foo", xmlAnyElementMapping.getValue());
+ assertEquals("Foo", attributeMapping.getSpecifiedValue());
+ assertEquals("Foo", attributeMapping.getValue());
- xmlAnyElementMapping.setSpecifiedValue(null);
+ attributeMapping.setSpecifiedValue(null);
xmlElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertNull(xmlElementAnnotation.getValue());
- assertNull(xmlAnyElementMapping.getSpecifiedValue());
+ assertNull(attributeMapping.getSpecifiedValue());
}
public void testUpdateValue() throws Exception {
createTypeWithXmlAnyElement();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
- assertNull(xmlAnyElementMapping.getSpecifiedValue());
+ assertNull(attributeMapping.getSpecifiedValue());
//add a Value member value pair
@@ -251,7 +263,7 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
GenericJavaXmlAnyElementMappingTests.this.addXmlAnyElementTypeMemberValuePair(declaration, JAXB.XML_ANY_ELEMENT__VALUE, "Foo");
}
});
- assertEquals("Foo", xmlAnyElementMapping.getValue());
+ assertEquals("Foo", attributeMapping.getValue());
//remove the Value member value pair
annotatedElement.edit(new Member.Editor() {
@@ -260,7 +272,7 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
GenericJavaXmlAnyElementMappingTests.this.values(xmlElementAnnotation).remove(0);
}
});
- assertNull(xmlAnyElementMapping.getSpecifiedValue());
+ assertNull(attributeMapping.getSpecifiedValue());
}
protected Annotation getXmlAnyElementAnnotation(ModifiedDeclaration declaration) {
@@ -283,13 +295,16 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
public void testSyncXmlElementRefs() throws Exception {
createTypeWithXmlAnyElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping mapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
- Iterable<XmlElementRef> xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ Iterable<XmlElementRef> xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
assertTrue(CollectionTools.isEmpty(xmlElementRefs));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
//add XmlElementRef annotation
AnnotatedElement annotatedElement = annotatedElement(resourceAttribute);
@@ -301,10 +316,10 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
JAXB.XML_ELEMENT_REF__NAME, "foo");
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("foo", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
// add XmlElementRefs annotation with nested annotation
@@ -321,10 +336,10 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
declaration, JAXB.XML_ELEMENT_REFS, 0, JAXB.XML_ELEMENT_REFS__VALUE, annotation);
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("bar", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
// add second nested XmlElementRef annotation
@@ -339,10 +354,10 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
declaration, JAXB.XML_ELEMENT_REFS, 1, JAXB.XML_ELEMENT_REFS__VALUE, annotation);
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("bar", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
assertEquals("baz", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
@@ -355,10 +370,10 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
JAXB.XML_ELEMENT_REFS__VALUE, 0, 1);
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("baz", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
assertEquals("bar", CollectionTools.get(xmlElementRefs, 1).getQName().getName());
@@ -376,10 +391,10 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
declaration, JAXB.XML_ELEMENT_REFS);
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertFalse(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(1, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertFalse(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("foo", CollectionTools.get(xmlElementRefs, 0).getQName().getName());
// remove XmlElementRef annotation
@@ -390,25 +405,28 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
declaration, JAXB.XML_ELEMENT_REF);
}
});
- xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
+ xmlElementRefs = attributeMapping.getXmlElementRefs().getXmlElementRefs();
- assertTrue(CollectionTools.isEmpty(mapping.getXmlElementRefs().getXmlElementRefs()));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertTrue(CollectionTools.isEmpty(attributeMapping.getXmlElementRefs().getXmlElementRefs()));
+ assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
}
public void testModifyXmlElementRefs() throws Exception {
createTypeWithXmlAnyElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAnyElementMapping mapping = (XmlAnyElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlElementRefsAnnotation xmlElementRefsAnnotation;
XmlElementRefAnnotation xmlElementRefAnnotation;
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
- mapping.getXmlElementRefs().addXmlElementRef(0).getQName().setSpecifiedName("foo");
+ attributeMapping.getXmlElementRefs().addXmlElementRef(0).getQName().setSpecifiedName("foo");
xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
@@ -416,75 +434,77 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
assertNotNull(xmlElementRefAnnotation);
assertEquals("foo", xmlElementRefAnnotation.getName());
- mapping.getXmlElementRefs().addXmlElementRef(1).getQName().setSpecifiedName("bar");
+ attributeMapping.getXmlElementRefs().addXmlElementRef(1).getQName().setSpecifiedName("bar");
xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
assertNotNull(xmlElementRefsAnnotation);
assertNull(xmlElementRefAnnotation);
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("foo", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 0).getName());
assertEquals("bar", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 1).getName());
- mapping.getXmlElementRefs().moveXmlElementRef(0, 1);
+ attributeMapping.getXmlElementRefs().moveXmlElementRef(0, 1);
xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
assertNotNull(xmlElementRefsAnnotation);
assertNull(xmlElementRefAnnotation);
- assertEquals(2, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(2, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("bar", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 0).getName());
assertEquals("foo", CollectionTools.get(xmlElementRefsAnnotation.getXmlElementRefs(), 1).getName());
- mapping.getXmlElementRefs().removeXmlElementRef(0);
+ attributeMapping.getXmlElementRefs().removeXmlElementRef(0);
xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
assertNull(xmlElementRefsAnnotation);
assertNotNull(xmlElementRefAnnotation);
- assertEquals(1, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(1, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
assertEquals("foo", xmlElementRefAnnotation.getName());
- mapping.getXmlElementRefs().removeXmlElementRef(0);
+ attributeMapping.getXmlElementRefs().removeXmlElementRef(0);
xmlElementRefsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS));
assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
- assertEquals(0, mapping.getXmlElementRefs().getXmlElementRefsSize());
+ assertEquals(0, attributeMapping.getXmlElementRefs().getXmlElementRefsSize());
}
public void testModifyXmlMixed() throws Exception {
createTypeWithXmlAnyElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlMixedAnnotation xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(xmlAnyElementMapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(xmlListAnnotation);
- xmlAnyElementMapping.addXmlMixed();
+ attributeMapping.addXmlMixed();
xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(xmlAnyElementMapping.getXmlMixed());
+ assertNotNull(attributeMapping.getXmlMixed());
assertNotNull(xmlListAnnotation);
- xmlAnyElementMapping.removeXmlMixed();
+ attributeMapping.removeXmlMixed();
xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
}
public void testUpdateXmlMixed() throws Exception {
createTypeWithXmlAnyElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlAnyElementMapping xmlAnyElementMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = xmlAnyElementMapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAnyElementMapping attributeMapping = (XmlAnyElementMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlMixedAnnotation xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(xmlAnyElementMapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(xmlListAnnotation);
@@ -496,7 +516,7 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
}
});
xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(xmlAnyElementMapping.getXmlMixed());
+ assertNotNull(attributeMapping.getXmlMixed());
assertNotNull(xmlListAnnotation);
//remove the XmlMixed annotation
@@ -506,7 +526,7 @@ public class GenericJavaXmlAnyElementMappingTests extends JaxbContextModelTestCa
}
});
xmlListAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(xmlAnyElementMapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(xmlListAnnotation);
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java
index a183b406fe..2353eeb1f9 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlAttributeMappingTests.java
@@ -21,8 +21,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
@@ -63,9 +64,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyName() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
@@ -87,9 +90,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateName() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getQName().getSpecifiedName());
@@ -116,9 +121,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyNamespace() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
@@ -136,9 +143,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateNamespace() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getQName().getSpecifiedNamespace());
@@ -165,9 +174,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyRequired() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getSpecifiedRequired());
@@ -191,9 +202,11 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateRequired() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
assertNull(xmlAttributeMapping.getSpecifiedRequired());
@@ -226,9 +239,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testChangeMappingType() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -251,9 +265,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -272,9 +287,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -307,9 +323,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlSchemaType() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -328,9 +345,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlSchemaType() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -382,9 +400,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlList() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -403,9 +422,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlList() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -438,9 +458,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlID() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -459,9 +480,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlID() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -494,9 +516,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlIDREF() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -515,9 +538,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlIDREF() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -550,9 +574,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testModifyXmlAttachmentRef() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -571,9 +596,10 @@ public class GenericJavaXmlAttributeMappingTests extends JaxbContextModelTestCas
public void testUpdateXmlAttachmentRef() throws Exception {
createTypeWithXmlAttribute();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlAttributeMapping xmlAttributeMapping = (XmlAttributeMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlAttributeMapping.getPersistentAttribute().getJavaResourceAttribute();
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java
index 6a5f06509d..66ae943122 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementMappingTests.java
@@ -23,8 +23,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElement;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
@@ -85,9 +86,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyName() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -110,12 +113,14 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateName() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
-
+
assertNull(xmlElement.getQName().getSpecifiedName());
@@ -140,9 +145,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyNamespace() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -161,9 +168,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateNamespace() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -191,9 +200,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyRequired() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -218,9 +229,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateRequired() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -254,9 +267,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyNillable() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -281,9 +296,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateNillable() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -317,10 +334,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testDefaultNillable() throws Exception {
createXmlTypeWithVariousAttributes();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
// string
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
@@ -337,7 +355,7 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
assertEquals(false, xmlElement.isDefaultNillable());
// string list
- persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 1);
+ persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 1);
xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
xmlElement = xmlElementMapping.getXmlElement();
resourceAttribute = persistentAttribute.getJavaResourceAttribute();
@@ -354,7 +372,7 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
assertEquals(false, xmlElement.isDefaultNillable());
// string array
- persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 2);
+ persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 2);
xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
xmlElement = xmlElementMapping.getXmlElement();
resourceAttribute = persistentAttribute.getJavaResourceAttribute();
@@ -373,9 +391,11 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyDefaultValue() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -395,8 +415,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateDefaultValue() throws Exception {
createTypeWithXmlElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -424,8 +446,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyType() throws Exception {
createTypeWithXmlElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
assertNull(xmlElement.getSpecifiedType());
@@ -443,8 +467,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateType() throws Exception {
createTypeWithXmlElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementMapping xmlElementMapping = (XmlElementMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
XmlElement xmlElement = xmlElementMapping.getXmlElement();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -475,9 +501,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testChangeMappingType() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -501,8 +528,9 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -523,9 +551,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -558,9 +587,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlSchemaType() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -579,9 +609,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlSchemaType() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -634,9 +665,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlElementWrapper() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -655,9 +687,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlElementWrapper() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -690,9 +723,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlList() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -711,9 +745,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlList() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -746,9 +781,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlID() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -767,9 +803,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlID() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -802,9 +839,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlIDREF() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -825,9 +863,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlIDREF() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -860,9 +899,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testModifyXmlAttachmentRef() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -881,9 +921,10 @@ public class GenericJavaXmlElementMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlAttachmentRef() throws Exception {
createTypeWithXmlElement();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementMapping xmlElementMapping = (XmlElementMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementMapping.getPersistentAttribute().getJavaResourceAttribute();
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java
index e6cbf507f5..96a910d5de 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefMappingTests.java
@@ -21,8 +21,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
@@ -111,24 +112,26 @@ public class GenericJavaXmlElementRefMappingTests
createTypeWithJAXBElementXmlElementRef(); // FULLY_QUALIFIED_TYPE_NAME + "2"
createTypeWithRootElementXmlElementRef(); // FULLY_QUALIFIED_TYPE_NAME + "3"
- JaxbPersistentClass persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
// XmlElementRef type is java.lang.String -> no default name or namespace
assertEquals("", xmlElementRef.getQName().getName());
assertEquals("", xmlElementRef.getQName().getNamespace());
- persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME + "2");
- xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ classMapping = ((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME + "2")).getMapping();
+ xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
xmlElementRef = xmlElementRefMapping.getXmlElementRef();
// XmlElementRef type is JAXBElement -> default name is name of attribute
assertEquals("foo", xmlElementRef.getQName().getName());
assertEquals("", xmlElementRef.getQName().getNamespace());
- persistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME + "3");
- xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ classMapping = ((JaxbClass) getContextRoot().getType(FULLY_QUALIFIED_TYPE_NAME + "3")).getMapping();
+ xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
xmlElementRef = xmlElementRefMapping.getXmlElementRef();
// XmlElementRef type is type with root element -> default name is root element name
@@ -139,8 +142,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyName() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -163,8 +167,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateName() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -193,8 +198,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyNamespace() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -214,8 +220,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateNamespace() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -244,8 +251,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyRequired() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -271,8 +279,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateRequired() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -306,8 +315,10 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyType() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
assertNull(xmlElementRef.getSpecifiedType());
@@ -325,8 +336,10 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateType() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
XmlElementRef xmlElementRef = xmlElementRefMapping.getXmlElementRef();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -358,8 +371,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testChangeMappingType() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -383,11 +397,12 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
+
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
assertNull(xmlElementRefMapping.getXmlJavaTypeAdapter());
assertNull(xmlJavaTypeAdapterAnnotation);
@@ -406,8 +421,9 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -460,9 +476,10 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyXmlElementWrapper() throws Exception {
createTypeWithXmlElementRef();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -481,12 +498,13 @@ public class GenericJavaXmlElementRefMappingTests
public void testUpdateXmlElementRefWrapper() throws Exception {
createTypeWithXmlElementRef();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefMapping xmlElementRefMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlElementRefMapping.getPersistentAttribute().getJavaResourceAttribute();
-
+
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertNull(xmlElementRefMapping.getXmlElementWrapper());
assertNull(xmlElementWrapperAnnotation);
@@ -516,36 +534,38 @@ public class GenericJavaXmlElementRefMappingTests
public void testModifyXmlMixed() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlElementRefMapping mapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementRefMapping attributeMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(annotation);
- mapping.addXmlMixed();
+ attributeMapping.addXmlMixed();
annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(mapping.getXmlMixed());
+ assertNotNull(attributeMapping.getXmlMixed());
assertNotNull(annotation);
- mapping.removeXmlMixed();
+ attributeMapping.removeXmlMixed();
annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(annotation);
}
-
+
public void testUpdateXmlMixed() throws Exception {
createTypeWithXmlElementRef();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
- XmlElementRefMapping mapping = (XmlElementRefMapping) persistentAttribute.getMapping();
- JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ XmlElementRefMapping attributeMapping = (XmlElementRefMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = attributeMapping.getPersistentAttribute().getJavaResourceAttribute();
XmlMixedAnnotation annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(annotation);
//add an XmlMixed annotation
@@ -557,7 +577,7 @@ public class GenericJavaXmlElementRefMappingTests
}
});
annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNotNull(mapping.getXmlMixed());
+ assertNotNull(attributeMapping.getXmlMixed());
assertNotNull(annotation);
//remove the XmlMixed annotation
@@ -568,7 +588,7 @@ public class GenericJavaXmlElementRefMappingTests
}
});
annotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
- assertNull(mapping.getXmlMixed());
+ assertNull(attributeMapping.getXmlMixed());
assertNull(annotation);
}
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java
index f1b12e65e7..2d74ff09a3 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementRefsMappingTests.java
@@ -22,8 +22,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRef;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
@@ -107,8 +108,9 @@ public class GenericJavaXmlElementRefsMappingTests
public void testSyncXmlElementRefs() throws Exception {
createTypeWithXmlElementRefs();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
Iterable<XmlElementRef> xmlElementRefs = mapping.getXmlElementRefs().getXmlElementRefs();
@@ -167,8 +169,9 @@ public class GenericJavaXmlElementRefsMappingTests
public void testModifyXmlElementRefs() throws Exception {
createTypeWithXmlElementRefs();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementRefsMapping mapping = (XmlElementRefsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlElementRefsAnnotation annotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
@@ -210,8 +213,9 @@ public class GenericJavaXmlElementRefsMappingTests
public void testChangeMappingType() throws Exception {
createTypeWithXmlElementRefs();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -233,9 +237,10 @@ public class GenericJavaXmlElementRefsMappingTests
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElementRefs();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -256,9 +261,10 @@ public class GenericJavaXmlElementRefsMappingTests
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElementRefs();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -291,9 +297,10 @@ public class GenericJavaXmlElementRefsMappingTests
public void testModifyXmlElementWrapper() throws Exception {
createTypeWithXmlElementRefs();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -312,9 +319,10 @@ public class GenericJavaXmlElementRefsMappingTests
public void testUpdateXmlElementWrapper() throws Exception {
createTypeWithXmlElementRefs();
-
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -347,8 +355,9 @@ public class GenericJavaXmlElementRefsMappingTests
public void testModifyXmlMixed() throws Exception {
createTypeWithXmlElementRefs();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -370,8 +379,9 @@ public class GenericJavaXmlElementRefsMappingTests
public void testUpdateXmlMixed() throws Exception {
createTypeWithXmlElementRefs();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlElementRefsMapping mapping = (XmlElementRefsMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java
index a41c2a5ab9..8b5d73cb67 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlElementsMappingTests.java
@@ -19,7 +19,8 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElement;
import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
@@ -84,8 +85,9 @@ public class GenericJavaXmlElementsMappingTests
public void testSyncXmlElements() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
Iterable<XmlElement> xmlElements = mapping.getXmlElements();
@@ -144,8 +146,9 @@ public class GenericJavaXmlElementsMappingTests
public void testModifyXmlElements() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlElementsAnnotation xmlElementsAnnotation = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
@@ -186,8 +189,9 @@ public class GenericJavaXmlElementsMappingTests
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
@@ -209,8 +213,9 @@ public class GenericJavaXmlElementsMappingTests
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_JAVA_TYPE_ADAPTER);
@@ -244,8 +249,9 @@ public class GenericJavaXmlElementsMappingTests
public void testModifyXmlElementWrapper() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
@@ -268,8 +274,9 @@ public class GenericJavaXmlElementsMappingTests
public void testUpdateXmlElementWrapper() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
@@ -303,8 +310,9 @@ public class GenericJavaXmlElementsMappingTests
public void testModifyXmlIDREF() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
@@ -327,8 +335,9 @@ public class GenericJavaXmlElementsMappingTests
public void testUpdateXmlIDREF() throws Exception {
createTypeWithXmlElements();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(persistentClass.getAttributes(), 0).getMapping();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlElementsMapping mapping = (XmlElementsMapping) CollectionTools.get(classMapping.getAttributes(), 0).getMapping();
JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
index eed8143249..c4382408a0 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -20,7 +20,8 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
@@ -52,9 +53,10 @@ public class GenericJavaXmlRootElementTests
public void testModifyNamespace() throws Exception {
createTypeWithXmlTypeWithXmlRootElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlRootElement contextRootElement = classMapping.getXmlRootElement();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
assertNull(contextRootElement.getQName().getSpecifiedNamespace());
assertEquals("", contextRootElement.getQName().getDefaultNamespace());
@@ -75,9 +77,10 @@ public class GenericJavaXmlRootElementTests
public void testUpdateNamespace() throws Exception {
createTypeWithXmlTypeWithXmlRootElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlRootElement contextRootElement = classMapping.getXmlRootElement();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
assertNull(contextRootElement.getQName().getSpecifiedNamespace());
assertEquals("", contextRootElement.getQName().getDefaultNamespace());
@@ -98,15 +101,15 @@ public class GenericJavaXmlRootElementTests
GenericJavaXmlRootElementTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
}
});
- contextRootElement = persistentClass.getRootElement();
- assertNull(contextRootElement);
+ assertNull(classMapping.getXmlRootElement());
}
public void testModifyName() throws Exception {
createTypeWithXmlTypeWithXmlRootElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlRootElement contextRootElement = classMapping.getXmlRootElement();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
String defaultName = Introspector.decapitalize(TYPE_NAME);
assertNull(contextRootElement.getQName().getSpecifiedName());
@@ -128,9 +131,10 @@ public class GenericJavaXmlRootElementTests
public void testUpdateName() throws Exception {
createTypeWithXmlTypeWithXmlRootElement();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceAbstractType resourceType = persistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlRootElement contextRootElement = classMapping.getXmlRootElement();
+ JavaResourceAbstractType resourceType = jaxbClass.getJavaResourceType();
String defaultName = Introspector.decapitalize(TYPE_NAME);
assertNull(contextRootElement.getQName().getSpecifiedName());
@@ -152,8 +156,7 @@ public class GenericJavaXmlRootElementTests
GenericJavaXmlRootElementTests.this.removeAnnotation(declaration, JAXB.XML_ROOT_ELEMENT);
}
});
- contextRootElement = persistentClass.getRootElement();
- assertNull(contextRootElement);
+ assertNull(classMapping.getXmlRootElement());
}
protected void addXmlRootElementMemberValuePair(ModifiedDeclaration declaration, String name, String value) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java
index 2f20f7df59..0ede8a964d 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlSeeAlsoTests.java
@@ -19,7 +19,8 @@ import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.XmlSeeAlso;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
@@ -50,9 +51,10 @@ public class GenericJavaXmlSeeAlsoTests
public void testModifyClasses() throws Exception {
createAnnotatedPersistentClassWithXmlSeeAlso();
- JaxbPersistentClass contextPersistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- XmlSeeAlso contextXmlSeeAlso = contextPersistentClass.getXmlSeeAlso();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlSeeAlso contextXmlSeeAlso = classMapping.getXmlSeeAlso();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
assertEquals(0, contextXmlSeeAlso.getClassesSize());
@@ -87,9 +89,10 @@ public class GenericJavaXmlSeeAlsoTests
public void testUpdateClasses() throws Exception {
createAnnotatedPersistentClassWithXmlSeeAlso();
- JaxbPersistentClass contextPersistentClass = getContextRoot().getPersistentClass(FULLY_QUALIFIED_TYPE_NAME);
- XmlSeeAlso contextXmlSeeAlso = contextPersistentClass.getXmlSeeAlso();
- JavaResourceType resourceType = contextPersistentClass.getJavaResourceType();
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ XmlSeeAlso contextXmlSeeAlso = classMapping.getXmlSeeAlso();
+ JavaResourceType resourceType = jaxbClass.getJavaResourceType();
AnnotatedElement annotatedElement = annotatedElement(resourceType);
assertEquals(0, contextXmlSeeAlso.getClassesSize());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java
index 439d54e059..222f7c39cc 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlValueMappingTests.java
@@ -18,8 +18,9 @@ import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
-import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
@@ -56,8 +57,8 @@ public class GenericJavaXmlValueMappingTests extends JaxbContextModelTestCase
public void testChangeMappingType() throws Exception {
createTypeWithXmlValue();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -93,8 +94,8 @@ public class GenericJavaXmlValueMappingTests extends JaxbContextModelTestCase
public void testModifyXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlValue();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
@@ -114,8 +115,8 @@ public class GenericJavaXmlValueMappingTests extends JaxbContextModelTestCase
public void testUpdateXmlJavaTypeAdapter() throws Exception {
createTypeWithXmlValue();
- JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JaxbPersistentAttribute persistentAttribute = CollectionTools.get(persistentClass.getAttributes(), 0);
+ JaxbClassMapping classMapping = ((JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0)).getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
XmlValueMapping xmlValueMapping = (XmlValueMapping) persistentAttribute.getMapping();
JavaResourceAttribute resourceAttribute = xmlValueMapping.getPersistentAttribute().getJavaResourceAttribute();
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
index a4b4fe2710..5ff192e9f1 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
@@ -22,9 +22,10 @@ public class JaxbCoreJavaContextModelTests
suite.addTestSuite(GenericJavaEnumConstantTests.class);
suite.addTestSuite(GenericJavaPackageInfoTests.class);
suite.addTestSuite(GenericJavaPersistentAttributeTests.class);
- suite.addTestSuite(GenericJavaPersistentClassTests.class);
- suite.addTestSuite(GenericJavaPersistentEnumTests.class);
+ suite.addTestSuite(GenericJavaClassMappingTests.class);
+ suite.addTestSuite(GenericJavaEnumMappingTests.class);
suite.addTestSuite(GenericJavaRegistryTests.class);
+ suite.addTestSuite(GenericJavaXmlAdapterTests.class);
suite.addTestSuite(GenericJavaXmlAnyAttributeMappingTests.class);
suite.addTestSuite(GenericJavaXmlAnyElementMappingTests.class);
suite.addTestSuite(GenericJavaXmlAttributeMappingTests.class);

Back to the top