diff options
22 files changed, 352 insertions, 933 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationDefinitionProvider.java deleted file mode 100644 index c5dfb9b527..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/AnnotationDefinitionProvider.java +++ /dev/null @@ -1,50 +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; - -import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; - -/** - * Provides annotationDefinitions for types and attributes. AnnotationProvider - * then uses a collection of these to build 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 3.0 - */ -public interface AnnotationDefinitionProvider -{ - /** - * Return all annotation definitions which can appear on a type - */ - Iterable<AnnotationDefinition> getTypeAnnotationDefinitions(); - - /** - * Return all annotation definitions which can appear on a type and are used to determine - * whether and how the type is persisted (how it is "mapped"). - * This should be a subset of {@link #typeAnnotationDefinitions()}. - */ - Iterable<AnnotationDefinition> getTypeMappingAnnotationDefinitions(); - - /** - * Return all annotation definitions which can appear on an attribute - */ - Iterable<AnnotationDefinition> getAttributeAnnotationDefinitions(); - - /** - * Return all annotation definitions which can appear on a package. - */ - Iterable<AnnotationDefinition> getPackageAnnotationDefinitions(); -} 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 6d4ec49d9a..31e8d1198d 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 @@ -10,13 +10,9 @@ package org.eclipse.jpt.jaxb.core; import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Type; +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.JavaResourceAttribute; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType; +import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; /** * This is used to provide type and attribute annotations. @@ -37,107 +33,31 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface AnnotationProvider -{ - // ********** type annotations ********** +public interface AnnotationProvider { /** - * Return the names of the annotations that can appear on a type. + * Return the names of the annotations. */ - Iterable<String> getTypeAnnotationNames(); - - /** - * Return the names of the annotations that can appear on a type and are used to - * determine whether and how the type is persisted (how it is "mapped"). - * This should be a subset of {@link #typeAnnotationNames()}. - */ - Iterable<String> getTypeMappingAnnotationNames(); - - /** - * Build a type annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #typeAnnotationNames() - */ - Annotation buildTypeAnnotation( - JavaResourceType parent, Type type, String annotationName); - - /** - * Build a type annotation for the specified JDT annotation. - * Throw an IllegalArgumentException if the specified annotation is unsupported. - * @see #typeAnnotationNames() - */ - Annotation buildTypeAnnotation( - JavaResourceType parent, IAnnotation jdtAnnotation); - - /** - * Build a null type annotation with the specified name. - * Throw an IllegalArgumentException if the specified annotation is unsupported. - * @see #typeAnnotationNames() - */ - Annotation buildNullTypeAnnotation( - JavaResourceType parent, String annotationName); - - - // ********** attribute annotations ********** + Iterable<String> getAnnotationNames(); /** - * Return the names of the annotations that can appear on an attribute. - */ - Iterable<String> getAttributeAnnotationNames(); - - /** - * Build an attribute annotation with the specified name. + * Build an annotation with the specified name. * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #attributeAnnotationNames() + * @see #getAnnotationNames() */ - Annotation buildAttributeAnnotation( - JavaResourceAttribute parent, Attribute attribute, String annotationName); - - /** - * Build an attribute annotation for the specified JDT annotation. - * Throw an IllegalArgumentException if the specified annotation is unsupported. - * @see #attributeAnnotationNames() - */ - Annotation buildAttributeAnnotation( - JavaResourceAttribute parent, IAnnotation jdtAnnotation); - + Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName); + /** - * Build a null attribute annotation with the specified name. + * Build an annotation for the specified JDT annotation. * Throw an IllegalArgumentException if the specified annotation is unsupported. - * @see #attributeMappingAnnotationNames() - */ - Annotation buildNullAttributeAnnotation( - JavaResourceAttribute parent, String annotationName); - - - // ********** package annotations ********** - - /** - * Return the names of the annotations that can appear on a package. + * @see #getAnnotationNames() */ - Iterable<String> getPackageAnnotationNames(); - - /** - * Build an package annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #packageAnnotationNames() - */ - Annotation buildPackageAnnotation( - JavaResourcePackage parent, AnnotatedPackage pack, String annotationName); - - /** - * Build a package annotation for the specified JDT annotation. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #packageAnnotationNames() - */ - Annotation buildPackageAnnotation( - JavaResourcePackage parent, IAnnotation jdtAnnotation); - + Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation); + /** - * Build a null package annotation with the specified name. + * Build a null annotation with the specified name. * Throw an IllegalArgumentException if the specified annotation is unsupported. - * @see #packageAnnotationNames() + * @see #getAnnotationNames() */ - Annotation buildNullPackageAnnotation( - JavaResourcePackage parent, String annotationName); + Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent, String annotationName); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java index ae18424f1a..b3d4103c84 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java @@ -45,7 +45,7 @@ import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. * - * @see org.eclipse.jpt.core.internal.jaxb1.GenericJaxbFactory + * @see org.eclipse.jpt.core.internal.Generic_2_1_JaxbFactory.GenericJaxbFactory * * @version 3.0 * @since 3.0 diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbPlatformProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbPlatformProvider.java deleted file mode 100644 index 5840cd0ee7..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbPlatformProvider.java +++ /dev/null @@ -1,69 +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; - -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; - -/** - * This interface is to be implemented by a JPA vendor to provide extensions to - * the core JPA model. The core JPA model will provide functionality for JPA - * spec annotations in java, persistence.xml and mapping (orm.xml) files. - * The org.eclipse.jpt.core.generic extension supplies - * resource models for those file types in GenericJpaPlatformProvider. - * - * This JpaPlatformProvider implementation most likely only returns providers - * that are extensions of other platforms. Then in the GenericJpaPlatform implementation - * you pass in 1 or more JpaPlatformProviders. - * - * See the org.eclipse.jpt.core.jpaPlatforms extension point - * - * 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 JaxbPlatformProvider -{ - /** - * Return the most recent resource type for the given content type supported by this platform - */ - public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType); - - /** - * Return the resource model providers that apply to this platform. - */ - ListIterable<JaxbResourceModelProvider> getResourceModelProviders(); - -// /** -// * Return the resource definitions supported by this platform. -// */ -// ListIterator<ResourceDefinition> resourceDefinitions(); -// -// /** -// * Return the java type mapping definitions that apply to this platform. -// */ -// ListIterator<JavaTypeMappingDefinition> javaTypeMappingDefinitions(); -// -// /** -// * Return the mapping definitions to use for default java attribute mappings for this platform. -// */ -// ListIterator<JavaAttributeMappingDefinition> defaultJavaAttributeMappingDefinitions(); -// -// /** -// * Return the mapping definitions to use for specified java attribute mappings for this platform. -// */ -// ListIterator<JavaAttributeMappingDefinition> specifiedJavaAttributeMappingDefinitions(); -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractAnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractAnnotationDefinitionProvider.java deleted file mode 100644 index ad8d4a29eb..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractAnnotationDefinitionProvider.java +++ /dev/null @@ -1,127 +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; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; -import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.utility.internal.iterables.ArrayListIterable; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; - -public abstract class AbstractAnnotationDefinitionProvider - implements AnnotationDefinitionProvider -{ - private AnnotationDefinition[] typeAnnotationDefinitions; - - private AnnotationDefinition[] typeMappingAnnotationDefinitions; - - private AnnotationDefinition[] attributeAnnotationDefinitions; - - private AnnotationDefinition[] packageAnnotationDefinitions; - - - protected AbstractAnnotationDefinitionProvider() { - super(); - } - - // ********** type annotation definitions ********** - - public synchronized Iterable<AnnotationDefinition> getTypeAnnotationDefinitions() { - if (this.typeAnnotationDefinitions == null) { - this.typeAnnotationDefinitions = this.buildTypeAnnotationDefinitions(); - } - return new ArrayIterable<AnnotationDefinition>(this.typeAnnotationDefinitions); - } - - protected AnnotationDefinition[] buildTypeAnnotationDefinitions() { - ArrayList<AnnotationDefinition> definitions = new ArrayList<AnnotationDefinition>(); - this.addTypeAnnotationDefinitionsTo(definitions); - return definitions.toArray(new AnnotationDefinition[definitions.size()]); - } - - /** - * Subclasses must override this to specify type annotation definitions. - */ - protected void addTypeAnnotationDefinitionsTo(@SuppressWarnings("unused") List<AnnotationDefinition> definitions) { - // no op - } - - // ********** type mapping annotation definitions ********** - - public synchronized Iterable<AnnotationDefinition> getTypeMappingAnnotationDefinitions() { - if (this.typeMappingAnnotationDefinitions == null) { - this.typeMappingAnnotationDefinitions = this.buildTypeMappingAnnotationDefinitions(); - } - return new ArrayIterable<AnnotationDefinition>(this.typeMappingAnnotationDefinitions); - } - - protected AnnotationDefinition[] buildTypeMappingAnnotationDefinitions() { - ArrayList<AnnotationDefinition> definitions = new ArrayList<AnnotationDefinition>(); - this.addTypeMappingAnnotationDefinitionsTo(definitions); - return definitions.toArray(new AnnotationDefinition[definitions.size()]); - } - - /** - * Subclasses must override this to specify type mapping annotation - * definitions. - */ - protected void addTypeMappingAnnotationDefinitionsTo(@SuppressWarnings("unused") List<AnnotationDefinition> definitions) { - // no op - } - - // ********** attribute annotation definitions ********** - - public synchronized Iterable<AnnotationDefinition> getAttributeAnnotationDefinitions() { - if (this.attributeAnnotationDefinitions == null) { - this.attributeAnnotationDefinitions = this.buildAttributeAnnotationDefinitions(); - } - return new ArrayListIterable<AnnotationDefinition>(this.attributeAnnotationDefinitions); - } - - protected AnnotationDefinition[] buildAttributeAnnotationDefinitions() { - ArrayList<AnnotationDefinition> definitions = new ArrayList<AnnotationDefinition>(); - this.addAttributeAnnotationDefinitionsTo(definitions); - return definitions.toArray(new AnnotationDefinition[definitions.size()]); - } - - /** - * Subclasses must override this to specify attribute annotation - * definitions. - */ - protected void addAttributeAnnotationDefinitionsTo(@SuppressWarnings("unused") List<AnnotationDefinition> definitions) { - // no op - } - - - // ********** package annotation definitions ********** - - public synchronized ListIterable<AnnotationDefinition> getPackageAnnotationDefinitions() { - if (this.packageAnnotationDefinitions == null) { - this.packageAnnotationDefinitions = this.buildPackageAnnotationDefinitions(); - } - return new ArrayListIterable<AnnotationDefinition>(this.packageAnnotationDefinitions); - } - - protected AnnotationDefinition[] buildPackageAnnotationDefinitions() { - ArrayList<AnnotationDefinition> definitions = new ArrayList<AnnotationDefinition>(); - this.addPackageAnnotationDefinitionsTo(definitions); - return definitions.toArray(new AnnotationDefinition[definitions.size()]); - } - - /** - * Subclasses must override this to specify package annotation - * definitions. No package annotation definitions by default. - */ - protected void addPackageAnnotationDefinitionsTo(@SuppressWarnings("unused") List<AnnotationDefinition> definitions) { - // no op - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java index 668ffd5d33..6023884958 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformProvider.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbPlatformDefinition.java @@ -9,20 +9,23 @@ ******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal; -import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; 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.utility.internal.iterables.ArrayListIterable; import org.eclipse.jpt.utility.internal.iterables.ListIterable; /** - * All the state in the JAXB platform should be "static" (i.e. unchanging once - * it is initialized). + * All the state in the JAXB platform definition should be "static" + * (i.e. unchanging once it is initialized). */ -public abstract class AbstractJaxbPlatformProvider - implements JaxbPlatformProvider -{ +public abstract class AbstractJaxbPlatformDefinition + implements JaxbPlatformDefinition { + + private AnnotationDefinition[] annotationDefinitions; + private JaxbResourceModelProvider[] resourceModelProviders; -// + // private JavaTypeMappingDefinition[] javaTypeMappingDefinitions; // // private JavaAttributeMappingDefinition[] specifiedJavaAttributeMappingDefinitions; @@ -35,12 +38,25 @@ public abstract class AbstractJaxbPlatformProvider /** * zero-argument constructor */ - protected AbstractJaxbPlatformProvider() { + protected AbstractJaxbPlatformDefinition() { super(); } - - + + + // ********** annotation definitions ********** + + public AnnotationDefinition[] getAnnotationDefinitions() { + if (this.annotationDefinitions == null) { + this.annotationDefinitions = this.buildAnnotationDefinitions(); + } + return this.annotationDefinitions; + } + + protected abstract AnnotationDefinition[] buildAnnotationDefinitions(); + + // ********** resource models ********** + public ListIterable<JaxbResourceModelProvider> getResourceModelProviders() { return new ArrayListIterable<JaxbResourceModelProvider>(getResourceModelProviders_()); } 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 9a43349880..6a521f991e 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 @@ -10,19 +10,12 @@ package org.eclipse.jpt.jaxb.core.internal; import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; +import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; 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.JavaResourceAttribute; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; -import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType; -import org.eclipse.jpt.utility.internal.iterables.ArrayListIterable; -import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.utility.internal.iterables.ListIterable; +import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement; +import org.eclipse.jpt.utility.internal.iterables.ArrayIterable; import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; /** @@ -34,27 +27,20 @@ import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; public final class GenericAnnotationProvider implements AnnotationProvider { - private final AnnotationDefinitionProvider[] annotationDefinitionProviders; + private final AnnotationDefinition[] annotationDefinitions; - public GenericAnnotationProvider(AnnotationDefinitionProvider... annotationDefinitionProviders) { + public GenericAnnotationProvider(AnnotationDefinition ... annotationDefinitions) { super(); - this.annotationDefinitionProviders = annotationDefinitionProviders; + this.annotationDefinitions = annotationDefinitions; } - // ********** convenience methods ********** - - protected Iterable<String> getAnnotationNames(Iterable<AnnotationDefinition> annotationDefinitions) { - return new TransformationIterable<AnnotationDefinition, String>(annotationDefinitions) { - @Override - protected String transform(AnnotationDefinition annotationDefinition) { - return annotationDefinition.getAnnotationName(); - } - }; + protected Iterable<AnnotationDefinition> getAnnotationDefinitions() { + return new ArrayIterable<AnnotationDefinition>(this.annotationDefinitions); } - protected AnnotationDefinition selectAnnotationDefinition(Iterable<AnnotationDefinition> annotationDefinitions, String annotationName) { - for (AnnotationDefinition annotationDefinition : annotationDefinitions) { + protected AnnotationDefinition getAnnotationDefinition(String annotationName) { + for (AnnotationDefinition annotationDefinition : this.annotationDefinitions) { if (annotationDefinition.getAnnotationName().equals(annotationName)) { return annotationDefinition; } @@ -62,140 +48,24 @@ public final class GenericAnnotationProvider return null; } - - // ********** annotation definition providers ********** - - protected ListIterable<AnnotationDefinitionProvider> getAnnotationDefinitionProviders() { - return new ArrayListIterable<AnnotationDefinitionProvider>(this.annotationDefinitionProviders); - } - - - // ********** type annotations ********** - - public Iterable<String> getTypeAnnotationNames() { - return this.getAnnotationNames(this.getTypeAnnotationDefinitions()); - } - - protected Iterable<AnnotationDefinition> getTypeAnnotationDefinitions() { - return new CompositeIterable<AnnotationDefinition> ( - new TransformationIterable<AnnotationDefinitionProvider, Iterable<AnnotationDefinition>>(this.getAnnotationDefinitionProviders()) { - @Override - protected Iterable<AnnotationDefinition> transform(AnnotationDefinitionProvider annotationDefinitionProvider) { - return annotationDefinitionProvider.getTypeAnnotationDefinitions(); - } - } - ); - } - - public Iterable<String> getTypeMappingAnnotationNames() { - return this.getAnnotationNames(getTypeMappingAnnotationDefinitions()); - } - - protected Iterable<AnnotationDefinition> getTypeMappingAnnotationDefinitions() { - return new CompositeIterable<AnnotationDefinition> ( - new TransformationIterable<AnnotationDefinitionProvider, Iterable<AnnotationDefinition>>(this.getAnnotationDefinitionProviders()) { - @Override - protected Iterable<AnnotationDefinition> transform(AnnotationDefinitionProvider annotationDefinitionProvider) { - return annotationDefinitionProvider.getTypeMappingAnnotationDefinitions(); - } - } - ); - } - - public Annotation buildTypeAnnotation(JavaResourceType parent, Type type, String annotationName) { - return this.getTypeAnnotationDefinition(annotationName).buildAnnotation(parent, type); - } - - public Annotation buildTypeAnnotation(JavaResourceType parent, IAnnotation jdtAnnotation) { - return this.getTypeAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); - } - - protected AnnotationDefinition getTypeAnnotationDefinition(String annotationName) { - AnnotationDefinition annotationDefinition = this.selectAnnotationDefinition(this.getTypeAnnotationDefinitions(), annotationName); - if (annotationDefinition == null) { - throw new IllegalArgumentException("unsupported type annotation: " + annotationName); //$NON-NLS-1$ - } - return annotationDefinition; - } - - public Annotation buildNullTypeAnnotation(JavaResourceType parent, String annotationName) { - return this.getTypeAnnotationDefinition(annotationName).buildNullAnnotation(parent); - } - - - // ********** attribute annotations ********** - - public Iterable<String> getAttributeAnnotationNames() { - return this.getAnnotationNames(getAttributeAnnotationDefinitions()); - } - - protected Iterable<AnnotationDefinition> getAttributeAnnotationDefinitions() { - return new CompositeIterable<AnnotationDefinition> ( - new TransformationIterable<AnnotationDefinitionProvider, Iterable<AnnotationDefinition>>(this.getAnnotationDefinitionProviders()) { - @Override - protected Iterable<AnnotationDefinition> transform(AnnotationDefinitionProvider annotationDefinitionProvider) { - return annotationDefinitionProvider.getAttributeAnnotationDefinitions(); - } + public Iterable<String> getAnnotationNames() { + return new TransformationIterable<AnnotationDefinition, String>(getAnnotationDefinitions()) { + @Override + protected String transform(AnnotationDefinition annotationDefinition) { + return annotationDefinition.getAnnotationName(); } - ); - } - - public Annotation buildAttributeAnnotation(JavaResourceAttribute parent, Attribute attribute, String annotationName) { - return this.getAttributeAnnotationDefinition(annotationName).buildAnnotation(parent, attribute); + }; } - public Annotation buildAttributeAnnotation(JavaResourceAttribute parent, IAnnotation jdtAnnotation) { - return this.getAttributeAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); + public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName) { + return this.getAnnotationDefinition(annotationName).buildAnnotation(parent, element); } - public Annotation buildNullAttributeAnnotation(JavaResourceAttribute parent, String annotationName) { - return this.getAttributeAnnotationDefinition(annotationName).buildNullAnnotation(parent); + public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { + return this.getAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); } - protected AnnotationDefinition getAttributeAnnotationDefinition(String annotationName) { - AnnotationDefinition annotationDefinition = this.selectAnnotationDefinition(this.getAttributeAnnotationDefinitions(), annotationName); - if (annotationDefinition == null) { - throw new IllegalArgumentException("unsupported attribute annotation: " + annotationName); //$NON-NLS-1$ - } - return annotationDefinition; + public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent, String annotationName) { + return this.getAnnotationDefinition(annotationName).buildNullAnnotation(parent); } - - - // ********** package annotations ********** - - public Iterable<String> getPackageAnnotationNames() { - return getAnnotationNames(getPackageAnnotationDefinitions()); - } - - protected Iterable<AnnotationDefinition> getPackageAnnotationDefinitions() { - return new CompositeIterable<AnnotationDefinition> ( - new TransformationIterable<AnnotationDefinitionProvider, Iterable<AnnotationDefinition>>(this.getAnnotationDefinitionProviders()) { - @Override - protected Iterable<AnnotationDefinition> transform(AnnotationDefinitionProvider annotationDefinitionProvider) { - return annotationDefinitionProvider.getPackageAnnotationDefinitions(); - } - } - ); - } - - public Annotation buildPackageAnnotation(JavaResourcePackage parent, AnnotatedPackage pack, String annotationName) { - return this.getPackageAnnotationDefinition(annotationName).buildAnnotation(parent, pack); - } - - public Annotation buildPackageAnnotation(JavaResourcePackage parent, IAnnotation jdtAnnotation) { - return this.getPackageAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); - } - - public Annotation buildNullPackageAnnotation(JavaResourcePackage parent, String annotationName) { - return this.getPackageAnnotationDefinition(annotationName).buildNullAnnotation(parent); - } - - protected AnnotationDefinition getPackageAnnotationDefinition(String annotationName) { - AnnotationDefinition annotationDefinition = this.selectAnnotationDefinition(this.getPackageAnnotationDefinitions(), annotationName); - if (annotationDefinition == null) { - throw new IllegalArgumentException("unsupported package mapping annotation: " + annotationName); //$NON-NLS-1$ - } - return annotationDefinition; - } - } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java deleted file mode 100644 index 1a535bd25e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java +++ /dev/null @@ -1,129 +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; - -import java.util.List; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorOrderAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorTypeAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyAttributeAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyElementAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttachmentRefAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttributeAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementDeclAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefsAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementWrapperAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementsAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumValueAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDREFAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlInlineBinaryDataAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlJavaTypeAdapterAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.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; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRootElementAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaTypeAnnotationDefinition; -import org.eclipse.jpt.jaxb.core.internal.resource.java.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.resource.java.AnnotationDefinition; - -/** - * Support for JAXB annotations - */ -public class GenericJaxbAnnotationDefinitionProvider - extends AbstractAnnotationDefinitionProvider -{ - // singleton - private static final AnnotationDefinitionProvider INSTANCE = - new GenericJaxbAnnotationDefinitionProvider(); - - - /** - * Return the singleton - */ - public static AnnotationDefinitionProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private GenericJaxbAnnotationDefinitionProvider() { - super(); - } - - - @Override - protected void addPackageAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(XmlAccessorOrderAnnotationDefinition.instance()); - definitions.add(XmlAccessorTypeAnnotationDefinition.instance()); - definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance()); - definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance()); - definitions.add(XmlSchemaAnnotationDefinition.instance()); - definitions.add(XmlSchemaTypeAnnotationDefinition.instance()); - definitions.add(XmlSchemaTypesAnnotationDefinition.instance()); - } - - @Override - protected void addTypeAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(XmlAccessorOrderAnnotationDefinition.instance()); - definitions.add(XmlAccessorTypeAnnotationDefinition.instance()); - definitions.add(XmlEnumAnnotationDefinition.instance()); - definitions.add(XmlInlineBinaryDataAnnotationDefinition.instance()); - definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance()); - definitions.add(XmlRegistryAnnotationDefinition.instance()); - definitions.add(XmlRootElementAnnotationDefinition.instance()); - definitions.add(XmlSeeAlsoAnnotationDefinition.instance()); - definitions.add(XmlTransientAnnotationDefinition.instance()); - definitions.add(XmlTypeAnnotationDefinition.instance()); - } - - @Override - protected void addTypeMappingAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(XmlRegistryAnnotationDefinition.instance()); - definitions.add(XmlTransientAnnotationDefinition.instance()); - definitions.add(XmlTypeAnnotationDefinition.instance()); - } - - @Override - protected void addAttributeAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(XmlAnyAttributeAnnotationDefinition.instance()); - definitions.add(XmlAnyElementAnnotationDefinition.instance()); - definitions.add(XmlAttachmentRefAnnotationDefinition.instance()); - definitions.add(XmlAttributeAnnotationDefinition.instance()); - definitions.add(XmlElementAnnotationDefinition.instance()); - definitions.add(XmlElementDeclAnnotationDefinition.instance()); - definitions.add(XmlElementsAnnotationDefinition.instance()); - definitions.add(XmlElementRefAnnotationDefinition.instance()); - definitions.add(XmlElementRefsAnnotationDefinition.instance()); - definitions.add(XmlElementWrapperAnnotationDefinition.instance()); - definitions.add(XmlEnumValueAnnotationDefinition.instance()); - definitions.add(XmlIDAnnotationDefinition.instance()); - definitions.add(XmlIDREFAnnotationDefinition.instance()); - definitions.add(XmlInlineBinaryDataAnnotationDefinition.instance()); - definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance()); - definitions.add(XmlListAnnotationDefinition.instance()); - definitions.add(XmlMimeTypeAnnotationDefinition.instance()); - definitions.add(XmlMixedAnnotationDefinition.instance()); - definitions.add(XmlTransientAnnotationDefinition.instance()); - definitions.add(XmlValueAnnotationDefinition.instance()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbPlatformProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbPlatformProvider.java deleted file mode 100644 index 8cdde915c3..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbPlatformProvider.java +++ /dev/null @@ -1,123 +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; - -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; -import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; - -/** - * All the state in the JAXB platform should be "static" (i.e. unchanging once - * it is initialized). - */ -public class GenericJaxbPlatformProvider - extends AbstractJaxbPlatformProvider -{ - // singleton - private static final JaxbPlatformProvider INSTANCE = - new GenericJaxbPlatformProvider(); - - - /** - * Return the singleton. - */ - public static JaxbPlatformProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private GenericJaxbPlatformProvider() { - super(); - } - - - // ********** resource models ********** - - public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType) { - if (contentType.equals(JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) { - return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; - } - else if (contentType.equals(JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) { - return JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE; - } -// else if (contentType.equals(JptCorePlugin.JAR_CONTENT_TYPE)) { -// return JptCorePlugin.JAR_RESOURCE_TYPE; -// } -// else if (contentType.equals(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { -// return JptCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE; -// } -// else if (contentType.equals(JptCorePlugin.ORM_XML_CONTENT_TYPE)) { -// return JptCorePlugin.ORM_XML_1_0_RESOURCE_TYPE; -// } - throw new IllegalArgumentException(contentType.toString()); - } - - @Override - protected JaxbResourceModelProvider[] buildResourceModelProviders() { - // order should not be important here - return new JaxbResourceModelProvider[] { - JavaResourceModelProvider.instance(), - JavaPackageInfoResourceModelProvider.instance()}; - } - -// -// // ********** Java type mappings ********** -// -// @Override -// protected JavaTypeMappingDefinition[] buildNonNullJavaTypeMappingDefinitions() { -// // order determined by analyzing order that reference implementation (toplink) uses -// return new JavaTypeMappingDefinition[] { -// JavaEntityDefinition.instance(), -// JavaEmbeddableDefinition.instance(), -// JavaMappedSuperclassDefinition.instance()}; -// } -// -// -// // ********** Java attribute mappings ********** -// -// @Override -// protected JavaAttributeMappingDefinition[] buildNonNullDefaultJavaAttributeMappingDefinitions() { -// // order determined by analyzing order that reference implementation (toplink) uses -// return new JavaAttributeMappingDefinition[] { -// JavaEmbeddedMappingDefinition.instance(), -// JavaBasicMappingDefinition.instance()}; -// } -// -// @Override -// protected JavaAttributeMappingDefinition[] buildNonNullSpecifiedJavaAttributeMappingDefinitions() { -// // order determined by analyzing order that reference implementation (eclipselink) uses -// return new JavaAttributeMappingDefinition[] { -// JavaTransientMappingDefinition.instance(), -// JavaIdMappingDefinition.instance(), -// JavaVersionMappingDefinition.instance(), -// JavaBasicMappingDefinition.instance(), -// JavaEmbeddedMappingDefinition.instance(), -// JavaEmbeddedIdMappingDefinition.instance(), -// JavaManyToManyMappingDefinition.instance(), -// JavaManyToOneMappingDefinition.instance(), -// JavaOneToManyMappingDefinition.instance(), -// JavaOneToOneMappingDefinition.instance()}; -// } -// -// -// // ********** Mapping Files ********** -// -// @Override -// protected ResourceDefinition[] buildResourceDefinitions() { -// return new ResourceDefinition[] { -// GenericPersistenceXmlDefinition.instance(), -// GenericOrmXmlDefinition.instance()}; -// } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxbPlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxbPlatformDefinition.java deleted file mode 100644 index 7b914d1ac5..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxbPlatformDefinition.java +++ /dev/null @@ -1,51 +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.jaxb21; - -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; -import org.eclipse.jpt.jaxb.core.JaxbFactory; -import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; -import org.eclipse.jpt.jaxb.core.internal.GenericJaxbAnnotationDefinitionProvider; -import org.eclipse.jpt.jaxb.core.internal.GenericJaxbPlatformProvider; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition; - -public class GenericJaxbPlatformDefinition - implements JaxbPlatformDefinition -{ - // singleton - private static final JaxbPlatformDefinition INSTANCE = new GenericJaxbPlatformDefinition(); - - /** - * Return the singleton. - */ - public static JaxbPlatformDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private GenericJaxbPlatformDefinition() { - super(); - } - - public JaxbFactory buildFactory() { - return GenericJaxbFactory.instance(); - } - - public JaxbPlatformProvider buildPlatformProvider() { - return GenericJaxbPlatformProvider.instance(); - } - - public AnnotationDefinitionProvider[] getAnnotationDefinitionProviders() { - return new AnnotationDefinitionProvider[] {GenericJaxbAnnotationDefinitionProvider.instance()}; - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbFactory.java index f9fcde4953..28928f8e58 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbFactory.java @@ -15,11 +15,11 @@ import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbFactory; /** * Generic JAXB */ -public class GenericJaxbFactory - extends AbstractJaxbFactory -{ +public class Generic_2_1_JaxbFactory + extends AbstractJaxbFactory { + // singleton - private static final JaxbFactory INSTANCE = new GenericJaxbFactory(); + private static final JaxbFactory INSTANCE = new Generic_2_1_JaxbFactory(); /** * Return the singleton. @@ -31,7 +31,7 @@ public class GenericJaxbFactory /** * Ensure single instance. */ - private GenericJaxbFactory() { + private Generic_2_1_JaxbFactory() { super(); } } 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 new file mode 100644 index 0000000000..70a119e6a8 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinition.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * 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.jaxb21; + +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jpt.core.JpaResourceType; +import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.jaxb.core.JaxbFactory; +import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; +import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbPlatformDefinition; +import org.eclipse.jpt.jaxb.core.internal.JavaPackageInfoResourceModelProvider; +import org.eclipse.jpt.jaxb.core.internal.JavaResourceModelProvider; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorOrderAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAccessorTypeAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyAttributeAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAnyElementAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttachmentRefAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlAttributeAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementDeclAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementRefsAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementWrapperAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlElementsAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlEnumValueAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlIDREFAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlInlineBinaryDataAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlJavaTypeAdapterAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.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; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRootElementAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaTypeAnnotationDefinition; +import org.eclipse.jpt.jaxb.core.internal.resource.java.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; + +public class Generic_2_1_JaxbPlatformDefinition + extends AbstractJaxbPlatformDefinition +{ + // singleton + private static final JaxbPlatformDefinition INSTANCE = new Generic_2_1_JaxbPlatformDefinition(); + + /** + * Return the singleton. + */ + public static JaxbPlatformDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private Generic_2_1_JaxbPlatformDefinition() { + super(); + } + + public JaxbFactory getFactory() { + return Generic_2_1_JaxbFactory.instance(); + } + + @Override + protected AnnotationDefinition[] buildAnnotationDefinitions() { + return new AnnotationDefinition[] { + XmlAccessorOrderAnnotationDefinition.instance(), + XmlAccessorTypeAnnotationDefinition.instance(), + XmlAnyAttributeAnnotationDefinition.instance(), + XmlAnyElementAnnotationDefinition.instance(), + XmlAttachmentRefAnnotationDefinition.instance(), + XmlAttributeAnnotationDefinition.instance(), + XmlElementAnnotationDefinition.instance(), + XmlElementDeclAnnotationDefinition.instance(), + XmlElementsAnnotationDefinition.instance(), + 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()}; + } + + // ********** resource models ********** + + public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType) { + if (contentType.equals(JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) { + return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; + } + else if (contentType.equals(JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) { + return JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE; + } +// else if (contentType.equals(JptCorePlugin.JAR_CONTENT_TYPE)) { +// return JptCorePlugin.JAR_RESOURCE_TYPE; +// } +// else if (contentType.equals(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { +// return JptCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE; +// } +// else if (contentType.equals(JptCorePlugin.ORM_XML_CONTENT_TYPE)) { +// return JptCorePlugin.ORM_XML_1_0_RESOURCE_TYPE; +// } + throw new IllegalArgumentException(contentType.toString()); + } + + @Override + protected JaxbResourceModelProvider[] buildResourceModelProviders() { + // order should not be important here + return new JaxbResourceModelProvider[] { + JavaResourceModelProvider.instance(), + JavaPackageInfoResourceModelProvider.instance()}; + } + +// +// // ********** Java type mappings ********** +// +// @Override +// protected JavaTypeMappingDefinition[] buildNonNullJavaTypeMappingDefinitions() { +// // order determined by analyzing order that reference implementation (toplink) uses +// return new JavaTypeMappingDefinition[] { +// JavaEntityDefinition.instance(), +// JavaEmbeddableDefinition.instance(), +// JavaMappedSuperclassDefinition.instance()}; +// } +// +// +// // ********** Java attribute mappings ********** +// +// @Override +// protected JavaAttributeMappingDefinition[] buildNonNullDefaultJavaAttributeMappingDefinitions() { +// // order determined by analyzing order that reference implementation (toplink) uses +// return new JavaAttributeMappingDefinition[] { +// JavaEmbeddedMappingDefinition.instance(), +// JavaBasicMappingDefinition.instance()}; +// } +// +// @Override +// protected JavaAttributeMappingDefinition[] buildNonNullSpecifiedJavaAttributeMappingDefinitions() { +// // order determined by analyzing order that reference implementation (eclipselink) uses +// return new JavaAttributeMappingDefinition[] { +// JavaTransientMappingDefinition.instance(), +// JavaIdMappingDefinition.instance(), +// JavaVersionMappingDefinition.instance(), +// JavaBasicMappingDefinition.instance(), +// JavaEmbeddedMappingDefinition.instance(), +// JavaEmbeddedIdMappingDefinition.instance(), +// JavaManyToManyMappingDefinition.instance(), +// JavaManyToOneMappingDefinition.instance(), +// JavaOneToManyMappingDefinition.instance(), +// JavaOneToOneMappingDefinition.instance()}; +// } +// +// +// // ********** Mapping Files ********** +// +// @Override +// protected ResourceDefinition[] buildResourceDefinitions() { +// return new ResourceDefinition[] { +// GenericPersistenceXmlDefinition.instance(), +// GenericOrmXmlDefinition.instance()}; +// } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinitionFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinitionFactory.java index c03bacf036..ff9a9a4223 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinitionFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/Generic_2_1_JaxbPlatformDefinitionFactory.java @@ -17,6 +17,6 @@ public class Generic_2_1_JaxbPlatformDefinitionFactory implements JaxbPlatformDefinitionFactory { public JaxbPlatformDefinition buildJaxbPlatformDefinition() { - return GenericJaxbPlatformDefinition.instance(); + return Generic_2_1_JaxbPlatformDefinition.instance(); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/Generic_2_2_JaxbPlatformDefinitionFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/Generic_2_2_JaxbPlatformDefinitionFactory.java index 96b8a3592e..4d7958edcd 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/Generic_2_2_JaxbPlatformDefinitionFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb22/Generic_2_2_JaxbPlatformDefinitionFactory.java @@ -9,7 +9,7 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.jaxb22; -import org.eclipse.jpt.jaxb.core.internal.jaxb21.GenericJaxbPlatformDefinition; +import org.eclipse.jpt.jaxb.core.internal.jaxb21.Generic_2_1_JaxbPlatformDefinition; import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition; import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinitionFactory; @@ -18,7 +18,7 @@ public class Generic_2_2_JaxbPlatformDefinitionFactory implements JaxbPlatformDefinitionFactory { public JaxbPlatformDefinition buildJaxbPlatformDefinition() { - return GenericJaxbPlatformDefinition.instance(); + return Generic_2_1_JaxbPlatformDefinition.instance(); } } 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 9ecf68c2db..a56bab86ee 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 @@ -18,7 +18,6 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; import org.eclipse.jpt.jaxb.core.AnnotationProvider; import org.eclipse.jpt.jaxb.core.JaxbFactory; import org.eclipse.jpt.jaxb.core.JaxbFile; -import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; import org.eclipse.jpt.jaxb.core.JaxbProject; import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; import org.eclipse.jpt.jaxb.core.internal.GenericAnnotationProvider; @@ -29,27 +28,25 @@ import org.eclipse.jpt.utility.internal.iterables.ListIterable; public final class JaxbPlatformImpl implements JaxbPlatform { - private final JaxbFactory jaxbFactory; + private JaxbPlatformDefinition platformDefinition; + + private AnnotationProvider annotationProvider; + - private final AnnotationProvider annotationProvider; - - private final JaxbPlatformProvider platformProvider; - public JaxbPlatformImpl(JaxbPlatformDefinition jaxbPlatformDefinition) { super(); - this.jaxbFactory = jaxbPlatformDefinition.buildFactory(); - this.annotationProvider = new GenericAnnotationProvider(jaxbPlatformDefinition.getAnnotationDefinitionProviders()); - this.platformProvider = jaxbPlatformDefinition.buildPlatformProvider(); + this.platformDefinition = jaxbPlatformDefinition; + this.annotationProvider = new GenericAnnotationProvider(this.platformDefinition.getAnnotationDefinitions()); } // ********** factory ********** public JaxbFactory getFactory() { - return this.jaxbFactory; + return this.platformDefinition.getFactory(); } - - + + // ********** JAXB file/resource models ********** public JaxbFile buildJaxbFile(JaxbProject jaxbProject, IFile file) { @@ -59,7 +56,7 @@ public final class JaxbPlatformImpl protected JaxbFile buildJaxbFile(JaxbProject jaxbProject, IFile file, IContentType contentType) { JpaResourceModel resourceModel = this.buildResourceModel(jaxbProject, file, contentType); - return (resourceModel == null) ? null : this.jaxbFactory.buildJaxbFile(jaxbProject, file, contentType, resourceModel); + return (resourceModel == null) ? null : getFactory().buildJaxbFile(jaxbProject, file, contentType, resourceModel); } protected JpaResourceModel buildResourceModel(JaxbProject jaxbProject, IFile file, IContentType contentType) { @@ -81,12 +78,12 @@ public final class JaxbPlatformImpl } protected ListIterable<JaxbResourceModelProvider> getResourceModelProviders() { - return this.platformProvider.getResourceModelProviders(); + return this.platformDefinition.getResourceModelProviders(); } - - + + // ********** Java annotations ********** - + public AnnotationProvider getAnnotationProvider() { return this.annotationProvider; } 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 b768998293..b7157a472f 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 @@ -254,13 +254,19 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> private boolean annotationIsValid(String annotationName) { return CollectionTools.contains(this.getValidAnnotationNames(), annotationName); } - - abstract Iterable<String> getValidAnnotationNames(); - - abstract Annotation buildAnnotation(String annotationName); - - abstract Annotation buildNullAnnotation(String annotationName); - + + Iterable<String> getValidAnnotationNames() { + return this.getAnnotationProvider().getAnnotationNames(); + } + + Annotation buildAnnotation(String annotationName) { + return this.getAnnotationProvider().buildAnnotation(this, this.annotatedElement, annotationName); + } + + Annotation buildNullAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullAnnotation(this, annotationName); + } + // minimize scope of suppressed warnings @SuppressWarnings("unchecked") private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java index c1ea323d38..391821ad3c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java @@ -151,37 +151,23 @@ final class SourceAttribute // ******** AbstractJavaResourcePersistentMember implementation ******** - - @Override - Iterable<String> getValidAnnotationNames() { - return this.getAnnotationProvider().getAttributeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildAttributeAnnotation(this, this.annotatedElement, annotationName); - } - - Annotation buildNullAnnotation_(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName); - } - + public boolean isFor(MethodSignature signature, int occurrence) { return ((MethodAttribute) this.annotatedElement).matches(signature, occurrence); } - - + + // ******** JavaResourcePersistentAttribute implementation ******** - + public String getName() { return this.annotatedElement.getAttributeName(); } - + @Override public Annotation buildNullAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); + return (annotationName == null) ? null : super.buildNullAnnotation(annotationName); } - + public boolean isField() { return this.annotatedElement.isField(); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackage.java index 6fabc31343..74f8c58a14 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackage.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackage.java @@ -15,7 +15,6 @@ import org.eclipse.jdt.core.dom.IPackageBinding; import org.eclipse.jdt.core.dom.PackageDeclaration; import org.eclipse.jpt.core.internal.utility.jdt.JDTPackage; import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage; -import org.eclipse.jpt.jaxb.core.resource.java.Annotation; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; @@ -89,24 +88,6 @@ public final class SourcePackage this.syncName(this.buildName(astRoot)); } - // ********** SourceAnnotatedElement implementation ********** - - @Override - Iterable<String> getValidAnnotationNames() { - return this.getAnnotationProvider().getPackageAnnotationNames(); - } - - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildPackageAnnotation(this, this.annotatedElement, annotationName); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullPackageAnnotation(this, annotationName); - } - @Override public void toString(StringBuilder sb) { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java index 1ce0539318..13716cd311 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java @@ -27,7 +27,6 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment; import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; import org.eclipse.jpt.core.internal.utility.jdt.JDTType; import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.jaxb.core.resource.java.Annotation; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType; @@ -166,21 +165,6 @@ final class SourceType // ********** SourceAnnotatedElement implementation ********** @Override - Iterable<String> getValidAnnotationNames() { - return this.getAnnotationProvider().getTypeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider().buildTypeAnnotation(this, this.annotatedElement, annotationName); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName); - } - - @Override public void resolveTypes(CompilationUnit astRoot) { super.resolveTypes(astRoot); @@ -396,22 +380,9 @@ final class SourceType } public boolean isMapped() { - for (Annotation each : this.getAnnotations()) { - if (this.annotationIsMappingAnnotation(each)) { - return true; - } - } - return false; - } - - private boolean annotationIsMappingAnnotation(Annotation annotation) { - return CollectionTools.contains(this.getMappingAnnotationNames(), annotation.getAnnotationName()); + return ! CollectionTools.isEmpty(getAnnotations()); } - - private Iterable<String> getMappingAnnotationNames() { - return this.getAnnotationProvider().getTypeMappingAnnotationNames(); - } - + /** * check only persistable attributes */ 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 b19e695254..c07ae65768 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 @@ -9,9 +9,12 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.core.platform; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jpt.core.JpaResourceType; import org.eclipse.jpt.jaxb.core.JaxbFactory; -import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; +import org.eclipse.jpt.jaxb.core.JaxbResourceModelProvider; +import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; +import org.eclipse.jpt.utility.internal.iterables.ListIterable; /** * Provisional API: This class is part of an interim API that is still @@ -25,10 +28,37 @@ import org.eclipse.jpt.jaxb.core.JaxbPlatformProvider; */ public interface JaxbPlatformDefinition { - JaxbFactory buildFactory(); - - AnnotationDefinitionProvider[] getAnnotationDefinitionProviders(); - - JaxbPlatformProvider buildPlatformProvider(); - + JaxbFactory getFactory(); + + AnnotationDefinition[] getAnnotationDefinitions(); + + /** + * Return the resource model providers that apply to this platform. + */ + ListIterable<JaxbResourceModelProvider> getResourceModelProviders(); + + /** + * Return the most recent resource type for the given content type supported by this platform + */ + public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType); + +// /** +// * Return the resource definitions supported by this platform. +// */ +// ListIterator<ResourceDefinition> resourceDefinitions(); +// +// /** +// * Return the java type mapping definitions that apply to this platform. +// */ +// ListIterator<JavaTypeMappingDefinition> javaTypeMappingDefinitions(); +// +// /** +// * Return the mapping definitions to use for default java attribute mappings for this platform. +// */ +// ListIterator<JavaAttributeMappingDefinition> defaultJavaAttributeMappingDefinitions(); +// +// /** +// * Return the mapping definitions to use for specified java attribute mappings for this platform. +// */ +// ListIterator<JavaAttributeMappingDefinition> specifiedJavaAttributeMappingDefinitions(); } diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java index 31b0b51ff3..4ea26c02f8 100644 --- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java +++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java @@ -17,11 +17,11 @@ import org.eclipse.jdt.core.IJavaElementDelta; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jpt.core.internal.utility.jdt.NullAnnotationEditFormatter; import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; import org.eclipse.jpt.jaxb.core.AnnotationProvider; import org.eclipse.jpt.jaxb.core.internal.GenericAnnotationProvider; import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourcePackageInfoCompilationUnit; import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceTypeCompilationUnit; +import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage; @@ -164,16 +164,15 @@ public abstract class JavaResourceModelTestCase throw new IllegalStateException(); } return new SourceTypeCompilationUnit( - cu, - this.buildAnnotationProvider(), - NullAnnotationEditFormatter.instance(), - CommandExecutor.Default.instance() - ); + cu, + this.buildAnnotationProvider(), + NullAnnotationEditFormatter.instance(), + CommandExecutor.Default.instance()); } protected AnnotationProvider buildAnnotationProvider() { - return new GenericAnnotationProvider(this.annotationDefinitionProvider()); + return new GenericAnnotationProvider(annotationDefinitions()); } - - protected abstract AnnotationDefinitionProvider annotationDefinitionProvider(); + + protected abstract AnnotationDefinition[] annotationDefinitions(); } diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTestCase.java index 5ece726dfa..30f84d4881 100644 --- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTestCase.java +++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTestCase.java @@ -9,8 +9,8 @@ ******************************************************************************/ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java; -import org.eclipse.jpt.jaxb.core.AnnotationDefinitionProvider; -import org.eclipse.jpt.jaxb.core.internal.GenericJaxbAnnotationDefinitionProvider; +import org.eclipse.jpt.jaxb.core.internal.jaxb21.Generic_2_1_JaxbPlatformDefinition; +import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition; public class JaxbJavaResourceModelTestCase extends JavaResourceModelTestCase { @@ -18,9 +18,10 @@ public class JaxbJavaResourceModelTestCase public JaxbJavaResourceModelTestCase(String name) { super(name); } - + + @Override - protected AnnotationDefinitionProvider annotationDefinitionProvider() { - return GenericJaxbAnnotationDefinitionProvider.instance(); + protected AnnotationDefinition[] annotationDefinitions() { + return Generic_2_1_JaxbPlatformDefinition.instance().getAnnotationDefinitions(); } } |