Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-02-10 22:47:27 +0000
committerkmoore2011-02-10 22:47:27 +0000
commit2bbdb7867df54644bd08cd304568810a2d609133 (patch)
treee1f1923f86a7e2806a9952acf6b73a4ccaf4f3bf /jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal
parent939ab9bf17afcf1a547123db00fc18a4295ed6bc (diff)
downloadwebtools.dali-2bbdb7867df54644bd08cd304568810a2d609133.tar.gz
webtools.dali-2bbdb7867df54644bd08cd304568810a2d609133.tar.xz
webtools.dali-2bbdb7867df54644bd08cd304568810a2d609133.zip
326718 - XmlAnyElement, XmlAnyAttribute, XmlMixed context model support and validation
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java12
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java42
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java108
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java228
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixed.java57
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java44
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyAttributeMappingDefinition.java63
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java66
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java3
10 files changed, 583 insertions, 44 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
index d861f835af..1061c9ab38 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
@@ -29,6 +29,8 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType;
import org.eclipse.jpt.jaxb.core.context.JaxbRegistry;
+import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlElementMapping;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
@@ -46,6 +48,8 @@ import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentEnum
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentField;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentProperty;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaRegistry;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyAttributeMapping;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAttributeMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementMapping;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlNs;
@@ -150,6 +154,14 @@ public abstract class AbstractJaxbFactory
return new GenericJavaXmlTransientMapping(parent);
}
+ public XmlAnyAttributeMapping buildJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) {
+ return new GenericJavaXmlAnyAttributeMapping(parent);
+ }
+
+ public XmlAnyElementMapping buildJavaXmlAnyElementMapping(JaxbPersistentAttribute parent) {
+ return new GenericJavaXmlAnyElementMapping(parent);
+ }
+
public XmlAttributeMapping buildJavaXmlAttributeMapping(JaxbPersistentAttribute parent) {
return new GenericJavaXmlAttributeMapping(parent);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
index 7504423b6f..93dda18a7a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
@@ -921,6 +921,8 @@ public class GenericJavaPersistentClass
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
this.xmlAdaptable.validate(messages, reporter, astRoot);
+ this.validateXmlAnyAttributeMapping(messages, astRoot);
+ this.validateXmlAnyElementMapping(messages, astRoot);
this.validateXmlValueMapping(messages, astRoot);
for (JaxbPersistentAttribute attribute : getAttributes()) {
attribute.validate(messages, reporter, astRoot);
@@ -962,4 +964,44 @@ public class GenericJavaPersistentClass
}
}
}
+
+ protected void validateXmlAnyAttributeMapping(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlAnyAttributeMapping = null;
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getMappingKey() == MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY) {
+ if (xmlAnyAttributeMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_ANY_ATTRIBUTE_MAPPINGS_DEFINED,
+ new String[] {attribute.getName(), xmlAnyAttributeMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlAnyAttributeMapping = attribute.getName();
+ }
+ }
+ }
+ }
+
+ protected void validateXmlAnyElementMapping(List<IMessage> messages, CompilationUnit astRoot) {
+ String xmlAnyElementMapping = null;
+ for (JaxbPersistentAttribute attribute : getAttributes()) {
+ if (attribute.getMappingKey() == MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY) {
+ if (xmlAnyElementMapping != null) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.MULTIPLE_XML_ANY_ELEMENT_MAPPINGS_DEFINED,
+ new String[] {attribute.getName(), xmlAnyElementMapping},
+ attribute.getMapping(),
+ attribute.getMapping().getValidationTextRange(astRoot)));
+ }
+ else {
+ xmlAnyElementMapping = attribute.getName();
+ }
+ }
+ }
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java
new file mode 100644
index 0000000000..936a98ca90
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyAttributeMapping.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.context.java;
+
+import java.util.List;
+import java.util.Map;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
+import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
+import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
+import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyAttributeAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+public class GenericJavaXmlAnyAttributeMapping
+ extends AbstractJavaAttributeMapping<XmlAnyAttributeAnnotation>
+ implements XmlAnyAttributeMapping
+{
+
+ protected final XmlAdaptable xmlAdaptable;
+
+
+ public GenericJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ this.xmlAdaptable = buildXmlAdaptable();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.xmlAdaptable.synchronizeWithResourceModel();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.xmlAdaptable.update();
+ }
+
+ public String getKey() {
+ return MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return XmlAnyAttributeAnnotation.ANNOTATION_NAME;
+ }
+
+ //****************** XmlJavaTypeAdapter *********************
+
+ public XmlAdaptable buildXmlAdaptable() {
+ return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
+ public JavaResourceAnnotatedElement getResource() {
+ return getJavaResourceAttribute();
+ }
+ public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
+ return GenericJavaXmlAnyAttributeMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
+ }
+ public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
+ GenericJavaXmlAnyAttributeMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
+ }
+ });
+ }
+
+ public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
+ return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ }
+
+ public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
+ return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ }
+
+ protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
+ return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
+ }
+
+ public void removeXmlJavaTypeAdapter() {
+ this.xmlAdaptable.removeXmlJavaTypeAdapter();
+ }
+
+ //************* validation ****************
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ if (!getPersistentAttribute().isJavaResourceAttributeTypeSubTypeOf(Map.class.getName())) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_ANY_ATTRIBUTE_MAPPING_DEFINED_ON_NON_MAP,
+ this,
+ getValidationTextRange(astRoot)));
+ }
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java
new file mode 100644
index 0000000000..609ccdf0ef
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAnyElementMapping.java
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * 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.context.java;
+
+import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
+import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
+import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
+import org.eclipse.jpt.jaxb.core.context.XmlMixed;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
+
+public class GenericJavaXmlAnyElementMapping
+ extends AbstractJavaAttributeMapping<XmlAnyElementAnnotation>
+ implements XmlAnyElementMapping
+{
+
+ protected Boolean specifiedLax;
+
+ protected String specifiedValue;
+
+ protected XmlMixed xmlMixed;
+
+ protected final XmlAdaptable xmlAdaptable;
+
+
+ public GenericJavaXmlAnyElementMapping(JaxbPersistentAttribute parent) {
+ super(parent);
+ this.specifiedLax = buildSpecifiedLax();
+ this.specifiedValue = this.getResourceValueString();
+ this.xmlAdaptable = buildXmlAdaptable();
+ this.initializeXmlMixed();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setSpecifiedLax(buildSpecifiedLax());
+ this.setSpecifiedValue_(this.getResourceValueString());
+ this.xmlAdaptable.synchronizeWithResourceModel();
+ this.syncXmlMixed();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.xmlAdaptable.update();
+ this.updateXmlMixed();
+ }
+
+ public String getKey() {
+ return MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ @Override
+ protected String getAnnotationName() {
+ return XmlAnyElementAnnotation.ANNOTATION_NAME;
+ }
+
+
+ //************ lax ***************
+
+ public boolean isLax() {
+ return (this.getSpecifiedLax() == null) ? this.isDefaultLax() : this.getSpecifiedLax().booleanValue();
+ }
+
+ public boolean isDefaultLax() {
+ return DEFAULT_LAX;
+ }
+
+ public Boolean getSpecifiedLax() {
+ return this.specifiedLax;
+ }
+
+ public void setSpecifiedLax(Boolean newSpecifiedLax) {
+ this.getAnnotationForUpdate().setLax(newSpecifiedLax);
+ this.setSpecifiedLax_(newSpecifiedLax);
+ }
+
+ protected void setSpecifiedLax_(Boolean newSpecifiedLax) {
+ Boolean oldLax = this.specifiedLax;
+ this.specifiedLax = newSpecifiedLax;
+ firePropertyChanged(SPECIFIED_LAX_PROPERTY, oldLax, newSpecifiedLax);
+ }
+
+ protected Boolean buildSpecifiedLax() {
+ return getMappingAnnotation().getLax();
+ }
+
+ // ********** value **********
+
+ public String getValue() {
+ return this.getSpecifiedValue() == null ? this.getDefaultValue() : this.getSpecifiedValue();
+ }
+
+ public String getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ public String getSpecifiedValue() {
+ return this.specifiedValue;
+ }
+
+ public void setSpecifiedValue(String location) {
+ this.getAnnotationForUpdate().setValue(location);
+ this.setSpecifiedValue_(location);
+ }
+
+ protected void setSpecifiedValue_(String type) {
+ String old = this.specifiedValue;
+ this.specifiedValue = type;
+ this.firePropertyChanged(SPECIFIED_VALUE_PROPERTY, old, type);
+ }
+
+ protected String getResourceValueString() {
+ return getMappingAnnotation().getValue();
+ }
+
+ //****************** XmlJavaTypeAdapter *********************
+
+ public XmlAdaptable buildXmlAdaptable() {
+ return new GenericJavaXmlAdaptable(this, new XmlAdaptable.Owner() {
+ public JavaResourceAnnotatedElement getResource() {
+ return getJavaResourceAttribute();
+ }
+ public XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation adapterAnnotation) {
+ return GenericJavaXmlAnyElementMapping.this.buildXmlJavaTypeAdapter(adapterAnnotation);
+ }
+ public void fireXmlAdapterChanged(XmlJavaTypeAdapter oldAdapter, XmlJavaTypeAdapter newAdapter) {
+ GenericJavaXmlAnyElementMapping.this.firePropertyChanged(XML_JAVA_TYPE_ADAPTER_PROPERTY, oldAdapter, newAdapter);
+ }
+ });
+ }
+
+ public XmlJavaTypeAdapter getXmlJavaTypeAdapter() {
+ return this.xmlAdaptable.getXmlJavaTypeAdapter();
+ }
+
+ public XmlJavaTypeAdapter addXmlJavaTypeAdapter() {
+ return this.xmlAdaptable.addXmlJavaTypeAdapter();
+ }
+
+ protected XmlJavaTypeAdapter buildXmlJavaTypeAdapter(XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation) {
+ return new GenericJavaAttributeXmlJavaTypeAdapter(this, xmlJavaTypeAdapterAnnotation);
+ }
+
+ public void removeXmlJavaTypeAdapter() {
+ this.xmlAdaptable.removeXmlJavaTypeAdapter();
+ }
+
+
+ //************ XmlMixed ***************
+
+ public XmlMixed getXmlMixed() {
+ return this.xmlMixed;
+ }
+
+ public XmlMixed addXmlMixed() {
+ if (this.xmlMixed != null) {
+ throw new IllegalStateException();
+ }
+ XmlMixedAnnotation annotation = (XmlMixedAnnotation) this.getJavaResourceAttribute().addAnnotation(XmlMixedAnnotation.ANNOTATION_NAME);
+
+ XmlMixed xmlMixed = this.buildXmlMixed(annotation);
+ this.setXmlMixed_(xmlMixed);
+ return xmlMixed;
+ }
+
+ protected XmlMixed buildXmlMixed(XmlMixedAnnotation xmlMixedAnnotation) {
+ return new GenericJavaXmlMixed(this, xmlMixedAnnotation);
+ }
+
+ public void removeXmlMixed() {
+ if (this.xmlMixed == null) {
+ throw new IllegalStateException();
+ }
+ this.getJavaResourceAttribute().removeAnnotation(XmlMixedAnnotation.ANNOTATION_NAME);
+ this.setXmlMixed_(null);
+ }
+
+ protected void initializeXmlMixed() {
+ XmlMixedAnnotation annotation = this.getXmlMixedAnnotation();
+ if (annotation != null) {
+ this.xmlMixed = this.buildXmlMixed(annotation);
+ }
+ }
+
+ protected XmlMixedAnnotation getXmlMixedAnnotation() {
+ return (XmlMixedAnnotation) this.getJavaResourceAttribute().getAnnotation(XmlMixedAnnotation.ANNOTATION_NAME);
+ }
+
+ protected void syncXmlMixed() {
+ XmlMixedAnnotation annotation = this.getXmlMixedAnnotation();
+ if (annotation != null) {
+ if (this.getXmlMixed() != null) {
+ this.getXmlMixed().synchronizeWithResourceModel();
+ }
+ else {
+ this.setXmlMixed_(this.buildXmlMixed(annotation));
+ }
+ }
+ else {
+ this.setXmlMixed_(null);
+ }
+ }
+
+ protected void updateXmlMixed() {
+ if (this.getXmlMixed() != null) {
+ this.getXmlMixed().update();
+ }
+ }
+
+ protected void setXmlMixed_(XmlMixed xmlMixed) {
+ XmlMixed oldXmlMixed = this.xmlMixed;
+ this.xmlMixed = xmlMixed;
+ firePropertyChanged(XML_MIXED_PROPERTY, oldXmlMixed, xmlMixed);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixed.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixed.java
new file mode 100644
index 0000000000..f4307f46e4
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixed.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.XmlMixed;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
+
+public class GenericJavaXmlMixed
+ extends AbstractJavaContextNode
+ implements XmlMixed
+{
+
+ protected final XmlMixedAnnotation resourceXmlMixed;
+
+ public GenericJavaXmlMixed(JaxbAttributeMapping parent, XmlMixedAnnotation resource) {
+ super(parent);
+ this.resourceXmlMixed = resource;
+ }
+
+ @Override
+ public JaxbAttributeMapping getParent() {
+ return (JaxbAttributeMapping) super.getParent();
+ }
+
+ protected JaxbPersistentAttribute getPersistentAttribute() {
+ return getParent().getParent();
+ }
+
+ // ********** synchronize/update **********
+
+ public void synchronizeWithResourceModel() {
+ //nothing yet
+ }
+
+ public void update() {
+ //nothing yet
+ }
+
+
+ //************* validation ****************
+
+ @Override
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.resourceXmlMixed.getTextRange(astRoot);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
index 0d31b6a659..fcd0f21f98 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlValueMapping.java
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.context.java;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.jaxb.core.MappingKeys;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
import org.eclipse.jpt.jaxb.core.context.XmlAdaptable;
@@ -19,8 +17,6 @@ import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlValueAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class GenericJavaXmlValueMapping
extends AbstractJavaAttributeMapping<XmlValueAnnotation>
@@ -86,44 +82,4 @@ public class GenericJavaXmlValueMapping
public void removeXmlJavaTypeAdapter() {
this.xmlAdaptable.removeXmlJavaTypeAdapter();
}
-
- //****************** validation *********************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- // TODO Auto-generated method stub
- super.validate(messages, reporter, astRoot);
- }
-
- //validation:
-// If a class contains a mapped property or field annotated with
-// @XmlValue annotation, then all other mapped fields or properties in the
-// class must be mapped to an XML attribute.
-
-
-
-
-
-
-
-//if the class, subClass, derives from another XML-bound class, baseClass
-// directly or indirectly (other than java.lang.Object), then the subClass
-// must not contain a mapped property or field annotated with @XmlValue
-// annotation.
-
-//The containing class must not extend another class (other than java.lang.Obect).
-
-
-
-//If the type of the field or property is a collection type, then the
-// collection item type must map to a simple schema type. Examples:
-// // Examples (not exhaustive): Legal usage of @XmlValue
-// @XmlValue List<Integer> foo; // int maps to xs:int
-// @XmlValue String[] foo; // String maps to xs:string
-// @XmlValue List<Bar> foo; // only if Bar maps to a simple schema type
-
-
-
-// If the type of the field or property is not a collection type, then the type
-// of the property or field must map to a schema simple type.
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyAttributeMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyAttributeMappingDefinition.java
new file mode 100644
index 0000000000..e7b3e43b54
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyAttributeMappingDefinition.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyAttributeAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+
+
+public class JavaXmlAnyAttributeMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition
+{
+ // singleton
+ private static final JavaXmlAnyAttributeMappingDefinition INSTANCE =
+ new JavaXmlAnyAttributeMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+ private static final String[] SUPPORTING_ANNOTATION_NAMES =
+ {XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME};
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaXmlAnyAttributeMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return XmlAnyAttributeAnnotation.ANNOTATION_NAME;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new ArrayListIterable<String>(SUPPORTING_ANNOTATION_NAMES);
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ return factory.buildJavaXmlAnyAttributeMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java
new file mode 100644
index 0000000000..ce4a60988b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFactory;
+import org.eclipse.jpt.jaxb.core.MappingKeys;
+import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
+import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyElementAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAttributeAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
+
+
+public class JavaXmlAnyElementMappingDefinition
+ extends AbstractJavaAttributeMappingDefinition
+{
+ // singleton
+ private static final JavaXmlAnyElementMappingDefinition INSTANCE =
+ new JavaXmlAnyElementMappingDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+ private static final String[] SUPPORTING_ANNOTATION_NAMES =
+ {XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME,
+ XmlMixedAnnotation.ANNOTATION_NAME};
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaXmlAnyElementMappingDefinition() {
+ super();
+ }
+
+
+ public String getKey() {
+ return MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY;
+ }
+
+ public String getAnnotationName() {
+ return XmlAnyElementAnnotation.ANNOTATION_NAME;
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return new ArrayListIterable<String>(SUPPORTING_ANNOTATION_NAMES);
+ }
+
+ public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) {
+ return factory.buildJavaXmlAnyElementMapping(parent);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
index 0a493a9304..58120fa9ae 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java
@@ -21,6 +21,8 @@ import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.core.internal.JavaPackageInfoResourceModelProvider;
import org.eclipse.jpt.jaxb.core.internal.JavaResourceModelProvider;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyAttributeMappingDefinition;
+import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyElementMappingDefinition;
import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAttributeMappingDefinition;
import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementMappingDefinition;
import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlTransientMappingDefinition;
@@ -156,6 +158,8 @@ public class GenericJaxb_2_1_PlatformDefinition
@Override
protected void addSpecifiedJavaAttributeMappingDefinitionsTo(ArrayList<JavaAttributeMappingDefinition> definitions) {
+ definitions.add(JavaXmlAnyAttributeMappingDefinition.instance());
+ definitions.add(JavaXmlAnyElementMappingDefinition.instance());
definitions.add(JavaXmlAttributeMappingDefinition.instance());
definitions.add(JavaXmlElementMappingDefinition.instance());
definitions.add(JavaXmlTransientMappingDefinition.instance());
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
index 7047c1697a..4ceb5b0592 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java
@@ -34,6 +34,9 @@ public interface JaxbValidationMessages {
public static final String ATTRIBUTE_MAPPING_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_DEFINED = "ATTRIBUTE_MAPPING_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_DEFINED";
public static final String XML_ELEMENT_WRAPPER_DEFINED_ON_NON_ARRAY_NON_COLLECTION = "XML_ELEMENT_WRAPPER_DEFINED_ON_NON_ARRAY_NON_COLLECTION";
public static final String XML_LIST_DEFINED_ON_NON_ARRAY_NON_COLLECTION = "XML_LIST_DEFINED_ON_NON_ARRAY_NON_COLLECTION";
+ public static final String MULTIPLE_XML_ANY_ATTRIBUTE_MAPPINGS_DEFINED = "MULTIPLE_XML_ANY_ATTRIBUTE_MAPPINGS_DEFINED";
+ public static final String MULTIPLE_XML_ANY_ELEMENT_MAPPINGS_DEFINED = "MULTIPLE_XML_ANY_ELEMENT_MAPPINGS_DEFINED";
public static final String MULTIPLE_XML_VALUE_MAPPINGS_DEFINED = "MULTIPLE_XML_VALUE_MAPPINGS_DEFINED";
public static final String XML_VALUE_MAPPING_WITH_NON_XML_ATTRIBUTE_MAPPING_DEFINED = "XML_VALUE_MAPPING_WITH_NON_XML_ATTRIBUTE_MAPPING_DEFINED";
+ public static final String XML_ANY_ATTRIBUTE_MAPPING_DEFINED_ON_NON_MAP = "XML_ANY_ATTRIBUTE_MAPPING_DEFINED_ON_NON_MAP";
}

Back to the top