Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-10-18 12:08:48 -0400
committerkmoore2010-10-18 12:08:48 -0400
commit045d8c3c67ec3eca67e1dc0a96ba30f355b82d5e (patch)
tree139ccc03e9e52a3db2f03be144a0bdbd21f2c813
parent3321d41addcfe4e42d0d9f539978eaa4c46cc87c (diff)
downloadwebtools.dali-045d8c3c67ec3eca67e1dc0a96ba30f355b82d5e.tar.gz
webtools.dali-045d8c3c67ec3eca67e1dc0a96ba30f355b82d5e.tar.xz
webtools.dali-045d8c3c67ec3eca67e1dc0a96ba30f355b82d5e.zip
327914 - JAXB java resource model and tests for XmlInlineBinaryDataAnnotation, XmlJavaTypeAdapter(s)Annotation
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbJpaAnnotationDefinitionProvider.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlInlineBinaryDataAnnotationDefinition.java62
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java60
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java60
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlInlineBinaryDataAnnotation.java32
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java81
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java72
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlInlineBinaryDataAnnotation.java44
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java178
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java113
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java13
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableXmlJavaTypeAdapterAnnotation.java31
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlInlineBinaryDataAnnotation.java32
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java68
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java33
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java2
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAnnotationTests.java49
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java124
18 files changed, 1065 insertions, 0 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbJpaAnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbJpaAnnotationDefinitionProvider.java
index 96f464a327..3b2af5e07b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbJpaAnnotationDefinitionProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbJpaAnnotationDefinitionProvider.java
@@ -16,6 +16,9 @@ import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
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.XmlEnumAnnotationDefinition;
+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.XmlRootElementAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTransientAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTypeAnnotationDefinition;
@@ -51,6 +54,8 @@ public class GenericJaxbJpaAnnotationDefinitionProvider
protected void addPackageAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) {
definitions.add(XmlAccessorOrderAnnotationDefinition.instance());
definitions.add(XmlAccessorTypeAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance());
}
@Override
@@ -58,6 +63,9 @@ public class GenericJaxbJpaAnnotationDefinitionProvider
definitions.add(XmlAccessorOrderAnnotationDefinition.instance());
definitions.add(XmlAccessorTypeAnnotationDefinition.instance());
definitions.add(XmlEnumAnnotationDefinition.instance());
+ definitions.add(XmlInlineBinaryDataAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance());
definitions.add(XmlRootElementAnnotationDefinition.instance());
definitions.add(XmlTransientAnnotationDefinition.instance());
definitions.add(XmlTypeAnnotationDefinition.instance());
@@ -71,6 +79,9 @@ public class GenericJaxbJpaAnnotationDefinitionProvider
@Override
protected void addAttributeAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) {
+ definitions.add(XmlInlineBinaryDataAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance());
+ definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance());
definitions.add(XmlTransientAnnotationDefinition.instance());
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlInlineBinaryDataAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlInlineBinaryDataAnnotationDefinition.java
new file mode 100644
index 0000000000..c5a6d6d5da
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlInlineBinaryDataAnnotationDefinition.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlInlineBinaryDataAnnotation;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlInlineBinaryDataAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlInlineBinaryDataAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlInlineBinaryData
+ */
+public final class XmlInlineBinaryDataAnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlInlineBinaryDataAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlInlineBinaryDataAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlInlineBinaryDataAnnotation((JavaResourcePersistentMember) parent, (Member) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlInlineBinaryDataAnnotation((JavaResourcePersistentMember) parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return XmlInlineBinaryDataAnnotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java
new file mode 100644
index 0000000000..c07f610c41
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdapterAnnotationDefinition.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapterAnnotation
+ */
+public final class XmlJavaTypeAdapterAnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlJavaTypeAdapterAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlJavaTypeAdapterAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlJavaTypeAdapterAnnotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java
new file mode 100644
index 0000000000..abf01aa9f3
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlJavaTypeAdaptersAnnotation;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlJavaTypeAdaptersAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdaptersAnnotation
+ */
+public final class XmlJavaTypeAdaptersAnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlJavaTypeAdaptersAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlJavaTypeAdaptersAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlJavaTypeAdaptersAnnotation(parent, annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ return new BinaryXmlJavaTypeAdaptersAnnotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlInlineBinaryDataAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlInlineBinaryDataAnnotation.java
new file mode 100644
index 0000000000..cbae7f549c
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlInlineBinaryDataAnnotation.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlInlineBinaryDataAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlInlineBinaryDataAnnotation
+ */
+public final class BinaryXmlInlineBinaryDataAnnotation
+ extends BinaryAnnotation
+ implements XmlInlineBinaryDataAnnotation
+{
+
+ public BinaryXmlInlineBinaryDataAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java
new file mode 100644
index 0000000000..b872ff6bec
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableXmlJavaTypeAdapterAnnotation;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+ */
+public final class BinaryXmlJavaTypeAdapterAnnotation
+ extends BinaryAnnotation
+ implements NestableXmlJavaTypeAdapterAnnotation
+{
+ private String value;
+
+
+ public BinaryXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.value = this.buildValue();
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.setValue_(this.buildValue());
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.value);
+ }
+
+
+ // ********** XmlJavaTypeAdapterAnnotation implementation **********
+
+ // ***** value
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setValue_(String value) {
+ String old = this.value;
+ this.value = value;
+ this.firePropertyChanged(VALUE_PROPERTY, old, value);
+ this.firePropertyChanged(FULLY_QUALIFIED_VALUE_CLASS_NAME_PROPERTY, old, value);
+ }
+
+ private String buildValue() {
+ return (String) this.getJdtMemberValue(JAXB.XML_JAVA_TYPE_ADAPTER__VALUE);
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ***** fully-qualified value class name
+ public String getFullyQualifiedValueClassName() {
+ return this.value;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java
new file mode 100644
index 0000000000..66e7fe823a
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.binary;
+
+import java.util.Vector;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryContainerAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableXmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
+ */
+public class BinaryXmlJavaTypeAdaptersAnnotation
+ extends BinaryContainerAnnotation<NestableXmlJavaTypeAdapterAnnotation>
+ implements XmlJavaTypeAdaptersAnnotation
+{
+ private final Vector<NestableXmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters;
+
+
+ public BinaryXmlJavaTypeAdaptersAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.xmlJavaTypeAdapters = this.buildXmlJavaTypeAdapters();
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public Iterable<NestableXmlJavaTypeAdapterAnnotation> getNestedAnnotations() {
+ return new LiveCloneIterable<NestableXmlJavaTypeAdapterAnnotation>(this.xmlJavaTypeAdapters);
+ }
+
+ public int getNestedAnnotationsSize() {
+ return this.xmlJavaTypeAdapters.size();
+ }
+
+ private Vector<NestableXmlJavaTypeAdapterAnnotation> buildXmlJavaTypeAdapters() {
+ Object[] jdtTypeAdapters = this.getJdtMemberValues(JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE);
+ Vector<NestableXmlJavaTypeAdapterAnnotation> result = new Vector<NestableXmlJavaTypeAdapterAnnotation>(jdtTypeAdapters.length);
+ for (Object jdtJavaTypeAdapter : jdtTypeAdapters) {
+ result.add(this.buildXmlJavaTypeAdapterAnnotation(jdtJavaTypeAdapter));
+ }
+ return result;
+ }
+
+ protected NestableXmlJavaTypeAdapterAnnotation buildXmlJavaTypeAdapterAnnotation(Object jdtJavaTypeAdapter) {
+ return new BinaryXmlJavaTypeAdapterAnnotation(this, (IAnnotation) jdtJavaTypeAdapter);
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateXmlJavaTypeAdapters();
+ }
+
+ // TODO
+ private void updateXmlJavaTypeAdapters() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlInlineBinaryDataAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlInlineBinaryDataAnnotation.java
new file mode 100644
index 0000000000..a52074a301
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlInlineBinaryDataAnnotation.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlInlineBinaryDataAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlInlineBinaryDataAnnotation
+ */
+public final class SourceXmlInlineBinaryDataAnnotation
+ extends SourceAnnotation<Member>
+ implements XmlInlineBinaryDataAnnotation
+{
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ public SourceXmlInlineBinaryDataAnnotation(JavaResourcePersistentMember parent, Member member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ //no-op
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ //no-op
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java
new file mode 100644
index 0000000000..64161ea5fd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ASTTools;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableXmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+ */
+public final class SourceXmlJavaTypeAdapterAnnotation
+ extends SourceAnnotation<AnnotatedElement>
+ implements NestableXmlJavaTypeAdapterAnnotation
+{
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter;
+ private final AnnotationElementAdapter<String> valueAdapter;
+ private String value;
+
+ private String fullyQualifiedValueClassName;
+
+
+ // ********** constructors **********
+ public SourceXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement type) {
+ this(parent, type, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public SourceXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, type, daa, annotationAdapter);
+ this.valueDeclarationAdapter = buildValueAdapter(daa);
+ this.valueAdapter = this.buildAnnotationElementAdapter(this.valueDeclarationAdapter);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildValueAdapter(DeclarationAnnotationAdapter daa) {
+ return buildAnnotationElementAdapter(daa, JAXB.XML_JAVA_TYPE_ADAPTER__VALUE, SimpleTypeStringExpressionConverter.instance());
+ }
+
+ static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, false, converter);
+ }
+
+ protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.value = this.buildValue(astRoot);
+ this.fullyQualifiedValueClassName = this.buildFullyQualifiedValueClassName(astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ this.syncValue(this.buildValue(astRoot));
+ this.syncFullyQualifiedValueClassName(this.buildFullyQualifiedValueClassName(astRoot));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.value);
+ }
+
+
+ // ********** XmlJavaTypeAdapterAnnotation implementation **********
+
+ // ***** value
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ if (this.attributeValueHasChanged(this.value, value)) {
+ this.value = value;
+ this.valueAdapter.setValue(value);
+ }
+ }
+
+ private void syncValue(String astValue) {
+ String old = this.value;
+ this.value = astValue;
+ this.firePropertyChanged(VALUE_PROPERTY, old, astValue);
+ }
+
+ private String buildValue(CompilationUnit astRoot) {
+ return this.valueAdapter.getValue(astRoot);
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.valueDeclarationAdapter, astRoot);
+ }
+
+ // ***** fully-qualified value class name
+ public String getFullyQualifiedValueClassName() {
+ return this.fullyQualifiedValueClassName;
+ }
+
+ private void syncFullyQualifiedValueClassName(String name) {
+ String old = this.fullyQualifiedValueClassName;
+ this.fullyQualifiedValueClassName = name;
+ this.firePropertyChanged(FULLY_QUALIFIED_VALUE_CLASS_NAME_PROPERTY, old, name);
+ }
+
+ private String buildFullyQualifiedValueClassName(CompilationUnit astRoot) {
+ return (this.value == null) ? null : ASTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot));
+ }
+
+
+ //*********** NestableAnnotation implementation ****************
+
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ XmlJavaTypeAdapterAnnotation oldJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) oldAnnotation;
+ this.setValue(oldJavaTypeAdapterAnnotation.getValue());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+
+ // ********** static methods **********
+
+ static SourceXmlJavaTypeAdapterAnnotation createNestedXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement annotatedElement, int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, javaTypeAdaptersAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(annotatedElement, idaa);
+
+ return new SourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(javaTypeAdaptersAdapter, index, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java
new file mode 100644
index 0000000000..226435d596
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import java.util.Vector;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.NestableXmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
+
+/**
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
+ */
+public class SourceXmlJavaTypeAdaptersAnnotation
+ extends SourceAnnotation<AnnotatedElement>
+ implements XmlJavaTypeAdaptersAnnotation
+{
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final Vector<NestableXmlJavaTypeAdapterAnnotation> adapters = new Vector<NestableXmlJavaTypeAdapterAnnotation>();
+
+
+ public SourceXmlJavaTypeAdaptersAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ super(parent, annotatedElement, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ AnnotationContainerTools.initialize(this, astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ AnnotationContainerTools.synchronize(this, astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.adapters);
+ }
+
+
+ // ********** AnnotationContainer implementation **********
+
+ public String getElementName() {
+ return JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE;
+ }
+
+ public String getNestedAnnotationName() {
+ return XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME;
+ }
+
+ public Iterable<NestableXmlJavaTypeAdapterAnnotation> getNestedAnnotations() {
+ return new LiveCloneIterable<NestableXmlJavaTypeAdapterAnnotation>(this.adapters);
+ }
+
+ public int getNestedAnnotationsSize() {
+ return this.adapters.size();
+ }
+
+ public NestableXmlJavaTypeAdapterAnnotation addNestedAnnotation() {
+ return this.addNestedAnnotation(this.adapters.size());
+ }
+
+ private NestableXmlJavaTypeAdapterAnnotation addNestedAnnotation(int index) {
+ NestableXmlJavaTypeAdapterAnnotation adapter = this.buildXmlJavaTypeAdapterAnnotation(index);
+ this.adapters.add(adapter);
+ return adapter;
+ }
+
+ public void syncAddNestedAnnotation(Annotation astAnnotation) {
+ int index = this.adapters.size();
+ NestableXmlJavaTypeAdapterAnnotation namedQuery = this.addNestedAnnotation(index);
+ namedQuery.initialize((CompilationUnit) astAnnotation.getRoot());
+ this.fireItemAdded(XML_JAVA_TYPE_ADAPTERS_LIST, index, namedQuery);
+ }
+
+ protected NestableXmlJavaTypeAdapterAnnotation buildXmlJavaTypeAdapterAnnotation(int index) {
+ return SourceXmlJavaTypeAdapterAnnotation.createNestedXmlJavaTypeAdapterAnnotation(this, this.annotatedElement, index, this.daa);
+ }
+
+ public NestableXmlJavaTypeAdapterAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.adapters, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ public NestableXmlJavaTypeAdapterAnnotation removeNestedAnnotation(int index) {
+ return this.adapters.remove(index);
+ }
+
+ public void syncRemoveNestedAnnotations(int index) {
+ this.removeItemsFromList(index, this.adapters, XML_JAVA_TYPE_ADAPTERS_LIST);
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
index b4252191d5..f02c1f49ed 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
@@ -28,6 +28,8 @@ public interface JAXB {
String PACKAGE = "javax.xml.bind.annotation";
String PACKAGE_ = PACKAGE + '.';
+ String ADAPTERS_PACKAGE = "javax.xml.bind.annotation.adapters";
+ String ADAPTERS_PACKAGE_ = ADAPTERS_PACKAGE + '.';
// ********** API **********
@@ -40,6 +42,8 @@ public interface JAXB {
String XML_ENUM = PACKAGE_ + "XmlEnum";
String XML_ENUM__VALUE = "value";
+
+ String XML_INLINE_BINARY_DATA = PACKAGE_ + "XmlInlineBinaryData";
String XML_ROOT_ELEMENT = PACKAGE_ + "XmlRootElement";
String XML_ROOT_ELEMENT__NAME = "name";
@@ -54,6 +58,15 @@ public interface JAXB {
String XML_TRANSIENT = PACKAGE_ + "XmlTransient";
+
+ // JAXB annotation adapters
+ String XML_JAVA_TYPE_ADAPTER = ADAPTERS_PACKAGE_ + "XmlJavaTypeAdapter";
+ String XML_JAVA_TYPE_ADAPTER__VALUE = "value";
+
+ String XML_JAVA_TYPE_ADAPTERS = ADAPTERS_PACKAGE_ + "XmlJavaTypeAdapters";
+ String XML_JAVA_TYPE_ADAPTERS__VALUE = "value";
+
+
// JAXB enums
String XML_ACCESS_ORDER = PACKAGE_ + "XmlAccessOrder";
String XML_ACCESS_ORDER_ = XML_ACCESS_ORDER + '.';
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableXmlJavaTypeAdapterAnnotation.java
new file mode 100644
index 0000000000..69cda336f2
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/NestableXmlJavaTypeAdapterAnnotation.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.jpt.core.resource.java.NestableAnnotation;
+
+/**
+ * Corresponds to the JAXB annotation
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+ *
+ * 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 NestableXmlJavaTypeAdapterAnnotation
+ extends XmlJavaTypeAdapterAnnotation, NestableAnnotation
+{
+ // combine two interfaces
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlInlineBinaryDataAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlInlineBinaryDataAnnotation.java
new file mode 100644
index 0000000000..ef26842510
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlInlineBinaryDataAnnotation.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.jpt.core.resource.java.Annotation;
+
+/**
+ * Corresponds to the JAXB annotation
+ * javax.xml.bind.annotation.XmlInlineBinaryData
+ *
+ * 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 XmlInlineBinaryDataAnnotation
+ extends Annotation
+{
+ String ANNOTATION_NAME = JAXB.XML_INLINE_BINARY_DATA;
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java
new file mode 100644
index 0000000000..2c14f490e2
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.core.resource.java.Annotation;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * Corresponds to the JAXB annotation
+ * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+ *
+ * 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 XmlJavaTypeAdapterAnnotation
+ extends Annotation
+{
+ String ANNOTATION_NAME = JAXB.XML_JAVA_TYPE_ADAPTER;
+
+ /**
+ * Corresponds to the 'value' element of the XmlJavaTypeAdapter annotation.
+ * Return null if the element does not exist in Java.
+ * Return the portion of the value preceding ".class".
+ * <pre>
+ * &#64;XmlJavaTypeAdapter(value=FooAdapter.class)
+ * </pre>
+ * will return "FooAdapter"
+ */
+ String getValue();
+ String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'value' element of the XmlJavaTypeAdapter annotation.
+ * Set to null to remove the element.
+ */
+ void setValue(String value);
+ /**
+ * Return the {@link TextRange} for the 'value' element. If the element
+ * does not exist return the {@link TextRange} for the XmlJavaTypeAdapter annotation.
+ */
+ TextRange getValueTextRange(CompilationUnit astRoot);
+
+ /**
+ * Return the fully-qualified value class name as resolved by the AST's bindings.
+ * <pre>
+ * &#64;XmlJavaTypeAdapter(value=FooAdapter.class)
+ * </pre>
+ * will return "model.FooAdapter" if there is an import for model.FooAdapter.
+ * @return
+ */
+ String getFullyQualifiedValueClassName();
+ String FULLY_QUALIFIED_VALUE_CLASS_NAME_PROPERTY = "fullyQualifiedValueClassName"; //$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
new file mode 100644
index 0000000000..dc6dbd86a3
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.jpt.core.resource.java.ContainerAnnotation;
+
+/**
+ * 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<NestableXmlJavaTypeAdapterAnnotation>
+{
+ String ANNOTATION_NAME = JAXB.XML_JAVA_TYPE_ADAPTERS;
+
+ String XML_JAVA_TYPE_ADAPTERS_LIST = "xmlJavaTypeAdapters"; //$NON-NLS-1$
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
index ffef719e0e..8fad7c93d7 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
@@ -19,6 +19,8 @@ public class JaxbJavaResourceModelTests {
suite.addTestSuite(XmlAccessorOrderAnnotationTests.class);
suite.addTestSuite(XmlAccessorTypeAnnotationTests.class);
suite.addTestSuite(XmlEnumAnnotationTests.class);
+ suite.addTestSuite(XmlInlineBinaryDataAnnotationTests.class);
+ suite.addTestSuite(XmlJavaTypeAdapterAnnotationTests.class);
suite.addTestSuite(XmlRootElementAnnotationTests.class);
suite.addTestSuite(XmlTransientAnnotationTests.class);
suite.addTestSuite(XmlTypeAnnotationTests.class);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAnnotationTests.java
new file mode 100644
index 0000000000..3fbc49522e
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAnnotationTests.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.tests.internal.resource.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlInlineBinaryDataAnnotation;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class XmlInlineBinaryDataAnnotationTests extends JaxbJavaResourceModelTestCase {
+
+ public XmlInlineBinaryDataAnnotationTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createTestXmlInlineBinaryData() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_INLINE_BINARY_DATA);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlInlineBinaryData");
+ }
+ });
+ }
+
+ public void testGetXmlInlineBinaryData() throws Exception {
+ ICompilationUnit cu = this.createTestXmlInlineBinaryData();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlInlineBinaryDataAnnotation xmlInlineBinaryDataAnnotation = (XmlInlineBinaryDataAnnotation) typeResource.getAnnotation(JAXB.XML_INLINE_BINARY_DATA);
+ assertTrue(xmlInlineBinaryDataAnnotation != null);
+
+ typeResource.removeAnnotation(JAXB.XML_INLINE_BINARY_DATA);
+ assertSourceDoesNotContain("@XmlInlineBinaryData", cu);
+ }
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java
new file mode 100644
index 0000000000..fe9ab5e4f3
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.tests.internal.resource.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class XmlJavaTypeAdapterAnnotationTests extends JaxbJavaResourceModelTestCase {
+
+ private static final String XML_JAVA_TYPE_ADAPTER_CLASS = "MyAdapterClass";
+
+ public XmlJavaTypeAdapterAnnotationTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createTestXmlJavaTypeAdapter() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlJavaTypeAdapter");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestXmlJavaTypeAdapterWithValue() throws Exception {
+ this.createTestAdapterClass();
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlJavaTypeAdapter(value = " + XML_JAVA_TYPE_ADAPTER_CLASS + ".class)");
+ }
+ });
+ }
+
+ private void createTestAdapterClass() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("public class ").append(XML_JAVA_TYPE_ADAPTER_CLASS).append(" ");
+ sb.append("{}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "MyAdapterClass.java", sourceWriter);
+ }
+
+ public void testGetNull() throws Exception {
+ ICompilationUnit cu = this.createTestXmlJavaTypeAdapter();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(xmlJavaTypeAdapterAnnotation != null);
+ assertNull(xmlJavaTypeAdapterAnnotation.getValue());
+ }
+
+ public void testGetValue() throws Exception {
+ ICompilationUnit cu = this.createTestXmlJavaTypeAdapterWithValue();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(xmlJavaTypeAdapterAnnotation != null);
+ assertEquals(XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getValue());
+ assertEquals("test." + XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getFullyQualifiedValueClassName());
+ }
+
+ public void testSetValue() throws Exception {
+ ICompilationUnit cu = this.createTestXmlJavaTypeAdapter();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertNull(xmlJavaTypeAdapterAnnotation.getValue());
+ xmlJavaTypeAdapterAnnotation.setValue(XML_JAVA_TYPE_ADAPTER_CLASS);
+ assertEquals(XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getValue());
+
+ assertSourceContains("@XmlJavaTypeAdapter(" + XML_JAVA_TYPE_ADAPTER_CLASS + ".class)", cu);
+ }
+
+ public void testSetValueNull() throws Exception {
+ ICompilationUnit cu = this.createTestXmlJavaTypeAdapterWithValue();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertEquals(XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getValue());
+
+ xmlJavaTypeAdapterAnnotation.setValue(null);
+ assertNull(xmlJavaTypeAdapterAnnotation.getValue());
+
+ assertSourceContains("@XmlJavaTypeAdapter", cu);
+ assertSourceDoesNotContain("@XmlJavaTypeAdapter(" + XML_JAVA_TYPE_ADAPTER_CLASS + ".class)", cu);
+ }
+
+ public void testAddXmlJavaTypeAdapterAnnotation() throws Exception {
+ ICompilationUnit cu = this.createTestXmlJavaTypeAdapterWithValue();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(xmlJavaTypeAdapterAnnotation != null);
+ assertEquals(XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getValue());
+
+ XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation2 = (XmlJavaTypeAdapterAnnotation) typeResource.addAnnotation(1, JAXB.XML_JAVA_TYPE_ADAPTER, JAXB.XML_JAVA_TYPE_ADAPTERS);
+ xmlJavaTypeAdapterAnnotation2.setValue("Foo");
+ assertSourceContains("@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(" + XML_JAVA_TYPE_ADAPTER_CLASS + ".class),@XmlJavaTypeAdapter(Foo.class)})", cu);
+ }
+}

Back to the top