Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java72
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java53
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java116
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementsAnnotation.java64
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java40
7 files changed, 360 insertions, 80 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
index ca0ea9c340..31b73bca8f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementAnnotationDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -15,26 +15,24 @@ import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementAnnotation;
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
-import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.NestableAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
/**
* javax.xml.bind.annotation.XmlElement
*/
public final class XmlElementAnnotationDefinition
- implements NestableAnnotationDefinition
+ implements AnnotationDefinition
{
// singleton
- private static final NestableAnnotationDefinition INSTANCE = new XmlElementAnnotationDefinition();
+ private static final AnnotationDefinition INSTANCE = new XmlElementAnnotationDefinition();
/**
* Return the singleton.
*/
- public static NestableAnnotationDefinition instance() {
+ public static AnnotationDefinition instance() {
return INSTANCE;
}
@@ -45,8 +43,12 @@ public final class XmlElementAnnotationDefinition
super();
}
- public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) {
- return SourceXmlElementAnnotation.buildSourceXmlElementAnnotation((JavaResourceMember) parent, (Attribute) annotatedElement, index);
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return SourceXmlElementAnnotation.buildSourceXmlElementAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
@@ -56,16 +58,4 @@ public final class XmlElementAnnotationDefinition
public String getAnnotationName() {
return XmlElementAnnotation.ANNOTATION_NAME;
}
-
- public String getNestableAnnotationName() {
- return JAXB.XML_ELEMENT;
- }
-
- public String getContainerAnnotationName() {
- return JAXB.XML_ELEMENTS;
- }
-
- public String getElementName() {
- return JAXB.XML_ELEMENTS__VALUE;
- }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java
new file mode 100644
index 0000000000..dfb9f4faac
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlElementsAnnotationDefinition.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.Attribute;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlElementsAnnotation;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlElementsAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlElement
+ */
+public final class XmlElementsAnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlElementsAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlElementsAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlElementsAnnotation((JavaResourceAttribute) parent, (Attribute) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlElementsAnnotation((JavaResourceAttribute) parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return XmlElementsAnnotation.ANNOTATION_NAME;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java
new file mode 100644
index 0000000000..ff5713246e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlElementsAnnotation.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.binary;
+
+import java.util.Vector;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
+import org.eclipse.jpt.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
+
+/**
+ * javax.xml.bind.annotation.XmlElements
+ */
+public final class BinaryXmlElementsAnnotation
+ extends BinaryAnnotation
+ implements XmlElementsAnnotation
+{
+ private final Vector<XmlElementAnnotation> xmlElements;
+
+
+ public BinaryXmlElementsAnnotation(JavaResourceAttribute parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.xmlElements = this.buildXmlElements();
+ }
+
+ private Vector<XmlElementAnnotation> buildXmlElements() {
+ Object[] jdtXmlElements = this.getJdtMemberValues(JAXB.XML_ELEMENTS__VALUE);
+ Vector<XmlElementAnnotation> result = new Vector<XmlElementAnnotation>(jdtXmlElements.length);
+ for (Object jdtXmlElement : jdtXmlElements) {
+ result.add(new BinaryXmlElementAnnotation(this, (IAnnotation) jdtXmlElement));
+ }
+ return result;
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public ListIterable<XmlElementAnnotation> getXmlElements() {
+ return new LiveCloneListIterable<XmlElementAnnotation>(this.xmlElements);
+ }
+
+ public int getXmlElementsSize() {
+ return this.xmlElements.size();
+ }
+
+ public XmlElementAnnotation xmlElementAt(int index) {
+ return this.xmlElements.elementAt(index);
+ }
+
+ public XmlElementAnnotation addXmlElement(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void moveXmlElement(int targetIndex, int sourceIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeXmlElement(int index) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
index 93c91e6cc6..d37400fb6f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
@@ -12,13 +12,13 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.ASTTools;
import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
@@ -28,6 +28,7 @@ import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
/**
@@ -37,8 +38,7 @@ public final class SourceXmlElementAnnotation
extends SourceAnnotation<Attribute>
implements XmlElementAnnotation
{
- public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public static final SimpleDeclarationAnnotationAdapter CONTAINER_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JAXB.XML_ELEMENTS);
+ private static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
private final AnnotationElementAdapter<String> nameAdapter;
@@ -67,21 +67,20 @@ public final class SourceXmlElementAnnotation
// ********** constructors **********
- public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceMember parent, Attribute attribute, int index) {
- IndexedDeclarationAnnotationAdapter idaa = buildXmlElementDeclarationAnnotationAdapter(index);
- IndexedAnnotationAdapter iaa = buildXmlElementAnnotationAdapter(attribute, idaa);
+ public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceMember parent, Attribute attribute) {
return new SourceXmlElementAnnotation(
parent,
attribute,
- idaa,
- iaa);
+ DECLARATION_ANNOTATION_ADAPTER);
}
-
- private SourceXmlElementAnnotation(
- JavaResourceMember parent,
- Attribute attribute,
- IndexedDeclarationAnnotationAdapter daa,
- IndexedAnnotationAdapter annotationAdapter) {
+
+ public static SourceXmlElementAnnotation buildNestedSourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) {
+ IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(attribute, idaa);
+ return new SourceXmlElementAnnotation(parent, attribute, idaa, annotationAdapter);
+ }
+
+
+ private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, attribute, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter);
@@ -97,6 +96,14 @@ public final class SourceXmlElementAnnotation
this.typeAdapter = this.buildAnnotationElementAdapter(this.typeDeclarationAdapter);
}
+ private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) {
+ this(parent, attribute, daa, new ElementAnnotationAdapter(attribute, daa));
+ }
+
+ private SourceXmlElementAnnotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) {
+ this(parent, attribute, idaa, new ElementIndexedAnnotationAdapter(attribute, idaa));
+ }
+
private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daa) {
return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_ELEMENT__NAME, false); // false = do not remove annotation when empty
}
@@ -352,20 +359,4 @@ public final class SourceXmlElementAnnotation
}
- // ********** static methods **********
-
- private static IndexedAnnotationAdapter buildXmlElementAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) {
- return new ElementIndexedAnnotationAdapter(annotatedElement, idaa);
- }
-
- private static IndexedDeclarationAnnotationAdapter buildXmlElementDeclarationAnnotationAdapter(int index) {
- IndexedDeclarationAnnotationAdapter idaa =
- new CombinationIndexedDeclarationAnnotationAdapter(
- DECLARATION_ANNOTATION_ADAPTER,
- CONTAINER_DECLARATION_ANNOTATION_ADAPTER,
- index,
- JAXB.XML_ELEMENT);
- return idaa;
- }
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java
new file mode 100644
index 0000000000..f6e85751bb
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementsAnnotation.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Attribute;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation;
+import org.eclipse.jpt.utility.internal.iterables.ListIterable;
+
+/**
+ * javax.xml.bind.annotation.XmlElements
+ */
+public class SourceXmlElementsAnnotation
+ extends SourceAnnotation<Attribute>
+ implements XmlElementsAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER
+ = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+
+ private final XmlElementsAnnotationContainer xmlElementsContainer = new XmlElementsAnnotationContainer();
+
+ public SourceXmlElementsAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public SourceXmlElementsAnnotation(JavaResourceAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) {
+ super(parent, attribute, daa);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.xmlElementsContainer.initialize(this.getAstAnnotation(astRoot));
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ this.xmlElementsContainer.synchronize(this.getAstAnnotation(astRoot));
+ }
+
+
+ // **************** xmlns *************************************************
+
+ public ListIterable<XmlElementAnnotation> getXmlElements() {
+ return this.xmlElementsContainer.getNestedAnnotations();
+ }
+
+ public int getXmlElementsSize() {
+ return this.xmlElementsContainer.getNestedAnnotationsSize();
+ }
+
+ public XmlElementAnnotation xmlElementAt(int index) {
+ return this.xmlElementsContainer.nestedAnnotationAt(index);
+ }
+
+ public XmlElementAnnotation addXmlElement(int index) {
+ return this.xmlElementsContainer.addNestedAnnotation(index);
+ }
+
+ private XmlElementAnnotation buildXmlElement(int index) {
+ return SourceXmlElementAnnotation.buildNestedSourceXmlElementAnnotation(this, this.annotatedElement, buildXmlElementIndexedDeclarationAnnotationAdapter(index));
+ }
+
+ private IndexedDeclarationAnnotationAdapter buildXmlElementIndexedDeclarationAnnotationAdapter(int index) {
+ return new NestedIndexedDeclarationAnnotationAdapter(
+ this.daa, JAXB.XML_ELEMENTS__VALUE, index, JAXB.XML_ELEMENT, false);
+ }
+
+ public void moveXmlElement(int targetIndex, int sourceIndex) {
+ this.xmlElementsContainer.moveNestedAnnotation(targetIndex, sourceIndex);
+ }
+
+ public void removeXmlElement(int index) {
+ this.xmlElementsContainer.removeNestedAnnotation(index);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the xml schema's xmlns
+ */
+ class XmlElementsAnnotationContainer
+ extends AnnotationContainer<XmlElementAnnotation>
+ {
+ @Override
+ protected String getAnnotationsPropertyName() {
+ return XML_ELEMENTS_LIST;
+ }
+ @Override
+ protected String getElementName() {
+ return JAXB.XML_ELEMENTS__VALUE;
+ }
+ @Override
+ protected String getNestedAnnotationName() {
+ return JAXB.XML_ELEMENT;
+ }
+ @Override
+ protected XmlElementAnnotation buildNestedAnnotation(int index) {
+ return SourceXmlElementsAnnotation.this.buildXmlElement(index);
+ }
+ }
+}
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
new file mode 100644
index 0000000000..57cb34dd27
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlElementsAnnotation.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.resource.java;
+
+import org.eclipse.jpt.utility.internal.iterables.ListIterable;
+
+/**
+ * Corresponds to the JAXB annotation
+ * javax.xml.bind.annotation.XmlElement
+ *
+ * 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 Annotation
+{
+ String ANNOTATION_NAME = JAXB.XML_ELEMENTS;
+
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterable<XmlElementAnnotation> getXmlElements();
+ String XML_ELEMENTS_LIST = "xmlElements"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ */
+ int getXmlElementsSize();
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ */
+ XmlElementAnnotation xmlElementAt(int index);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ */
+ XmlElementAnnotation addXmlElement(int index);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ */
+ void moveXmlElement(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'value' element of the XmlElements annotation.
+ */
+ void removeXmlElement(int index);
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
index 661eb1fe9c..fb150868d2 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
@@ -98,7 +98,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
}
@@ -108,7 +108,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
assertNull(xmlElementAnnotation.getName());
assertNull(xmlElementAnnotation.getNamespace());
@@ -123,7 +123,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getName());
xmlElementAnnotation.setName(XML_ELEMENT_NAME);
assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
@@ -142,7 +142,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
}
@@ -152,7 +152,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getNamespace());
xmlElementAnnotation.setNamespace(XML_ELEMENT_NAMESPACE);
assertEquals(XML_ELEMENT_NAMESPACE, xmlElementAnnotation.getNamespace());
@@ -171,7 +171,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
}
@@ -181,7 +181,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getDefaultValue());
xmlElementAnnotation.setDefaultValue(XML_ELEMENT_DEFAULT_VALUE);
assertEquals(XML_ELEMENT_DEFAULT_VALUE, xmlElementAnnotation.getDefaultValue());
@@ -199,7 +199,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("nillable");
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertEquals(Boolean.TRUE, xmlElementAnnotation.getNillable());
}
@@ -208,7 +208,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNotNull(xmlElementAnnotation);
assertNull(xmlElementAnnotation.getNillable());
@@ -227,7 +227,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("required");
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertEquals(Boolean.TRUE, xmlElementAnnotation.getRequired());
}
@@ -236,7 +236,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNotNull(xmlElementAnnotation);
assertNull(xmlElementAnnotation.getRequired());
@@ -256,7 +256,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
assertEquals("java.lang." + XML_ELEMENT_TYPE, xmlElementAnnotation.getFullyQualifiedTypeName());
@@ -267,7 +267,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
JavaResourceType resourceType = buildJavaResourceType(cu);
JavaResourceField resourceAttribute = getField(resourceType, 0);
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
+ XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getType());
xmlElementAnnotation.setType(XML_ELEMENT_TYPE);
assertEquals(XML_ELEMENT_TYPE, xmlElementAnnotation.getType());
@@ -280,18 +280,4 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
assertSourceContains("@XmlElement", cu);
assertSourceDoesNotContain("@XmlElement(type = " + XML_ELEMENT_TYPE + ".class", cu);
}
-
- public void testAddXmlElementAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestXmlElementWithName();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceField resourceAttribute = getField(resourceType, 0);
-
- XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
- assertTrue(xmlElementAnnotation != null);
- assertEquals(XML_ELEMENT_NAME, xmlElementAnnotation.getName());
-
- XmlElementAnnotation xmlElementAnnotation2 = (XmlElementAnnotation) resourceAttribute.addAnnotation(1, JAXB.XML_ELEMENT);
- xmlElementAnnotation2.setName("Foo");
- assertSourceContains("@XmlElements({ @XmlElement(name = \"" + XML_ELEMENT_NAME + "\"), @XmlElement(name = \"Foo\") })", cu);
- }
}

Back to the top