Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2011-05-11 11:02:04 -0400
committerpfullbright2011-05-11 11:02:04 -0400
commit7ad44dd68ee96a7d83031c1cc7677cfd35571ae2 (patch)
tree0609bb65a16aeec38461c8dfe72e6749f5033498
parent1d1ee9cf7c65d5206e7439aa03225d34eae579a8 (diff)
downloadwebtools.dali-7ad44dd68ee96a7d83031c1cc7677cfd35571ae2.tar.gz
webtools.dali-7ad44dd68ee96a7d83031c1cc7677cfd35571ae2.tar.xz
webtools.dali-7ad44dd68ee96a7d83031c1cc7677cfd35571ae2.zip
bug 343851 - minimal support for XmlElements, XmlElementRef, XmlElementRefs, (EclipseLink) XmlInverseReference, and (EclipseLink) XmlTransformation attribute mappings
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java53
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java53
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java53
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java80
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/AbstractJaxb_2_1_PlatformDefinition.java148
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java133
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/GenericJaxb_2_2_PlatformDefinition.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java23
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefAnnotationDefinition.java41
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefsAnnotationDefinition.java62
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementRefsAnnotation.java71
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java73
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java111
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefsAnnotation.java121
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementRefsAnnotation.java64
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbMappingKeys.java26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/AbstractELJaxbPlatformDefinition.java25
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java35
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java52
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMapping.java35
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlInverseReferenceAnnotationDefinition.java62
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlTransformationAnnotationDefinition.java62
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlInverseReferenceAnnotation.java73
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlTransformationAnnotation.java73
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlInverseReferenceAnnotation.java104
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlTransformationAnnotation.java103
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java24
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/ELJaxb.java40
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlInverseReferenceAnnotation.java44
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlTransformationAnnotation.java44
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/build.properties1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-inverse-reference.gifbin0 -> 908 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-transformation.gifbin0 -> 908 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiPlugin.java36
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java37
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorItemLabelProviderFactory.java45
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorUi.java36
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbPersistentAttributeItemLabelProvider.java42
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/JptJaxbEclipseLinkUiIcons.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/AbstractJaxb_2_2_PlatformDefinition.java)11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_2/ELJaxb_2_2_PlatformUi.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_3/ELJaxb_2_3_PlatformUi.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/package.gifbin227 -> 950 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/persistent_enum.gifbin981 -> 981 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-attribute.gifbin901 -> 951 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-element.gifbin900 -> 973 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-attribute.gifbin883 -> 937 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-ref.gifbin0 -> 995 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-refs.gifbin0 -> 978 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element.gifbin881 -> 960 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-elements.gifbin0 -> 940 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java33
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java2
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java2
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java146
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java119
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefsAnnotationTests.java290
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementsAnnotationTests.java380
69 files changed, 2894 insertions, 451 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java
index c004390a0a..4a547d1c1a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java
@@ -28,7 +28,12 @@ public interface MappingKeys {
String XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY = "xml-any-element";
String XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY = "xml-attribute";
String XML_ELEMENT_ATTRIBUTE_MAPPING_KEY = "xml-element";
+ String XML_ELEMENTS_ATTRIBUTE_MAPPING_KEY = "xml-elements";
+ String XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY = "xml-element-ref";
+ String XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY = "xml-element-refs";
String XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY = "xml-transient";
String XML_VALUE_ATTRIBUTE_MAPPING_KEY = "xml-value";
+
+ /** mapping key for attribute mappings that are unrecognized */
String NULL_ATTRIBUTE_MAPPING_KEY = null;
}
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
new file mode 100644
index 0000000000..dc7e6df0d1
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
+
+
+public class GenericJavaXmlElementRefMapping
+ extends AbstractJavaAttributeMapping<XmlElementRefAnnotation> {
+
+ public GenericJavaXmlElementRefMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return JAXB.XML_ELEMENT_REF;
+ }
+}
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
new file mode 100644
index 0000000000..0cdbc4d3bd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
+
+
+public class GenericJavaXmlElementRefsMapping
+ extends AbstractJavaAttributeMapping<XmlElementRefsAnnotation> {
+
+ public GenericJavaXmlElementRefsMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return JAXB.XML_ELEMENT_REFS;
+ }
+}
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
new file mode 100644
index 0000000000..9aae42ed46
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
+
+
+public class GenericJavaXmlElementsMapping
+ extends AbstractJavaAttributeMapping<XmlElementsAnnotation> {
+
+ public GenericJavaXmlElementsMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENTS_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return JAXB.XML_ELEMENTS;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java
index ac77dc9fee..50fd24e34f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java
@@ -16,6 +16,7 @@ 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.java.DefaultJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAttachmentRefAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
@@ -30,56 +31,58 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
public class JavaXmlElementMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
- implements DefaultJavaAttributeMappingDefinition
-{
+ extends AbstractJavaAttributeMappingDefinition
+ implements DefaultJavaAttributeMappingDefinition {
+
// singleton
private static final JavaXmlElementMappingDefinition INSTANCE =
- new JavaXmlElementMappingDefinition();
-
+ new JavaXmlElementMappingDefinition();
+
private static final String[] SUPPORTING_ANNOTATION_NAMES =
- {XmlIDAnnotation.ANNOTATION_NAME,
- XmlIDREFAnnotation.ANNOTATION_NAME,
- XmlListAnnotation.ANNOTATION_NAME,
- XmlSchemaTypeAnnotation.ANNOTATION_NAME,
- XmlAttachmentRefAnnotation.ANNOTATION_NAME,
- XmlMimeTypeAnnotation.ANNOTATION_NAME,
- XmlInlineBinaryDataAnnotation.ANNOTATION_NAME,
- XmlElementWrapperAnnotation.ANNOTATION_NAME,
- XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME};
-
+ {
+ JAXB.XML_ID,
+ JAXB.XML_IDREF,
+ JAXB.XML_LIST,
+ JAXB.XML_SCHEMA_TYPE,
+ JAXB.XML_ATTACHMENT_REF,
+ JAXB.XML_MIME_TYPE,
+ JAXB.XML_INLINE_BINARY_DATA,
+ JAXB.XML_ELEMENT_WRAPPER,
+ JAXB.XML_JAVA_TYPE_ADAPTER };
+
+
/**
* Return the singleton.
*/
public static DefaultJavaAttributeMappingDefinition instance() {
return INSTANCE;
}
-
-
+
+
/**
* Enforce singleton usage
*/
private JavaXmlElementMappingDefinition() {
super();
}
-
-
+
+
public String getKey() {
return MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY;
}
-
+
public String getAnnotationName() {
- return XmlElementAnnotation.ANNOTATION_NAME;
+ return JAXB.XML_ELEMENT;
}
-
+
public Iterable<String> getSupportingAnnotationNames() {
return new ArrayListIterable<String>(SUPPORTING_ANNOTATION_NAMES);
}
-
+
public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
return factory.buildJavaXmlElementMapping(parent);
}
-
+
/**
* From the JAXB spec section 8.12.5.1 Default Mapping:
* <p>
@@ -98,7 +101,7 @@ public class JavaXmlElementMappingDefinition
public boolean isDefault(JaxbPersistentAttribute persistentAttribute) {
JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
if (resourceAttribute.typeIsSubTypeOf(Collection.class.getName())) {
- return resourceAttribute.getAnnotation(XmlListAnnotation.ANNOTATION_NAME) != null;
+ return resourceAttribute.getAnnotation(JAXB.XML_LIST) != null;
}
return true;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java
new file mode 100644
index 0000000000..8d116fe3e5
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java
@@ -0,0 +1,53 @@
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+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.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+
+
+public class JavaXmlElementRefMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition {
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new JavaXmlElementRefMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaXmlElementRefMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return JAXB.XML_ELEMENT_REF;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new ArrayListIterable<String>( new String[] {
+ JAXB.XML_ELEMENT_WRAPPER,
+ JAXB.XML_JAVA_TYPE_ADAPTER });
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ // TODO: move to factory once API opens up again
+ return new GenericJavaXmlElementRefMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java
new file mode 100644
index 0000000000..5c33c1e390
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java
@@ -0,0 +1,53 @@
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+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.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+
+
+public class JavaXmlElementRefsMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition {
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new JavaXmlElementRefsMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaXmlElementRefsMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return JAXB.XML_ELEMENT_REFS;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new ArrayListIterable<String>( new String[] {
+ JAXB.XML_ELEMENT_WRAPPER,
+ JAXB.XML_JAVA_TYPE_ADAPTER });
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ // TODO: move to factory once API opens up again
+ return new GenericJavaXmlElementRefsMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java
new file mode 100644
index 0000000000..0b25f3c344
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java
@@ -0,0 +1,80 @@
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import java.util.Collection;
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+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.java.DefaultJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+
+
+public class JavaXmlElementsMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition
+ implements DefaultJavaAttributeMappingDefinition {
+
+ // singleton
+ private static final DefaultJavaAttributeMappingDefinition INSTANCE = new JavaXmlElementsMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static DefaultJavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaXmlElementsMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ELEMENTS_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return JAXB.XML_ELEMENTS;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new ArrayListIterable<String>( new String[] {
+ JAXB.XML_ELEMENT_WRAPPER,
+ JAXB.XML_IDREF,
+ JAXB.XML_JAVA_TYPE_ADAPTER });
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ // TODO: move to factory once API opens up again
+ return new GenericJavaXmlElementsMapping(parent);
+ }
+
+ /**
+ * From the JAXB spec section 8.12.5.1 Default Mapping:
+ * <p>
+ * A single valued property or field must be mapped by with the following default mapping annotation:<ul>
+ * <li> @XmlElement
+ * </ul>
+ * <p>
+ * A property or field with a collection type must be mapped by with the following default mapping annotation:<ul>
+ * <li> if the property or field is annotated with @XmlList, then the default mapping annotation is:<ul>
+ * <li> @XmlElement
+ * </ul>
+ * <li> otherwise the default mapping annotation is:<ul>
+ * <li> @XmlElements({ @XmlElement(nillable=true)})
+ * </ul>
+ */
+ public boolean isDefault(JaxbPersistentAttribute persistentAttribute) {
+ JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute();
+ if (resourceAttribute.typeIsSubTypeOf(Collection.class.getName())) {
+ return resourceAttribute.getAnnotation(JAXB.XML_LIST) == null;
+ }
+ return true;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/AbstractJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/AbstractJaxb_2_1_PlatformDefinition.java
deleted file mode 100644
index 9f1caba3b0..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/AbstractJaxb_2_1_PlatformDefinition.java
+++ /dev/null
@@ -1,148 +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.jaxb21;
-
-import java.util.ArrayList;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider;
-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.AbstractJaxbPlatformDefinition;
-import org.eclipse.jpt.jaxb.core.internal.JavaPackageInfoResourceModelProvider;
-import org.eclipse.jpt.jaxb.core.internal.JavaResourceModelProvider;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyAttributeMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyElementMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAttributeMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlTransientMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlValueMappingDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorOrderAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorTypeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyAttributeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyElementAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttachmentRefAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttributeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementDeclAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementWrapperAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementsAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumValueAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDREFAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlInlineBinaryDataAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlJavaTypeAdapterAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlListAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMimeTypeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMixedAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRootElementAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaTypeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSeeAlsoAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTransientAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTypeAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlValueAnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.internal.resource.jaxbindex.JaxbIndexResourceModelProvider;
-import org.eclipse.jpt.jaxb.core.internal.resource.jaxbprops.JaxbPropertiesResourceModelProvider;
-import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition;
-
-
-public abstract class AbstractJaxb_2_1_PlatformDefinition
- extends AbstractJaxbPlatformDefinition {
-
- protected AbstractJaxb_2_1_PlatformDefinition() {
- super();
- }
-
-
- @Override
- protected AnnotationDefinition[] buildAnnotationDefinitions() {
- return new AnnotationDefinition[] {
- XmlAccessorOrderAnnotationDefinition.instance(),
- XmlAccessorTypeAnnotationDefinition.instance(),
- XmlAnyAttributeAnnotationDefinition.instance(),
- XmlAnyElementAnnotationDefinition.instance(),
- XmlAttachmentRefAnnotationDefinition.instance(),
- XmlAttributeAnnotationDefinition.instance(),
- XmlElementAnnotationDefinition.instance(),
- XmlElementDeclAnnotationDefinition.instance(),
- XmlElementsAnnotationDefinition.instance(),
- XmlElementWrapperAnnotationDefinition.instance(),
- XmlEnumAnnotationDefinition.instance(),
- XmlEnumValueAnnotationDefinition.instance(),
- XmlIDAnnotationDefinition.instance(),
- XmlIDREFAnnotationDefinition.instance(),
- XmlInlineBinaryDataAnnotationDefinition.instance(),
- XmlListAnnotationDefinition.instance(),
- XmlMimeTypeAnnotationDefinition.instance(),
- XmlMixedAnnotationDefinition.instance(),
- XmlRegistryAnnotationDefinition.instance(),
- XmlRootElementAnnotationDefinition.instance(),
- XmlSchemaAnnotationDefinition.instance(),
- XmlSeeAlsoAnnotationDefinition.instance(),
- XmlTransientAnnotationDefinition.instance(),
- XmlTypeAnnotationDefinition.instance(),
- XmlValueAnnotationDefinition.instance()};
- }
-
- @Override
- protected NestableAnnotationDefinition[] buildNestableAnnotationDefinitions() {
- return new NestableAnnotationDefinition[] {
- XmlElementRefAnnotationDefinition.instance(),
- XmlJavaTypeAdapterAnnotationDefinition.instance(),
- XmlSchemaTypeAnnotationDefinition.instance()
- };
- }
-
- // ********** resource models **********
-
- public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
- return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
- }
- else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
- return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
- }
- throw new IllegalArgumentException(contentType.toString());
- }
-
- @Override
- protected JaxbResourceModelProvider[] buildResourceModelProviders() {
- // order should not be important here
- return new JaxbResourceModelProvider[] {
- JavaResourceModelProvider.instance(),
- JavaPackageInfoResourceModelProvider.instance(),
- JaxbIndexResourceModelProvider.instance(),
- JaxbPropertiesResourceModelProvider.instance()};
- }
-
-
- // ********** Java attribute mappings **********
-
- @Override
- protected void addSpecifiedJavaAttributeMappingDefinitionsTo(ArrayList<JavaAttributeMappingDefinition> definitions) {
- definitions.add(JavaXmlAnyAttributeMappingDefinition.instance());
- definitions.add(JavaXmlAnyElementMappingDefinition.instance());
- definitions.add(JavaXmlAttributeMappingDefinition.instance());
- definitions.add(JavaXmlElementMappingDefinition.instance());
- definitions.add(JavaXmlTransientMappingDefinition.instance());
- definitions.add(JavaXmlValueMappingDefinition.instance());
- }
-
- @Override
- protected void addDefaultJavaAttributeMappingDefinitionsTo(ArrayList<DefaultJavaAttributeMappingDefinition> definitions) {
- definitions.add(JavaXmlElementMappingDefinition.instance());
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
index d37260c1b5..32d276f4eb 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
@@ -9,13 +9,65 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.jaxb21;
+import java.util.ArrayList;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
+import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jaxb.core.GenericJaxbPlatform;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
+import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider;
+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.AbstractJaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.core.internal.JavaPackageInfoResourceModelProvider;
+import org.eclipse.jpt.jaxb.core.internal.JavaResourceModelProvider;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyElementMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementRefMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementRefsMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementsMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlTransientMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlValueMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorOrderAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorTypeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyAttributeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyElementAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttachmentRefAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttributeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementDeclAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefsAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementWrapperAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementsAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumValueAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDREFAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlInlineBinaryDataAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlJavaTypeAdapterAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlListAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMimeTypeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMixedAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRootElementAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaTypeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSeeAlsoAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTransientAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTypeAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlValueAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.jaxbindex.JaxbIndexResourceModelProvider;
+import org.eclipse.jpt.jaxb.core.internal.resource.jaxbprops.JaxbPropertiesResourceModelProvider;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition;
public class GenericJaxb_2_1_PlatformDefinition
- extends AbstractJaxb_2_1_PlatformDefinition {
+ extends AbstractJaxbPlatformDefinition {
// singleton
private static final JaxbPlatformDefinition INSTANCE = new GenericJaxb_2_1_PlatformDefinition();
@@ -39,4 +91,83 @@ public class GenericJaxb_2_1_PlatformDefinition
public JaxbFactory getFactory() {
return GenericJaxb_2_1_Factory.instance();
}
+
+ @Override
+ protected JaxbResourceModelProvider[] buildResourceModelProviders() {
+ // order should not be important here
+ return new JaxbResourceModelProvider[] {
+ JavaResourceModelProvider.instance(),
+ JavaPackageInfoResourceModelProvider.instance(),
+ JaxbIndexResourceModelProvider.instance(),
+ JaxbPropertiesResourceModelProvider.instance()};
+ }
+
+ public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
+ if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
+ }
+ else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
+ }
+ throw new IllegalArgumentException(contentType.toString());
+ }
+
+ @Override
+ protected AnnotationDefinition[] buildAnnotationDefinitions() {
+ return new AnnotationDefinition[] {
+ XmlAccessorOrderAnnotationDefinition.instance(),
+ XmlAccessorTypeAnnotationDefinition.instance(),
+ XmlAnyAttributeAnnotationDefinition.instance(),
+ XmlAnyElementAnnotationDefinition.instance(),
+ XmlAttachmentRefAnnotationDefinition.instance(),
+ XmlAttributeAnnotationDefinition.instance(),
+ XmlElementAnnotationDefinition.instance(),
+ XmlElementDeclAnnotationDefinition.instance(),
+ XmlElementRefAnnotationDefinition.instance(),
+ XmlElementRefsAnnotationDefinition.instance(),
+ XmlElementsAnnotationDefinition.instance(),
+ XmlElementWrapperAnnotationDefinition.instance(),
+ XmlEnumAnnotationDefinition.instance(),
+ XmlEnumValueAnnotationDefinition.instance(),
+ XmlIDAnnotationDefinition.instance(),
+ XmlIDREFAnnotationDefinition.instance(),
+ XmlInlineBinaryDataAnnotationDefinition.instance(),
+ XmlListAnnotationDefinition.instance(),
+ XmlMimeTypeAnnotationDefinition.instance(),
+ XmlMixedAnnotationDefinition.instance(),
+ XmlRegistryAnnotationDefinition.instance(),
+ XmlRootElementAnnotationDefinition.instance(),
+ XmlSchemaAnnotationDefinition.instance(),
+ XmlSeeAlsoAnnotationDefinition.instance(),
+ XmlTransientAnnotationDefinition.instance(),
+ XmlTypeAnnotationDefinition.instance(),
+ XmlValueAnnotationDefinition.instance()};
+ }
+
+ @Override
+ protected NestableAnnotationDefinition[] buildNestableAnnotationDefinitions() {
+ return new NestableAnnotationDefinition[] {
+ XmlJavaTypeAdapterAnnotationDefinition.instance(),
+ XmlSchemaTypeAnnotationDefinition.instance()
+ };
+ }
+
+ @Override
+ protected void addDefaultJavaAttributeMappingDefinitionsTo(ArrayList<DefaultJavaAttributeMappingDefinition> definitions) {
+ definitions.add(JavaXmlElementMappingDefinition.instance());
+ definitions.add(JavaXmlElementsMappingDefinition.instance());
+ }
+
+ @Override
+ protected void addSpecifiedJavaAttributeMappingDefinitionsTo(ArrayList<JavaAttributeMappingDefinition> definitions) {
+ definitions.add(JavaXmlAnyAttributeMappingDefinition.instance());
+ definitions.add(JavaXmlAnyElementMappingDefinition.instance());
+ definitions.add(JavaXmlAttributeMappingDefinition.instance());
+ definitions.add(JavaXmlElementMappingDefinition.instance());
+ definitions.add(JavaXmlElementRefMappingDefinition.instance());
+ definitions.add(JavaXmlElementRefsMappingDefinition.instance());
+ definitions.add(JavaXmlElementsMappingDefinition.instance());
+ definitions.add(JavaXmlTransientMappingDefinition.instance());
+ definitions.add(JavaXmlValueMappingDefinition.instance());
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/GenericJaxb_2_2_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/GenericJaxb_2_2_PlatformDefinition.java
index adc1b32c67..50df9e2c93 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/GenericJaxb_2_2_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/GenericJaxb_2_2_PlatformDefinition.java
@@ -12,16 +12,18 @@ package org.eclipse.jpt.jaxb.core.internal.jaxb22;
import org.eclipse.jpt.jaxb.core.GenericJaxbPlatform;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
import org.eclipse.jpt.jaxb.core.internal.jaxb21.GenericJaxb_2_1_Factory;
+import org.eclipse.jpt.jaxb.core.internal.jaxb21.GenericJaxb_2_1_PlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
public class GenericJaxb_2_2_PlatformDefinition
- extends AbstractJaxb_2_2_PlatformDefinition {
+ extends GenericJaxb_2_1_PlatformDefinition {
// singleton
private static final JaxbPlatformDefinition INSTANCE = new GenericJaxb_2_2_PlatformDefinition();
+
/**
* Return the singleton.
*/
@@ -29,15 +31,18 @@ public class GenericJaxb_2_2_PlatformDefinition
return INSTANCE;
}
+
protected GenericJaxb_2_2_PlatformDefinition() {
super();
}
+ @Override
public JaxbPlatformDescription getDescription() {
return GenericJaxbPlatform.VERSION_2_2;
}
+ @Override
public JaxbFactory getFactory() {
return GenericJaxb_2_1_Factory.instance();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
index aadf23dedf..bcd235e9df 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
@@ -16,46 +16,49 @@ import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementA
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
/**
* javax.xml.bind.annotation.XmlElement
*/
public final class XmlElementAnnotationDefinition
- implements AnnotationDefinition
-{
+ implements AnnotationDefinition {
+
// singleton
private static final AnnotationDefinition INSTANCE = new XmlElementAnnotationDefinition();
-
+
+
/**
* Return the singleton.
*/
public static AnnotationDefinition instance() {
return INSTANCE;
}
-
+
+
/**
* Ensure single instance.
*/
private XmlElementAnnotationDefinition() {
super();
}
-
+
+
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
return SourceXmlElementAnnotation.buildSourceXmlElementAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement);
}
-
+
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
throw new UnsupportedOperationException();
}
-
+
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
return new BinaryXmlElementAnnotation(parent, jdtAnnotation);
}
-
+
public String getAnnotationName() {
- return XmlElementAnnotation.ANNOTATION_NAME;
+ return JAXB.XML_ELEMENT;
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefAnnotationDefinition.java
index 906de66d39..1094603452 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefAnnotationDefinition.java
@@ -15,57 +15,50 @@ import org.eclipse.jpt.common.core.utility.jdt.Attribute;
import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementRefAnnotation;
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementRefAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
/**
* javax.xml.bind.annotation.XmlElementRef
*/
public final class XmlElementRefAnnotationDefinition
- implements NestableAnnotationDefinition
-{
+ implements AnnotationDefinition {
+
// singleton
- private static final NestableAnnotationDefinition INSTANCE = new XmlElementRefAnnotationDefinition();
-
+ private static final AnnotationDefinition INSTANCE = new XmlElementRefAnnotationDefinition();
+
+
/**
* Return the singleton.
*/
- public static NestableAnnotationDefinition instance() {
+ public static AnnotationDefinition instance() {
return INSTANCE;
}
-
+
+
/**
* Ensure single instance.
*/
private XmlElementRefAnnotationDefinition() {
super();
}
-
- public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) {
- return SourceXmlElementRefAnnotation.buildSourceXmlElementRefAnnotation((JavaResourceField) parent, (Attribute) annotatedElement, index);
+
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return SourceXmlElementRefAnnotation.buildSourceXmlElementRefAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement);
}
-
+
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
throw new UnsupportedOperationException();
}
-
+
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
return new BinaryXmlElementRefAnnotation(parent, jdtAnnotation);
}
- public String getNestableAnnotationName() {
+ public String getAnnotationName() {
return JAXB.XML_ELEMENT_REF;
}
-
- public String getContainerAnnotationName() {
- return JAXB.XML_ELEMENT_REFS;
- }
-
- public String getElementName() {
- return JAXB.XML_ELEMENT_REFS__VALUE;
- }
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefsAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefsAnnotationDefinition.java
new file mode 100644
index 0000000000..66f30dd2bd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefsAnnotationDefinition.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementRefsAnnotation;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementRefsAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+
+
+public class XmlElementRefsAnnotationDefinition
+ implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlElementRefsAnnotationDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlElementRefsAnnotationDefinition() {
+ super();
+ }
+
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlElementRefsAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlElementRefsAnnotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return JAXB.XML_ELEMENT_REFS;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementRefsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementRefsAnnotation.java
new file mode 100644
index 0000000000..5e24cdd73b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementRefsAnnotation.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.resource.java.binary;
+
+import java.util.Vector;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
+
+
+public class BinaryXmlElementRefsAnnotation
+ extends BinaryAnnotation
+ implements XmlElementRefsAnnotation {
+
+ private final Vector<XmlElementRefAnnotation> xmlElementRefs;
+
+
+ public BinaryXmlElementRefsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.xmlElementRefs = this.buildXmlElementRefs();
+ }
+
+
+ private Vector<XmlElementRefAnnotation> buildXmlElementRefs() {
+ Object[] jdtXmlElementRefs = this.getJdtMemberValues(JAXB.XML_ELEMENT_REFS__VALUE);
+ Vector<XmlElementRefAnnotation> result = new Vector<XmlElementRefAnnotation>(jdtXmlElementRefs.length);
+ for (Object jdtXmlElementRef : jdtXmlElementRefs) {
+ result.add(new BinaryXmlElementRefAnnotation(this, (IAnnotation) jdtXmlElementRef));
+ }
+ return result;
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public ListIterable<XmlElementRefAnnotation> getXmlElementRefs() {
+ return new LiveCloneListIterable<XmlElementRefAnnotation>(this.xmlElementRefs);
+ }
+
+ public int getXmlElementRefsSize() {
+ return this.xmlElementRefs.size();
+ }
+
+ public XmlElementRefAnnotation xmlElementRefAt(int index) {
+ return this.xmlElementRefs.elementAt(index);
+ }
+
+ public XmlElementRefAnnotation addXmlElementRef(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void moveXmlElementRef(int targetIndex, int sourceIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeXmlElementRef(int index) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
index 18fe641193..1cc3a469e3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
@@ -67,7 +67,7 @@ public final class SourceXmlAnyElementAnnotation
return buildAnnotationElementAdapter(daa, JAXB.XML_ANY_ELEMENT__VALUE, SimpleTypeStringExpressionConverter.instance());
}
- private static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) {
+ private DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) {
return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, converter);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
index f10ddd2b7e..bb77fc6a2c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
@@ -27,7 +27,7 @@ import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
@@ -35,15 +35,16 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
* javax.xml.bind.annotation.XmlElement
*/
public final class SourceXmlElementAnnotation
- extends SourceAnnotation<Attribute>
- implements XmlElementAnnotation
-{
+ extends SourceAnnotation<Attribute>
+ implements XmlElementAnnotation {
+
private static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
+
+
private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
private final AnnotationElementAdapter<String> nameAdapter;
private String name;
-
+
private final DeclarationAnnotationElementAdapter<String> namespaceDeclarationAdapter;
private final AnnotationElementAdapter<String> namespaceAdapter;
private String namespace;
@@ -55,32 +56,47 @@ public final class SourceXmlElementAnnotation
private final DeclarationAnnotationElementAdapter<Boolean> requiredDeclarationAdapter;
private final AnnotationElementAdapter<Boolean> requiredAdapter;
private Boolean required;
-
+
private final DeclarationAnnotationElementAdapter<String> defaultValueDeclarationAdapter;
private final AnnotationElementAdapter<String> defaultValueAdapter;
private String defaultValue;
-
+
private final DeclarationAnnotationElementAdapter<String> typeDeclarationAdapter;
private final AnnotationElementAdapter<String> typeAdapter;
private String type;
private String fullyQualifiedTypeName;
-
-
- // ********** constructors **********
- public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceMember parent, Attribute attribute) {
- return new SourceXmlElementAnnotation(
- parent,
- attribute,
- DECLARATION_ANNOTATION_ADAPTER);
+
+
+ public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(
+ JavaResourceAttribute parent,
+ Attribute attribute) {
+
+ return new SourceXmlElementAnnotation(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
-
- public static SourceXmlElementAnnotation buildNestedSourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) {
- IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(attribute, idaa);
- return new SourceXmlElementAnnotation(parent, attribute, idaa, annotationAdapter);
+
+ public static SourceXmlElementAnnotation buildNestedSourceXmlElementAnnotation(
+ JavaResourceNode parent,
+ Attribute attribute,
+ IndexedDeclarationAnnotationAdapter idaa) {
+
+ return new SourceXmlElementAnnotation(parent, attribute, idaa);
}
-
-
- private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+
+
+ private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) {
+ this(parent, attribute, daa, new ElementAnnotationAdapter(attribute, daa));
+ }
+
+ private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) {
+ this(parent, attribute, idaa, new ElementIndexedAnnotationAdapter(attribute, idaa));
+ }
+
+ private SourceXmlElementAnnotation(
+ JavaResourceNode parent,
+ Attribute attribute,
+ DeclarationAnnotationAdapter daa,
+ AnnotationAdapter annotationAdapter) {
+
super(parent, attribute, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter);
@@ -95,14 +111,7 @@ public final class SourceXmlElementAnnotation
this.typeDeclarationAdapter = this.buildTypeAdapter(daa);
this.typeAdapter = this.buildAnnotationElementAdapter(this.typeDeclarationAdapter);
}
-
- private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) {
- this(parent, attribute, daa, new ElementAnnotationAdapter(attribute, daa));
- }
-
- private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) {
- this(parent, attribute, idaa, new ElementIndexedAnnotationAdapter(attribute, idaa));
- }
+
private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daa) {
return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_ELEMENT__NAME);
@@ -367,6 +376,4 @@ public final class SourceXmlElementAnnotation
private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
-
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
index 33971cf6d2..c45bbcb47b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
@@ -12,13 +12,13 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.Attribute;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
@@ -27,68 +27,93 @@ import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
/**
* javax.xml.bind.annotation.XmlElementRef
*/
public final class SourceXmlElementRefAnnotation
- extends SourceAnnotation<Attribute>
- implements XmlElementRefAnnotation
-{
+ extends SourceAnnotation<Attribute>
+ implements XmlElementRefAnnotation {
+
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public static final SimpleDeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JAXB.XML_ELEMENT_REFS);
+
private String fullyQualifiedTypeName;
-
+
private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
private final AnnotationElementAdapter<String> nameAdapter;
private String name;
-
+
private final DeclarationAnnotationElementAdapter<String> namespaceDeclarationAdapter;
private final AnnotationElementAdapter<String> namespaceAdapter;
private String namespace;
-
+
private final DeclarationAnnotationElementAdapter<String> typeDeclarationAdapter;
private final AnnotationElementAdapter<String> typeAdapter;
private String type;
-
- // ********** constructors **********
- public static SourceXmlElementRefAnnotation buildSourceXmlElementRefAnnotation(JavaResourceField parent, Attribute attribute, int index) {
- IndexedDeclarationAnnotationAdapter idaa = buildXmlElementRefDeclarationAnnotationAdapter(index);
- IndexedAnnotationAdapter iaa = buildXmlElementRefAnnotationAdapter(attribute, idaa);
- return new SourceXmlElementRefAnnotation(
- parent,
- attribute,
- idaa,
- iaa);
+
+
+ public static SourceXmlElementRefAnnotation buildSourceXmlElementRefAnnotation(
+ JavaResourceAttribute parent,
+ Attribute attribute) {
+
+ return new SourceXmlElementRefAnnotation(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public static SourceXmlElementRefAnnotation buildNestedSourceXmlElementRefAnnotation(
+ JavaResourceNode parent,
+ Attribute attribute,
+ IndexedDeclarationAnnotationAdapter idaa) {
+
+ return new SourceXmlElementRefAnnotation(parent, attribute, idaa);
}
+
private SourceXmlElementRefAnnotation(
- JavaResourceField parent,
+ JavaResourceNode parent,
Attribute attribute,
- IndexedDeclarationAnnotationAdapter daa,
- IndexedAnnotationAdapter annotationAdapter) {
+ DeclarationAnnotationAdapter daa) {
+
+ this(parent, attribute, daa, new ElementAnnotationAdapter(attribute, daa));
+ }
+
+ private SourceXmlElementRefAnnotation(
+ JavaResourceNode parent,
+ Attribute attribute,
+ IndexedDeclarationAnnotationAdapter idaa) {
+
+ this(parent, attribute, idaa, new ElementIndexedAnnotationAdapter(attribute, idaa));
+ }
+
+ private SourceXmlElementRefAnnotation(
+ JavaResourceNode parent,
+ Attribute attribute,
+ DeclarationAnnotationAdapter daa,
+ AnnotationAdapter annotationAdapter) {
+
super(parent, attribute, daa, annotationAdapter);
- this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameDeclarationAdapter = this.buildNameDeclarationAdapter();
this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter);
- this.namespaceDeclarationAdapter = this.buildNamespaceAdapter(daa);
+ this.namespaceDeclarationAdapter = this.buildNamespaceDeclarationAdapter();
this.namespaceAdapter = this.buildAnnotationElementAdapter(this.namespaceDeclarationAdapter);
- this.typeDeclarationAdapter = this.buildTypeAdapter(daa);
+ this.typeDeclarationAdapter = this.buildTypeDeclarationAdapter();
this.typeAdapter = this.buildAnnotationElementAdapter(this.typeDeclarationAdapter);
}
-
- private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daa) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_ELEMENT_REF__NAME);
+
+
+ private DeclarationAnnotationElementAdapter<String> buildNameDeclarationAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, JAXB.XML_ELEMENT_REF__NAME);
}
-
- private DeclarationAnnotationElementAdapter<String> buildNamespaceAdapter(DeclarationAnnotationAdapter daa) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_ELEMENT_REF__NAMESPACE);
+
+ private DeclarationAnnotationElementAdapter<String> buildNamespaceDeclarationAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, JAXB.XML_ELEMENT_REF__NAMESPACE);
}
- private DeclarationAnnotationElementAdapter<String> buildTypeAdapter(DeclarationAnnotationAdapter daa) {
- return buildAnnotationElementAdapter(daa, JAXB.XML_ELEMENT_REF__TYPE, SimpleTypeStringExpressionConverter.instance());
+ private DeclarationAnnotationElementAdapter<String> buildTypeDeclarationAdapter() {
+ return buildAnnotationElementAdapter(this.daa, JAXB.XML_ELEMENT_REF__TYPE, SimpleTypeStringExpressionConverter.instance());
}
private static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) {
@@ -232,22 +257,4 @@ public final class SourceXmlElementRefAnnotation
private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
-
-
- // ********** static methods **********
-
- private static IndexedAnnotationAdapter buildXmlElementRefAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) {
- return new ElementIndexedAnnotationAdapter(annotatedElement, idaa);
- }
-
- private static IndexedDeclarationAnnotationAdapter buildXmlElementRefDeclarationAnnotationAdapter(int index) {
- IndexedDeclarationAnnotationAdapter idaa =
- new CombinationIndexedDeclarationAnnotationAdapter(
- DECLARATION_ANNOTATION_ADAPTER,
- CONTAINER_DECLARATION_ANNOTATION_ADAPTER,
- index,
- JAXB.XML_ELEMENT_REF);
- return idaa;
- }
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefsAnnotation.java
new file mode 100644
index 0000000000..239606096b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefsAnnotation.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlElementRefs
+ */
+public class SourceXmlElementRefsAnnotation
+ extends SourceAnnotation<Attribute>
+ implements XmlElementRefsAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER
+ = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+
+ private final XmlElementRefsAnnotationContainer xmlElementRefsContainer
+ = new XmlElementRefsAnnotationContainer();
+
+
+ public SourceXmlElementRefsAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public SourceXmlElementRefsAnnotation(JavaResourceAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) {
+ super(parent, attribute, daa);
+ }
+
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.xmlElementRefsContainer.initialize(this.getAstAnnotation(astRoot));
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ this.xmlElementRefsContainer.synchronize(this.getAstAnnotation(astRoot));
+ }
+
+
+ // **************** xml element refs **************************************
+
+ public ListIterable<XmlElementRefAnnotation> getXmlElementRefs() {
+ return this.xmlElementRefsContainer.getNestedAnnotations();
+ }
+
+ public int getXmlElementRefsSize() {
+ return this.xmlElementRefsContainer.getNestedAnnotationsSize();
+ }
+
+ public XmlElementRefAnnotation xmlElementRefAt(int index) {
+ return this.xmlElementRefsContainer.nestedAnnotationAt(index);
+ }
+
+ public XmlElementRefAnnotation addXmlElementRef(int index) {
+ return this.xmlElementRefsContainer.addNestedAnnotation(index);
+ }
+
+ private XmlElementRefAnnotation buildXmlElementRef(int index) {
+ return SourceXmlElementRefAnnotation.buildNestedSourceXmlElementRefAnnotation(
+ this, this.annotatedElement, buildXmlElementRefIndexedDeclarationAnnotationAdapter(index));
+ }
+
+ private IndexedDeclarationAnnotationAdapter buildXmlElementRefIndexedDeclarationAnnotationAdapter(int index) {
+ return new NestedIndexedDeclarationAnnotationAdapter(
+ this.daa, JAXB.XML_ELEMENT_REFS__VALUE, index, JAXB.XML_ELEMENT_REF);
+ }
+
+ public void moveXmlElementRef(int targetIndex, int sourceIndex) {
+ this.xmlElementRefsContainer.moveNestedAnnotation(targetIndex, sourceIndex);
+ }
+
+ public void removeXmlElementRef(int index) {
+ this.xmlElementRefsContainer.removeNestedAnnotation(index);
+ }
+
+
+ class XmlElementRefsAnnotationContainer
+ extends AnnotationContainer<XmlElementRefAnnotation> {
+
+ @Override
+ protected String getAnnotationsPropertyName() {
+ return XML_ELEMENT_REFS_LIST;
+ }
+
+ @Override
+ protected String getElementName() {
+ return JAXB.XML_ELEMENT_REFS__VALUE;
+ }
+
+ @Override
+ protected String getNestedAnnotationName() {
+ return JAXB.XML_ELEMENT_REF;
+ }
+
+ @Override
+ protected XmlElementRefAnnotation buildNestedAnnotation(int index) {
+ return SourceXmlElementRefsAnnotation.this.buildXmlElementRef(index);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementRefsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementRefsAnnotation.java
new file mode 100644
index 0000000000..28d7cfa692
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementRefsAnnotation.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
+
+/**
+ * Corresponds to the JAXB annotation
+ * javax.xml.bind.annotation.XmlElementRefs
+ *
+ * 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 XmlElementRefsAnnotation
+ extends Annotation {
+
+ String ANNOTATION_NAME = JAXB.XML_ELEMENT_REFS;
+
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterable<XmlElementRefAnnotation> getXmlElementRefs();
+ String XML_ELEMENT_REFS_LIST = "xmlElementRefs"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ */
+ int getXmlElementRefsSize();
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ */
+ XmlElementRefAnnotation xmlElementRefAt(int index);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ */
+ XmlElementRefAnnotation addXmlElementRef(int index);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ */
+ void moveXmlElementRef(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElementRefs annotation.
+ */
+ void removeXmlElementRef(int index);
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
index 3f964bf63b..7ea33b7ac1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
@@ -22,7 +22,10 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)",
Export-Package: org.eclipse.jpt.jaxb.eclipselink.core,
org.eclipse.jpt.jaxb.eclipselink.core.internal.context,
org.eclipse.jpt.jaxb.eclipselink.core.internal.libval;x-internal:=true,
+ org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.binary,
+ org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.source,
org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_3;x-internal:=true,
- org.eclipse.jpt.jaxb.eclipselink.core.internal.validation
+ org.eclipse.jpt.jaxb.eclipselink.core.internal.validation,
+ org.eclipse.jpt.jaxb.eclipselink.core.resource.java
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbMappingKeys.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbMappingKeys.java
new file mode 100644
index 0000000000..d42f183721
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbMappingKeys.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.eclipselink.core;
+
+/**
+ * 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 ELJaxbMappingKeys {
+
+ String XML_INVERSE_REFERENCE_ATTRIBUTE_MAPPING_KEY = "xml-inverse-reference";
+ String XML_TRANSFORMATION_ATTRIBUTE_MAPPING_KEY = "xml-transformation";
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/AbstractELJaxbPlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/AbstractELJaxbPlatformDefinition.java
new file mode 100644
index 0000000000..965951125e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/AbstractELJaxbPlatformDefinition.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal;
+
+import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
+
+
+public abstract class AbstractELJaxbPlatformDefinition
+ extends AbstractJaxbPlatformDefinition {
+
+ protected AbstractELJaxbPlatformDefinition() {
+ super();
+ }
+
+
+ protected abstract JaxbPlatformDefinition getGenericJaxbPlatformDefinition();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java
new file mode 100644
index 0000000000..3683391644
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMapping.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaAttributeMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlInverseReferenceAnnotation;
+
+
+public class ELJavaXmlInverseReferenceMapping
+ extends AbstractJavaAttributeMapping<XmlInverseReferenceAnnotation> {
+
+ public ELJavaXmlInverseReferenceMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ }
+
+
+ public String getKey() {
+ return ELJaxbMappingKeys.XML_INVERSE_REFERENCE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return ELJaxb.XML_INVERSE_REFERENCE;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java
new file mode 100644
index 0000000000..a62e305ea0
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java
@@ -0,0 +1,52 @@
+package org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+
+
+public class ELJavaXmlInverseReferenceMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition {
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new ELJavaXmlInverseReferenceMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private ELJavaXmlInverseReferenceMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return ELJaxbMappingKeys.XML_INVERSE_REFERENCE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return ELJaxb.XML_INVERSE_REFERENCE;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return EmptyIterable.instance();
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ // TODO: move to factory once API opens up again
+ return new ELJavaXmlInverseReferenceMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMapping.java
new file mode 100644
index 0000000000..036908cb6c
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMapping.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaAttributeMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlTransformationAnnotation;
+
+
+public class ELJavaXmlTransformationMapping
+ extends AbstractJavaAttributeMapping<XmlTransformationAnnotation> {
+
+ public ELJavaXmlTransformationMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ }
+
+
+ public String getKey() {
+ return ELJaxbMappingKeys.XML_TRANSFORMATION_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return ELJaxb.XML_TRANSFORMATION;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java
new file mode 100644
index 0000000000..852c0810d0
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.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.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+
+
+public class ELJavaXmlTransformationMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition {
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new ELJavaXmlTransformationMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private ELJavaXmlTransformationMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return ELJaxbMappingKeys.XML_TRANSFORMATION_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return ELJaxb.XML_TRANSFORMATION;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return EmptyIterable.instance();
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ // TODO: move to factory once API opens up again
+ return new ELJavaXmlTransformationMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlInverseReferenceAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlInverseReferenceAnnotationDefinition.java
new file mode 100644
index 0000000000..cd9d1cf4c9
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlInverseReferenceAnnotationDefinition.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.binary.BinaryXmlInverseReferenceAnnotation;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.source.SourceXmlInverseReferenceAnnotation;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+
+
+public class XmlInverseReferenceAnnotationDefinition
+ implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlInverseReferenceAnnotationDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlInverseReferenceAnnotationDefinition() {
+ super();
+ }
+
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlInverseReferenceAnnotation((JavaResourceMember) parent, (Attribute) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlInverseReferenceAnnotation((JavaResourceMember) parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return ELJaxb.XML_INVERSE_REFERENCE;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlTransformationAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlTransformationAnnotationDefinition.java
new file mode 100644
index 0000000000..b4e92120fe
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/XmlTransformationAnnotationDefinition.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.binary.BinaryXmlTransformationAnnotation;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.source.SourceXmlTransformationAnnotation;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+
+
+public class XmlTransformationAnnotationDefinition
+ implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlTransformationAnnotationDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlTransformationAnnotationDefinition() {
+ super();
+ }
+
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlTransformationAnnotation((JavaResourceMember) parent, (Attribute) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlTransformationAnnotation((JavaResourceMember) parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return ELJaxb.XML_TRANSFORMATION;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlInverseReferenceAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlInverseReferenceAnnotation.java
new file mode 100644
index 0000000000..b851d3e4a8
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlInverseReferenceAnnotation.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlInverseReferenceAnnotation;
+
+
+public class BinaryXmlInverseReferenceAnnotation
+ extends BinaryAnnotation
+ implements XmlInverseReferenceAnnotation {
+
+ private String mappedBy;
+
+
+ public BinaryXmlInverseReferenceAnnotation(JavaResourceMember parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.mappedBy = buildMappedBy();
+ }
+
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ setMappedBy_(buildMappedBy());
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.mappedBy);
+ }
+
+
+ // ***** mappedBy
+
+ public String getMappedBy() {
+ return this.mappedBy;
+ }
+
+ public void setMappedBy(String mappedBy) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setMappedBy_(String mappedBy) {
+ String old = this.mappedBy;
+ this.mappedBy = mappedBy;
+ this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy);
+ }
+
+ private String buildMappedBy() {
+ return (String) this.getJdtMemberValue(ELJaxb.XML_INVERSE_REFERENCE__MAPPED_BY);
+ }
+
+ public TextRange getMappedByTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlTransformationAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlTransformationAnnotation.java
new file mode 100644
index 0000000000..52c37c8d99
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlTransformationAnnotation.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlTransformationAnnotation;
+
+
+public class BinaryXmlTransformationAnnotation
+ extends BinaryAnnotation
+ implements XmlTransformationAnnotation {
+
+ private Boolean optional;
+
+
+ public BinaryXmlTransformationAnnotation(JavaResourceMember parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.optional = buildOptional();
+ }
+
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ setOptional_(buildOptional());
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.optional);
+ }
+
+
+ // ***** optional
+
+ public Boolean getOptional() {
+ return this.optional;
+ }
+
+ public void setOptional(Boolean optional) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setOptional_(Boolean optional) {
+ Boolean old = this.optional;
+ this.optional = optional;
+ this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional);
+ }
+
+ private Boolean buildOptional() {
+ return (Boolean) this.getJdtMemberValue(ELJaxb.XML_TRANSFORMATION__OPTIONAL);
+ }
+
+ public TextRange getOptionalTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlInverseReferenceAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlInverseReferenceAnnotation.java
new file mode 100644
index 0000000000..24eff13faf
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlInverseReferenceAnnotation.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.StringExpressionConverter;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlInverseReferenceAnnotation;
+
+
+public class SourceXmlInverseReferenceAnnotation
+ extends SourceAnnotation<Attribute>
+ implements XmlInverseReferenceAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> mappedByDeclarationAdapter;
+ private final AnnotationElementAdapter<String> mappedByAdapter;
+ private String mappedBy;
+
+
+ public SourceXmlInverseReferenceAnnotation(JavaResourceMember parent, Attribute attribute) {
+ this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public SourceXmlInverseReferenceAnnotation(JavaResourceMember parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, attribute, daa, annotationAdapter);
+ this.mappedByDeclarationAdapter = buildMappedByDeclarationAdapter(daa);
+ this.mappedByAdapter = buildMappedByAdapter(this.mappedByDeclarationAdapter);
+ }
+
+
+ private DeclarationAnnotationElementAdapter<String> buildMappedByDeclarationAdapter(DeclarationAnnotationAdapter daa) {
+ return new ConversionDeclarationAnnotationElementAdapter<String>(daa, ELJaxb.XML_INVERSE_REFERENCE__MAPPED_BY, StringExpressionConverter.instance());
+ }
+
+ private AnnotationElementAdapter<String> buildMappedByAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.mappedBy = buildMappedBy(astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ this.syncMappedBy(buildMappedBy(astRoot));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.mappedBy);
+ }
+
+
+ // ********** mappedBy
+
+ public String getMappedBy() {
+ return this.mappedBy;
+ }
+
+ public void setMappedBy(String mappedBy) {
+ if (attributeValueHasChanged(this.mappedBy, mappedBy)) {
+ this.mappedBy = mappedBy;
+ this.mappedByAdapter.setValue(mappedBy);
+ }
+ }
+
+ private void syncMappedBy(String astMappedBy) {
+ String old = this.mappedBy;
+ this.mappedBy = astMappedBy;
+ this.firePropertyChanged(MAPPED_BY_PROPERTY, old, this.mappedBy);
+ }
+
+ private String buildMappedBy(CompilationUnit astRoot) {
+ return this.mappedByAdapter.getValue(astRoot);
+ }
+
+ public TextRange getMappedByTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.mappedByDeclarationAdapter, astRoot);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlTransformationAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlTransformationAnnotation.java
new file mode 100644
index 0000000000..ec6d349f7e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/source/SourceXmlTransformationAnnotation.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
+import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.Attribute;
+import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlTransformationAnnotation;
+
+
+public class SourceXmlTransformationAnnotation
+ extends SourceAnnotation<Attribute>
+ implements XmlTransformationAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<Boolean> optionalDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> optionalAdapter;
+ private Boolean optional;
+
+
+ public SourceXmlTransformationAnnotation(JavaResourceMember parent, Attribute attribute) {
+ this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public SourceXmlTransformationAnnotation(JavaResourceMember parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, attribute, daa, annotationAdapter);
+ this.optionalDeclarationAdapter = buildOptionalDeclarationAdapter(daa);
+ this.optionalAdapter = buildShortCircuitBooleanElementAdapter(this.optionalDeclarationAdapter);
+ }
+
+
+ private DeclarationAnnotationElementAdapter<Boolean> buildOptionalDeclarationAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, ELJaxb.XML_TRANSFORMATION__OPTIONAL);
+ }
+
+ private AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) {
+ return new AnnotatedElementAnnotationElementAdapter<Boolean>(this.annotatedElement, daea);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.optional = buildOptional(astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ this.syncOptional(buildOptional(astRoot));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.optional);
+ }
+
+
+ // ********** optional
+
+ public Boolean getOptional() {
+ return this.optional;
+ }
+
+ public void setOptional(Boolean optional) {
+ if (attributeValueHasChanged(this.optional, optional)) {
+ this.optional = optional;
+ this.optionalAdapter.setValue(optional);
+ }
+ }
+
+ private void syncOptional(Boolean astOptional) {
+ Boolean old = this.optional;
+ this.optional = astOptional;
+ this.firePropertyChanged(OPTIONAL_PROPERTY, old, this.optional);
+ }
+
+ private Boolean buildOptional(CompilationUnit astRoot) {
+ return this.optionalAdapter.getValue(astRoot);
+ }
+
+ public TextRange getOptionalTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.optionalDeclarationAdapter, astRoot);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
index ebdf91bfd0..a50bbb612e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
@@ -9,15 +9,29 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1;
+import java.util.ArrayList;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.utility.internal.ArrayTools;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
-import org.eclipse.jpt.jaxb.core.internal.jaxb21.AbstractJaxb_2_1_PlatformDefinition;
+import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider;
+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.jaxb21.GenericJaxb_2_1_PlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.AbstractELJaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlInverseReferenceMappingDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlInverseReferenceAnnotationDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlTransformationAnnotationDefinition;
public class ELJaxb_2_1_PlatformDefinition
- extends AbstractJaxb_2_1_PlatformDefinition {
+ extends AbstractELJaxbPlatformDefinition {
// singleton
private static final JaxbPlatformDefinition INSTANCE = new ELJaxb_2_1_PlatformDefinition();
@@ -35,6 +49,11 @@ public class ELJaxb_2_1_PlatformDefinition
}
+ @Override
+ protected JaxbPlatformDefinition getGenericJaxbPlatformDefinition() {
+ return GenericJaxb_2_1_PlatformDefinition.instance();
+ }
+
public JaxbPlatformDescription getDescription() {
return ELJaxbPlatform.VERSION_2_1;
}
@@ -42,4 +61,42 @@ public class ELJaxb_2_1_PlatformDefinition
public JaxbFactory getFactory() {
return ELJaxb_2_1_Factory.instance();
}
+
+ @Override
+ protected JaxbResourceModelProvider[] buildResourceModelProviders() {
+ return ArrayTools.array(
+ getGenericJaxbPlatformDefinition().getResourceModelProviders(),
+ new JaxbResourceModelProvider[0]);
+
+ }
+
+ public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
+ return getGenericJaxbPlatformDefinition().getMostRecentSupportedResourceType(contentType);
+ }
+
+ @Override
+ protected AnnotationDefinition[] buildAnnotationDefinitions() {
+ return ArrayTools.addAll(
+ getGenericJaxbPlatformDefinition().getAnnotationDefinitions(),
+ XmlInverseReferenceAnnotationDefinition.instance(),
+ XmlTransformationAnnotationDefinition.instance());
+ }
+
+ @Override
+ protected NestableAnnotationDefinition[] buildNestableAnnotationDefinitions() {
+ return getGenericJaxbPlatformDefinition().getNestableAnnotationDefinitions();
+ }
+
+ @Override
+ protected void addDefaultJavaAttributeMappingDefinitionsTo(
+ ArrayList<DefaultJavaAttributeMappingDefinition> definitions) {
+ CollectionTools.addAll(definitions, getGenericJaxbPlatformDefinition().getDefaultJavaAttributeMappingDefinitions());
+ }
+
+ @Override
+ protected void addSpecifiedJavaAttributeMappingDefinitionsTo(
+ ArrayList<JavaAttributeMappingDefinition> definitions) {
+ CollectionTools.addAll(definitions, getGenericJaxbPlatformDefinition().getSpecifiedJavaAttributeMappingDefinitions());
+ CollectionTools.addAll(definitions, ELJavaXmlInverseReferenceMappingDefinition.instance());
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
index 557a8a9060..16d15f20fc 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
@@ -9,20 +9,26 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2;
+import java.util.ArrayList;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
-import org.eclipse.jpt.jaxb.core.internal.jaxb22.AbstractJaxb_2_2_PlatformDefinition;
+import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.jaxb22.GenericJaxb_2_2_PlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlTransformationMappingDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1.ELJaxb_2_1_Factory;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1.ELJaxb_2_1_PlatformDefinition;
public class ELJaxb_2_2_PlatformDefinition
- extends AbstractJaxb_2_2_PlatformDefinition {
+ extends ELJaxb_2_1_PlatformDefinition {
// singleton
private static final JaxbPlatformDefinition INSTANCE = new ELJaxb_2_2_PlatformDefinition();
+
/**
* Return the singleton.
*/
@@ -36,11 +42,25 @@ public class ELJaxb_2_2_PlatformDefinition
}
+ @Override
public JaxbPlatformDescription getDescription() {
return ELJaxbPlatform.VERSION_2_2;
}
+ @Override
public JaxbFactory getFactory() {
return ELJaxb_2_1_Factory.instance();
}
+
+ @Override
+ protected JaxbPlatformDefinition getGenericJaxbPlatformDefinition() {
+ return GenericJaxb_2_2_PlatformDefinition.instance();
+ }
+
+ @Override
+ protected void addSpecifiedJavaAttributeMappingDefinitionsTo(
+ ArrayList<JavaAttributeMappingDefinition> definitions) {
+ super.addSpecifiedJavaAttributeMappingDefinitionsTo(definitions);
+ CollectionTools.addAll(definitions, ELJavaXmlTransformationMappingDefinition.instance());
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
index 9b24d0847f..1a9faca9c5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
@@ -10,15 +10,15 @@
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_3;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
-import org.eclipse.jpt.jaxb.core.internal.jaxb22.AbstractJaxb_2_2_PlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1.ELJaxb_2_1_Factory;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.ELJaxb_2_2_PlatformDefinition;
public class ELJaxb_2_3_PlatformDefinition
- extends AbstractJaxb_2_2_PlatformDefinition {
+ extends ELJaxb_2_2_PlatformDefinition {
// singleton
private static final JaxbPlatformDefinition INSTANCE = new ELJaxb_2_3_PlatformDefinition();
@@ -36,10 +36,12 @@ public class ELJaxb_2_3_PlatformDefinition
}
+ @Override
public JaxbPlatformDescription getDescription() {
return ELJaxbPlatform.VERSION_2_3;
}
+ @Override
public JaxbFactory getFactory() {
return ELJaxb_2_1_Factory.instance();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/ELJaxb.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/ELJaxb.java
new file mode 100644
index 0000000000..74b85352aa
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/ELJaxb.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.eclipselink.core.resource.java;
+
+/**
+ * EclipseLink JAXB Java-related stuff (annotations etc.)
+ * <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
+ */
+@SuppressWarnings("nls")
+public interface ELJaxb {
+
+ // EclipseLink annotations package
+
+ String PACKAGE = "org.eclipse.persistence.oxm.annotations";
+ String PACKAGE_ = PACKAGE + '.';
+
+
+ // Annotations
+
+ String XML_INVERSE_REFERENCE = PACKAGE_ + "XmlInverseReference";
+ String XML_INVERSE_REFERENCE__MAPPED_BY = "mappedBy";
+
+ String XML_TRANSFORMATION = PACKAGE_ + "XmlTransformation";
+ String XML_TRANSFORMATION__OPTIONAL = "optional";
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlInverseReferenceAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlInverseReferenceAnnotation.java
new file mode 100644
index 0000000000..ed9612bac7
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlInverseReferenceAnnotation.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.eclipselink.core.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+
+
+public interface XmlInverseReferenceAnnotation
+ extends Annotation {
+
+ String ANNOTATION_NAME = ELJaxb.XML_INVERSE_REFERENCE;
+
+ /**
+ * String associated with change events to the 'mappedBy' property
+ */
+ String MAPPED_BY_PROPERTY = "mappedBy"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'mappedBy' element of the XmlInverseReference annotation.
+ * Return null if the element does not exist in Java.
+ */
+ String getMappedBy();
+
+ /**
+ * Corresponds to the 'mappedBy' element of the XmlInverseReference annotation.
+ * Set to null to remove the element.
+ */
+ void setMappedBy(String mappedBy);
+
+ /**
+ * Return the text range associated with the 'mappedBy' element.
+ * Return the text range of this annotation if the element is absent.
+ */
+ TextRange getMappedByTextRange(CompilationUnit astRoot);
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlTransformationAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlTransformationAnnotation.java
new file mode 100644
index 0000000000..2960d9ae61
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlTransformationAnnotation.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.eclipselink.core.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+
+
+public interface XmlTransformationAnnotation
+ extends Annotation {
+
+ String ANNOTATION_NAME = ELJaxb.XML_TRANSFORMATION;
+
+ /**
+ * String associated with change events to the 'optional' property
+ */
+ String OPTIONAL_PROPERTY = "optional"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'optional' element of the XmlTransformation annotation.
+ * Return null if the element does not exist in Java.
+ */
+ Boolean getOptional();
+
+ /**
+ * Corresponds to the 'optional' element of the XmlTransformation annotation.
+ * Set to null to remove the element.
+ */
+ void setOptional(Boolean optional);
+
+ /**
+ * Return the text range associated with the 'optional' element.
+ * Return the text range of this annotation if the element is absent.
+ */
+ TextRange getOptionalTextRange(CompilationUnit astRoot);
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
index 31eeef31b8..37a68afd9f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
@@ -10,7 +10,14 @@ Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.jface;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.jpt.common.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jpt.common.ui;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.jpt.jaxb.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jpt.jaxb.eclipselink.core;bundle-version="[1.0.0,2.0.0)",
org.eclipse.jpt.jaxb.ui;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.swt;bundle-version="[3.7.0,4.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.7.0,4.0.0)"
Export-Package: org.eclipse.jpt.jaxb.eclipselink.ui,
org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_1;x-internal:=true,
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/build.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/build.properties
index f0dca02368..08bc038360 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/build.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/build.properties
@@ -12,6 +12,7 @@ output.. = bin/
bin.includes = .,\
META-INF/,\
about.html,\
+ icons/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-inverse-reference.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-inverse-reference.gif
new file mode 100644
index 0000000000..ce55b84284
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-inverse-reference.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-transformation.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-transformation.gif
new file mode 100644
index 0000000000..fecf9e54c3
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/icons/full/obj16/xml-transformation.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiPlugin.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiPlugin.java
index 78a56d9b25..23b5d76ee8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiPlugin.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiPlugin.java
@@ -11,6 +11,9 @@ package org.eclipse.jpt.jaxb.eclipselink.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
@@ -57,6 +60,39 @@ public class JptJaxbEclipseLinkUiPlugin
}
+ // ********** Image API **********
+
+ /**
+ * This gets a .gif from the icons folder.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ if (! key.startsWith("icons/")) {
+ key = "icons/" + key;
+ }
+ if (! key.endsWith(".gif")) {
+ key = key + ".gif";
+ }
+ return imageDescriptorFromPlugin(PLUGIN_ID, key);
+ }
+
+ /**
+ * This returns an image for a .gif from the icons folder
+ */
+ //TODO we are using the ImageRegistry here and storing all our icons for the life of the plugin,
+ //which means until the workspace is closed. This is better than before where we constantly
+ //created new images. Bug 306437 is about cleaning this up and using Local Resource Managers
+ //on our views so that closing the JPA perspective would mean our icons are disposed.
+ public static Image getImage(String key) {
+ ImageRegistry imageRegistry = instance().getImageRegistry();
+ Image image = imageRegistry.get(key);
+ if (image == null) {
+ imageRegistry.put(key, getImageDescriptor(key));
+ image = imageRegistry.get(key);
+ }
+ return image;
+ }
+
+
// ********** constructors **********
public JptJaxbEclipseLinkUiPlugin() {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java
new file mode 100644
index 0000000000..91fa343855
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbMappingImageHelper.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.eclipselink.ui.internal;
+
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbMappingKeys;
+import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.JaxbMappingImageHelper;
+import org.eclipse.swt.graphics.Image;
+
+
+public class ELJaxbMappingImageHelper {
+
+ public static Image imageForAttributeMapping(String mappingKey) {
+ String iconKey = iconKeyForAttributeMapping(mappingKey);
+ return (iconKey == null) ?
+ JaxbMappingImageHelper.imageForAttributeMapping(mappingKey)
+ : JptJaxbEclipseLinkUiPlugin.getImage(iconKey);
+ }
+
+ public static String iconKeyForAttributeMapping(String mappingKey) {
+ if (ELJaxbMappingKeys.XML_INVERSE_REFERENCE_ATTRIBUTE_MAPPING_KEY == mappingKey) {
+ return JptJaxbEclipseLinkUiIcons.XML_INVERSE_REFERENCE;
+ }
+ else if (ELJaxbMappingKeys.XML_TRANSFORMATION_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
+ return JptJaxbEclipseLinkUiIcons.XML_TRANSFORMATION;
+ }
+
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorItemLabelProviderFactory.java
new file mode 100644
index 0000000000..547c390161
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorItemLabelProviderFactory.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.eclipselink.ui.internal;
+
+import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
+import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.ui.internal.jaxb21.GenericJaxb_2_1_NavigatorItemLabelProviderFactory;
+
+
+public class ELJaxbNavigatorItemLabelProviderFactory
+ extends GenericJaxb_2_1_NavigatorItemLabelProviderFactory {
+
+ private static ELJaxbNavigatorItemLabelProviderFactory INSTANCE = new ELJaxbNavigatorItemLabelProviderFactory();
+
+
+ public static GenericJaxb_2_1_NavigatorItemLabelProviderFactory instance() {
+ return INSTANCE;
+ }
+
+
+ private ELJaxbNavigatorItemLabelProviderFactory() {
+ super();
+ }
+
+
+ @Override
+ public ItemLabelProvider buildItemLabelProvider(
+ Object item,
+ DelegatingContentAndLabelProvider contentAndLabelProvider) {
+
+ if (item instanceof JaxbPersistentAttribute) {
+ return new ELJaxbPersistentAttributeItemLabelProvider((JaxbPersistentAttribute) item, contentAndLabelProvider);
+ }
+
+ return super.buildItemLabelProvider(item, contentAndLabelProvider);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorUi.java
new file mode 100644
index 0000000000..e8a1573b48
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbNavigatorUi.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.eclipselink.ui.internal;
+
+import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory;
+import org.eclipse.jpt.jaxb.ui.internal.jaxb21.GenericJaxb_2_1_NavigatorUi;
+
+
+public class ELJaxbNavigatorUi
+ extends GenericJaxb_2_1_NavigatorUi {
+
+ private static ELJaxbNavigatorUi INSTANCE = new ELJaxbNavigatorUi();
+
+
+ public static ELJaxbNavigatorUi instance() {
+ return INSTANCE;
+ }
+
+
+ private ELJaxbNavigatorUi() {
+ super();
+ }
+
+
+ @Override
+ public ItemLabelProviderFactory getItemLabelProviderFactory() {
+ return ELJaxbNavigatorItemLabelProviderFactory.instance();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbPersistentAttributeItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbPersistentAttributeItemLabelProvider.java
new file mode 100644
index 0000000000..00999326b7
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/ELJaxbPersistentAttributeItemLabelProvider.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.eclipselink.ui.internal;
+
+import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.ui.internal.jaxb21.JaxbPersistentAttributeItemLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+
+public class ELJaxbPersistentAttributeItemLabelProvider
+ extends JaxbPersistentAttributeItemLabelProvider {
+
+ public ELJaxbPersistentAttributeItemLabelProvider(
+ JaxbPersistentAttribute attribute, DelegatingContentAndLabelProvider labelProvider) {
+ super(attribute, labelProvider);
+ }
+
+
+ @Override
+ protected PropertyValueModel<Image> buildImageModel() {
+
+ return new PropertyAspectAdapter<JaxbPersistentAttribute, Image>(
+ new String[] {JaxbPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY, JaxbPersistentAttribute.MAPPING_PROPERTY},
+ getModel()) {
+
+ @Override
+ protected Image buildValue_() {
+ return ELJaxbMappingImageHelper.imageForAttributeMapping(this.subject.getMappingKey());
+ }
+ };
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/AbstractJaxb_2_2_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/JptJaxbEclipseLinkUiIcons.java
index 37ed7e7a15..148333842e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/AbstractJaxb_2_2_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/JptJaxbEclipseLinkUiIcons.java
@@ -7,14 +7,11 @@
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.jaxb22;
+package org.eclipse.jpt.jaxb.eclipselink.ui.internal;
-import org.eclipse.jpt.jaxb.core.internal.jaxb21.AbstractJaxb_2_1_PlatformDefinition;
-public abstract class AbstractJaxb_2_2_PlatformDefinition
- extends AbstractJaxb_2_1_PlatformDefinition {
+public class JptJaxbEclipseLinkUiIcons {
- protected AbstractJaxb_2_2_PlatformDefinition() {
- super();
- }
+ public static final String XML_INVERSE_REFERENCE = "full/obj16/xml-inverse-reference";
+ public static final String XML_TRANSFORMATION = "full/obj16/xml-transformation";
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_2/ELJaxb_2_2_PlatformUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_2/ELJaxb_2_2_PlatformUi.java
index 075aa3c866..2737982fd4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_2/ELJaxb_2_2_PlatformUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_2/ELJaxb_2_2_PlatformUi.java
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_2;
-import org.eclipse.jpt.jaxb.ui.internal.jaxb21.GenericJaxb_2_1_NavigatorUi;
+import org.eclipse.jpt.jaxb.eclipselink.ui.internal.ELJaxbNavigatorUi;
import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi;
import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi;
@@ -18,6 +18,6 @@ public class ELJaxb_2_2_PlatformUi
implements JaxbPlatformUi {
public JaxbNavigatorUi getNavigatorUi() {
- return GenericJaxb_2_1_NavigatorUi.instance();
+ return ELJaxbNavigatorUi.instance();
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_3/ELJaxb_2_3_PlatformUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_3/ELJaxb_2_3_PlatformUi.java
index 27e5f7cad4..dbc9c4f31e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_3/ELJaxb_2_3_PlatformUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/v2_3/ELJaxb_2_3_PlatformUi.java
@@ -9,14 +9,15 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_3;
-import org.eclipse.jpt.jaxb.ui.internal.jaxb21.GenericJaxb_2_1_NavigatorUi;
+import org.eclipse.jpt.jaxb.eclipselink.ui.internal.ELJaxbNavigatorUi;
import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi;
import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi;
+
public class ELJaxb_2_3_PlatformUi
implements JaxbPlatformUi {
public JaxbNavigatorUi getNavigatorUi() {
- return GenericJaxb_2_1_NavigatorUi.instance();
+ return ELJaxbNavigatorUi.instance();
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/package.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/package.gif
index 131c28da40..6989b8df73 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/package.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/package.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/persistent_enum.gif
index 679ca81e14..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/persistent_enum.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-attribute.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-attribute.gif
index 5b01857f30..a5d9fb0dd6 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-attribute.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-attribute.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-element.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-element.gif
index d68d73f340..f73d02bf43 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-element.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-any-element.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-attribute.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-attribute.gif
index da905e3f12..851ee72391 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-attribute.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-attribute.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-ref.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-ref.gif
new file mode 100644
index 0000000000..3220052c41
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-ref.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-refs.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-refs.gif
new file mode 100644
index 0000000000..77e4d6a8bd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element-refs.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element.gif
index b9248dcf67..8c953dc928 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element.gif
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-element.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-elements.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-elements.gif
new file mode 100644
index 0000000000..cb6aad6b16
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/xml-elements.gif
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java
index 12c75d47dc..4c0ddd7a7b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java
@@ -57,12 +57,22 @@ public class JaxbMappingImageHelper
else if (MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
return JptJaxbUiIcons.XML_ELEMENT;
}
+ else if (MappingKeys.XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
+ return JptJaxbUiIcons.XML_ELEMENT_REF;
+ }
+ else if (MappingKeys.XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
+ return JptJaxbUiIcons.XML_ELEMENT_REFS;
+ }
+ else if (MappingKeys.XML_ELEMENTS_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
+ return JptJaxbUiIcons.XML_ELEMENTS;
+ }
else if (MappingKeys.XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
return JptJaxbUiIcons.XML_TRANSIENT;
}
else if (MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) {
return JptJaxbUiIcons.XML_VALUE;
}
+
//return the JAXB_CONTENT icon instead of null, might as well have an icon if one is not defined
return JptJaxbUiIcons.JAXB_CONTENT;
}
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 13cc8458a0..d89b9c0605 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
@@ -10,8 +10,8 @@
package org.eclipse.jpt.jaxb.ui.internal;
@SuppressWarnings("nls")
-public class JptJaxbUiIcons
-{
+public class JptJaxbUiIcons {
+
// **************** General icons **************************************
public static final String JAXB_CONTENT = "full/obj16/jaxb_content";
@@ -22,25 +22,28 @@ public class JptJaxbUiIcons
public static final String TRANSIENT_CLASS = "full/obj16/transient_class";
public static final String REGISTRY = "full/obj16/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";
+ public static final String XML_ATTRIBUTE = "full/obj16/xml-attribute";
+ public static final String XML_ELEMENT = "full/obj16/xml-element";
+ public static final String XML_ELEMENT_REF = "full/obj16/xml-element-ref";
+ public static final String XML_ELEMENT_REFS = "full/obj16/xml-element-refs";
+ public static final String XML_ELEMENTS = "full/obj16/xml-elements";
+
+ public static final String XML_TRANSIENT = "full/obj16/xml-transient";
+ public static final String XML_VALUE = "full/obj16/xml-value";
+ public static final String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping";
+
public static final String PERSISTENT_FIELD = "full/obj16/persistent_field";
public static final String PERSISTENT_PROPERTY = "full/obj16/persistent_property";
public static final String ENUM_CONSTANT = "full/obj16/enum_constant";
- public static final String SCHEMA_GEN = "full/wizban/NewXSD";
-
+
// **************** Wizard icons *******************************************
-
+
+ public static final String SCHEMA_GEN = "full/wizban/NewXSD";
+
public static final String SCHEMA_GEN_WIZ_BANNER = "full/wizban/NewXSD";
public static final String CLASSES_GEN_WIZ_BANNER = "full/wizban/newclass_wiz";
public static final String JAXB_WIZ_BANNER = "full/wizban/new_jaxb_prj_wiz";
-
-
- public static final String XML_ANY_ATTRIBUTE = "full/obj16/xml-any-attribute";
- public static final String XML_ANY_ELEMENT = "full/obj16/xml-any-element";
- public static final String XML_ATTRIBUTE = "full/obj16/xml-attribute";
- public static final String XML_ELEMENT = "full/obj16/xml-element";
- public static final String XML_TRANSIENT = "full/obj16/xml-transient";
- public static final String XML_VALUE = "full/obj16/xml-value";
- public static final String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping";
-
}
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 7734572337..08ad6c8d98 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
@@ -37,7 +37,7 @@ public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory
}
- private GenericJaxb_2_1_NavigatorItemLabelProviderFactory() {
+ protected GenericJaxb_2_1_NavigatorItemLabelProviderFactory() {
super();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java
index 10da002510..175f5e6d0d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java
@@ -28,7 +28,7 @@ public class GenericJaxb_2_1_NavigatorUi
}
- private GenericJaxb_2_1_NavigatorUi() {
+ protected GenericJaxb_2_1_NavigatorUi() {
super();
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
index d76311ba11..e3864f284e 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
@@ -27,6 +27,8 @@ public class JaxbJavaResourceModelTests {
suite.addTestSuite(XmlElementAnnotationTests.class);
suite.addTestSuite(XmlElementDeclAnnotationTests.class);
suite.addTestSuite(XmlElementRefAnnotationTests.class);
+ suite.addTestSuite(XmlElementRefsAnnotationTests.class);
+ suite.addTestSuite(XmlElementsAnnotationTests.class);
suite.addTestSuite(XmlElementWrapperAnnotationTests.class);
suite.addTestSuite(XmlEnumAnnotationTests.class);
suite.addTestSuite(XmlEnumValueAnnotationTests.class);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
index 2706f40ea6..06e9c05d63 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
@@ -18,97 +18,103 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
@SuppressWarnings("nls")
-public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
-
+public class XmlElementAnnotationTests
+ extends JaxbJavaResourceModelTestCase {
+
private static final String XML_ELEMENT_NAME = "elementName";
private static final String XML_ELEMENT_NAMESPACE = "XmlElementNamespace";
private static final String XML_ELEMENT_DEFAULT_VALUE = "myDefaultValue";
private static final String XML_ELEMENT_TYPE = "String";
-
+
+
public XmlElementAnnotationTests(String name) {
super(name);
}
-
+
+
private ICompilationUnit createTestXmlElement() throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElement");
}
});
}
-
+
private ICompilationUnit createTestXmlElementWithName() throws Exception {
return this.createTestXmlElementWithStringElement("name", XML_ELEMENT_NAME);
}
-
+
private ICompilationUnit createTestXmlElementWithNamespace() throws Exception {
return this.createTestXmlElementWithStringElement("namespace", XML_ELEMENT_NAMESPACE);
}
-
+
private ICompilationUnit createTestXmlElementWithDefaultValue() throws Exception {
return this.createTestXmlElementWithStringElement("defaultValue", XML_ELEMENT_DEFAULT_VALUE);
}
-
+
private ICompilationUnit createTestXmlElementWithStringElement(final String element, final String value) throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElement(" + element + " = \"" + value + "\")");
}
});
}
-
+
private ICompilationUnit createTestXmlElementWithBooleanElement(final String booleanElement) throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElement(" + booleanElement + " = true)");
}
});
}
-
+
private ICompilationUnit createTestXmlElementWithType() throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class)");
}
});
}
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestXmlElementWithName();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
- assertTrue(xmlElementAnnotation != null);
- assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
- }
-
+
+
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertTrue(xmlElementAnnotation != null);
assertNull(xmlElementAnnotation.getName());
assertNull(xmlElementAnnotation.getNamespace());
@@ -117,166 +123,182 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
assertNull(xmlElementAnnotation.getRequired());
assertNull(xmlElementAnnotation.getType());
}
-
+
+ public void testGetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
+ }
+
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertNull(xmlElementAnnotation.getName());
+
xmlElementAnnotation.setName(XML_ELEMENT_NAME);
+
assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
-
assertSourceContains("@XmlElement(name = \"" + XML_ELEMENT_NAME + "\")", cu);
-
+
xmlElementAnnotation.setName(null);
+
assertNull(xmlElementAnnotation.getName());
-
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("@XmlElement(name = \"" + XML_ELEMENT_NAME + "\")", cu);
}
-
+
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
}
-
+
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertNull(xmlElementAnnotation.getNamespace());
+
xmlElementAnnotation.setNamespace(XML_ELEMENT_NAMESPACE);
+
assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
-
assertSourceContains("@XmlElement(namespace = \"" + XML_ELEMENT_NAMESPACE + "\")", cu);
-
+
xmlElementAnnotation.setNamespace(null);
+
assertNull(xmlElementAnnotation.getNamespace());
-
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("@XmlElement(namespace = \"" + XML_ELEMENT_NAMESPACE + "\")", cu);
}
-
+
public void testGetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithDefaultValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
}
-
+
public void testSetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertNull(xmlElementAnnotation.getDefaultValue());
+
xmlElementAnnotation.setDefaultValue(XML_ELEMENT_DEFAULT_VALUE);
+
assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
-
assertSourceContains("@XmlElement(defaultValue = \"" + XML_ELEMENT_DEFAULT_VALUE + "\")", cu);
-
+
xmlElementAnnotation.setDefaultValue(null);
+
assertNull(xmlElementAnnotation.getDefaultValue());
-
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("@XmlElement(defaultValue = \"" + XML_ELEMENT_DEFAULT_VALUE + "\")", cu);
}
-
+
public void testGetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("nillable");
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
-
+
assertEquals(Boolean.TRUE, xmlElementAnnotation.getNillable());
}
-
+
public void testSetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
-
+
assertNotNull(xmlElementAnnotation);
assertNull(xmlElementAnnotation.getNillable());
-
+
xmlElementAnnotation.setNillable(Boolean.FALSE);
+
assertEquals(Boolean.FALSE, xmlElementAnnotation.getNillable());
-
assertSourceContains("@XmlElement(nillable = false)", cu);
-
+
xmlElementAnnotation.setNillable(null);
+
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("nillable", cu);
}
-
+
public void testGetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("required");
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
-
+
assertEquals(Boolean.TRUE, xmlElementAnnotation.getRequired());
}
-
+
public void testSetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
-
+
assertNotNull(xmlElementAnnotation);
assertNull(xmlElementAnnotation.getRequired());
-
+
xmlElementAnnotation.setRequired(Boolean.FALSE);
+
assertEquals(Boolean.FALSE, xmlElementAnnotation.getRequired());
-
assertSourceContains("@XmlElement(required = false)", cu);
-
+
xmlElementAnnotation.setRequired(null);
+
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("required", cu);
}
-
+
public void testGetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithType();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
assertEquals("java.lang." + XML_ELEMENT_TYPE, xmlElementAnnotation.getFullyQualifiedTypeName());
}
-
+
public void testSetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
+
assertNull(xmlElementAnnotation.getType());
+
xmlElementAnnotation.setType(XML_ELEMENT_TYPE);
+
assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
-
assertSourceContains("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class", cu);
-
+
xmlElementAnnotation.setType(null);
+
assertNull(xmlElementAnnotation.getType());
-
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class", cu);
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
index c2908ebcd7..5700eacefe 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
@@ -18,174 +18,175 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
@SuppressWarnings("nls")
-public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase {
-
+public class XmlElementRefAnnotationTests
+ extends JaxbJavaResourceModelTestCase {
+
private static final String XML_ELEMENT_REF_NAME = "elementName";
private static final String XML_ELEMENT_REF_NAMESPACE = "XmlElementRefNamespace";
private static final String XML_ELEMENT_REF_TYPE = "String";
-
+
+
public XmlElementRefAnnotationTests(String name) {
super(name);
}
-
+
+
private ICompilationUnit createTestXmlElementRef() throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElementRef");
}
});
}
-
+
private ICompilationUnit createTestXmlElementRefWithName() throws Exception {
return this.createTestXmlElementRefWithStringElement("name", XML_ELEMENT_REF_NAME);
}
-
+
private ICompilationUnit createTestXmlElementRefWithNamespace() throws Exception {
return this.createTestXmlElementRefWithStringElement("namespace", XML_ELEMENT_REF_NAMESPACE);
}
-
+
private ICompilationUnit createTestXmlElementRefWithStringElement(final String element, final String value) throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElementRef(" + element + " = \"" + value + "\")");
}
});
}
-
+
private ICompilationUnit createTestXmlElementRefWithType() throws Exception {
+
return this.createTestType(new DefaultAnnotationWriter() {
+
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF);
}
+
@Override
public void appendIdFieldAnnotationTo(StringBuilder sb) {
sb.append("@XmlElementRef(type = " + XML_ELEMENT_REF_TYPE + ".class)");
}
});
}
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestXmlElementRefWithName();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
- assertTrue(xmlElementRefAnnotation != null);
- assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
- }
-
+
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertTrue(xmlElementRefAnnotation != null);
assertNull(xmlElementRefAnnotation.getName());
assertNull(xmlElementRefAnnotation.getNamespace());
assertNull(xmlElementRefAnnotation.getType());
}
-
+
+ public void testGetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
+ assertTrue(xmlElementRefAnnotation != null);
+ assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
+ }
+
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertNull(xmlElementRefAnnotation.getName());
+
xmlElementRefAnnotation.setName(XML_ELEMENT_REF_NAME);
+
assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
-
assertSourceContains("@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME + "\")", cu);
-
+
xmlElementRefAnnotation.setName(null);
+
assertNull(xmlElementRefAnnotation.getName());
-
assertSourceContains("@XmlElementRef", cu);
assertSourceDoesNotContain("@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME + "\")", cu);
}
-
+
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertTrue(xmlElementRefAnnotation != null);
assertEquals(XML_ELEMENT_REF_NAMESPACE, xmlElementRefAnnotation.getNamespace());
}
-
+
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertNull(xmlElementRefAnnotation.getNamespace());
+
xmlElementRefAnnotation.setNamespace(XML_ELEMENT_REF_NAMESPACE);
+
assertEquals(XML_ELEMENT_REF_NAMESPACE, xmlElementRefAnnotation.getNamespace());
-
assertSourceContains("@XmlElementRef(namespace = \"" + XML_ELEMENT_REF_NAMESPACE + "\")", cu);
-
+
xmlElementRefAnnotation.setNamespace(null);
+
assertNull(xmlElementRefAnnotation.getNamespace());
-
assertSourceContains("@XmlElementRef", cu);
assertSourceDoesNotContain("@XmlElementRef(namespace = \"" + XML_ELEMENT_REF_NAMESPACE + "\")", cu);
}
-
+
public void testGetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithType();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertTrue(xmlElementRefAnnotation != null);
assertEquals(XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getType());
assertEquals("java.lang." + XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getFullyQualifiedTypeName());
}
-
+
public void testSetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
+ XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF);
+
assertNull(xmlElementRefAnnotation.getType());
+
xmlElementRefAnnotation.setType(XML_ELEMENT_REF_TYPE);
+
assertEquals(XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getType());
-
assertSourceContains("@XmlElementRef(type = " + XML_ELEMENT_REF_TYPE + ".class", cu);
-
+
xmlElementRefAnnotation.setType(null);
+
assertNull(xmlElementRefAnnotation.getType());
-
assertSourceContains("@XmlElementRef", cu);
assertSourceDoesNotContain("@XmlElementRef(type = " + XML_ELEMENT_REF_TYPE + ".class", cu);
}
-
- public void testAddXmlElementRefAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestXmlElementRefWithName();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
- assertTrue(xmlElementRefAnnotation != null);
- assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
-
- XmlElementRefAnnotation xmlElementRefAnnotation2 = (XmlElementRefAnnotation) resourceAttribute.addAnnotation(1, JAXB.XML_ELEMENT_REF);
- xmlElementRefAnnotation2.setName("Foo");
- assertSourceContains("@XmlElementRefs({ @XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME + "\"), @XmlElementRef(name = \"Foo\") })", cu);
- }
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefsAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefsAnnotationTests.java
new file mode 100644
index 0000000000..cf82aae130
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefsAnnotationTests.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation;
+
+
+public class XmlElementRefsAnnotationTests
+ extends JaxbJavaResourceModelTestCase {
+
+ private static final String XML_ELEMENT_REF_NAME = "elementName";
+ private static final String XML_ELEMENT_REF_NAMESPACE = "XmlElementRefNamespace";
+ private static final String XML_ELEMENT_REF_TYPE = "String";
+
+
+ public XmlElementRefsAnnotationTests(String name) {
+ super(name);
+ }
+
+
+ private ICompilationUnit createTestXmlElementRef() throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF, JAXB.XML_ELEMENT_REFS);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElementRefs(@XmlElementRef)");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementRefWithName() throws Exception {
+ return this.createTestXmlElementRefWithStringElement("name", XML_ELEMENT_REF_NAME);
+ }
+
+ private ICompilationUnit createTestXmlElementRefWithNamespace() throws Exception {
+ return this.createTestXmlElementRefWithStringElement("namespace", XML_ELEMENT_REF_NAMESPACE);
+ }
+
+ private ICompilationUnit createTestXmlElementRefWithStringElement(final String element, final String value) throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF, JAXB.XML_ELEMENT_REFS);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElementRefs(@XmlElementRef(" + element + " = \"" + value + "\"))");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementRefWithType() throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF, JAXB.XML_ELEMENT_REFS);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElementRefs(@XmlElementRef(type = " + XML_ELEMENT_REF_TYPE + ".class))");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementRefWithAll() throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENT_REF, JAXB.XML_ELEMENT_REFS);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElementRefs(@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE + "\", type = " + XML_ELEMENT_REF_TYPE + ".class))");
+ }
+ });
+ }
+
+
+ private XmlElementRefAnnotation getXmlElementRefAnnotation(JavaResourceAttribute resourceAttribute) {
+ XmlElementRefsAnnotation refsAnnotation
+ = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
+ return refsAnnotation.xmlElementRefAt(0);
+ }
+
+ private XmlElementRefAnnotation addXmlElementRefAnnotation(int index, JavaResourceAttribute resourceAttribute) {
+ XmlElementRefsAnnotation refsAnnotation
+ = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
+ return refsAnnotation.addXmlElementRef(index);
+ }
+
+ private void removeXmlElementRefAnnotation(int index, JavaResourceAttribute resourceAttribute) {
+ XmlElementRefsAnnotation refsAnnotation
+ = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
+ refsAnnotation.removeXmlElementRef(index);
+ }
+
+ public void testGetNull() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRef();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementRefAnnotation != null);
+ assertNull(xmlElementRefAnnotation.getName());
+ assertNull(xmlElementRefAnnotation.getNamespace());
+ assertNull(xmlElementRefAnnotation.getType());
+ }
+
+ public void testGetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementRefAnnotation != null);
+ assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
+ }
+
+ public void testSetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRef();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertNull(xmlElementRefAnnotation.getName());
+
+ xmlElementRefAnnotation.setName(XML_ELEMENT_REF_NAME);
+ assertEquals(XML_ELEMENT_REF_NAME, xmlElementRefAnnotation.getName());
+
+ assertSourceContains("@XmlElementRefs(@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME + "\"))", cu);
+
+ xmlElementRefAnnotation.setName(null);
+ assertNull(xmlElementRefAnnotation.getName());
+
+ assertSourceContains("@XmlElementRefs(@XmlElementRef)", cu);
+ }
+
+ public void testGetNamespace() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithNamespace();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementRefAnnotation != null);
+ assertEquals(XML_ELEMENT_REF_NAMESPACE, xmlElementRefAnnotation.getNamespace());
+ }
+
+ public void testSetNamespace() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRef();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertNull(xmlElementRefAnnotation.getNamespace());
+
+ xmlElementRefAnnotation.setNamespace(XML_ELEMENT_REF_NAMESPACE);
+
+ assertEquals(XML_ELEMENT_REF_NAMESPACE, xmlElementRefAnnotation.getNamespace());
+ assertSourceContains("@XmlElementRefs(@XmlElementRef(namespace = \"" + XML_ELEMENT_REF_NAMESPACE + "\"))", cu);
+
+ xmlElementRefAnnotation.setNamespace(null);
+
+ assertNull(xmlElementRefAnnotation.getNamespace());
+ assertSourceContains("@XmlElementRefs(@XmlElementRef)", cu);
+ }
+
+ public void testGetType() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithType();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementRefAnnotation != null);
+ assertEquals(XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getType());
+ assertEquals("java.lang." + XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getFullyQualifiedTypeName());
+ }
+
+ public void testSetType() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRef();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementRefAnnotation xmlElementRefAnnotation = getXmlElementRefAnnotation(resourceAttribute);
+
+ assertNull(xmlElementRefAnnotation.getType());
+
+ xmlElementRefAnnotation.setType(XML_ELEMENT_REF_TYPE);
+
+ assertEquals(XML_ELEMENT_REF_TYPE, xmlElementRefAnnotation.getType());
+ assertSourceContains("@XmlElementRefs(@XmlElementRef(type = " + XML_ELEMENT_REF_TYPE + ".class))", cu);
+
+ xmlElementRefAnnotation.setType(null);
+
+ assertNull(xmlElementRefAnnotation.getType());
+ assertSourceContains("@XmlElementRefs(@XmlElementRef)", cu);
+ }
+
+ public void testAddXmlElementRef() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithAll();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementRefAnnotation(1, resourceAttribute);
+ XmlElementRefsAnnotation refsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
+
+ assertSourceContains(
+ "@XmlElementRefs({@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME
+ + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE
+ + "\", type = " + XML_ELEMENT_REF_TYPE
+ + ".class),@XmlElementRef})", cu);
+ assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
+ assertNotNull(refsAnnotation);
+ assertEquals(2, refsAnnotation.getXmlElementRefsSize());
+ }
+
+ public void testAddXmlElementRefToBeginningOfList() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithAll();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementRefAnnotation(1, resourceAttribute);
+ XmlElementRefsAnnotation refsAnnotation = (XmlElementRefsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REFS);
+
+ assertSourceContains(
+ "@XmlElementRefs({@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME
+ + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE
+ + "\", type = " + XML_ELEMENT_REF_TYPE
+ + ".class),@XmlElementRef})", cu);
+
+ addXmlElementRefAnnotation(0, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElementRefs({@XmlElementRef,@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME
+ + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE
+ + "\", type = " + XML_ELEMENT_REF_TYPE
+ + ".class), @XmlElementRef})", cu);
+
+ assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_REF));
+ assertNotNull(refsAnnotation);
+ assertEquals(3, refsAnnotation.getXmlElementRefsSize());
+ }
+
+ public void testRemoveXmlElementRef() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementRefWithAll();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementRefAnnotation(1, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElementRefs({@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME
+ + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE
+ + "\", type = " + XML_ELEMENT_REF_TYPE
+ + ".class),@XmlElementRef})", cu);
+
+ removeXmlElementRefAnnotation(1, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElementRef(name = \"" + XML_ELEMENT_REF_NAME
+ + "\", namespace = \"" + XML_ELEMENT_REF_NAMESPACE
+ + "\", type = " + XML_ELEMENT_REF_TYPE
+ + ".class)", cu);
+ }
+} \ 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/resource/java/XmlElementsAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementsAnnotationTests.java
new file mode 100644
index 0000000000..b085a2b3be
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementsAnnotationTests.java
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * 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.resource.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
+
+
+public class XmlElementsAnnotationTests
+ extends JaxbJavaResourceModelTestCase {
+
+ private static final String XML_ELEMENT_NAME = "elementName";
+ private static final String XML_ELEMENT_NAMESPACE = "XmlElementNamespace";
+ private static final String XML_ELEMENT_DEFAULT_VALUE = "myDefaultValue";
+ private static final String XML_ELEMENT_TYPE = "String";
+
+
+ public XmlElementsAnnotationTests(String name) {
+ super(name);
+ }
+
+
+ private ICompilationUnit createTestXmlElement() throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENTS, JAXB.XML_ELEMENT);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElements(@XmlElement)");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementWithName() throws Exception {
+ return this.createTestXmlElementWithStringElement("name", XML_ELEMENT_NAME);
+ }
+
+ private ICompilationUnit createTestXmlElementWithNamespace() throws Exception {
+ return this.createTestXmlElementWithStringElement("namespace", XML_ELEMENT_NAMESPACE);
+ }
+
+ private ICompilationUnit createTestXmlElementWithDefaultValue() throws Exception {
+ return this.createTestXmlElementWithStringElement("defaultValue", XML_ELEMENT_DEFAULT_VALUE);
+ }
+
+ private ICompilationUnit createTestXmlElementWithStringElement(final String element, final String value) throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENTS, JAXB.XML_ELEMENT);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElements(@XmlElement(" + element + " = \"" + value + "\"))");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementWithBooleanElement(final String booleanElement) throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENTS, JAXB.XML_ELEMENT);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElements(@XmlElement(" + booleanElement + " = true))");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlElementWithType() throws Exception {
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_ELEMENTS, JAXB.XML_ELEMENT);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlElements(@XmlElement(type = " + XML_ELEMENT_TYPE + ".class))");
+ }
+ });
+ }
+
+
+ private XmlElementAnnotation getXmlElementAnnotation(JavaResourceAttribute resourceAttribute) {
+ XmlElementsAnnotation annotation
+ = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
+ return annotation.xmlElementAt(0);
+ }
+
+ private XmlElementAnnotation addXmlElementAnnotation(int index, JavaResourceAttribute resourceAttribute) {
+ XmlElementsAnnotation annotation
+ = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
+ return annotation.addXmlElement(index);
+ }
+
+ private void removeXmlElementAnnotation(int index, JavaResourceAttribute resourceAttribute) {
+ XmlElementsAnnotation annotation
+ = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
+ annotation.removeXmlElement(index);
+ }
+
+
+ public void testGetNull() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertNull(xmlElementAnnotation.getName());
+ assertNull(xmlElementAnnotation.getNamespace());
+ assertNull(xmlElementAnnotation.getDefaultValue());
+ assertNull(xmlElementAnnotation.getNillable());
+ assertNull(xmlElementAnnotation.getRequired());
+ assertNull(xmlElementAnnotation.getType());
+ }
+
+ public void testGetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
+ }
+
+ public void testSetName() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNull(xmlElementAnnotation.getName());
+
+ xmlElementAnnotation.setName(XML_ELEMENT_NAME);
+
+ assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
+ assertSourceContains("@XmlElement(name = \"" + XML_ELEMENT_NAME + "\")", cu);
+
+ xmlElementAnnotation.setName(null);
+
+ assertNull(xmlElementAnnotation.getName());
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("@XmlElement(name = \"" + XML_ELEMENT_NAME + "\")", cu);
+ }
+
+ public void testGetNamespace() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithNamespace();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
+ }
+
+ public void testSetNamespace() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNull(xmlElementAnnotation.getNamespace());
+
+ xmlElementAnnotation.setNamespace(XML_ELEMENT_NAMESPACE);
+
+ assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
+ assertSourceContains("@XmlElement(namespace = \"" + XML_ELEMENT_NAMESPACE + "\")", cu);
+
+ xmlElementAnnotation.setNamespace(null);
+
+ assertNull(xmlElementAnnotation.getNamespace());
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("@XmlElement(namespace = \"" + XML_ELEMENT_NAMESPACE + "\")", cu);
+ }
+
+ public void testGetDefaultValue() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithDefaultValue();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
+ }
+
+ public void testSetDefaultValue() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNull(xmlElementAnnotation.getDefaultValue());
+
+ xmlElementAnnotation.setDefaultValue(XML_ELEMENT_DEFAULT_VALUE);
+
+ assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
+ assertSourceContains("@XmlElement(defaultValue = \"" + XML_ELEMENT_DEFAULT_VALUE + "\")", cu);
+
+ xmlElementAnnotation.setDefaultValue(null);
+
+ assertNull(xmlElementAnnotation.getDefaultValue());
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("@XmlElement(defaultValue = \"" + XML_ELEMENT_DEFAULT_VALUE + "\")", cu);
+ }
+
+ public void testGetNillable() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("nillable");
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertEquals(Boolean.TRUE, xmlElementAnnotation.getNillable());
+ }
+
+ public void testSetNillable() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNotNull(xmlElementAnnotation);
+ assertNull(xmlElementAnnotation.getNillable());
+
+ xmlElementAnnotation.setNillable(Boolean.FALSE);
+
+ assertEquals(Boolean.FALSE, xmlElementAnnotation.getNillable());
+ assertSourceContains("@XmlElement(nillable = false)", cu);
+
+ xmlElementAnnotation.setNillable(null);
+
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("nillable", cu);
+ }
+
+ public void testGetRequired() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("required");
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertEquals(Boolean.TRUE, xmlElementAnnotation.getRequired());
+ }
+
+ public void testSetRequired() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNotNull(xmlElementAnnotation);
+ assertNull(xmlElementAnnotation.getRequired());
+
+ xmlElementAnnotation.setRequired(Boolean.FALSE);
+
+ assertEquals(Boolean.FALSE, xmlElementAnnotation.getRequired());
+ assertSourceContains("@XmlElement(required = false)", cu);
+
+ xmlElementAnnotation.setRequired(null);
+
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("required", cu);
+ }
+
+ public void testGetType() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElementWithType();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertTrue(xmlElementAnnotation != null);
+ assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
+ assertEquals("java.lang." + XML_ELEMENT_TYPE, xmlElementAnnotation.getFullyQualifiedTypeName());
+ }
+
+ public void testSetType() throws Exception {
+ ICompilationUnit cu = this.createTestXmlElement();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ XmlElementAnnotation xmlElementAnnotation = getXmlElementAnnotation(resourceAttribute);
+
+ assertNull(xmlElementAnnotation.getType());
+
+ xmlElementAnnotation.setType(XML_ELEMENT_TYPE);
+
+ assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
+ assertSourceContains("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class", cu);
+
+ xmlElementAnnotation.setType(null);
+
+ assertNull(xmlElementAnnotation.getType());
+ assertSourceContains("@XmlElement", cu);
+ assertSourceDoesNotContain("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class", cu);
+ }
+
+ public void testAddXmlElement() throws Exception {
+ ICompilationUnit cu = createTestXmlElementWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementAnnotation(1, resourceAttribute);
+ XmlElementsAnnotation annotation = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
+
+ assertSourceContains(
+ "@XmlElements({@XmlElement(name = \"" + XML_ELEMENT_NAME + "\"),@XmlElement})",
+ cu);
+ assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
+ assertNotNull(annotation);
+ assertEquals(2, annotation.getXmlElementsSize());
+ }
+
+ public void testAddXmlElementToBeginningOfList() throws Exception {
+ ICompilationUnit cu = createTestXmlElementWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementAnnotation(1, resourceAttribute);
+ XmlElementsAnnotation annotation = (XmlElementsAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENTS);
+
+ assertSourceContains(
+ "@XmlElements({@XmlElement(name = \"" + XML_ELEMENT_NAME + "\"),@XmlElement})",
+ cu);
+
+ addXmlElementAnnotation(0, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElements({@XmlElement,@XmlElement(name = \"" + XML_ELEMENT_NAME + "\"), @XmlElement})",
+ cu);
+
+ assertNull(resourceAttribute.getAnnotation(JAXB.XML_ELEMENT));
+ assertNotNull(annotation);
+ assertEquals(3, annotation.getXmlElementsSize());
+ }
+
+ public void testRemoveXmlElement() throws Exception {
+ ICompilationUnit cu = createTestXmlElementWithName();
+ JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
+ addXmlElementAnnotation(1, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElements({@XmlElement(name = \"" + XML_ELEMENT_NAME + "\"),@XmlElement})",
+ cu);
+
+ removeXmlElementAnnotation(1, resourceAttribute);
+
+ assertSourceContains(
+ "@XmlElement(name = \"" + XML_ELEMENT_NAME + "\")",
+ cu);
+ }
+} \ No newline at end of file

Back to the top