Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authorpfullbright2012-04-03 21:24:04 +0000
committerpfullbright2012-04-03 21:24:04 +0000
commitab1e9b17e9a75b1e4c21447961a954cf00e262ae (patch)
tree68fd76cae1c5891db0100196ca9a972baa56a67b /jaxb
parent899af9e5a376dba57d8a83e6b12699359525dc9b (diff)
downloadwebtools.dali-ab1e9b17e9a75b1e4c21447961a954cf00e262ae.tar.gz
webtools.dali-ab1e9b17e9a75b1e4c21447961a954cf00e262ae.tar.xz
webtools.dali-ab1e9b17e9a75b1e4c21447961a954cf00e262ae.zip
bug 366897 - XmlCDATA support
Diffstat (limited to 'jaxb')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATA.java29
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATAMapping.java50
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementMapping.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlValueMapping.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlCDATA.java43
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlValueMapping.java105
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlCDATAAnnotation.java3
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlCDATAAnnotation.java5
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java109
10 files changed, 367 insertions, 6 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATA.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATA.java
new file mode 100644
index 0000000000..ed3bff2e59
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATA.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.eclipselink.core.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+
+/**
+ * Corresponds to the XmlCDATA annotation
+ *
+ * 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.2
+ * @since 3.2
+ */
+public interface ELXmlCDATA
+ extends JaxbContextNode {
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATAMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATAMapping.java
new file mode 100644
index 0000000000..761c7fe09f
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlCDATAMapping.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.eclipselink.core.context.java;
+
+/**
+ * EclipseLink mappings that have an XmlCDATA
+ *
+ * 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.2
+ * @since 3.2
+ */
+public interface ELXmlCDATAMapping {
+
+ // ***** xmlCDATA *****
+
+ /**
+ * String associated with changes to the xmlCDATA property
+ */
+ String XML_CDATA_PROPERTY = "xmlCDATA"; ///$NON-NLS-1$
+
+ /**
+ * Return the xmlCDATA property value.
+ * A null indicates it is not specified.
+ */
+ ELXmlCDATA getXmlCDATA();
+
+ /**
+ * Add (and return) an xmlCDATA property value.
+ * (Specifies the property)
+ */
+ ELXmlCDATA addXmlCDATA();
+
+ /**
+ * Remove the xmlCDATA property value.
+ * (Unspecifies the property)
+ */
+ void removeXmlCDATA();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementMapping.java
index 5d39b77f5d..9c0df040a6 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementMapping.java
@@ -24,6 +24,6 @@ import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
* @since 3.2
*/
public interface ELXmlElementMapping
- extends XmlElementMapping, ELXmlNamedNodeMapping {
-
+ extends XmlElementMapping, ELXmlNamedNodeMapping, ELXmlCDATAMapping {
+
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlValueMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlValueMapping.java
new file mode 100644
index 0000000000..a9a6f71237
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlValueMapping.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.eclipselink.core.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
+
+
+public interface ELXmlValueMapping
+ extends XmlValueMapping, ELXmlCDATAMapping {
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlCDATA.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlCDATA.java
new file mode 100644
index 0000000000..f9679d350e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlCDATA.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.eclipselink.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode;
+import org.eclipse.jpt.jaxb.core.internal.context.java.AbstractJavaContextNode;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlCDATA;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlCDATAAnnotation;
+
+
+public class ELJavaXmlCDATA
+ extends AbstractJavaContextNode
+ implements ELXmlCDATA {
+
+ protected final Context context;
+
+
+ public ELJavaXmlCDATA(JavaContextNode parent, Context context) {
+ super(parent);
+ this.context = context;
+ }
+
+
+ @Override
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.context.getAnnotation().getTextRange(astRoot);
+ }
+
+
+ public interface Context {
+
+ XmlCDATAAnnotation getAnnotation();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlValueMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlValueMapping.java
new file mode 100644
index 0000000000..e3521bfbbf
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlValueMapping.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlValueMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlCDATA;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlValueMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlCDATAAnnotation;
+
+
+public class ELJavaXmlValueMapping
+ extends GenericJavaXmlValueMapping
+ implements ELXmlValueMapping {
+
+ protected ELJavaXmlCDATA xmlCDATA;
+
+
+ public ELJavaXmlValueMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ initXmlCDATA();
+ }
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ syncXmlCDATA();
+ }
+
+
+ // ***** XmlCDATA *****
+
+ public ELXmlCDATA getXmlCDATA() {
+ return this.xmlCDATA;
+ }
+
+ protected void setXmlCDATA_(ELJavaXmlCDATA xmlCDATA) {
+ ELJavaXmlCDATA old = this.xmlCDATA;
+ this.xmlCDATA = xmlCDATA;
+ firePropertyChanged(XML_CDATA_PROPERTY, old, this.xmlCDATA);
+ }
+
+ public ELXmlCDATA addXmlCDATA() {
+ if (this.xmlCDATA != null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().addAnnotation(ELJaxb.XML_CDATA);
+ ELJavaXmlCDATA xmlCDATA = buildXmlCDATA();
+ setXmlCDATA_(xmlCDATA);
+ return xmlCDATA;
+ }
+
+ public void removeXmlCDATA() {
+ if (this.xmlCDATA == null) {
+ throw new IllegalStateException();
+ }
+ getJavaResourceAttribute().removeAnnotation(ELJaxb.XML_CDATA);
+ setXmlCDATA_(null);
+ }
+
+ protected void initXmlCDATA() {
+ XmlCDATAAnnotation annotation = getXmlCDATAAnnotation();
+ this.xmlCDATA = (annotation == null) ? null : buildXmlCDATA();
+ }
+
+ protected void syncXmlCDATA() {
+ XmlCDATAAnnotation annotation = getXmlCDATAAnnotation();
+ if (annotation != null) {
+ if (this.xmlCDATA == null) {
+ setXmlCDATA_(buildXmlCDATA());
+ }
+ }
+ else {
+ setXmlCDATA_(null);
+ }
+ }
+
+ protected ELJavaXmlCDATA buildXmlCDATA() {
+ return new ELJavaXmlCDATA(this, new XmlCDATAContext());
+ }
+
+ protected XmlCDATAAnnotation getXmlCDATAAnnotation() {
+ return (XmlCDATAAnnotation) getJavaResourceAttribute().getAnnotation(ELJaxb.XML_CDATA);
+ }
+
+
+ protected class XmlCDATAContext
+ implements ELJavaXmlCDATA.Context {
+
+ public XmlCDATAAnnotation getAnnotation() {
+ return ELJavaXmlValueMapping.this.getXmlCDATAAnnotation();
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlCDATAAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlCDATAAnnotation.java
index ccadc0758b..25655c5254 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlCDATAAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/java/binary/BinaryXmlCDATAAnnotation.java
@@ -20,9 +20,6 @@ public class BinaryXmlCDATAAnnotation
extends BinaryAnnotation
implements XmlCDATAAnnotation {
- private String value;
-
-
public BinaryXmlCDATAAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
super(parent, jdtAnnotation);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
index c4ea3afa86..cedaa85079 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
@@ -25,6 +25,7 @@ import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
+import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbFactory;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.ELJaxbContextRoot;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaClassMapping;
@@ -36,6 +37,7 @@ import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElem
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementRefMapping;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementRefsMapping;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementsMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlValueMapping;
public class ELJaxb_2_1_Factory
@@ -111,4 +113,9 @@ public class ELJaxb_2_1_Factory
public XmlElementsMapping buildJavaXmlElementsMapping(JaxbPersistentAttribute parent) {
return new ELJavaXmlElementsMapping(parent);
}
+
+ @Override
+ public XmlValueMapping buildJavaXmlValueMapping(JaxbPersistentAttribute parent) {
+ return new ELJavaXmlValueMapping(parent);
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlCDATAAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlCDATAAnnotation.java
index ff6e3742d0..07675041d8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlCDATAAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/java/XmlCDATAAnnotation.java
@@ -9,6 +9,8 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.resource.java;
+import org.eclipse.jpt.common.core.resource.java.Annotation;
+
/**
* Corresponds to the EclipseLink annotation
* org.eclipse.persistence.oxm.annotations.XmlCDATA
@@ -22,6 +24,7 @@ package org.eclipse.jpt.jaxb.eclipselink.core.resource.java;
* @version 3.2
* @since 3.2
*/
-public interface XmlCDATAAnnotation {
+public interface XmlCDATAAnnotation
+ extends Annotation {
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java
new file mode 100644
index 0000000000..b1e44a2b14
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.eclipselink.core.tests/src/org/eclipse/jpt/jaxb/eclipselink/core/tests/internal/context/java/ELJavaXmlValueMappingTests.java
@@ -0,0 +1,109 @@
+package org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.common.core.utility.jdt.Member;
+import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlValueMapping;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb;
+import org.eclipse.jpt.jaxb.eclipselink.core.tests.internal.context.ELJaxbContextModelTestCase;
+
+
+public class ELJavaXmlValueMappingTests
+ extends ELJaxbContextModelTestCase {
+
+ public ELJavaXmlValueMappingTests(String name) {
+ super(name);
+ }
+
+
+ @Override
+ protected JaxbPlatformDescription getPlatform() {
+ return ELJaxbPlatform.VERSION_2_2;
+ }
+
+ private ICompilationUnit createTypeWithXmlValue() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JAXB.XML_TYPE, JAXB.XML_VALUE);
+ }
+
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlType");
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@XmlValue");
+ }
+ });
+ }
+
+ public void testModifyXmlCDATA() throws Exception {
+ createTypeWithXmlValue();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ ELJavaXmlValueMapping mapping = (ELJavaXmlValueMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNull(mapping.getXmlCDATA());
+
+ mapping.addXmlCDATA();
+
+ assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNotNull(mapping.getXmlCDATA());
+
+ mapping.removeXmlCDATA();
+
+ assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNull(mapping.getXmlCDATA());
+ }
+
+ public void testUpdateXmlCDATA() throws Exception {
+ createTypeWithXmlValue();
+
+ JaxbClass jaxbClass = (JaxbClass) CollectionTools.get(getContextRoot().getTypes(), 0);
+ JaxbClassMapping classMapping = jaxbClass.getMapping();
+ JaxbPersistentAttribute persistentAttribute = CollectionTools.get(classMapping.getAttributes(), 0);
+ ELJavaXmlValueMapping mapping = (ELJavaXmlValueMapping) persistentAttribute.getMapping();
+ JavaResourceAttribute resourceAttribute = mapping.getPersistentAttribute().getJavaResourceAttribute();
+
+ assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNull(mapping.getXmlCDATA());
+
+ AnnotatedElement annotatedElement = this.annotatedElement(resourceAttribute);
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ ELJavaXmlValueMappingTests.this.addMarkerAnnotation(
+ declaration.getDeclaration(), ELJaxb.XML_CDATA);
+ }
+ });
+
+ assertNotNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNotNull(mapping.getXmlCDATA());
+
+ annotatedElement.edit(new Member.Editor() {
+ public void edit(ModifiedDeclaration declaration) {
+ ELJavaXmlValueMappingTests.this.removeAnnotation(declaration, ELJaxb.XML_CDATA);
+ }
+ });
+
+ assertNull(resourceAttribute.getAnnotation(ELJaxb.XML_CDATA));
+ assertNull(mapping.getXmlCDATA());
+ }
+}

Back to the top