diff options
Diffstat (limited to 'jaxb/plugins')
40 files changed, 728 insertions, 1764 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationProvider.java index 31e8d1198d..ae8b8e7003 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationProvider.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationProvider.java @@ -13,6 +13,7 @@ import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.jaxb.core.resource.java.Annotation; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; /** * This is used to provide type and attribute annotations. @@ -34,26 +35,41 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; * will almost certainly be broken (repeatedly) as the API evolves. */ public interface AnnotationProvider { - + /** * Return the names of the annotations. */ Iterable<String> getAnnotationNames(); - + + Iterable<String> getContainerAnnotationNames(); + + Iterable<String> getNestableAnnotationNames(); + + String getNestableAnnotationName(String containerAnnotationName); + + String getNestableElementName(String containerAnnotationName); + /** * Build an annotation with the specified name. * Throw an IllegalArgumentException if the specified name is unsupported. * @see #getAnnotationNames() */ Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName); - + + /** + * Build a nestable annotation with the specified name and index. + * Throw an IllegalArgumentException if the specified name is unsupported. + * @see #getNestableAnnotationNames() + */ + NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName, int index); + /** * Build an annotation for the specified JDT annotation. * Throw an IllegalArgumentException if the specified annotation is unsupported. * @see #getAnnotationNames() */ Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation); - + /** * Build a null annotation with the specified name. * Throw an IllegalArgumentException if the specified annotation is unsupported. diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java index 6023884958..c95ad909d1 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java @@ -12,6 +12,7 @@ package org.eclipse.jpt.jaxb.core.internal; import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition; import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; import org.eclipse.jpt.utility.internal.iterables.ArrayListIterable; import org.eclipse.jpt.utility.internal.iterables.ListIterable; @@ -23,6 +24,8 @@ public abstract class AbstractJaxbPlatformDefinition implements JaxbPlatformDefinition { private AnnotationDefinition[] annotationDefinitions; + + private NestableAnnotationDefinition[] nestableAnnotationDefinitions; private JaxbResourceModelProvider[] resourceModelProviders; @@ -53,6 +56,18 @@ public abstract class AbstractJaxbPlatformDefinition } protected abstract AnnotationDefinition[] buildAnnotationDefinitions(); + + + // ********** nestable annotation definitions ********** + + public NestableAnnotationDefinition[] getNestableAnnotationDefinitions() { + if (this.nestableAnnotationDefinitions == null) { + this.nestableAnnotationDefinitions = this.buildNestableAnnotationDefinitions(); + } + return this.nestableAnnotationDefinitions; + } + + protected abstract NestableAnnotationDefinition[] buildNestableAnnotationDefinitions(); // ********** resource models ********** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericAnnotationProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericAnnotationProvider.java index 6a521f991e..3b2da1153c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericAnnotationProvider.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericAnnotationProvider.java @@ -15,6 +15,8 @@ import org.eclipse.jpt.jaxb.core.AnnotationProvider; 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.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; import org.eclipse.jpt.utility.internal.iterables.ArrayIterable; import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; @@ -28,10 +30,13 @@ public final class GenericAnnotationProvider implements AnnotationProvider { private final AnnotationDefinition[] annotationDefinitions; + + private final NestableAnnotationDefinition[] nestableAnnotationDefinitions; - public GenericAnnotationProvider(AnnotationDefinition ... annotationDefinitions) { + public GenericAnnotationProvider(AnnotationDefinition[] annotationDefinitions, NestableAnnotationDefinition[] nestableAnnotationDefinitions) { super(); this.annotationDefinitions = annotationDefinitions; + this.nestableAnnotationDefinitions = nestableAnnotationDefinitions; } @@ -56,7 +61,25 @@ public final class GenericAnnotationProvider } }; } - + + public Iterable<String> getContainerAnnotationNames() { + return new TransformationIterable<NestableAnnotationDefinition, String>(getNestableAnnotationDefinitions()) { + @Override + protected String transform(NestableAnnotationDefinition annotationDefinition) { + return annotationDefinition.getContainerAnnotationName(); + } + }; + } + + public Iterable<String> getNestableAnnotationNames() { + return new TransformationIterable<NestableAnnotationDefinition, String>(getNestableAnnotationDefinitions()) { + @Override + protected String transform(NestableAnnotationDefinition annotationDefinition) { + return annotationDefinition.getNestableAnnotationName(); + } + }; + } + public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName) { return this.getAnnotationDefinition(annotationName).buildAnnotation(parent, element); } @@ -68,4 +91,38 @@ public final class GenericAnnotationProvider public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent, String annotationName) { return this.getAnnotationDefinition(annotationName).buildNullAnnotation(parent); } + + protected Iterable<NestableAnnotationDefinition> getNestableAnnotationDefinitions() { + return new ArrayIterable<NestableAnnotationDefinition>(this.nestableAnnotationDefinitions); + } + + protected NestableAnnotationDefinition getNestableAnnotationDefinition(String annotationName) { + for (NestableAnnotationDefinition annotationDefinition : this.nestableAnnotationDefinitions) { + if (annotationDefinition.getNestableAnnotationName().equals(annotationName)) { + return annotationDefinition; + } + } + return null; + } + + public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName, int index) { + return this.getNestableAnnotationDefinition(annotationName).buildAnnotation(parent, element, index); + } + + public String getNestableAnnotationName(String containerAnnotationName) { + return getNestableAnnotationDefinitionForContainer(containerAnnotationName).getNestableAnnotationName(); + } + + public String getNestableElementName(String containerAnnotationName) { + return getNestableAnnotationDefinitionForContainer(containerAnnotationName).getElementName(); + } + + private NestableAnnotationDefinition getNestableAnnotationDefinitionForContainer(String containerAnnotationName) { + for (NestableAnnotationDefinition nestableAnnotationDefinition : getNestableAnnotationDefinitions()) { + if (nestableAnnotationDefinition.getContainerAnnotationName().equals(containerAnnotationName)) { + return nestableAnnotationDefinition; + } + } + return null; + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java index f37bd8060e..3329a9c12f 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java @@ -21,9 +21,7 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypesAnnotation; import org.eclipse.jpt.utility.internal.iterables.ListIterable; public class GenericJavaPackageInfo @@ -160,7 +158,7 @@ public class GenericJavaPackageInfo } public XmlSchemaType addXmlSchemaType(int index) { - XmlSchemaTypeAnnotation annotation = (XmlSchemaTypeAnnotation) this.resourcePackage.addAnnotation(index, XmlSchemaTypeAnnotation.ANNOTATION_NAME, XmlSchemaTypesAnnotation.ANNOTATION_NAME); + XmlSchemaTypeAnnotation annotation = (XmlSchemaTypeAnnotation) this.resourcePackage.addAnnotation(index, XmlSchemaTypeAnnotation.ANNOTATION_NAME); return this.xmlSchemaTypeContainer.addContextElement(index, annotation); } @@ -169,12 +167,12 @@ public class GenericJavaPackageInfo } public void removeXmlSchemaType(int index) { - this.resourcePackage.removeAnnotation(index, XmlSchemaTypeAnnotation.ANNOTATION_NAME, XmlSchemaTypesAnnotation.ANNOTATION_NAME); + this.resourcePackage.removeAnnotation(index, XmlSchemaTypeAnnotation.ANNOTATION_NAME); this.xmlSchemaTypeContainer.removeContextElement(index); } public void moveXmlSchemaType(int targetIndex, int sourceIndex) { - this.resourcePackage.moveAnnotation(targetIndex, sourceIndex, XmlSchemaTypesAnnotation.ANNOTATION_NAME); + this.resourcePackage.moveAnnotation(targetIndex, sourceIndex, XmlSchemaTypeAnnotation.ANNOTATION_NAME); this.xmlSchemaTypeContainer.moveContextElement(targetIndex, sourceIndex); } @@ -188,7 +186,7 @@ public class GenericJavaPackageInfo @SuppressWarnings("unchecked") protected Iterable<XmlSchemaTypeAnnotation> getXmlSchemaTypeAnnotations() { - return (Iterable<XmlSchemaTypeAnnotation>) this.resourcePackage.getAnnotations(XmlSchemaTypeAnnotation.ANNOTATION_NAME, XmlSchemaTypesAnnotation.ANNOTATION_NAME); + return (Iterable<XmlSchemaTypeAnnotation>) this.resourcePackage.getAnnotations(XmlSchemaTypeAnnotation.ANNOTATION_NAME); } @@ -203,7 +201,7 @@ public class GenericJavaPackageInfo } public XmlJavaTypeAdapter addXmlJavaTypeAdapter(int index) { - XmlJavaTypeAdapterAnnotation annotation = (XmlJavaTypeAdapterAnnotation) this.resourcePackage.addAnnotation(index, XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME, XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME); + XmlJavaTypeAdapterAnnotation annotation = (XmlJavaTypeAdapterAnnotation) this.resourcePackage.addAnnotation(index, XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME); return this.xmlJavaTypeAdapterContainer.addContextElement(index, annotation); } @@ -212,12 +210,12 @@ public class GenericJavaPackageInfo } public void removeXmlJavaTypeAdapter(int index) { - this.resourcePackage.removeAnnotation(index, XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME, XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME); + this.resourcePackage.removeAnnotation(index, XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME); this.xmlJavaTypeAdapterContainer.removeContextElement(index); } public void moveXmlJavaTypeAdapter(int targetIndex, int sourceIndex) { - this.resourcePackage.moveAnnotation(targetIndex, sourceIndex, XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME); + this.resourcePackage.moveAnnotation(targetIndex, sourceIndex, XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME); this.xmlJavaTypeAdapterContainer.moveContextElement(targetIndex, sourceIndex); } @@ -231,7 +229,7 @@ public class GenericJavaPackageInfo @SuppressWarnings("unchecked") protected Iterable<XmlJavaTypeAdapterAnnotation> getXmlJavaTypeAdapterAnnotations() { - return (Iterable<XmlJavaTypeAdapterAnnotation>) this.resourcePackage.getAnnotations(XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME, XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME); + return (Iterable<XmlJavaTypeAdapterAnnotation>) this.resourcePackage.getAnnotations(XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME); } /** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinition.java index 70a119e6a8..1c1e21d5e4 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinition.java @@ -26,16 +26,13 @@ import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttributeAnnotationDe 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.XmlJavaTypeAdaptersAnnotationDefinition; 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; @@ -43,13 +40,13 @@ import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDef 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.XmlSchemaTypesAnnotationDefinition; 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.platform.JaxbPlatformDefinition; import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; public class Generic_2_1_JaxbPlatformDefinition extends AbstractJaxbPlatformDefinition @@ -84,32 +81,34 @@ public class Generic_2_1_JaxbPlatformDefinition XmlAnyElementAnnotationDefinition.instance(), XmlAttachmentRefAnnotationDefinition.instance(), XmlAttributeAnnotationDefinition.instance(), - XmlElementAnnotationDefinition.instance(), XmlElementDeclAnnotationDefinition.instance(), - XmlElementsAnnotationDefinition.instance(), - XmlElementRefAnnotationDefinition.instance(), - XmlElementRefsAnnotationDefinition.instance(), XmlElementWrapperAnnotationDefinition.instance(), XmlEnumAnnotationDefinition.instance(), XmlEnumValueAnnotationDefinition.instance(), XmlIDAnnotationDefinition.instance(), XmlIDREFAnnotationDefinition.instance(), XmlInlineBinaryDataAnnotationDefinition.instance(), - XmlJavaTypeAdapterAnnotationDefinition.instance(), - XmlJavaTypeAdaptersAnnotationDefinition.instance(), XmlListAnnotationDefinition.instance(), XmlMimeTypeAnnotationDefinition.instance(), XmlMixedAnnotationDefinition.instance(), XmlRegistryAnnotationDefinition.instance(), XmlRootElementAnnotationDefinition.instance(), XmlSchemaAnnotationDefinition.instance(), - XmlSchemaTypeAnnotationDefinition.instance(), - XmlSchemaTypesAnnotationDefinition.instance(), XmlSeeAlsoAnnotationDefinition.instance(), XmlTransientAnnotationDefinition.instance(), XmlTypeAnnotationDefinition.instance(), XmlValueAnnotationDefinition.instance()}; } + + @Override + protected NestableAnnotationDefinition[] buildNestableAnnotationDefinitions() { + return new NestableAnnotationDefinition[] { + XmlElementAnnotationDefinition.instance(), + XmlElementRefAnnotationDefinition.instance(), + XmlJavaTypeAdapterAnnotationDefinition.instance(), + XmlSchemaTypeAnnotationDefinition.instance() + }; + } // ********** resource models ********** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformImpl.java index a56bab86ee..36daaa7e71 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformImpl.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformImpl.java @@ -36,7 +36,7 @@ public final class JaxbPlatformImpl public JaxbPlatformImpl(JaxbPlatformDefinition jaxbPlatformDefinition) { super(); this.platformDefinition = jaxbPlatformDefinition; - this.annotationProvider = new GenericAnnotationProvider(this.platformDefinition.getAnnotationDefinitions()); + this.annotationProvider = new GenericAnnotationProvider(this.platformDefinition.getAnnotationDefinitions(), this.platformDefinition.getNestableAnnotationDefinitions()); } 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 8ca806b342..1d203c0c32 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 @@ -15,24 +15,26 @@ import org.eclipse.jpt.core.utility.jdt.Attribute; import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementAnnotation; 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.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation; /** * javax.xml.bind.annotation.XmlElement */ public final class XmlElementAnnotationDefinition - implements AnnotationDefinition + implements NestableAnnotationDefinition { // singleton - private static final AnnotationDefinition INSTANCE = new XmlElementAnnotationDefinition(); + private static final NestableAnnotationDefinition INSTANCE = new XmlElementAnnotationDefinition(); /** * Return the singleton. */ - public static AnnotationDefinition instance() { + public static NestableAnnotationDefinition instance() { return INSTANCE; } @@ -43,12 +45,8 @@ public final class XmlElementAnnotationDefinition super(); } - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlElementAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); + public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { + return SourceXmlElementAnnotation.buildSourceXmlElementAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement, index); } public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { @@ -59,4 +57,15 @@ public final class XmlElementAnnotationDefinition return XmlElementAnnotation.ANNOTATION_NAME; } + public String getNestableAnnotationName() { + return JAXB.XML_ELEMENT; + } + + public String getContainerAnnotationName() { + return JAXB.XML_ELEMENTS; + } + + public String getElementName() { + return JAXB.XML_ELEMENTS__VALUE; + } } 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 a5a7b804ff..065b162b66 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,24 +15,25 @@ import org.eclipse.jpt.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.JavaResourceAttribute; -import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; /** * javax.xml.bind.annotation.XmlElementRef */ public final class XmlElementRefAnnotationDefinition - implements AnnotationDefinition + implements NestableAnnotationDefinition { // singleton - private static final AnnotationDefinition INSTANCE = new XmlElementRefAnnotationDefinition(); + private static final NestableAnnotationDefinition INSTANCE = new XmlElementRefAnnotationDefinition(); /** * Return the singleton. */ - public static AnnotationDefinition instance() { + public static NestableAnnotationDefinition instance() { return INSTANCE; } @@ -43,8 +44,8 @@ public final class XmlElementRefAnnotationDefinition super(); } - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlElementRefAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement); + public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { + return SourceXmlElementRefAnnotation.buildSourceXmlElementRefAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement, index); } public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { @@ -54,9 +55,17 @@ public final class XmlElementRefAnnotationDefinition public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { return new BinaryXmlElementRefAnnotation(parent, jdtAnnotation); } + + public String getNestableAnnotationName() { + return JAXB.XML_ELEMENT_REF; + } + + public String getContainerAnnotationName() { + return JAXB.XML_ELEMENT_REFS; + } - public String getAnnotationName() { - return XmlElementRefAnnotation.ANNOTATION_NAME; + 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 deleted file mode 100644 index 9726905af0..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementRefsAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.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.JavaResourceAnnotatedElement; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute; -import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation; - -/** - * javax.xml.bind.annotation.XmlElementRefs - */ -public final 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((JavaResourceAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return XmlElementRefsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java deleted file mode 100644 index 2440c8d03d..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementsAnnotation; -import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementsAnnotation; -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.JavaResourceAttribute; -import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation; - -/** - * javax.xml.bind.annotation.XmlElements - */ -public final class XmlElementsAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new XmlElementsAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private XmlElementsAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlElementsAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryXmlElementsAnnotation((JavaResourceAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return XmlElementsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java index 8578353b47..5c9282b04f 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java @@ -14,23 +14,24 @@ import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlJavaTypeAdapterAnnotation; import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlJavaTypeAdapterAnnotation; 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.XmlJavaTypeAdapterAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; /** * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapterAnnotation */ public final class XmlJavaTypeAdapterAnnotationDefinition - implements AnnotationDefinition + implements NestableAnnotationDefinition { // singleton - private static final AnnotationDefinition INSTANCE = new XmlJavaTypeAdapterAnnotationDefinition(); + private static final NestableAnnotationDefinition INSTANCE = new XmlJavaTypeAdapterAnnotationDefinition(); /** * Return the singleton. */ - public static AnnotationDefinition instance() { + public static NestableAnnotationDefinition instance() { return INSTANCE; } @@ -41,20 +42,23 @@ public final class XmlJavaTypeAdapterAnnotationDefinition super(); } - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); + public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { + return SourceXmlJavaTypeAdapterAnnotation.buildSourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement, index); } public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { return new BinaryXmlJavaTypeAdapterAnnotation(parent, jdtAnnotation); } - public String getAnnotationName() { - return XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME; + public String getNestableAnnotationName() { + return JAXB.XML_JAVA_TYPE_ADAPTER; } + public String getContainerAnnotationName() { + return JAXB.XML_JAVA_TYPE_ADAPTERS; + } + + public String getElementName() { + return JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE; + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java deleted file mode 100644 index 7e49a99e86..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlJavaTypeAdaptersAnnotation; -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.JavaResourcePackage; -import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation; - -/** - * javax.xml.bind.annotation.adapters.XmlJavaTypeAdaptersAnnotation - */ -public final class XmlJavaTypeAdaptersAnnotationDefinition - implements AnnotationDefinition { - - // singleton - private static final AnnotationDefinition INSTANCE = new XmlJavaTypeAdaptersAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private XmlJavaTypeAdaptersAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlJavaTypeAdaptersAnnotation((JavaResourcePackage) parent, (AnnotatedPackage) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - // TODO - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypeAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypeAnnotationDefinition.java index 8a7e874403..52e1bcbd06 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypeAnnotationDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypeAnnotationDefinition.java @@ -14,23 +14,23 @@ import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlSchemaTypeAnnotation; 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.JavaResourceNode; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; public class XmlSchemaTypeAnnotationDefinition - implements AnnotationDefinition { + implements NestableAnnotationDefinition { // singleton - private static final AnnotationDefinition INSTANCE = new XmlSchemaTypeAnnotationDefinition(); + private static final NestableAnnotationDefinition INSTANCE = new XmlSchemaTypeAnnotationDefinition(); /** * Return the singleton. */ - public static AnnotationDefinition instance() { + public static NestableAnnotationDefinition instance() { return INSTANCE; } @@ -38,22 +38,24 @@ public class XmlSchemaTypeAnnotationDefinition private XmlSchemaTypeAnnotationDefinition() { super(); } - - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlSchemaTypeAnnotation((JavaResourceNode) parent, (AnnotatedPackage) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); + + public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { + return SourceXmlSchemaTypeAnnotation.buildSourceXmlSchemaTypeAnnotation(parent, (AnnotatedPackage) annotatedElement, index); } public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - // TODO throw new UnsupportedOperationException(); } - public String getAnnotationName() { + public String getNestableAnnotationName() { return JAXB.XML_SCHEMA_TYPE; } + + public String getContainerAnnotationName() { + return JAXB.XML_SCHEMA_TYPES; + } + + public String getElementName() { + return JAXB.XML_SCHEMA_TYPES__VALUE; + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypesAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypesAnnotationDefinition.java deleted file mode 100644 index e583951315..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaTypesAnnotationDefinition.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlSchemaTypesAnnotation; -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.JavaResourcePackage; - - -public class XmlSchemaTypesAnnotationDefinition - implements AnnotationDefinition { - - // singleton - private static final AnnotationDefinition INSTANCE = new XmlSchemaTypesAnnotationDefinition(); - - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - - private XmlSchemaTypesAnnotationDefinition() { - super(); - } - - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceXmlSchemaTypesAnnotation((JavaResourcePackage) parent, (AnnotatedPackage) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - // TODO - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return JAXB.XML_SCHEMA_TYPES; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryAnnotation.java index 4d4d02a961..5dd44ff4c6 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryAnnotation.java @@ -16,7 +16,6 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; import org.eclipse.jpt.jaxb.core.resource.java.Annotation; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; /** * JAR annotation @@ -90,8 +89,5 @@ public abstract class BinaryAnnotation public void moveAnnotation(@SuppressWarnings("unused") int index) { throw new UnsupportedOperationException(); } - public void initializeFrom(@SuppressWarnings("unused") NestableAnnotation oldAnnotation) { - throw new UnsupportedOperationException(); - } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryContainerAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryContainerAnnotation.java deleted file mode 100644 index cb3aa63ecd..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryContainerAnnotation.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jpt.jaxb.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; - -/** - * JAR annotations do not support most of the container annotation protocol. - */ -public abstract class BinaryContainerAnnotation<T extends NestableAnnotation> - extends BinaryAnnotation - implements ContainerAnnotation<T> -{ - - protected BinaryContainerAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getElementName() { - throw new UnsupportedOperationException(); - } - - public String getNestedAnnotationName() { - throw new UnsupportedOperationException(); - } - - public T addNestedAnnotation(int index) { - throw new UnsupportedOperationException(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - throw new UnsupportedOperationException(); - } - - public T moveNestedAnnotation(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public T removeNestedAnnotation(int index) { - throw new UnsupportedOperationException(); - } - - public void syncRemoveNestedAnnotations(int index) { - throw new UnsupportedOperationException(); - } - -} 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 deleted file mode 100644 index 36fe72441e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementRefsAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.binary; - -import java.util.Vector; -import org.eclipse.jdt.core.IAnnotation; -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; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - -/** - * javax.xml.bind.annotation.adapters.XmlElementRefs - */ -public class BinaryXmlElementRefsAnnotation - extends BinaryContainerAnnotation<XmlElementRefAnnotation> - implements XmlElementRefsAnnotation { - - private final Vector<XmlElementRefAnnotation> xmlElementRefs; - - - public BinaryXmlElementRefsAnnotation(JavaResourceAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.xmlElementRefs = this.buildXmlElementRefs(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterable<XmlElementRefAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlElementRefAnnotation>(this.xmlElementRefs); - } - - public int getNestedAnnotationsSize() { - return this.xmlElementRefs.size(); - } - - private Vector<XmlElementRefAnnotation> buildXmlElementRefs() { - Object[] jdtElementRefs = this.getJdtMemberValues(JAXB.XML_ELEMENT_REFS__VALUE); - Vector<XmlElementRefAnnotation> result = new Vector<XmlElementRefAnnotation>(jdtElementRefs.length); - for (Object jdtElementRef : jdtElementRefs) { - result.add(this.buildXmlElementRefAnnotation(jdtElementRef)); - } - return result; - } - - protected XmlElementRefAnnotation buildXmlElementRefAnnotation(Object jdtElementRef) { - return new BinaryXmlElementRefAnnotation(this, (IAnnotation) jdtElementRef); - } - - @Override - public void update() { - super.update(); - this.updateXmlElementRefs(); - } - - // TODO - private void updateXmlElementRefs() { - throw new UnsupportedOperationException(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java deleted file mode 100644 index 39a235a79d..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.binary; - -import java.util.Vector; -import org.eclipse.jdt.core.IAnnotation; -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.XmlElementAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - -/** - * javax.xml.bind.annotation.adapters.XmlElements - */ -public class BinaryXmlElementsAnnotation - extends BinaryContainerAnnotation<XmlElementAnnotation> - implements XmlElementsAnnotation { - - private final Vector<XmlElementAnnotation> xmlElements; - - - public BinaryXmlElementsAnnotation(JavaResourceAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.xmlElements = this.buildXmlElements(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterable<XmlElementAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlElementAnnotation>(this.xmlElements); - } - - public int getNestedAnnotationsSize() { - return this.xmlElements.size(); - } - - private Vector<XmlElementAnnotation> buildXmlElements() { - Object[] jdtElements = this.getJdtMemberValues(JAXB.XML_ELEMENTS__VALUE); - Vector<XmlElementAnnotation> result = new Vector<XmlElementAnnotation>(jdtElements.length); - for (Object jdtElement : jdtElements) { - result.add(this.buildXmlElementAnnotation(jdtElement)); - } - return result; - } - - protected XmlElementAnnotation buildXmlElementAnnotation(Object jdtElement) { - return new BinaryXmlElementAnnotation(this, (IAnnotation) jdtElement); - } - - @Override - public void update() { - super.update(); - this.updateXmlElements(); - } - - // TODO - private void updateXmlElements() { - throw new UnsupportedOperationException(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/AnnotationContainerTools.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/AnnotationContainerTools.java deleted file mode 100644 index 3da45631b9..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/AnnotationContainerTools.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.source; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.ArrayInitializer; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.MemberValuePair; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * Utility methods for manipulating annotation containers. - */ -public final class AnnotationContainerTools { - - /** - * Add a nested annotation to the specified annotation container - * at the specified index. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> NestableAnnotation addNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - // add a new annotation to the end of the list... - int sourceIndex = annotationContainer.getNestedAnnotationsSize(); - T nestedAnnotation = annotationContainer.addNestedAnnotation(sourceIndex); - nestedAnnotation.newAnnotation(); - // ...then move it to the specified index - moveNestedAnnotation(index, sourceIndex, annotationContainer); - return nestedAnnotation; - } - - /** - * Move the nested annotation at the specified source index in the - * specified annotation container to the specified target index. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> void moveNestedAnnotation(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { - if (targetIndex != sourceIndex) { - moveNestedAnnotation_(targetIndex, sourceIndex, annotationContainer); - } - } - - private static <T extends NestableAnnotation> void moveNestedAnnotation_(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { - NestableAnnotation nestedAnnotation = annotationContainer.moveNestedAnnotation(targetIndex, sourceIndex); - syncAstAnnotationsAfterMove(targetIndex, sourceIndex, annotationContainer, nestedAnnotation); - } - - /** - * An annotation was moved within the specified annotation container from - * the specified source index to the specified target index. - * Synchronize the AST annotations with the resource model annotation container, - * starting with the lower index to prevent overlap. - */ - private static <T extends NestableAnnotation> void syncAstAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer, NestableAnnotation nestedAnnotation) { - // move the Java annotation to the end of the list... - nestedAnnotation.moveAnnotation(annotationContainer.getNestedAnnotationsSize()); - // ...then shift the other AST annotations over one slot... - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.getNestedAnnotations()); - if (sourceIndex < targetIndex) { - for (int i = sourceIndex; i < targetIndex; i++) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } else { - for (int i = sourceIndex; i > targetIndex; i-- ) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } - // ...then move the AST annotation to the now empty slot at the target index - nestedAnnotation.moveAnnotation(targetIndex); - } - - /** - * Remove the nested annotation at the specified index in the - * specified annotation container. - * This method modifies both the resource model annotation container and the - * AST; with <em>no</em> change notification. - */ - public static <T extends NestableAnnotation> void removeNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - T nestedAnnotation = annotationContainer.removeNestedAnnotation(index); - nestedAnnotation.removeAnnotation(); - syncAstAnnotationsAfterRemove(index, annotationContainer); - } - - /** - * An annotation was removed from the specified annotation container at the - * specified index. - * Synchronize the AST annotations with the resource model annotation container, - * starting at the specified index to prevent overlap. - */ - private static <T extends NestableAnnotation> void syncAstAnnotationsAfterRemove(int index, AnnotationContainer<T> annotationContainer) { - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.getNestedAnnotations()); - for (int i = index; i < nestableAnnotations.size(); i++) { - // the indices are the same because the model annotations are - // already in the proper locations - it's the AST annotations that - // need to be moved to the matching location - nestableAnnotations.get(i).moveAnnotation(i); - } - } - - /** - * Initialize the specified resource model annotation container to be in - * sync with the specified AST. No change notification will occur. - */ - public static <T extends NestableAnnotation> void initialize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - // ignore the nested AST annotations themselves - // (maybe someday we can use them during initialization...) - int size = getNestedAstAnnotations(astRoot, annotationContainer).size(); - for (int i = 0; i < size; i++) { - T nestedAnnotation = annotationContainer.addNestedAnnotation(i); - nestedAnnotation.initialize(astRoot); - } - } - - /** - * Return a list of the nested AST annotations. - */ - private static <T extends NestableAnnotation> ArrayList<Annotation> getNestedAstAnnotations(CompilationUnit astRoot, AnnotationContainer<T> annotationContainer) { - ArrayList<Annotation> result = new ArrayList<Annotation>(); - Annotation astContainerAnnotation = annotationContainer.getAstAnnotation(astRoot); - if (astContainerAnnotation == null || astContainerAnnotation.isMarkerAnnotation()) { - // no nested annotations - } - else if (astContainerAnnotation.isSingleMemberAnnotation()) { - if (annotationContainer.getElementName().equals("value")) { //$NON-NLS-1$ - Expression ex = ((SingleMemberAnnotation) astContainerAnnotation).getValue(); - addAstAnnotationsTo(ex, annotationContainer.getNestedAnnotationName(), result); - } else { - // no nested annotations - } - } - else if (astContainerAnnotation.isNormalAnnotation()) { - MemberValuePair pair = getMemberValuePair((NormalAnnotation) astContainerAnnotation, annotationContainer.getElementName()); - if (pair == null) { - // no nested annotations - } else { - addAstAnnotationsTo(pair.getValue(), annotationContainer.getNestedAnnotationName(), result); - } - } - return result; - } - - /** - * Add whatever annotations are represented by the specified expression to - * the specified list. Do not add null to the list for any non-annotation expression. - */ - private static void addAstAnnotationsTo(Expression expression, String annotationName, ArrayList<Annotation> astAnnotations) { - if (expression == null) { - //do not add null to the list, not sure how we would get here... - } - else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { - addAstAnnotationsTo((ArrayInitializer) expression, annotationName, astAnnotations); - } - else { - Annotation astAnnotation = getAstAnnotation_(expression, annotationName); - if (astAnnotation != null) { - astAnnotations.add(astAnnotation); - } - } - } - - private static void addAstAnnotationsTo(ArrayInitializer arrayInitializer, String annotationName, ArrayList<Annotation> astAnnotations) { - @SuppressWarnings("unchecked") - List<Expression> expressions = arrayInitializer.expressions(); - for (Expression expression : expressions) { - Annotation astAnnotation = getAstAnnotation(expression, annotationName); - if (astAnnotation != null) { - astAnnotations.add(astAnnotation); - } - } - } - - /** - * If the specified expression is an annotation with the specified name, return it; - * otherwise return null. - */ - private static Annotation getAstAnnotation(Expression expression, String annotationName) { - // not sure how the expression could be null... - return (expression == null) ? null : getAstAnnotation_(expression, annotationName); - } - - /** - * pre-condition: expression is not null - */ - private static Annotation getAstAnnotation_(Expression expression, String annotationName) { - switch (expression.getNodeType()) { - case ASTNode.NORMAL_ANNOTATION: - case ASTNode.SINGLE_MEMBER_ANNOTATION: - case ASTNode.MARKER_ANNOTATION: - Annotation astAnnotation = (Annotation) expression; - if (getQualifiedName(astAnnotation).equals(annotationName)) { - return astAnnotation; - } - return null; - default: - return null; - } - } - - private static String getQualifiedName(Annotation astAnnotation) { - ITypeBinding typeBinding = astAnnotation.resolveTypeBinding(); - if (typeBinding != null) { - String resolvedName = typeBinding.getQualifiedName(); - if (resolvedName != null) { - return resolvedName; - } - } - return astAnnotation.getTypeName().getFullyQualifiedName(); - } - - private static MemberValuePair getMemberValuePair(NormalAnnotation annotation, String elementName) { - @SuppressWarnings("unchecked") - List<MemberValuePair> pairs = annotation.values(); - for (MemberValuePair pair : pairs) { - if (pair.getName().getFullyQualifiedName().equals(elementName)) { - return pair; - } - } - return null; - } - - /** - * Synchronize the resource model annotations in the specified annotation - * container with those in the specified AST. Trigger the appropriate change - * notification. - */ - public static <T extends NestableAnnotation> void synchronize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - ArrayList<Annotation> astAnnotations = getNestedAstAnnotations(astRoot, annotationContainer); - Iterator<Annotation> astAnnotationStream = astAnnotations.iterator(); - - for (T nestedAnnotation : annotationContainer.getNestedAnnotations()) { - if (astAnnotationStream.hasNext()) { - // matching AST annotation is present - synchronize the nested annotation - astAnnotationStream.next(); // maybe someday we can pass this to the update - nestedAnnotation.synchronizeWith(astRoot); - } else { - // no more AST annotations - remove the remaining nested annotations and exit - annotationContainer.syncRemoveNestedAnnotations(astAnnotations.size()); - return; - } - } - - // add nested annotations for any remaining AST annotations - while (astAnnotationStream.hasNext()) { - annotationContainer.syncAddNestedAnnotation(astAnnotationStream.next()); - } - } - - private AnnotationContainerTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java index a32db337fa..8f2b27f5c4 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java @@ -9,13 +9,22 @@ ******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.resource.java.source; +import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Set; import java.util.Vector; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTVisitor; +import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.Expression; +import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.MarkerAnnotation; +import org.eclipse.jdt.core.dom.MemberValuePair; import org.eclipse.jdt.core.dom.NormalAnnotation; import org.eclipse.jdt.core.dom.SingleMemberAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; @@ -23,14 +32,14 @@ import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.jaxb.core.resource.java.Annotation; -import org.eclipse.jpt.jaxb.core.resource.java.ContainerAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode; import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.EmptyIterable; +import org.eclipse.jpt.utility.internal.iterables.EmptyListIterable; +import org.eclipse.jpt.utility.internal.iterables.ListIterable; import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable; +import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; /** * Java source annotated element (annotations) @@ -46,6 +55,10 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> */ final Vector<Annotation> annotations = new Vector<Annotation>(); + /** + * Nestable annotations keyed on nestable annotation name + */ + final Map<String, List<NestableAnnotation>> nestableAnnotations = new HashMap<String, List<NestableAnnotation>>(); // ********** construction/initialization ********** @@ -68,21 +81,147 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> /* private */ void addInitialAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot) { String jdtAnnotationName = ASTTools.resolveAnnotation(node); if (jdtAnnotationName != null) { - this.addInitialAnnotation(jdtAnnotationName, astRoot); + if (this.annotationIsValid(jdtAnnotationName)) { + if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates + Annotation annotation = this.buildAnnotation(jdtAnnotationName); + annotation.initialize(astRoot); + this.annotations.add(annotation); + } + } + else if(this.annotationIsValidNestable(jdtAnnotationName)) { + Vector<NestableAnnotation> annotations = new Vector<NestableAnnotation>(); + NestableAnnotation annotation = this.buildNestableAnnotation(jdtAnnotationName, 0); + annotations.add(annotation); + annotation.initialize(astRoot); + this.nestableAnnotations.put(jdtAnnotationName, annotations); + } + else if(this.annotationIsValidContainer(jdtAnnotationName)) { + String nestableAnnotationName = this.getNestableAnnotationName(jdtAnnotationName); + List<org.eclipse.jdt.core.dom.Annotation> nestedAnnotations = + this.getNestedAstAnnotations(node, this.getNestableElementName(jdtAnnotationName), nestableAnnotationName); + int index = 0; + Vector<NestableAnnotation> annotations = new Vector<NestableAnnotation>(); + for (org.eclipse.jdt.core.dom.Annotation nestedAstAnnotation : nestedAnnotations) { + NestableAnnotation annotation = this.buildNestableAnnotation(ASTTools.resolveAnnotation(nestedAstAnnotation), index++); + annotations.add(annotation); + annotation.initialize(astRoot); + } + this.nestableAnnotations.put(nestableAnnotationName, annotations); + } } } /** - * pre-condition: jdtAnnotationName is not null + * Return a list of the nested AST annotations. */ - void addInitialAnnotation(String jdtAnnotationName, CompilationUnit astRoot) { - if (this.annotationIsValid(jdtAnnotationName)) { - if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.annotations.add(annotation); + private ArrayList<org.eclipse.jdt.core.dom.Annotation> getNestedAstAnnotations(org.eclipse.jdt.core.dom.Annotation astContainerAnnotation, String elementName, String nestedAnnotationName) { + ArrayList<org.eclipse.jdt.core.dom.Annotation> result = new ArrayList<org.eclipse.jdt.core.dom.Annotation>(); + if (astContainerAnnotation == null || astContainerAnnotation.isMarkerAnnotation()) { + // no nested annotations + } + else if (astContainerAnnotation.isSingleMemberAnnotation()) { + if (elementName.equals("value")) { //$NON-NLS-1$ + Expression ex = ((SingleMemberAnnotation) astContainerAnnotation).getValue(); + addAstAnnotationsTo(ex, nestedAnnotationName, result); + } else { + // no nested annotations + } + } + else if (astContainerAnnotation.isNormalAnnotation()) { + MemberValuePair pair = this.getMemberValuePair((NormalAnnotation) astContainerAnnotation, elementName); + if (pair == null) { + // no nested annotations + } else { + addAstAnnotationsTo(pair.getValue(), nestedAnnotationName, result); + } + } + return result; + } + /** + * Add whatever annotations are represented by the specified expression to + * the specified list. Do not add null to the list for any non-annotation expression. + */ + private void addAstAnnotationsTo(Expression expression, String annotationName, ArrayList<org.eclipse.jdt.core.dom.Annotation> astAnnotations) { + if (expression == null) { + //do not add null to the list, not sure how we would get here... + } + else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { + this.addAstAnnotationsTo((ArrayInitializer) expression, annotationName, astAnnotations); + } + else { + org.eclipse.jdt.core.dom.Annotation astAnnotation = getAstAnnotation_(expression, annotationName); + if (astAnnotation != null) { + astAnnotations.add(astAnnotation); + } + } + } + + private void addAstAnnotationsTo(ArrayInitializer arrayInitializer, String annotationName, ArrayList<org.eclipse.jdt.core.dom.Annotation> astAnnotations) { + List<Expression> expressions = this.expressions(arrayInitializer); + for (Expression expression : expressions) { + org.eclipse.jdt.core.dom.Annotation astAnnotation = this.getAstAnnotation(expression, annotationName); + if (astAnnotation != null) { + astAnnotations.add(astAnnotation); + } + } + } + // minimize scope of suppressed warnings + @SuppressWarnings("unchecked") + private List<Expression> expressions(ArrayInitializer arrayInitializer) { + return arrayInitializer.expressions(); + } + + /** + * If the specified expression is an annotation with the specified name, return it; + * otherwise return null. + */ + private org.eclipse.jdt.core.dom.Annotation getAstAnnotation(Expression expression, String annotationName) { + // not sure how the expression could be null... + return (expression == null) ? null : getAstAnnotation_(expression, annotationName); + } + + /** + * pre-condition: expression is not null + */ + private org.eclipse.jdt.core.dom.Annotation getAstAnnotation_(Expression expression, String annotationName) { + switch (expression.getNodeType()) { + case ASTNode.NORMAL_ANNOTATION: + case ASTNode.SINGLE_MEMBER_ANNOTATION: + case ASTNode.MARKER_ANNOTATION: + org.eclipse.jdt.core.dom.Annotation astAnnotation = (org.eclipse.jdt.core.dom.Annotation) expression; + if (this.getQualifiedName(astAnnotation).equals(annotationName)) { + return astAnnotation; + } + return null; + default: + return null; + } + } + + private String getQualifiedName(org.eclipse.jdt.core.dom.Annotation astAnnotation) { + ITypeBinding typeBinding = astAnnotation.resolveTypeBinding(); + if (typeBinding != null) { + String resolvedName = typeBinding.getQualifiedName(); + if (resolvedName != null) { + return resolvedName; } } + return astAnnotation.getTypeName().getFullyQualifiedName(); + } + + private MemberValuePair getMemberValuePair(NormalAnnotation annotation, String elementName) { + List<MemberValuePair> pairs = this.values(annotation); + for (MemberValuePair pair : pairs) { + if (pair.getName().getFullyQualifiedName().equals(elementName)) { + return pair; + } + } + return null; + } + + @SuppressWarnings("unchecked") + protected List<MemberValuePair> values(NormalAnnotation na) { + return na.values(); } public void synchronizeWith(CompilationUnit astRoot) { @@ -109,26 +248,30 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); } - public Iterable<NestableAnnotation> getAnnotations(String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.getNestedAnnotations(); + public ListIterable<NestableAnnotation> getAnnotations(String nestableAnnotationName) { + List<NestableAnnotation> annotations = this.nestableAnnotations.get(nestableAnnotationName); + if (annotations != null) { + return new LiveCloneListIterable<NestableAnnotation>(annotations); } - NestableAnnotation nestableAnnotation = this.getNestableAnnotation(nestableAnnotationName); - if (nestableAnnotation != null) { - return new SingleElementIterable<NestableAnnotation>(nestableAnnotation); - } - return EmptyIterable.instance(); + return EmptyListIterable.instance(); } - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName); + public int getAnnotationsSize(String nestableAnnotationName) { + List<NestableAnnotation> annotations = this.nestableAnnotations.get(nestableAnnotationName); + return annotations == null ? 0 : annotations.size(); + } + + public NestableAnnotation getAnnotation(int index, String nestableAnnotationName) { + List<NestableAnnotation> annotations = this.nestableAnnotations.get(nestableAnnotationName); + return annotations == null ? null : annotations.get(index); + } + + private String getNestableAnnotationName(String containerAnnotationName) { + return getAnnotationProvider().getNestableAnnotationName(containerAnnotationName); } - private NestableAnnotation getNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getAnnotation(annotationName); + private String getNestableElementName(String containerAnnotationName) { + return getAnnotationProvider().getNestableElementName(containerAnnotationName); } public Annotation addAnnotation(String annotationName) { @@ -147,53 +290,51 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> * add a container annotation and move the stand-alone nested annotation to it * and add a new nested annotation to it also */ - public NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - // ignore any stand-alone nestable annotations and just add to the container annotation - return AnnotationContainerTools.addNestedAnnotation(index, containerAnnotation); - } - NestableAnnotation standAloneAnnotation = this.getNestableAnnotation(nestableAnnotationName); - if (standAloneAnnotation == null) { - // add a stand-alone nestable annotation since neither the nestable nor the container exist - return (NestableAnnotation) this.addAnnotation(nestableAnnotationName); - } - // move the stand-alone nestable annotation to a container and add another nestable - return this.addSecondNestedAnnotation(index, containerAnnotationName, standAloneAnnotation); + public NestableAnnotation addAnnotation(int index, String nestableAnnotationName) { + List<NestableAnnotation> nestableAnnotations = this.nestableAnnotations.get(nestableAnnotationName); + if (nestableAnnotations == null) { + nestableAnnotations = new Vector<NestableAnnotation>(); + this.nestableAnnotations.put(nestableAnnotationName, nestableAnnotations); + } + //build the new nestable annotation at the end of the list then move it to the correct location. + int sourceIndex = this.getAnnotationsSize(nestableAnnotationName); + NestableAnnotation annotation = this.buildNestableAnnotation(nestableAnnotationName, sourceIndex); + nestableAnnotations.add(sourceIndex, annotation); + annotation.newAnnotation(); + this.moveAnnotation(index, sourceIndex, nestableAnnotationName); + return annotation; + } + + public void moveAnnotation(int targetIndex, int sourceIndex, String nestableAnnotationName) { + List<NestableAnnotation> nestedAnnotations = this.nestableAnnotations.get(nestableAnnotationName); + NestableAnnotation nestedAnnotation = nestedAnnotations.get(sourceIndex); + CollectionTools.move(nestedAnnotations, targetIndex, sourceIndex); + + this.syncAstAnnotationsAfterMove(targetIndex, sourceIndex, nestedAnnotations, nestedAnnotation); } /** - * "move" the existing nestable annotation to a new container annotation and - * add a new nestable annotation at the specified index (which should be 0 or 1) + * An annotation was moved within the specified annotation container from + * the specified source index to the specified target index. + * Synchronize the AST annotations with the resource model annotation container, + * starting with the lower index to prevent overlap. */ - private NestableAnnotation addSecondNestedAnnotation(int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.buildContainerAnnotation(containerAnnotationName); - this.annotations.add(containerAnnotation); - containerAnnotation.newAnnotation(); - - NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotation(0); - nestedAnnotation0.newAnnotation(); - NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotation(1); - nestedAnnotation1.newAnnotation(); - this.removeAnnotation(standAloneAnnotation); - - if (index == 0) { - // adding new annotation at 0, so stand-alone is "copied" to slot 1 - nestedAnnotation1.initializeFrom(standAloneAnnotation); + private void syncAstAnnotationsAfterMove(int targetIndex, int sourceIndex, List<NestableAnnotation> nestedAnnotations, NestableAnnotation nestedAnnotation) { + // move the Java annotation to the end of the list... + nestedAnnotation.moveAnnotation(nestedAnnotations.size()); + // ...then shift the other AST annotations over one slot... + List<NestableAnnotation> nestableAnnotations = CollectionTools.list(nestedAnnotations); + if (sourceIndex < targetIndex) { + for (int i = sourceIndex; i < targetIndex; i++) { + nestableAnnotations.get(i).moveAnnotation(i); + } } else { - // adding new annotation at 1, so stand-alone is "copied" to slot 0 - nestedAnnotation0.initializeFrom(standAloneAnnotation); + for (int i = sourceIndex; i > targetIndex; i-- ) { + nestableAnnotations.get(i).moveAnnotation(i); + } } - - return (index == 0) ? nestedAnnotation0 : nestedAnnotation1; - } - - public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - this.moveAnnotation(targetIndex, sourceIndex, this.getContainerAnnotation(containerAnnotationName)); - } - - private void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation); + // ...then move the AST annotation to the now empty slot at the target index + nestedAnnotation.moveAnnotation(targetIndex); } public void removeAnnotation(String annotationName) { @@ -208,57 +349,51 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> annotation.removeAnnotation(); } - public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation == null) { // assume the index is 0 - this.removeAnnotation(this.getAnnotation(nestableAnnotationName)); - } else { - this.removeAnnotation(index, containerAnnotation); - } + public void removeAnnotation(int index, String nestableAnnotationName) { + NestableAnnotation nestableAnnotation = this.nestableAnnotations.get(nestableAnnotationName).remove(index); + nestableAnnotation.removeAnnotation(); + this.syncAstAnnotationsAfterRemove(index, this.nestableAnnotations.get(nestableAnnotationName)); } /** - * after we remove the nested annotation, check to see whether we need to - * either remove the container (if it is empty) or convert the last nested - * annotation to a stand-alone annotation + * An annotation was removed from the specified annotation container at the + * specified index. + * Synchronize the AST annotations with the resource model annotation container, + * starting at the specified index to prevent overlap. */ - private void removeAnnotation(int index, ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.removeNestedAnnotation(index, containerAnnotation); - switch (containerAnnotation.getNestedAnnotationsSize()) { - case 0: - this.removeAnnotation(containerAnnotation); - break; - case 1: - this.convertLastNestedAnnotation(containerAnnotation); - break; - default: - break; + private void syncAstAnnotationsAfterRemove(int index, List<NestableAnnotation> nestedAnnotations) { + for (int i = index; i < nestedAnnotations.size(); i++) { + // the indices are the same because the model annotations are + // already in the proper locations - it's the AST annotations that + // need to be moved to the matching location + nestedAnnotations.get(i).moveAnnotation(i); } } - /** - * convert the last nested annotation in the container to a stand-alone - * annotation - */ - private void convertLastNestedAnnotation(ContainerAnnotation<NestableAnnotation> containerAnnotation) { - NestableAnnotation lastNestedAnnotation = containerAnnotation.getNestedAnnotations().iterator().next(); - this.annotations.remove(containerAnnotation); - containerAnnotation.removeAnnotation(); + private boolean annotationIsValid(String annotationName) { + return CollectionTools.contains(this.getValidAnnotationNames(), annotationName); + } - NestableAnnotation standAloneAnnotation = this.buildNestableAnnotation(lastNestedAnnotation.getAnnotationName()); - this.annotations.add(standAloneAnnotation); - standAloneAnnotation.newAnnotation(); - standAloneAnnotation.initializeFrom(lastNestedAnnotation); + private boolean annotationIsValidContainer(String annotationName) { + return CollectionTools.contains(this.getValidContainerAnnotationNames(), annotationName); } - private boolean annotationIsValid(String annotationName) { - return CollectionTools.contains(this.getValidAnnotationNames(), annotationName); + private boolean annotationIsValidNestable(String annotationName) { + return CollectionTools.contains(this.getValidNestableAnnotationNames(), annotationName); } Iterable<String> getValidAnnotationNames() { return this.getAnnotationProvider().getAnnotationNames(); } + Iterable<String> getValidContainerAnnotationNames() { + return this.getAnnotationProvider().getContainerAnnotationNames(); + } + + Iterable<String> getValidNestableAnnotationNames() { + return this.getAnnotationProvider().getNestableAnnotationNames(); + } + Annotation buildAnnotation(String annotationName) { return this.getAnnotationProvider().buildAnnotation(this, this.annotatedElement, annotationName); } @@ -267,46 +402,51 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> return this.getAnnotationProvider().buildNullAnnotation(this, annotationName); } - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.buildAnnotation(annotationName); - } - - private NestableAnnotation buildNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.buildAnnotation(annotationName); + NestableAnnotation buildNestableAnnotation(String annotationName, int index) { + return this.getAnnotationProvider().buildAnnotation(this, this.annotatedElement, annotationName, index); } private void syncAnnotations(CompilationUnit astRoot) { HashSet<Annotation> annotationsToRemove = new HashSet<Annotation>(this.annotations); + HashSet<NestableAnnotation> nestableAnnotationsToRemove = new HashSet<NestableAnnotation>(); + for (List<NestableAnnotation> annotations : this.nestableAnnotations.values()) { + nestableAnnotationsToRemove.addAll(annotations); + } - this.annotatedElement.getBodyDeclaration(astRoot).accept(this.buildSynchronizeAnnotationVisitor(astRoot, annotationsToRemove)); + this.annotatedElement.getBodyDeclaration(astRoot).accept(this.buildSynchronizeAnnotationVisitor(astRoot, annotationsToRemove, nestableAnnotationsToRemove)); for (Annotation annotation : annotationsToRemove) { this.removeItemFromCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); } + for (NestableAnnotation nestableAnnotation : nestableAnnotationsToRemove) { + List<NestableAnnotation> list = this.nestableAnnotations.get(nestableAnnotation.getAnnotationName()); + list.remove(nestableAnnotation); + if (list.isEmpty()) { + this.nestableAnnotations.remove(nestableAnnotation.getAnnotationName()); + } + this.fireItemRemoved(NESTABLE_ANNOTATIONS_COLLECTION, nestableAnnotation); + } } - private ASTVisitor buildSynchronizeAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - return new SynchronizeAnnotationVisitor(astRoot, this.annotatedElement.getBodyDeclaration(astRoot), annotationsToRemove); + private ASTVisitor buildSynchronizeAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> annotationsToRemove, Set<NestableAnnotation> nestableAnnotationsToRemove) { + return new SynchronizeAnnotationVisitor(astRoot, this.annotatedElement.getBodyDeclaration(astRoot), annotationsToRemove, nestableAnnotationsToRemove); } /** * called from {@link SynchronizeAnnotationVisitor} */ - /* private */ void addOrSyncAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + /* private */ void addOrSyncAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> annotationsToRemove, Set<NestableAnnotation> nestableAnnotationsToRemove) { String jdtAnnotationName = ASTTools.resolveAnnotation(node); if (jdtAnnotationName != null) { - this.addOrSyncAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); - } - } - - /** - * pre-condition: jdtAnnotationName is not null - */ - void addOrSyncAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - if (this.annotationIsValid(jdtAnnotationName)) { - this.addOrSyncAnnotation_(jdtAnnotationName, astRoot, annotationsToRemove); + if (this.annotationIsValid(jdtAnnotationName)) { + this.addOrSyncAnnotation_(jdtAnnotationName, astRoot, annotationsToRemove); + } + else if(this.annotationIsValidNestable(jdtAnnotationName)) { + this.addOrSyncNestableAnnotation_(jdtAnnotationName, astRoot, nestableAnnotationsToRemove); + } + else if(this.annotationIsValidContainer(jdtAnnotationName)) { + this.addOrSyncContainerAnnotation_(node, jdtAnnotationName, astRoot, nestableAnnotationsToRemove); + } } } @@ -325,11 +465,77 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> } } + /** + * pre-condition: jdtAnnotationName is valid + */ + private void addOrSyncNestableAnnotation_(String jdtAnnotationName, CompilationUnit astRoot, Set<NestableAnnotation> annotationsToRemove) { + List<NestableAnnotation> nestableAnnotations = this.nestableAnnotations.get(jdtAnnotationName); + if (nestableAnnotations != null) { + if (nestableAnnotations.size() > 1) { + //ignore the new standalone annotation as a container annotation already exists + } + else if (nestableAnnotations.size() == 1) { + nestableAnnotations.get(0).synchronizeWith(astRoot); + annotationsToRemove.remove(nestableAnnotations.get(0)); + } + } + else { + nestableAnnotations = new Vector<NestableAnnotation>(); + NestableAnnotation annotation = this.buildNestableAnnotation(jdtAnnotationName, 0); + annotation.initialize(astRoot); + this.nestableAnnotations.put(jdtAnnotationName, nestableAnnotations); + this.fireItemAdded(NESTABLE_ANNOTATIONS_COLLECTION, annotation); + } + } + + /** + * pre-condition: node is valid container annotation + */ + private void addOrSyncContainerAnnotation_(org.eclipse.jdt.core.dom.Annotation node, String containerAnnotationName, CompilationUnit astRoot, Set<NestableAnnotation> annotationsToRemove) { + String nestableAnnotationName = this.getNestableAnnotationName(containerAnnotationName); + List<org.eclipse.jdt.core.dom.Annotation> nestedAstAnnotations = + this.getNestedAstAnnotations(node, this.getNestableElementName(containerAnnotationName), nestableAnnotationName); + List<NestableAnnotation> nestedAnnotations = this.nestableAnnotations.get(nestableAnnotationName); + if (nestedAnnotations == null) { + nestedAnnotations = new Vector<NestableAnnotation>(); + int index = 0; + for (org.eclipse.jdt.core.dom.Annotation nestedAstAnnotation : nestedAstAnnotations) { + NestableAnnotation annotation = this.buildNestableAnnotation(ASTTools.resolveAnnotation(nestedAstAnnotation), index++); + annotation.initialize(astRoot); + nestedAnnotations.add(annotation); + } + this.nestableAnnotations.put(nestableAnnotationName, nestedAnnotations); + this.fireItemsAdded(NESTABLE_ANNOTATIONS_COLLECTION, nestedAnnotations); + } + else { + Iterator<org.eclipse.jdt.core.dom.Annotation> astAnnotationStream = nestedAstAnnotations.iterator(); + Iterator<NestableAnnotation> nestedAnnotationsStream = nestedAnnotations.iterator(); + int index = 0; + while (nestedAnnotationsStream.hasNext()) { + index++; + NestableAnnotation nestedAnnotation = nestedAnnotationsStream.next(); + if (astAnnotationStream.hasNext()) { + // matching AST annotation is present - synchronize the nested annotation + astAnnotationStream.next(); // maybe someday we can pass this to the update + nestedAnnotation.synchronizeWith(astRoot); + annotationsToRemove.remove(nestedAnnotation); + } + } + while (astAnnotationStream.hasNext()) { + NestableAnnotation nestedAnnotation = this.buildNestableAnnotation(ASTTools.resolveAnnotation(astAnnotationStream.next()), index++); + nestedAnnotation.initialize(astRoot); + nestedAnnotations.add(nestedAnnotation); + this.fireItemAdded(NESTABLE_ANNOTATIONS_COLLECTION, nestedAnnotation); + } + } + } + + // ********** miscellaneous ********** public boolean isAnnotated() { - return ! this.annotations.isEmpty(); + return ! this.annotations.isEmpty() || ! this.nestableAnnotations.isEmpty(); } public TextRange getTextRange(CompilationUnit astRoot) { @@ -428,14 +634,17 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> { protected final Set<Annotation> annotationsToRemove; - protected SynchronizeAnnotationVisitor(CompilationUnit astRoot, ASTNode node, Set<Annotation> annotationsToRemove) { + protected final Set<NestableAnnotation> nestableAnnotationsToRemove; + + protected SynchronizeAnnotationVisitor(CompilationUnit astRoot, ASTNode node, Set<Annotation> annotationsToRemove, Set<NestableAnnotation> nestableAnnotationsToRemove) { super(astRoot, node); this.annotationsToRemove = annotationsToRemove; + this.nestableAnnotationsToRemove = nestableAnnotationsToRemove; } @Override protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourceAnnotatedElement.this.addOrSyncAnnotation(node, this.astRoot, this.annotationsToRemove); + SourceAnnotatedElement.this.addOrSyncAnnotation(node, this.astRoot, this.annotationsToRemove, this.nestableAnnotationsToRemove); } } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotation.java index bb0f2eac53..05f4e7a222 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotation.java @@ -328,6 +328,7 @@ public abstract class SourceAnnotation<A extends AnnotatedElement> } } } + // minimize scope of suppressed warnings @SuppressWarnings("unchecked") private List<Expression> expressions(ArrayInitializer arrayInitializer) { 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 a226f88e5d..601c892014 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 @@ -12,14 +12,13 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Attribute; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; @@ -29,8 +28,6 @@ import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; 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.JavaResourceNode; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation; /** @@ -40,7 +37,8 @@ public final class SourceXmlElementAnnotation extends SourceAnnotation<Attribute> implements XmlElementAnnotation { - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JAXB.XML_ELEMENTS); private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; private final AnnotationElementAdapter<String> nameAdapter; @@ -69,15 +67,21 @@ public final class SourceXmlElementAnnotation // ********** constructors ********** - public SourceXmlElementAnnotation(JavaResourceAttribute parent, Attribute attribute) { - this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER)); + public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceAttribute parent, Attribute attribute, int index) { + IndexedDeclarationAnnotationAdapter idaa = buildXmlElementDeclarationAnnotationAdapter(index); + IndexedAnnotationAdapter iaa = buildXmlElementAnnotationAdapter(attribute, idaa); + return new SourceXmlElementAnnotation( + parent, + attribute, + idaa, + iaa); } - - /** - * Parent is a JavaResourceNode instead of a JavaResourcePersistentAttribute because - * the parent is sometimes the outer annotation XmlElementsAnnotation - */ - public SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { + + private SourceXmlElementAnnotation( + JavaResourceAttribute parent, + Attribute attribute, + IndexedDeclarationAnnotationAdapter daa, + IndexedAnnotationAdapter annotationAdapter) { super(parent, attribute, daa, annotationAdapter); this.nameDeclarationAdapter = this.buildNameAdapter(daa); this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter); @@ -339,20 +343,6 @@ public final class SourceXmlElementAnnotation * convenience implementation of method from NestableAnnotation interface * for subclasses */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - XmlElementAnnotation oldXmlElementAnnotation = (XmlElementAnnotation) oldAnnotation; - this.setName(oldXmlElementAnnotation.getName()); - this.setNamespace(oldXmlElementAnnotation.getNamespace()); - this.setDefaultValue (oldXmlElementAnnotation.getDefaultValue()); - this.setNillable(oldXmlElementAnnotation.getNillable()); - this.setRequired(oldXmlElementAnnotation.getRequired()); - this.setType(oldXmlElementAnnotation.getType()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ public void moveAnnotation(int newIndex) { this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); } @@ -361,17 +351,21 @@ public final class SourceXmlElementAnnotation return (IndexedAnnotationAdapter) this.annotationAdapter; } - // ********** static methods ********** - static SourceXmlElementAnnotation createNestedXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, int index, DeclarationAnnotationAdapter elementsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, elementsAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(attribute, idaa); + // ********** static methods ********** - return new SourceXmlElementAnnotation(parent, attribute, idaa, annotationAdapter); + private static IndexedAnnotationAdapter buildXmlElementAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) { + return new ElementIndexedAnnotationAdapter(annotatedElement, idaa); } - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter elementsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(elementsAdapter, index, JAXB.XML_ELEMENT); + private static IndexedDeclarationAnnotationAdapter buildXmlElementDeclarationAnnotationAdapter(int index) { + IndexedDeclarationAnnotationAdapter idaa = + new CombinationIndexedDeclarationAnnotationAdapter( + DECLARATION_ANNOTATION_ADAPTER, + CONTAINER_DECLARATION_ANNOTATION_ADAPTER, + index, + JAXB.XML_ELEMENT); + return idaa; } } 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 1e3b3d1497..57203f6f41 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,14 +12,13 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Attribute; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; @@ -29,8 +28,6 @@ import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; 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.JavaResourceNode; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation; /** @@ -40,7 +37,8 @@ public final class SourceXmlElementRefAnnotation extends SourceAnnotation<Attribute> implements XmlElementRefAnnotation { - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + 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; @@ -57,15 +55,21 @@ public final class SourceXmlElementRefAnnotation private String type; // ********** constructors ********** - public SourceXmlElementRefAnnotation(JavaResourceAttribute parent, Attribute attribute) { - this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER)); + public static SourceXmlElementRefAnnotation buildSourceXmlElementRefAnnotation(JavaResourceAttribute parent, Attribute attribute, int index) { + IndexedDeclarationAnnotationAdapter idaa = buildXmlElementRefDeclarationAnnotationAdapter(index); + IndexedAnnotationAdapter iaa = buildXmlElementRefAnnotationAdapter(attribute, idaa); + return new SourceXmlElementRefAnnotation( + parent, + attribute, + idaa, + iaa); } - - /** - * Parent is a JavaResourceNode instead of a JavaResourcePersistentAttribute because - * the parent is sometimes the outer annotation XmlElementRefsAnnotation - */ - public SourceXmlElementRefAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { + + private SourceXmlElementRefAnnotation( + JavaResourceAttribute parent, + Attribute attribute, + IndexedDeclarationAnnotationAdapter daa, + IndexedAnnotationAdapter annotationAdapter) { super(parent, attribute, daa, annotationAdapter); this.nameDeclarationAdapter = this.buildNameAdapter(daa); this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter); @@ -221,17 +225,6 @@ public final class SourceXmlElementRefAnnotation * convenience implementation of method from NestableAnnotation interface * for subclasses */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - XmlElementRefAnnotation oldXmlElementRefAnnotation = (XmlElementRefAnnotation) oldAnnotation; - this.setName(oldXmlElementRefAnnotation.getName()); - this.setNamespace(oldXmlElementRefAnnotation.getNamespace()); - this.setType(oldXmlElementRefAnnotation.getType()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ public void moveAnnotation(int newIndex) { this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); } @@ -240,17 +233,21 @@ public final class SourceXmlElementRefAnnotation return (IndexedAnnotationAdapter) this.annotationAdapter; } - // ********** static methods ********** - static SourceXmlElementRefAnnotation createNestedXmlElementRefAnnotation(JavaResourceNode parent, Attribute attribute, int index, DeclarationAnnotationAdapter elementsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, elementsAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(attribute, idaa); + // ********** static methods ********** - return new SourceXmlElementRefAnnotation(parent, attribute, idaa, annotationAdapter); + private static IndexedAnnotationAdapter buildXmlElementRefAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) { + return new ElementIndexedAnnotationAdapter(annotatedElement, idaa); } - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter elementsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(elementsAdapter, index, JAXB.XML_ELEMENT_REF); + 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 deleted file mode 100644 index df6cb9e904..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefsAnnotation.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.source; - -import java.util.Vector; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -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; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - -/** - * javax.xml.bind.annotation.adapters.XmlElementRefs - */ -public class SourceXmlElementRefsAnnotation - extends SourceAnnotation<Attribute> - implements XmlElementRefsAnnotation { - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<XmlElementRefAnnotation> elementRefs = new Vector<XmlElementRefAnnotation>(); - - - public SourceXmlElementRefsAnnotation(JavaResourceAttribute parent, Attribute attibute) { - super(parent, attibute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.elementRefs); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JAXB.XML_ELEMENT_REFS__VALUE; - } - - public String getNestedAnnotationName() { - return XmlElementRefAnnotation.ANNOTATION_NAME; - } - - public ListIterable<XmlElementRefAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlElementRefAnnotation>(this.elementRefs); - } - - public int getNestedAnnotationsSize() { - return this.elementRefs.size(); - } - - public XmlElementRefAnnotation addNestedAnnotation(int index) { - XmlElementRefAnnotation elementRef = this.buildXmlElementRefAnnotation(index); - this.elementRefs.add(elementRef); - return elementRef; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.elementRefs.size(); - XmlElementRefAnnotation elementRef = this.addNestedAnnotation(index); - elementRef.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(XML_ELEMENT_REFS_LIST, index, elementRef); - } - - protected XmlElementRefAnnotation buildXmlElementRefAnnotation(int index) { - return SourceXmlElementRefAnnotation.createNestedXmlElementRefAnnotation(this, this.annotatedElement, index, this.daa); - } - - public XmlElementRefAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.elementRefs, targetIndex, sourceIndex).get(targetIndex); - } - - public XmlElementRefAnnotation removeNestedAnnotation(int index) { - return this.elementRefs.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.elementRefs, XML_ELEMENT_REFS_LIST); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java deleted file mode 100644 index d876ea0034..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.source; - -import java.util.Vector; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -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.XmlElementAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - -/** - * javax.xml.bind.annotation.adapters.XmlElements - */ -public class SourceXmlElementsAnnotation - extends SourceAnnotation<Attribute> - implements XmlElementsAnnotation { - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<XmlElementAnnotation> elements = new Vector<XmlElementAnnotation>(); - - - public SourceXmlElementsAnnotation(JavaResourceAttribute parent, Attribute attibute) { - super(parent, attibute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.elements); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JAXB.XML_ELEMENTS__VALUE; - } - - public String getNestedAnnotationName() { - return XmlElementAnnotation.ANNOTATION_NAME; - } - - public ListIterable<XmlElementAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlElementAnnotation>(this.elements); - } - - public int getNestedAnnotationsSize() { - return this.elements.size(); - } - - public XmlElementAnnotation addNestedAnnotation(int index) { - XmlElementAnnotation element = this.buildXmlElementAnnotation(index); - this.elements.add(element); - return element; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.elements.size(); - XmlElementAnnotation element = this.addNestedAnnotation(index); - element.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(XML_ELEMENTS_LIST, index, element); - } - - protected XmlElementAnnotation buildXmlElementAnnotation(int index) { - return SourceXmlElementAnnotation.createNestedXmlElementAnnotation(this, this.annotatedElement, index, this.daa); - } - - public XmlElementAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.elements, targetIndex, sourceIndex).get(targetIndex); - } - - public XmlElementAnnotation removeNestedAnnotation(int index) { - return this.elements.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.elements, XML_ELEMENTS_LIST); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java index ebf7b4b5b3..8fec00cf65 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java @@ -12,15 +12,13 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; @@ -29,8 +27,6 @@ import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; 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.JavaResourceNode; -import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation; /** @@ -40,7 +36,8 @@ public final class SourceXmlJavaTypeAdapterAnnotation extends SourceAnnotation<AnnotatedElement> implements XmlJavaTypeAdapterAnnotation { - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JAXB.XML_JAVA_TYPE_ADAPTERS); private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter; private final AnnotationElementAdapter<String> valueAdapter; @@ -54,15 +51,21 @@ public final class SourceXmlJavaTypeAdapterAnnotation // ********** constructors ********** - public SourceXmlJavaTypeAdapterAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element) { - this(parent, element, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(element, DECLARATION_ANNOTATION_ADAPTER)); + public static SourceXmlJavaTypeAdapterAnnotation buildSourceXmlJavaTypeAdapterAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { + IndexedDeclarationAnnotationAdapter idaa = buildXmlJavaTypeAdapterDeclarationAnnotationAdapter(index); + IndexedAnnotationAdapter iaa = buildXmlJavaTypeAdapterAnnotationAdapter(annotatedElement, idaa); + return new SourceXmlJavaTypeAdapterAnnotation( + parent, + annotatedElement, + idaa, + iaa); } - - /** - * Parent is a JavaResourceNode instead of a JavaResourceAnnotatedElement because - * the parent is sometimes the outer annotation XmlJavaTypeAdaptersAnnotation - */ - public SourceXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement element, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { + + private SourceXmlJavaTypeAdapterAnnotation( + JavaResourceAnnotatedElement parent, + AnnotatedElement element, + IndexedDeclarationAnnotationAdapter daa, + IndexedAnnotationAdapter annotationAdapter) { super(parent, element, daa, annotationAdapter); this.valueDeclarationAdapter = buildValueAdapter(daa); this.valueAdapter = this.buildAnnotationElementAdapter(this.valueDeclarationAdapter); @@ -199,16 +202,6 @@ public final class SourceXmlJavaTypeAdapterAnnotation * convenience implementation of method from NestableAnnotation interface * for subclasses */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - XmlJavaTypeAdapterAnnotation oldJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) oldAnnotation; - setValue(oldJavaTypeAdapterAnnotation.getValue()); - setType(oldJavaTypeAdapterAnnotation.getType()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ public void moveAnnotation(int newIndex) { this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); } @@ -219,15 +212,18 @@ public final class SourceXmlJavaTypeAdapterAnnotation // ********** static methods ********** - - static SourceXmlJavaTypeAdapterAnnotation createNestedXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement annotatedElement, int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, javaTypeAdaptersAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(annotatedElement, idaa); - - return new SourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement, idaa, annotationAdapter); + + private static IndexedAnnotationAdapter buildXmlJavaTypeAdapterAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) { + return new ElementIndexedAnnotationAdapter(annotatedElement, idaa); } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(javaTypeAdaptersAdapter, index, JAXB.XML_JAVA_TYPE_ADAPTER); + + private static IndexedDeclarationAnnotationAdapter buildXmlJavaTypeAdapterDeclarationAnnotationAdapter(int index) { + IndexedDeclarationAnnotationAdapter idaa = + new CombinationIndexedDeclarationAnnotationAdapter( + DECLARATION_ANNOTATION_ADAPTER, + CONTAINER_DECLARATION_ANNOTATION_ADAPTER, + index, + JAXB.XML_JAVA_TYPE_ADAPTER); + return idaa; } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java deleted file mode 100644 index 1387e172be..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.source; - -import java.util.Vector; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.jaxb.core.resource.java.JAXB; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - -/** - * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters - */ -public class SourceXmlJavaTypeAdaptersAnnotation - extends SourceAnnotation<AnnotatedPackage> - implements XmlJavaTypeAdaptersAnnotation { - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<XmlJavaTypeAdapterAnnotation> adapters = new Vector<XmlJavaTypeAdapterAnnotation>(); - - - public SourceXmlJavaTypeAdaptersAnnotation(JavaResourcePackage parent, AnnotatedPackage annotatedElement) { - super(parent, annotatedElement, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.adapters); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE; - } - - public String getNestedAnnotationName() { - return XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME; - } - - public ListIterable<XmlJavaTypeAdapterAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlJavaTypeAdapterAnnotation>(this.adapters); - } - - public int getNestedAnnotationsSize() { - return this.adapters.size(); - } - - public XmlJavaTypeAdapterAnnotation getNestedAnnotation(int index) { - return this.adapters.get(index); - } - - public XmlJavaTypeAdapterAnnotation addNestedAnnotation(int index) { - XmlJavaTypeAdapterAnnotation adapter = this.buildXmlJavaTypeAdapterAnnotation(index); - this.adapters.add(adapter); - return adapter; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.adapters.size(); - XmlJavaTypeAdapterAnnotation adapter = this.addNestedAnnotation(index); - adapter.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(XML_JAVA_TYPE_ADAPTERS_LIST, index, adapter); - } - - protected XmlJavaTypeAdapterAnnotation buildXmlJavaTypeAdapterAnnotation(int index) { - return SourceXmlJavaTypeAdapterAnnotation.createNestedXmlJavaTypeAdapterAnnotation(this, this.annotatedElement, index, this.daa); - } - - public XmlJavaTypeAdapterAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.adapters, targetIndex, sourceIndex).get(targetIndex); - } - - public XmlJavaTypeAdapterAnnotation removeNestedAnnotation(int index) { - return this.adapters.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.adapters, XML_JAVA_TYPE_ADAPTERS_LIST); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java index 8893189d45..ecf71e7510 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java @@ -22,7 +22,6 @@ import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; 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.NestableAnnotation; import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation; @@ -142,12 +141,6 @@ public class SourceXmlNsAnnotation // **************** NestableAnnotation impl ******************************* - public void initializeFrom(NestableAnnotation oldAnnotation) { - XmlNsAnnotation oldXmlNsAnnotation = (XmlNsAnnotation) oldAnnotation; - this.setNamespaceURI(oldXmlNsAnnotation.getNamespaceURI()); - this.setPrefix(oldXmlNsAnnotation.getPrefix()); - } - public void moveAnnotation(int newIndex) { this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypeAnnotation.java index f72817474e..bfb55c39a0 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypeAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypeAnnotation.java @@ -12,15 +12,14 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; @@ -28,8 +27,7 @@ import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; 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.NestableAnnotation; +import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; /** @@ -39,8 +37,8 @@ public class SourceXmlSchemaTypeAnnotation extends SourceAnnotation<AnnotatedPackage> implements XmlSchemaTypeAnnotation { - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = - new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + public static final SimpleDeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JAXB.XML_SCHEMA_TYPES); private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; private final AnnotationElementAdapter<String> nameAdapter; @@ -57,13 +55,21 @@ public class SourceXmlSchemaTypeAnnotation // ********** constructors ********** - public SourceXmlSchemaTypeAnnotation(JavaResourceNode parent, AnnotatedPackage element) { - this(parent, element, DECLARATION_ANNOTATION_ADAPTER, - new ElementAnnotationAdapter(element, DECLARATION_ANNOTATION_ADAPTER)); - } - - public SourceXmlSchemaTypeAnnotation(JavaResourceNode parent, AnnotatedPackage element, - DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { + public static SourceXmlSchemaTypeAnnotation buildSourceXmlSchemaTypeAnnotation(JavaResourceAnnotatedElement parent, AnnotatedPackage annotatedElement, int index) { + IndexedDeclarationAnnotationAdapter idaa = buildXmlSchemaTypeDeclarationAnnotationAdapter(index); + IndexedAnnotationAdapter iaa = buildXmlSchemaTypeAnnotationAdapter(annotatedElement, idaa); + return new SourceXmlSchemaTypeAnnotation( + parent, + annotatedElement, + idaa, + iaa); + } + + private SourceXmlSchemaTypeAnnotation( + JavaResourceAnnotatedElement parent, + AnnotatedPackage element, + IndexedDeclarationAnnotationAdapter daa, + IndexedAnnotationAdapter annotationAdapter) { super(parent, element, daa, annotationAdapter); this.nameDeclarationAdapter = buildNameAdapter(daa); @@ -229,17 +235,6 @@ public class SourceXmlSchemaTypeAnnotation * convenience implementation of method from NestableAnnotation interface * for subclasses */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - XmlSchemaTypeAnnotation oldSchemaTypeAnnotation = (XmlSchemaTypeAnnotation) oldAnnotation; - setName(oldSchemaTypeAnnotation.getName()); - setNamespace(oldSchemaTypeAnnotation.getNamespace()); - setType(oldSchemaTypeAnnotation.getType()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ public void moveAnnotation(int newIndex) { this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); } @@ -247,24 +242,21 @@ public class SourceXmlSchemaTypeAnnotation private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { return (IndexedAnnotationAdapter) this.annotationAdapter; } - - + + // ********** static methods ********** - - static SourceXmlSchemaTypeAnnotation createNestedXmlSchemaTypeAnnotation( - JavaResourceNode parent, AnnotatedPackage annotatedElement, int index, - DeclarationAnnotationAdapter schemaTypesAdapter) { - - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, schemaTypesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(annotatedElement, idaa); - - return new SourceXmlSchemaTypeAnnotation(parent, annotatedElement, idaa, annotationAdapter); + + private static IndexedAnnotationAdapter buildXmlSchemaTypeAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) { + return new ElementIndexedAnnotationAdapter(annotatedElement, idaa); } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter( - int index, DeclarationAnnotationAdapter schemaTypesAdapter) { - - return new NestedIndexedDeclarationAnnotationAdapter( - schemaTypesAdapter, index, JAXB.XML_SCHEMA_TYPE); + + private static IndexedDeclarationAnnotationAdapter buildXmlSchemaTypeDeclarationAnnotationAdapter(int index) { + IndexedDeclarationAnnotationAdapter idaa = + new CombinationIndexedDeclarationAnnotationAdapter( + DECLARATION_ANNOTATION_ADAPTER, + CONTAINER_DECLARATION_ANNOTATION_ADAPTER, + index, + JAXB.XML_SCHEMA_TYPE); + return idaa; } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypesAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypesAnnotation.java deleted file mode 100644 index 6e1d2a32a0..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaTypesAnnotation.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.internal.resource.java.source; - -import java.util.Vector; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.jaxb.core.resource.java.JAXB; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation; -import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypesAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable; - - -public class SourceXmlSchemaTypesAnnotation - extends SourceAnnotation<AnnotatedPackage> - implements XmlSchemaTypesAnnotation { - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = - new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<XmlSchemaTypeAnnotation> schemaTypes = new Vector<XmlSchemaTypeAnnotation>(); - - - public SourceXmlSchemaTypesAnnotation(JavaResourcePackage parent, AnnotatedPackage annotatedElement) { - super(parent, annotatedElement, DECLARATION_ANNOTATION_ADAPTER); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.schemaTypes); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JAXB.XML_SCHEMA_TYPES__VALUE; - } - - public String getNestedAnnotationName() { - return JAXB.XML_SCHEMA_TYPE; - } - - public ListIterable<XmlSchemaTypeAnnotation> getNestedAnnotations() { - return new LiveCloneListIterable<XmlSchemaTypeAnnotation>(this.schemaTypes); - } - - public int getNestedAnnotationsSize() { - return this.schemaTypes.size(); - } - - public XmlSchemaTypeAnnotation getNestedAnnotation(int index) { - return this.schemaTypes.get(index); - } - - public XmlSchemaTypeAnnotation addNestedAnnotation(int index) { - XmlSchemaTypeAnnotation adapter = this.buildXmlSchemaTypeAnnotation(index); - this.schemaTypes.add(adapter); - return adapter; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.schemaTypes.size(); - XmlSchemaTypeAnnotation schemaType = this.addNestedAnnotation(index); - schemaType.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(XML_SCHEMA_TYPES_LIST, index, schemaType); - } - - protected XmlSchemaTypeAnnotation buildXmlSchemaTypeAnnotation(int index) { - return SourceXmlSchemaTypeAnnotation.createNestedXmlSchemaTypeAnnotation( - this, this.annotatedElement, index, this.daa); - } - - public XmlSchemaTypeAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.schemaTypes, targetIndex, sourceIndex).get(targetIndex); - } - - public XmlSchemaTypeAnnotation removeNestedAnnotation(int index) { - return this.schemaTypes.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.schemaTypes, XML_SCHEMA_TYPES_LIST); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/platform/JaxbPlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/platform/JaxbPlatformDefinition.java index c07ae65768..0ef276e2c4 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/platform/JaxbPlatformDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/platform/JaxbPlatformDefinition.java @@ -14,6 +14,7 @@ import org.eclipse.jpt.core.JpaResourceType; import org.eclipse.jpt.jaxb.core.JaxbFactory; import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition; import org.eclipse.jpt.utility.internal.iterables.ListIterable; /** @@ -31,6 +32,8 @@ public interface JaxbPlatformDefinition { JaxbFactory getFactory(); AnnotationDefinition[] getAnnotationDefinitions(); + + NestableAnnotationDefinition[] getNestableAnnotationDefinitions(); /** * Return the resource model providers that apply to this platform. diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AnnotationContainer.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AnnotationContainer.java deleted file mode 100644 index 003908c0f4..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AnnotationContainer.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; - -/** - * Common behavior for all annotation "containers". - * This interface is used mainly in - * {@link org.eclipse.jpt.jaxb.core.internal.resource.java.source.AnnotationContainerTools}. - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 3.0 - */ -public interface AnnotationContainer<T extends NestableAnnotation> -{ - /** - * Return the corresponding JDT DOM annotation from the specified - * AST compilation unit. Used as a starting point when traversing the AST. - */ - org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot); - - /** - * Return the name of the container annotation's element that is used - * to indicate the nested annotations (typically "value"). - * Used when traversing the AST. - */ - String getElementName(); - - /** - * Return the name of the nested annotations held by the container. - * Used when traversing the AST. - */ - String getNestedAnnotationName(); - - /** - * Return the nested annotations held by the container. - */ - ListIterable<T> getNestedAnnotations(); - - /** - * Return the number of nested annotations held by the container. - */ - int getNestedAnnotationsSize(); - - /** - * Add a nested annotation to the container - * without firing change notification. - */ - T addNestedAnnotation(int index); - - /** - * The specified nested annotation was added to the container at the - * specified index; notify interested parties. - */ - void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation); - - /** - * Move the nested annotation at the specified source index in the - * container to the specified target index without firing change notification. - * Return the moved nested annotation. - */ - T moveNestedAnnotation(int targetIndex, int sourceIndex); - - /** - * Remove the nested annotation at the specified index from the - * container without firing change notification. - */ - T removeNestedAnnotation(int index); - - /** - * Remove the nested annotations starting at the specified index from the - * container; notify interested parties. - */ - void syncRemoveNestedAnnotations(int index); - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/ContainerAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/ContainerAnnotation.java deleted file mode 100644 index 5f0f13d0c9..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/ContainerAnnotation.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - -/** - * Common behavior for all "container" annotations. - * - * 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 2.0 - */ -public interface ContainerAnnotation<T extends NestableAnnotation> - extends Annotation, AnnotationContainer<T> -{ - // combine two interfaces -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAnnotatedElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAnnotatedElement.java index 61d0d22b07..79acf8d83c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAnnotatedElement.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAnnotatedElement.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.utility.internal.iterables.ListIterable; /** * Java source code or binary annotated element. @@ -35,6 +36,11 @@ public interface JavaResourceAnnotatedElement String ANNOTATIONS_COLLECTION = "annotations"; //$NON-NLS-1$ /** + * String associated with changes to the "nestableAnnotations" collection + */ + String NESTABLE_ANNOTATIONS_COLLECTION = "nestableAnnotations"; //$NON-NLS-1$ + + /** * Return the member's annotations in the order that they appear. * Do not return duplicate annotations as this error is handled by the Java * compiler. @@ -64,12 +70,25 @@ public interface JavaResourceAnnotatedElement * Return the nestable annotations with the specified name in the order that * they appear. * If nestable and container annotations are both specified on the - * member directly, return only the nestable annotations specified within - * the container annotation. + * member directly, the behavior is undefined */ // TODO tie the singular and plural annotations together so we can generate // a validation error when both are specified - Iterable<? extends NestableAnnotation> getAnnotations(String nestableAnnotationName, String containerAnnotationName); + ListIterable<? extends NestableAnnotation> getAnnotations(String nestableAnnotationName); + + /** + * Return the number of nestable annotations with the specified name. + * If nestable and container annotations are both specified on the + * member directly, the behavior is undefined + */ + int getAnnotationsSize(String nestableAnnotationName); + + /** + * Return the nestable annotation at the specified index with the specified name. + * If nestable and container annotations are both specified on the + * member directly, the behavior is undefined + */ + NestableAnnotation getAnnotation(int index, String nestableAnnotationName); /** * Add an annotation with the specified name. @@ -89,13 +108,12 @@ public interface JavaResourceAnnotatedElement * the new one. If neither annotation exists, then create a new nestable * annotation. */ - NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); + NestableAnnotation addAnnotation(int index, String nestableAnnotationName); /** - * Move the nestable annotation found in the specified container - * annotation at the specified source index to the specified target index. + * Move the nestable annotation at the specified source index to the specified target index. */ - void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName); + void moveAnnotation(int targetIndex, int sourceIndex, String nestableAnnotationName); /** * Remove the specified annotation. @@ -105,10 +123,9 @@ public interface JavaResourceAnnotatedElement /** * Remove the specified nestable annotation from the container annotation at the specified * index. - * If there is no container, assume the index is zero and this does the same as - * {@link #removeAnnotation(String)} + * If there is no container, assume the index is zero and just remove the nestable annotation */ - void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); + void removeAnnotation(int index, String nestableAnnotationName); // ********** queries ********** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotation.java index 63224828e8..4fcae43c04 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotation.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotation.java @@ -19,17 +19,12 @@ package org.eclipse.jpt.jaxb.core.resource.java; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. * - * @version 2.0 + * @version 3.0 * @since 2.0 */ public interface NestableAnnotation extends Annotation { - // currently using this when the NestableAnnotation is moved from - // stand-alone to nested or from nested to stand-alone; - // not the greatest, since you have to make sure to call all setter methods - void initializeFrom(NestableAnnotation oldAnnotation); - /** * Move the annotation to the specified index within its container annotation. * This should only be called when the annotation is actually nested. diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotationDefinition.java new file mode 100644 index 0000000000..278cd65b8a --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableAnnotationDefinition.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.jaxb.core.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; + +/** + * Used to build NestableAnnotations discovered in the Java source code. + * To provide new NestableAnnotationDefinitions, create a new JaxbPlatform + * by implementing JaxbPlatformDefinition. + * + * @see NestableAnnotation + * @see org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition + * + * 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 NestableAnnotationDefinition +{ + /** + * Return the name of the annotation the definition will build in the + * various #build...(...) methods. + */ + String getNestableAnnotationName(); + + String getContainerAnnotationName(); + + String getElementName(); + + /** + * Build and return an annotation for the specified annotated element. + */ + NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index); + + /** + * Build and return an annotation for the specified JDT annotation + * on the specified annotated element. + */ + Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation); +} 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 deleted file mode 100644 index c08a95073e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementRefsAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - - -/** - * 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 ContainerAnnotation<XmlElementRefAnnotation> { - - String ANNOTATION_NAME = JAXB.XML_ELEMENT_REFS; - - String XML_ELEMENT_REFS_LIST = "xmlElementRefs"; //$NON-NLS-1$ -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementsAnnotation.java deleted file mode 100644 index c2319bce29..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementsAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - - -/** - * Corresponds to the JAXB annotation - * javax.xml.bind.annotation.XmlElements - * - * 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 XmlElementsAnnotation - extends ContainerAnnotation<XmlElementAnnotation> { - - String ANNOTATION_NAME = JAXB.XML_ELEMENTS; - - String XML_ELEMENTS_LIST = "xmlElements"; //$NON-NLS-1$ -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java deleted file mode 100644 index c7481c63d3..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - - -/** - * Corresponds to the JAXB annotation - * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters - * - * 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 XmlJavaTypeAdaptersAnnotation - extends ContainerAnnotation<XmlJavaTypeAdapterAnnotation> { - - String ANNOTATION_NAME = JAXB.XML_JAVA_TYPE_ADAPTERS; - - String XML_JAVA_TYPE_ADAPTERS_LIST = "xmlJavaTypeAdapters"; //$NON-NLS-1$ - - /** - * shortcut API - */ - XmlJavaTypeAdapterAnnotation getNestedAnnotation(int index); -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypesAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypesAnnotation.java deleted file mode 100644 index c0ebdf7ea6..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaTypesAnnotation.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.core.resource.java; - - -public interface XmlSchemaTypesAnnotation - extends ContainerAnnotation<XmlSchemaTypeAnnotation> { - - String ANNOTATION_NAME = JAXB.XML_SCHEMA_TYPES; - - String XML_SCHEMA_TYPES_LIST = "xmlSchemaTypes"; //$NON-NLS-1$ - - /** - * shortcut API - */ - XmlSchemaTypeAnnotation getNestedAnnotation(int index); -} |