Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java32
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java136
2 files changed, 94 insertions, 74 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
index aed08b703e..5409f66620 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlSchema.java
@@ -24,17 +24,29 @@ import org.eclipse.jpt.utility.internal.iterables.ListIterable;
* @since 3.0
*/
public interface XmlSchema
- extends
- JaxbContextNode
-{
+ extends JaxbContextNode {
+
+ /**
+ * Return the specified namespace or "" (default value)
+ */
String getNamespace();
-
- void setNamespace(String namespace);
- /**
- * String constant associated with changes to the namespace
- */
- String NAMESPACE_PROPERTY = "namespace"; //$NON-NLS-1$
-
+
+ /**
+ * Return the specified namespace, null if it is not specified
+ */
+ String getSpecifiedNamespace();
+
+ /**
+ * Set the namespace, null to unspecify
+ */
+ void setSpecifiedNamespace(String namespace);
+
+ /**
+ * String constant associated with changes to the specified namespace
+ */
+ String SPECIFIED_NAMESPACE_PROPERTY = "specifiedNamespace"; //$NON-NLS-1$
+
+
/**
* Corresponds to the XmlSchema annotation location element
*/
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
index 0643d00a93..4ab5a1210a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlSchema.java
@@ -20,210 +20,218 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaAnnotation;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
public class GenericJavaXmlSchema
- extends AbstractJaxbContextNode
- implements XmlSchema
-{
-
- protected String namespace;
-
+ extends AbstractJaxbContextNode
+ implements XmlSchema {
+
+ protected String specifiedNamespace;
+
protected String location;
-
+
protected XmlNsForm attributeFormDefault;
-
+
protected XmlNsForm elementFormDefault;
-
+
protected final XmlNsPrefixContainer xmlNsPrefixContainer;
-
+
+
public GenericJavaXmlSchema(JaxbPackageInfo parent) {
super(parent);
- this.namespace = this.getResourceNamespace();
+ this.specifiedNamespace = this.getResourceNamespace();
this.location = this.getResourceLocation();
this.attributeFormDefault = this.getResourceAttributeFormDefault();
this.elementFormDefault = this.getResourceElementFormDefault();
this.xmlNsPrefixContainer = new XmlNsPrefixContainer();
}
-
-
+
+
// ********** synchronize/update **********
-
+
public void synchronizeWithResourceModel() {
- this.setNamespace_(this.getResourceNamespace());
+ this.setSpecifiedNamespace_(this.getResourceNamespace());
this.setLocation_(this.getResourceLocation());
this.setAttributeFormDefault_(this.getResourceAttributeFormDefault());
this.setElementFormDefault_(this.getResourceElementFormDefault());
this.syncXmlNsPrefixes();
}
-
+
public void update() {
this.updateNodes(getXmlNsPrefixes());
}
-
-
+
@Override
public JaxbPackageInfo getParent() {
return (JaxbPackageInfo) super.getParent();
}
-
+
protected JavaResourcePackage getResourcePackage() {
return getParent().getResourcePackage();
}
-
-
+
+
// ********** xml schema annotation **********
-
+
protected XmlSchemaAnnotation getXmlSchemaAnnotation() {
return (XmlSchemaAnnotation) this.getResourcePackage().getNonNullAnnotation(XmlSchemaAnnotation.ANNOTATION_NAME);
}
-
+
// ********** namespace **********
-
+
public String getNamespace() {
- return this.namespace;
+ return (this.specifiedNamespace == null) ? "" : this.specifiedNamespace;
+ }
+
+ public String getSpecifiedNamespace() {
+ return this.specifiedNamespace;
}
- public void setNamespace(String namespace) {
+ public void setSpecifiedNamespace(String namespace) {
this.getXmlSchemaAnnotation().setNamespace(namespace);
- this.setNamespace_(namespace);
+ this.setSpecifiedNamespace_(namespace);
}
-
- protected void setNamespace_(String namespace) {
- String old = this.namespace;
- this.namespace = namespace;
- this.firePropertyChanged(NAMESPACE_PROPERTY, old, namespace);
+
+ protected void setSpecifiedNamespace_(String namespace) {
+ String old = this.specifiedNamespace;
+ this.specifiedNamespace = namespace;
+ this.firePropertyChanged(SPECIFIED_NAMESPACE_PROPERTY, old, namespace);
}
-
+
protected String getResourceNamespace() {
return getXmlSchemaAnnotation().getNamespace();
}
-
+
+
// ********** location **********
-
+
public String getLocation() {
return this.location;
}
-
+
public void setLocation(String location) {
this.getXmlSchemaAnnotation().setLocation(location);
this.setLocation_(location);
}
-
+
protected void setLocation_(String location) {
String old = this.location;
this.location = location;
this.firePropertyChanged(LOCATION_PROPERTY, old, location);
}
-
+
protected String getResourceLocation() {
return getXmlSchemaAnnotation().getLocation();
}
-
+
+
// ********** attribute form default **********
-
+
public XmlNsForm getAttributeFormDefault() {
return this.attributeFormDefault;
}
-
+
public void setAttributeFormDefault(XmlNsForm xmlNsForm) {
this.getXmlSchemaAnnotation().setAttributeFormDefault(XmlNsForm.toJavaResourceModel(xmlNsForm));
this.setAttributeFormDefault_(xmlNsForm);
}
-
+
protected void setAttributeFormDefault_(XmlNsForm xmlNsForm) {
XmlNsForm old = this.attributeFormDefault;
this.attributeFormDefault = xmlNsForm;
this.firePropertyChanged(ATTRIBUTE_FROM_DEFAULT_PROPERTY, old, xmlNsForm);
}
-
+
protected XmlNsForm getResourceAttributeFormDefault() {
return XmlNsForm.fromJavaResourceModel(getXmlSchemaAnnotation().getAttributeFormDefault());
}
-
+
+
// ********** element form default **********
-
+
public XmlNsForm getElementFormDefault() {
return this.elementFormDefault;
}
-
+
public void setElementFormDefault(XmlNsForm xmlNsForm) {
this.getXmlSchemaAnnotation().setElementFormDefault(XmlNsForm.toJavaResourceModel(xmlNsForm));
this.setElementFormDefault_(xmlNsForm);
}
-
+
protected void setElementFormDefault_(XmlNsForm xmlNsForm) {
XmlNsForm old = this.elementFormDefault;
this.elementFormDefault = xmlNsForm;
this.firePropertyChanged(ELEMENT_FROM_DEFAULT_PROPERTY, old, xmlNsForm);
}
-
+
protected XmlNsForm getResourceElementFormDefault() {
return XmlNsForm.fromJavaResourceModel(getXmlSchemaAnnotation().getElementFormDefault());
}
-
-
+
+
// ********** xml namespace prefixes **********
-
+
public ListIterable<XmlNs> getXmlNsPrefixes() {
return this.xmlNsPrefixContainer.getContextElements();
}
-
+
public int getXmlNsPrefixesSize() {
return this.xmlNsPrefixContainer.getContextElementsSize();
}
-
+
public XmlNs addXmlNsPrefix(int index) {
XmlNsAnnotation annotation = this.getXmlSchemaAnnotation().addXmlns(index);
return this.xmlNsPrefixContainer.addContextElement(index, annotation);
}
-
+
public void removeXmlNsPrefix(XmlNs xmlNsPrefix) {
this.removeXmlNsPrefix(this.xmlNsPrefixContainer.indexOfContextElement(xmlNsPrefix));
}
-
+
public void removeXmlNsPrefix(int index) {
this.getXmlSchemaAnnotation().removeXmlns(index);
this.xmlNsPrefixContainer.removeContextElement(index);
}
-
+
public void moveXmlNsPrefix(int targetIndex, int sourceIndex) {
this.getXmlSchemaAnnotation().moveXmlns(targetIndex, sourceIndex);
this.xmlNsPrefixContainer.moveContextElement(targetIndex, sourceIndex);
}
-
+
protected XmlNs buildXmlNs(XmlNsAnnotation xmlNsAnnotation) {
return this.getFactory().buildJavaXmlNs(this, xmlNsAnnotation);
}
-
+
protected void syncXmlNsPrefixes() {
this.xmlNsPrefixContainer.synchronizeWithResourceModel();
}
-
+
protected ListIterable<XmlNsAnnotation> getXmlNsAnnotations() {
return getXmlSchemaAnnotation().getXmlns();
}
-
-
+
+
/**
* xml ns prefix container adapter
*/
protected class XmlNsPrefixContainer
- extends ContextListContainer<XmlNs, XmlNsAnnotation>
- {
+ extends ContextListContainer<XmlNs, XmlNsAnnotation> {
+
@Override
protected String getContextElementsPropertyName() {
return XML_NS_PREFIXES_LIST;
}
+
@Override
protected XmlNs buildContextElement(XmlNsAnnotation resourceElement) {
return GenericJavaXmlSchema.this.buildXmlNs(resourceElement);
}
+
@Override
protected ListIterable<XmlNsAnnotation> getResourceElements() {
return GenericJavaXmlSchema.this.getXmlNsAnnotations();
}
+
@Override
protected XmlNsAnnotation getResourceElement(XmlNs contextElement) {
return contextElement.getResourceXmlNs();
}
}
-
}

Back to the top