diff options
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource')
9 files changed, 82 insertions, 260 deletions
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); -} |