Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2012-03-21 16:32:52 -0400
committerpfullbright2012-03-21 16:32:52 -0400
commit36f8e0125fe95757f51d0a79646d6307fd27b04d (patch)
tree7c4987b787805e041a282aaba1f4894748924ab7
parent206b9030bb3c9c8e334b087690fa17156c740130 (diff)
downloadwebtools.dali-36f8e0125fe95757f51d0a79646d6307fd27b04d.tar.gz
webtools.dali-36f8e0125fe95757f51d0a79646d6307fd27b04d.tar.xz
webtools.dali-36f8e0125fe95757f51d0a79646d6307fd27b04d.zip
validation for multiple XmlRegistries in a package
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidationMessages.java1
3 files changed, 12 insertions, 0 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
index 2ef752fd93..98fb8d159d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jaxb_validation.properties
@@ -77,6 +77,7 @@ XML_ID_REF__SCHEMA_TYPE_NOT_IDREF = In order to be used with XmlIDREF, the item
XML_LIST__ATTRIBUTE_NOT_COLLECTION_TYPE = In order to be mapped as XmlList, an attribute must have a collection or array type.
XML_LIST__ITEM_TYPE_NOT_MAPPED_TO_VALID_SCHEMA_TYPE = In order to be mapped as XmlList, the type ''{0}'' must be mapped to a non-list simple schema type.
+XML_REGISTRY__MULTIPLE_XML_REGISTRIES_FOR_PACKAGE = Multiple classes in package annotated with XmlRegistry.
XML_REGISTRY__DUPLICATE_XML_ELEMENT_QNAME = Duplicate XmlElementDecl name ''{0}'' {1}.
XML_VALUE__MULTIPLE_MAPPINGS_DEFINED = Multiple attributes are mapped as XmlValue. At most one field or property per class is allowed.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java
index 63b7b64d1d..2a69368779 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlRegistry.java
@@ -166,6 +166,16 @@ public class GenericJavaXmlRegistry
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
+ Iterable<XmlRegistry> registries = getContextRoot().getXmlRegistries(getJaxbPackage());
+ if (CollectionTools.size(registries) > 1) {
+ messages.add(
+ DefaultValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JaxbValidationMessages.XML_REGISTRY__MULTIPLE_XML_REGISTRIES_FOR_PACKAGE,
+ this,
+ getValidationTextRange(astRoot)));
+ }
+
validateDuplicateQNames(messages, reporter, astRoot);
for (JaxbElementFactoryMethod efm : getElementFactoryMethods()) {
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 4f687a96d1..04a0816a10 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
@@ -99,6 +99,7 @@ public interface JaxbValidationMessages {
String XML_LIST__ATTRIBUTE_NOT_COLLECTION_TYPE = "XML_LIST__ATTRIBUTE_NOT_COLLECTION_TYPE";
String XML_LIST__ITEM_TYPE_NOT_MAPPED_TO_VALID_SCHEMA_TYPE = "XML_LIST__ITEM_TYPE_NOT_MAPPED_TO_VALID_SCHEMA_TYPE";
+ String XML_REGISTRY__MULTIPLE_XML_REGISTRIES_FOR_PACKAGE = "XML_REGISTRY__MULTIPLE_XML_REGISTRIES_FOR_PACKAGE";
String XML_REGISTRY__DUPLICATE_XML_ELEMENT_QNAME = "XML_REGISTRY__DUPLICATE_XML_ELEMENT_QNAME";
String XML_VALUE__MULTIPLE_MAPPINGS_DEFINED = "XML_VALUE__MULTIPLE_MAPPINGS_DEFINED";

Back to the top