diff options
author | pfullbright | 2011-04-07 20:47:03 +0000 |
---|---|---|
committer | pfullbright | 2011-04-07 20:47:03 +0000 |
commit | bad0bb05dab01276f5c9831eed09f75e3bb88698 (patch) | |
tree | d52037a6167a7968c977e18339c03a45e298399b | |
parent | a478ec6a681a517a73426cbae5d078c75fd7121b (diff) | |
download | webtools.dali-bad0bb05dab01276f5c9831eed09f75e3bb88698.tar.gz webtools.dali-bad0bb05dab01276f5c9831eed09f75e3bb88698.tar.xz webtools.dali-bad0bb05dab01276f5c9831eed09f75e3bb88698.zip |
added element support (and more) to schema model
15 files changed, 521 insertions, 35 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XSDNodeVisitor.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XSDNodeVisitor.java new file mode 100644 index 0000000000..ed5b5e4515 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XSDNodeVisitor.java @@ -0,0 +1,151 @@ +/******************************************************************************* + * 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.xsd; + +import java.util.Stack; +import org.eclipse.xsd.XSDAttributeDeclaration; +import org.eclipse.xsd.XSDAttributeGroupDefinition; +import org.eclipse.xsd.XSDAttributeUse; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDModelGroupDefinition; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.util.XSDSwitch; + + +public class XSDNodeVisitor { + + private Stack<XSDComponent> visitedNodeStack = new Stack<XSDComponent>(); + + + public void visitNode(XSDComponent node) { + if (node != null && ! visitedNodeStack.contains(node)) { + visitedNodeStack.push(node); + XSDSwitch xsdSwitch = new XSDSwitch() { + @Override + public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) { + visitXSDAttributeDeclaration(object); + return null; + } + + @Override + public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) { + visitXSDAttributeGroupDefinition(object); + return null; + } + + @Override + public Object caseXSDAttributeUse(XSDAttributeUse object) { + visitXSDAttributeUse(object); + return null; + } + + @Override + public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) { + visitXSDComplexTypeDefinition(object); + return null; + } + + @Override + public Object caseXSDElementDeclaration(XSDElementDeclaration object) { + visitXSDElementDeclaration(object); + return null; + } + + @Override + public Object caseXSDModelGroup(XSDModelGroup object) { + visitXSDModelGroup(object); + return null; + } + + @Override + public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) { + visitXSDModelGroupDefinition(object); + return null; + } + + @Override + public Object caseXSDParticle(XSDParticle object) { + visitXSDParticle(object); + return null; + } + + @Override + public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) { + visitXSDSimpleTypeDefinition(object); + return null; + } + }; + xsdSwitch.doSwitch(node); + visitedNodeStack.pop(); + } + } + + public void visitXSDAttributeDeclaration(XSDAttributeDeclaration node) {} + + public void visitXSDAttributeGroupDefinition(XSDAttributeGroupDefinition node) { + for (XSDAttributeUse attrUse : node.getAttributeUses()) { + visitNode(attrUse); + } + } + + public void visitXSDAttributeUse(XSDAttributeUse node) {} + + public void visitXSDComplexTypeDefinition(XSDComplexTypeDefinition node) { + if (node.getBaseType() != null) { + visitNode(node.getBaseType()); + } + + for (XSDAttributeUse attrUse : node.getAttributeUses()) { + visitNode(attrUse); + } + + if (node.getContent() != null) { + visitNode(node.getContent()); + } + } + + public void visitXSDElementDeclaration(XSDElementDeclaration node) { + for (XSDElementDeclaration element : node.getSubstitutionGroup()) { + visitNode(element); + } + + if (node.getTypeDefinition() != null) { + visitNode(node.getTypeDefinition()); + } + } + + public void visitXSDModelGroup(XSDModelGroup node) { + for (XSDParticle particle : node.getParticles()) { + visitNode(particle); + } + } + + public void visitXSDModelGroupDefinition(XSDModelGroupDefinition node) { + if (node.getModelGroup() != null) { + visitNode(node.getModelGroup()); + } + } + + public void visitXSDParticle(XSDParticle node) { + if (node.getTerm() != null) { + visitNode(node.getTerm()); + } + } + + public void visitXSDSimpleTypeDefinition(XSDSimpleTypeDefinition node) { + if (node.getBaseType() != null) { + visitNode(node.getBaseType()); + } + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeDeclaration.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeDeclaration.java new file mode 100644 index 0000000000..5cc82ad60a --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeDeclaration.java @@ -0,0 +1,12 @@ +package org.eclipse.jpt.jaxb.core.xsd; + +import org.eclipse.xsd.XSDAttributeDeclaration; + + +public class XsdAttributeDeclaration + extends XsdFeature<XSDAttributeDeclaration> { + + XsdAttributeDeclaration(XSDAttributeDeclaration xsdAttributeDeclaration) { + super(xsdAttributeDeclaration); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeGroupDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeGroupDefinition.java new file mode 100644 index 0000000000..3feb1b3778 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeGroupDefinition.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDAttributeGroupDefinition; + + +public class XsdAttributeGroupDefinition + extends XsdComponent<XSDAttributeGroupDefinition> { + + XsdAttributeGroupDefinition(XSDAttributeGroupDefinition xsdAttributeGroupDefinition) { + super(xsdAttributeGroupDefinition); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeUse.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeUse.java new file mode 100644 index 0000000000..fd2f3c62df --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAttributeUse.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDAttributeUse; + + +public class XsdAttributeUse + extends XsdComponent<XSDAttributeUse> { + + + XsdAttributeUse(XSDAttributeUse xsdAttributeUse) { + super(xsdAttributeUse); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComplexTypeDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComplexTypeDefinition.java index 53b457aa34..fd97f2fba3 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComplexTypeDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComplexTypeDefinition.java @@ -9,13 +9,128 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.core.xsd; +import java.util.ArrayList; +import java.util.List; +import org.eclipse.jpt.common.utility.Filter; +import org.eclipse.jpt.common.utility.internal.StringTools; +import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; +import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; +import org.eclipse.xsd.XSDAttributeUse; import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDElementDeclaration; public class XsdComplexTypeDefinition - extends XsdTypeDefinition { + extends XsdTypeDefinition<XSDComplexTypeDefinition> { XsdComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition) { super(xsdComplexTypeDefinition); } + + + @Override + public XsdAttributeUse getAttribute(String namespace, String name) { + for (XsdAttributeUse attrUse : getAttributeUses(namespace)) { + if (attrUse.getXSDComponent().getAttributeDeclaration().getName().equals(name)) { + return attrUse; + } + } + return null; + } + + @Override + public Iterable<String> getAttributeNameProposals(String namespace, Filter<String> filter) { + return StringTools.convertToJavaStringLiterals( + new FilteringIterable<String>( + new TransformationIterable<XsdAttributeUse, String>(getAttributeUses(namespace)) { + @Override + protected String transform(XsdAttributeUse attrUse) { + return attrUse.getXSDComponent().getAttributeDeclaration().getName(); + } + }, + filter)); + } + + protected Iterable<XsdAttributeUse> getAttributeUses(final String namespace) { + return new TransformationIterable<XSDAttributeUse, XsdAttributeUse>( + new FilteringIterable<XSDAttributeUse>(getXSDComponent().getAttributeUses()) { + @Override + protected boolean accept(XSDAttributeUse attrUse) { + String otherNamespace = attrUse.getAttributeDeclaration().getTargetNamespace(); + return StringTools.stringsAreEqual(namespace, otherNamespace) + || (StringTools.stringIsEmpty(namespace) && (StringTools.stringIsEmpty(otherNamespace))); + } + }) { + @Override + protected XsdAttributeUse transform(XSDAttributeUse attrUse) { + return (XsdAttributeUse) XsdUtil.getAdapter(attrUse); + } + }; + } + + @Override + public XsdElementDeclaration getElement(String namespace, String name) { + for (XsdElementDeclaration element : getElementDeclarations(namespace)) { + if (element.getXSDComponent().getName().equals(name)) { + return element; + } + } + return null; + } + + @Override + public Iterable<String> getElementNameProposals(String namespace, Filter<String> filter) { + return StringTools.convertToJavaStringLiterals( + new FilteringIterable<String>( + new TransformationIterable<XsdElementDeclaration, String>(getElementDeclarations(namespace)) { + @Override + protected String transform(XsdElementDeclaration element) { + return element.getXSDComponent().getName(); + } + }, + filter)); + } + + protected Iterable<XsdElementDeclaration> getElementDeclarations(final String namespace) { + return new TransformationIterable<XSDElementDeclaration, XsdElementDeclaration>( + new FilteringIterable<XSDElementDeclaration>(getXSDElementDeclarations()) { + @Override + protected boolean accept(XSDElementDeclaration element) { + String otherNamespace = element.getTargetNamespace(); + return StringTools.stringsAreEqual(namespace, otherNamespace) + || (StringTools.stringIsEmpty(namespace) && (StringTools.stringIsEmpty(otherNamespace))); + } + }) { + @Override + protected XsdElementDeclaration transform(XSDElementDeclaration element) { + return (XsdElementDeclaration) XsdUtil.getAdapter(element); + } + }; + } + + protected Iterable<XSDElementDeclaration> getXSDElementDeclarations() { + ElementFinder elementFinder = new ElementFinder(); + elementFinder.visitNode(getXSDComponent()); + return elementFinder.getElements(); + } + + + private class ElementFinder + extends XSDNodeVisitor { + + private List<XSDElementDeclaration> elements = new ArrayList<XSDElementDeclaration>(); + + + @Override + public void visitXSDElementDeclaration(XSDElementDeclaration node) { + super.visitXSDElementDeclaration(node); + if (! this.elements.contains(node)) { + elements.add(node); + } + } + + public Iterable<XSDElementDeclaration> getElements() { + return this.elements; + } + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAdapter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComponent.java index 7ad4345bf1..fb7fec486b 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdAdapter.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdComponent.java @@ -10,16 +10,25 @@ package org.eclipse.jpt.jaxb.core.xsd; import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.xsd.XSDConcreteComponent; -public class XsdAdapter +public class XsdComponent<A extends XSDConcreteComponent> extends AdapterImpl { - protected XsdAdapter() { + protected final A xsdComponent; + + + protected XsdComponent(A xsdComponent) { super(); + this.xsdComponent = xsdComponent; } + public A getXSDComponent() { + return this.xsdComponent; + } + @Override public boolean isAdapterForType(Object type) { return type == XsdUtil.adapterFactory; diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdElementDeclaration.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdElementDeclaration.java index d27229f828..dc4ae5719e 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdElementDeclaration.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdElementDeclaration.java @@ -14,23 +14,19 @@ import org.eclipse.xsd.XSDTypeDefinition; public class XsdElementDeclaration - extends XsdAdapter { - - protected final XSDElementDeclaration xsdElementDeclaration; - + extends XsdFeature<XSDElementDeclaration> { XsdElementDeclaration(XSDElementDeclaration xsdElementDeclaration) { - super(); - this.xsdElementDeclaration = xsdElementDeclaration; + super(xsdElementDeclaration); } - public String getName() { - return this.xsdElementDeclaration.getName(); + public XSDElementDeclaration getXSDElementDeclaration() { + return getXSDFeature(); } public XsdTypeDefinition getType() { - XSDTypeDefinition xsdType = this.xsdElementDeclaration.getTypeDefinition(); + XSDTypeDefinition xsdType = getXSDElementDeclaration().getTypeDefinition(); return (xsdType == null) ? null : (XsdTypeDefinition) XsdUtil.getAdapter(xsdType); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdFeature.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdFeature.java new file mode 100644 index 0000000000..21dc57361e --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdFeature.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDFeature; + + +public abstract class XsdFeature<A extends XSDFeature> + extends XsdComponent<A> { + + protected XsdFeature(A xsdFeature) { + super(xsdFeature); + } + + + public A getXSDFeature() { + return getXSDComponent(); + } + + public String getName() { + return getXSDFeature().getName(); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroup.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroup.java new file mode 100644 index 0000000000..ecda07b617 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroup.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDModelGroup; + + +public class XsdModelGroup + extends XsdComponent<XSDModelGroup> { + + XsdModelGroup(XSDModelGroup xsdModelGroup) { + super(xsdModelGroup); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroupDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroupDefinition.java new file mode 100644 index 0000000000..7e9c2a7385 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdModelGroupDefinition.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDModelGroupDefinition; + + +public class XsdModelGroupDefinition + extends XsdComponent<XSDModelGroupDefinition> { + + XsdModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) { + super(xsdModelGroupDefinition); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdParticle.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdParticle.java new file mode 100644 index 0000000000..23bbf9c99e --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdParticle.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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.xsd; + +import org.eclipse.xsd.XSDParticle; + + +public class XsdParticle + extends XsdComponent<XSDParticle> { + + XsdParticle(XSDParticle xsdParticle) { + super(xsdParticle); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java index e8c9e01b53..fa4a829fe5 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSchema.java @@ -22,20 +22,19 @@ import org.eclipse.xsd.XSDTypeDefinition; import org.eclipse.xsd.util.XSDUtil; public class XsdSchema - extends XsdAdapter { - - protected final XSDSchema xsdSchema; - - + extends XsdComponent<XSDSchema> { XsdSchema(XSDSchema xsdSchema) { - super(); - this.xsdSchema = xsdSchema; + super(xsdSchema); } + public XSDSchema getXSDSchema() { + return getXSDComponent(); + } + public Iterable<String> getNamespaces() { - return new SnapshotCloneIterable(this.xsdSchema.getQNamePrefixToNamespaceMap().values()); + return new SnapshotCloneIterable(getXSDSchema().getQNamePrefixToNamespaceMap().values()); } public Iterable<XsdTypeDefinition> getAllTypeDefinitions() { @@ -99,11 +98,11 @@ public class XsdSchema } protected Iterable<XSDTypeDefinition> getDeclaredXSDTypeDefinitions() { - return new SnapshotCloneIterable(this.xsdSchema.getTypeDefinitions()); + return new SnapshotCloneIterable(getXSDSchema().getTypeDefinitions()); } protected Iterable<XSDTypeDefinition> getBuiltInXSDTypeDefinitions() { - return new SnapshotCloneIterable(this.xsdSchema.getSchemaForSchema().getTypeDefinitions()); + return new SnapshotCloneIterable(getXSDSchema().getSchemaForSchema().getTypeDefinitions()); } protected Iterable<XSDTypeDefinition> getXSDTypeDefinitions(final String namespace) { @@ -167,7 +166,7 @@ public class XsdSchema } protected Iterable<XSDElementDeclaration> getXSDElementDeclarations() { - return new SnapshotCloneIterable(this.xsdSchema.getElementDeclarations()); + return new SnapshotCloneIterable(getXSDSchema().getElementDeclarations()); } public Iterable<String> getNamespaceProposals(Filter<String> filter) { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java index c50310c85f..17068711fe 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdSimpleTypeDefinition.java @@ -9,13 +9,40 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.core.xsd; +import org.eclipse.jpt.common.utility.Filter; +import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; import org.eclipse.xsd.XSDSimpleTypeDefinition; public class XsdSimpleTypeDefinition - extends XsdTypeDefinition { + extends XsdTypeDefinition<XSDSimpleTypeDefinition> { XsdSimpleTypeDefinition(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { super(xsdSimpleTypeDefinition); } + + + @Override + public XsdAttributeUse getAttribute(String namespace, String name) { + // simple types have no attributes + return null; + } + + @Override + public Iterable<String> getAttributeNameProposals(String namespace, Filter<String> filter) { + // simple types have no attributes + return EmptyIterable.instance(); + } + + @Override + public XsdElementDeclaration getElement(String namespace, String name) { + // simple types have no elements + return null; + } + + @Override + public Iterable<String> getElementNameProposals(String namespace, Filter<String> filter) { + // simple types have no elements + return EmptyIterable.instance(); + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java index 85d95bbf9b..cddb3c41fa 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdTypeDefinition.java @@ -9,22 +9,27 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.core.xsd; +import org.eclipse.jpt.common.utility.Filter; import org.eclipse.xsd.XSDTypeDefinition; -public abstract class XsdTypeDefinition - extends XsdAdapter { +public abstract class XsdTypeDefinition<A extends XSDTypeDefinition> + extends XsdComponent<A> { - protected final XSDTypeDefinition xsdTypeDefinition; - - - protected XsdTypeDefinition(XSDTypeDefinition xsdTypeDefinition) { - super(); - this.xsdTypeDefinition = xsdTypeDefinition; + protected XsdTypeDefinition(A xsdTypeDefinition) { + super(xsdTypeDefinition); } public String getName() { - return this.xsdTypeDefinition.getName(); + return getXSDComponent().getName(); } + + public abstract XsdAttributeUse getAttribute(String namespace, String name); + + public abstract Iterable<String> getAttributeNameProposals(String namespace, Filter<String> filter); + + public abstract XsdElementDeclaration getElement(String namespace, String name); + + public abstract Iterable<String> getElementNameProposals(String namespace, Filter<String> filter); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java index c4882c9b48..fb6519770c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/xsd/XsdUtil.java @@ -27,8 +27,14 @@ import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; import org.eclipse.wst.xsd.contentmodel.internal.util.XSDSchemaLocatorAdapterFactory; +import org.eclipse.xsd.XSDAttributeDeclaration; +import org.eclipse.xsd.XSDAttributeGroupDefinition; +import org.eclipse.xsd.XSDAttributeUse; import org.eclipse.xsd.XSDComplexTypeDefinition; import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDModelGroupDefinition; +import org.eclipse.xsd.XSDParticle; import org.eclipse.xsd.XSDSchema; import org.eclipse.xsd.XSDSchemaContent; import org.eclipse.xsd.XSDSimpleTypeDefinition; @@ -164,8 +170,18 @@ public class XsdUtil { } @Override - public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) { - return new XsdSimpleTypeDefinition(object); + public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) { + return new XsdAttributeDeclaration(object); + } + + @Override + public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) { + return new XsdAttributeGroupDefinition(object); + } + + @Override + public Object caseXSDAttributeUse(XSDAttributeUse object) { + return new XsdAttributeUse(object); } @Override @@ -177,6 +193,26 @@ public class XsdUtil { public Object caseXSDElementDeclaration(XSDElementDeclaration object) { return new XsdElementDeclaration(object); } + + @Override + public Object caseXSDModelGroup(XSDModelGroup object) { + return new XsdModelGroup(object); + } + + @Override + public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) { + return new XsdModelGroupDefinition(object); + } + + @Override + public Object caseXSDParticle(XSDParticle object) { + return new XsdParticle(object); + } + + @Override + public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) { + return new XsdSimpleTypeDefinition(object); + } }; Object o = xsdSwitch.doSwitch((EObject) target); |