diff options
author | pfullbright | 2012-01-13 22:30:50 +0000 |
---|---|---|
committer | pfullbright | 2012-01-13 22:30:50 +0000 |
commit | 1c957c39dd545338bcd7868413e1684390413341 (patch) | |
tree | 5b79893911efa7228187f51930953b5d2489f300 /jaxb/plugins/org.eclipse.jpt.jaxb.core | |
parent | 0cd4ad87aab6513a72fda9404fcc3d0807eb45bd (diff) | |
download | webtools.dali-1c957c39dd545338bcd7868413e1684390413341.tar.gz webtools.dali-1c957c39dd545338bcd7868413e1684390413341.tar.xz webtools.dali-1c957c39dd545338bcd7868413e1684390413341.zip |
validation for XmlPath w/ XmlElement, XmlAttribute and XmlElementWrapper
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core')
8 files changed, 141 insertions, 117 deletions
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 index 5c1837002f..4068e3116e 100644 --- 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 @@ -59,7 +59,7 @@ public class GenericJavaXmlAnyElementMapping this.specifiedValue = getResourceValueString(); this.xmlElementRefs = buildXmlElementRefs(); initializeXmlElementWrapper(); - this.initializeXmlMixed(); + initializeXmlMixed(); } @@ -142,7 +142,7 @@ public class GenericJavaXmlAnyElementMapping protected void setSpecifiedValue_(String type) { String old = this.specifiedValue; this.specifiedValue = type; - this.firePropertyChanged(SPECIFIED_VALUE_PROPERTY, old, type); + firePropertyChanged(SPECIFIED_VALUE_PROPERTY, old, type); } protected String getResourceValueString() { @@ -181,10 +181,9 @@ public class GenericJavaXmlAnyElementMapping if (this.xmlElementWrapper != null) { throw new IllegalStateException(); } - XmlElementWrapperAnnotation annotation = - (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); - XmlElementWrapper xmlElementWrapper = this.buildXmlElementWrapper(annotation); - this.setXmlElementWrapper_(xmlElementWrapper); + getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); + XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(); + setXmlElementWrapper_(xmlElementWrapper); return xmlElementWrapper; } @@ -192,43 +191,41 @@ public class GenericJavaXmlAnyElementMapping if (this.xmlElementWrapper == null) { throw new IllegalStateException(); } - this.getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); - this.setXmlElementWrapper_(null); + getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); + setXmlElementWrapper_(null); } protected XmlElementWrapperAnnotation getXmlElementWrapperAnnotation() { - return (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); + return (XmlElementWrapperAnnotation) getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); } - protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) { - return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation); + protected XmlElementWrapper buildXmlElementWrapper() { + return new GenericJavaXmlElementWrapper(this, new GenericJavaXmlElementWrapper.SimpleContext(getXmlElementWrapperAnnotation())); } protected void initializeXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - this.xmlElementWrapper = this.buildXmlElementWrapper(annotation); + if (getXmlElementWrapperAnnotation() != null) { + this.xmlElementWrapper = buildXmlElementWrapper(); } } protected void syncXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().synchronizeWithResourceModel(); + if (getXmlElementWrapperAnnotation() != null) { + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.synchronizeWithResourceModel(); } else { - this.setXmlElementWrapper_(this.buildXmlElementWrapper(annotation)); + setXmlElementWrapper_(buildXmlElementWrapper()); } } else { - this.setXmlElementWrapper_(null); + setXmlElementWrapper_(null); } } protected void updateXmlElementWrapper() { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().update(); + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.update(); } } @@ -365,7 +362,7 @@ public class GenericJavaXmlAnyElementMapping } } - public class XmlElementRefsContext + protected class XmlElementRefsContext implements GenericJavaXmlElementRefs.Context { protected XmlElementRefsAnnotation getXmlElementRefsAnnotation() { @@ -498,7 +495,7 @@ public class GenericJavaXmlAnyElementMapping } - public class XmlElementRefContext + protected class XmlElementRefContext implements GenericJavaXmlElementRef.Context { protected XmlElementRefAnnotation annotation; diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java index 52859a1a9a..7d9428c5a5 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlAttributeMapping.java @@ -183,11 +183,14 @@ public class GenericJavaXmlAttributeMapping public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); - this.qName.validate(messages, reporter, astRoot); - + validateQName(messages, reporter, astRoot); validateSchemaType(messages, reporter, astRoot); } + protected void validateQName(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + this.qName.validate(messages, reporter, astRoot); + } + protected void validateSchemaType(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { XsdFeature xsdFeature = getXsdFeature(); if (xsdFeature == null) { 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 c61d1c321b..a1f56707cc 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 @@ -351,11 +351,15 @@ public class GenericJavaXmlElement @Override public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); - this.qName.validate(messages, reporter, astRoot); + validateQName(messages, reporter, astRoot); validateType(messages, reporter, astRoot); validateSchemaType(messages, reporter, astRoot); } + protected void validateQName(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + this.qName.validate(messages, reporter, astRoot); + } + protected void validateType(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { String fqType = getFullyQualifiedType(); if (StringTools.stringIsEmpty(fqType)) { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java index 8e581ab8ed..903c32f0c0 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java @@ -45,7 +45,7 @@ public class GenericJavaXmlElementMapping public GenericJavaXmlElementMapping(JaxbPersistentAttribute parent) { super(parent); this.xmlElement = buildXmlElement(); - this.initializeXmlElementWrapper(); + initializeXmlElementWrapper(); } @@ -91,18 +91,17 @@ public class GenericJavaXmlElementMapping return this.xmlElementWrapper; } - protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) { - return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation); + protected XmlElementWrapper buildXmlElementWrapper() { + return new GenericJavaXmlElementWrapper(this, new GenericJavaXmlElementWrapper.SimpleContext(getXmlElementWrapperAnnotation())); } public XmlElementWrapper addXmlElementWrapper() { if (this.xmlElementWrapper != null) { throw new IllegalStateException(); } - XmlElementWrapperAnnotation annotation = - (XmlElementWrapperAnnotation) getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); - XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(annotation); - this.setXmlElementWrapper_(xmlElementWrapper); + getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); + XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(); + setXmlElementWrapper_(xmlElementWrapper); return xmlElementWrapper; } @@ -110,39 +109,37 @@ public class GenericJavaXmlElementMapping if (this.xmlElementWrapper == null) { throw new IllegalStateException(); } - this.getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); - this.setXmlElementWrapper_(null); + getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); + setXmlElementWrapper_(null); } protected void initializeXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - this.xmlElementWrapper = this.buildXmlElementWrapper(annotation); + if (getXmlElementWrapperAnnotation() != null) { + this.xmlElementWrapper = buildXmlElementWrapper(); } } protected XmlElementWrapperAnnotation getXmlElementWrapperAnnotation() { - return (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); + return (XmlElementWrapperAnnotation) getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); } protected void syncXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().synchronizeWithResourceModel(); + if (getXmlElementWrapperAnnotation() != null) { + if (getXmlElementWrapper() != null) { + getXmlElementWrapper().synchronizeWithResourceModel(); } else { - this.setXmlElementWrapper_(this.buildXmlElementWrapper(annotation)); + setXmlElementWrapper_(buildXmlElementWrapper()); } } else { - this.setXmlElementWrapper_(null); + setXmlElementWrapper_(null); } } protected void updateXmlElementWrapper() { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().update(); + if (getXmlElementWrapper() != null) { + getXmlElementWrapper().update(); } } @@ -235,13 +232,13 @@ public class GenericJavaXmlElementMapping this.xmlElement.validate(messages, reporter, astRoot); - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().validate(messages, reporter, astRoot); + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.validate(messages, reporter, astRoot); } } - public class XmlElementContext + protected class XmlElementContext implements GenericJavaXmlElement.Context { public XmlElementAnnotation getAnnotation(boolean createIfNull) { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java index d116239ec1..58a790be8e 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java @@ -101,10 +101,9 @@ public class GenericJavaXmlElementRefMapping if (this.xmlElementWrapper != null) { throw new IllegalStateException(); } - XmlElementWrapperAnnotation annotation = - (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); - XmlElementWrapper xmlElementWrapper = this.buildXmlElementWrapper(annotation); - this.setXmlElementWrapper_(xmlElementWrapper); + getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); + XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(); + setXmlElementWrapper_(xmlElementWrapper); return xmlElementWrapper; } @@ -112,43 +111,41 @@ public class GenericJavaXmlElementRefMapping if (this.xmlElementWrapper == null) { throw new IllegalStateException(); } - this.getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); - this.setXmlElementWrapper_(null); + getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); + setXmlElementWrapper_(null); } protected XmlElementWrapperAnnotation getXmlElementWrapperAnnotation() { - return (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); + return (XmlElementWrapperAnnotation) getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); } - protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) { - return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation); + protected XmlElementWrapper buildXmlElementWrapper() { + return new GenericJavaXmlElementWrapper(this, new GenericJavaXmlElementWrapper.SimpleContext(getXmlElementWrapperAnnotation())); } protected void initializeXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - this.xmlElementWrapper = this.buildXmlElementWrapper(annotation); + if (getXmlElementWrapperAnnotation() != null) { + this.xmlElementWrapper = buildXmlElementWrapper(); } } protected void syncXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().synchronizeWithResourceModel(); + if (getXmlElementWrapperAnnotation() != null) { + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.synchronizeWithResourceModel(); } else { - this.setXmlElementWrapper_(this.buildXmlElementWrapper(annotation)); + setXmlElementWrapper_(buildXmlElementWrapper()); } } else { - this.setXmlElementWrapper_(null); + setXmlElementWrapper_(null); } } protected void updateXmlElementWrapper() { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().update(); + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.update(); } } @@ -273,7 +270,7 @@ public class GenericJavaXmlElementRefMapping } - public class XmlElementRefContext + protected class XmlElementRefContext implements GenericJavaXmlElementRef.Context { public XmlElementRefAnnotation getAnnotation() { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java index 92f9ad8143..63f7e7d26e 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java @@ -109,10 +109,9 @@ public class GenericJavaXmlElementRefsMapping if (this.xmlElementWrapper != null) { throw new IllegalStateException(); } - XmlElementWrapperAnnotation annotation = - (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); - XmlElementWrapper xmlElementWrapper = this.buildXmlElementWrapper(annotation); - this.setXmlElementWrapper_(xmlElementWrapper); + getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); + XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(); + setXmlElementWrapper_(xmlElementWrapper); return xmlElementWrapper; } @@ -120,43 +119,41 @@ public class GenericJavaXmlElementRefsMapping if (this.xmlElementWrapper == null) { throw new IllegalStateException(); } - this.getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); - this.setXmlElementWrapper_(null); + getJavaResourceAttribute().removeAnnotation(JAXB.XML_ELEMENT_WRAPPER); + setXmlElementWrapper_(null); } protected XmlElementWrapperAnnotation getXmlElementWrapperAnnotation() { - return (XmlElementWrapperAnnotation) this.getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); + return (XmlElementWrapperAnnotation) getJavaResourceAttribute().getAnnotation(JAXB.XML_ELEMENT_WRAPPER); } - protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) { - return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation); + protected XmlElementWrapper buildXmlElementWrapper() { + return new GenericJavaXmlElementWrapper(this, new GenericJavaXmlElementWrapper.SimpleContext(getXmlElementWrapperAnnotation())); } protected void initializeXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - this.xmlElementWrapper = this.buildXmlElementWrapper(annotation); + if (getXmlElementWrapperAnnotation() != null) { + this.xmlElementWrapper = buildXmlElementWrapper(); } } protected void syncXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = this.getXmlElementWrapperAnnotation(); - if (annotation != null) { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().synchronizeWithResourceModel(); + if (getXmlElementWrapperAnnotation() != null) { + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.synchronizeWithResourceModel(); } else { - this.setXmlElementWrapper_(this.buildXmlElementWrapper(annotation)); + setXmlElementWrapper_(buildXmlElementWrapper()); } } else { - this.setXmlElementWrapper_(null); + setXmlElementWrapper_(null); } } protected void updateXmlElementWrapper() { - if (this.getXmlElementWrapper() != null) { - this.getXmlElementWrapper().update(); + if (this.xmlElementWrapper != null) { + this.xmlElementWrapper.update(); } } @@ -285,7 +282,7 @@ public class GenericJavaXmlElementRefsMapping } - public class XmlElementRefsContext + protected class XmlElementRefsContext implements GenericJavaXmlElementRefs.Context { protected XmlElementRefsAnnotation getXmlElementRefsAnnotation() { @@ -318,7 +315,7 @@ public class GenericJavaXmlElementRefsMapping } - public class XmlElementRefContext + protected class XmlElementRefContext implements GenericJavaXmlElementRef.Context { protected XmlElementRefAnnotation annotation; diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java index 7d6e9b19c0..23f7c5aa00 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementWrapper.java @@ -38,7 +38,7 @@ public class GenericJavaXmlElementWrapper extends AbstractJavaContextNode implements XmlElementWrapper { - protected final XmlElementWrapperAnnotation annotation; + protected final Context context; protected JaxbQName qName; @@ -47,9 +47,9 @@ public class GenericJavaXmlElementWrapper protected Boolean specifiedNillable; - public GenericJavaXmlElementWrapper(JaxbAttributeMapping parent, XmlElementWrapperAnnotation annotation) { + public GenericJavaXmlElementWrapper(JaxbAttributeMapping parent, Context context) { super(parent); - this.annotation = annotation; + this.context = context; this.qName = buildQName(); this.specifiedRequired = buildSpecifiedRequired(); this.specifiedNillable = this.buildSpecifiedNillable(); @@ -81,6 +81,10 @@ public class GenericJavaXmlElementWrapper return getJaxbClassMapping().getJaxbType().getJaxbPackage(); } + protected XmlElementWrapperAnnotation getAnnotation() { + return this.context.getAnnotation(); + } + // ********** synchronize/update ********** @@ -121,7 +125,7 @@ public class GenericJavaXmlElementWrapper } public void setSpecifiedRequired(Boolean newSpecifiedRequired) { - this.annotation.setRequired(newSpecifiedRequired); + getAnnotation().setRequired(newSpecifiedRequired); this.setSpecifiedRequired_(newSpecifiedRequired); } @@ -132,7 +136,7 @@ public class GenericJavaXmlElementWrapper } protected Boolean buildSpecifiedRequired() { - return this.annotation.getRequired(); + return getAnnotation().getRequired(); } @@ -151,7 +155,7 @@ public class GenericJavaXmlElementWrapper } public void setSpecifiedNillable(Boolean newSpecifiedNillable) { - this.annotation.setNillable(newSpecifiedNillable); + getAnnotation().setNillable(newSpecifiedNillable); this.setSpecifiedNillable_(newSpecifiedNillable); } @@ -162,7 +166,7 @@ public class GenericJavaXmlElementWrapper } protected Boolean buildSpecifiedNillable() { - return this.annotation.getNillable(); + return getAnnotation().getNillable(); } @@ -199,8 +203,6 @@ public class GenericJavaXmlElementWrapper public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); - this.qName.validate(messages, reporter, astRoot); - if (! getPersistentAttribute().isJavaResourceAttributeCollectionType()) { messages.add( DefaultValidationMessages.buildMessage( @@ -209,11 +211,41 @@ public class GenericJavaXmlElementWrapper this, getValidationTextRange(astRoot))); } + + validateQName(messages, reporter, astRoot); + } + + protected void validateQName(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + this.qName.validate(messages, reporter, astRoot); } @Override public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.annotation.getTextRange(astRoot); + return getAnnotation().getTextRange(astRoot); + } + + + public interface Context { + + /** + * This should never be null + */ + XmlElementWrapperAnnotation getAnnotation(); + } + + + public static class SimpleContext + implements Context { + + protected XmlElementWrapperAnnotation annotation; + + public SimpleContext(XmlElementWrapperAnnotation annotation) { + this.annotation = annotation; + } + + public XmlElementWrapperAnnotation getAnnotation() { + return this.annotation; + } } @@ -278,7 +310,7 @@ public class GenericJavaXmlElementWrapper @Override protected QNameAnnotation getAnnotation(boolean createIfNull) { - return GenericJavaXmlElementWrapper.this.annotation; + return GenericJavaXmlElementWrapper.this.getAnnotation(); } } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java index d686f947fa..3fb0f0d07c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java @@ -55,7 +55,7 @@ public class GenericJavaXmlElementsMapping public GenericJavaXmlElementsMapping(JaxbPersistentAttribute parent) { super(parent); - this.xmlElementContainer = this.buildXmlElementContainer(); + this.xmlElementContainer = buildXmlElementContainer(); initializeXmlElementWrapper(); initializeXmlIDREF(); } @@ -138,9 +138,8 @@ public class GenericJavaXmlElementsMapping if (this.xmlElementWrapper != null) { throw new IllegalStateException(); } - XmlElementWrapperAnnotation annotation = - (XmlElementWrapperAnnotation) getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); - XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(annotation); + getJavaResourceAttribute().addAnnotation(JAXB.XML_ELEMENT_WRAPPER); + XmlElementWrapper xmlElementWrapper = buildXmlElementWrapper(); setXmlElementWrapper_(xmlElementWrapper); return xmlElementWrapper; } @@ -159,8 +158,8 @@ public class GenericJavaXmlElementsMapping firePropertyChanged(XML_ELEMENT_WRAPPER_PROPERTY, oldXmlElementWrapper, xmlElementWrapper); } - protected XmlElementWrapper buildXmlElementWrapper(XmlElementWrapperAnnotation xmlElementWrapperAnnotation) { - return new GenericJavaXmlElementWrapper(this, xmlElementWrapperAnnotation); + protected XmlElementWrapper buildXmlElementWrapper() { + return new GenericJavaXmlElementWrapper(this, new GenericJavaXmlElementWrapper.SimpleContext(getXmlElementWrapperAnnotation())); } protected XmlElementWrapperAnnotation getXmlElementWrapperAnnotation() { @@ -168,20 +167,18 @@ public class GenericJavaXmlElementsMapping } protected void initializeXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = getXmlElementWrapperAnnotation(); - if (annotation != null) { - this.xmlElementWrapper = buildXmlElementWrapper(annotation); + if (getXmlElementWrapperAnnotation() != null) { + this.xmlElementWrapper = buildXmlElementWrapper(); } } protected void syncXmlElementWrapper() { - XmlElementWrapperAnnotation annotation = getXmlElementWrapperAnnotation(); - if (annotation != null) { + if (getXmlElementWrapperAnnotation() != null) { if (this.xmlElementWrapper != null) { this.xmlElementWrapper.synchronizeWithResourceModel(); } else { - setXmlElementWrapper_(buildXmlElementWrapper(annotation)); + setXmlElementWrapper_(buildXmlElementWrapper()); } } else { |