Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2011-08-16 16:37:40 -0400
committerpfullbright2011-08-16 16:37:40 -0400
commit686a98da5a0b22826b300ad0853c10463854a020 (patch)
treefed222bf1b27b75baf71157c6b0953d222432918
parent3075889b4020ee6771c09850f6ff9ac3251b5936 (diff)
downloadwebtools.dali-686a98da5a0b22826b300ad0853c10463854a020.tar.gz
webtools.dali-686a98da5a0b22826b300ad0853c10463854a020.tar.xz
webtools.dali-686a98da5a0b22826b300ad0853c10463854a020.zip
added validation for XmlElement.type being subtype of attribute base type
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java33
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java1
2 files changed, 27 insertions, 7 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
index 025c688016..880570543d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElement.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.core.internal.context.java;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -310,22 +311,40 @@ public class GenericJavaXmlElement
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
- if (StringTools.stringIsEmpty(getFullyQualifiedType())) {
+ validateType(messages, reporter, astRoot);
+
+ if (StringTools.stringIsEmpty(this.schemaElementRef.getName())) {
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.XML_ELEMENT__UNSPECIFIED_TYPE,
+ JaxbValidationMessages.XML_ELEMENT__UNSPECIFIED_ELEMENT_NAME,
this,
- getTypeTextRange(astRoot)));
+ this.schemaElementRef.getNameTextRange(astRoot)));
}
-
- if (StringTools.stringIsEmpty(this.schemaElementRef.getName())) {
+ }
+
+ protected void validateType(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ String fqType = getFullyQualifiedType();
+ if (StringTools.stringIsEmpty(fqType)) {
messages.add(
DefaultValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.XML_ELEMENT__UNSPECIFIED_ELEMENT_NAME,
+ JaxbValidationMessages.XML_ELEMENT__UNSPECIFIED_TYPE,
this,
- this.schemaElementRef.getNameTextRange(astRoot)));
+ getTypeTextRange(astRoot)));
+ }
+ else if (! StringTools.stringIsEmpty(this.specifiedType)) {
+ String attributeBaseType = getPersistentAttribute().getJavaResourceAttributeBaseTypeName();
+ if (! JDTTools.typeIsSubType(getJaxbProject().getJavaProject(), fqType, attributeBaseType)) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_ELEMENT__ILLEGAL_TYPE,
+ new String[] { attributeBaseType },
+ this,
+ getTypeTextRange(astRoot)));
+
+ }
}
}
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 53b4577ccf..9692051250 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
@@ -44,6 +44,7 @@ public interface JaxbValidationMessages {
String ATTRIBUTE_MAPPING_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_DEFINED = "ATTRIBUTE_MAPPING_XML_JAVA_TYPE_ADAPTER_TYPE_NOT_DEFINED";
String XML_ELEMENT_WRAPPER_DEFINED_ON_NON_ARRAY_NON_COLLECTION = "XML_ELEMENT_WRAPPER_DEFINED_ON_NON_ARRAY_NON_COLLECTION";
String XML_ELEMENT__UNSPECIFIED_TYPE = "XML_ELEMENT__UNSPECIFIED_TYPE";
+ String XML_ELEMENT__ILLEGAL_TYPE = "XML_ELEMENT__ILLEGAL_TYPE";
String XML_ELEMENT__UNSPECIFIED_ELEMENT_NAME = "XML_ELEMENT__UNSPECIFIED_ELEMENT_NAME";
String XML_ELEMENTS__DUPLICATE_XML_ELEMENT_TYPE = "XML_ELEMENTS__DUPLICATE_XML_ELEMENT_TYPE";
String XML_ELEMENTS__DUPLICATE_XML_ELEMENT_QNAME = "XML_ELEMENTS__DUPLICATE_XML_ELEMENT_QNAME";

Back to the top