You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2005/07/06 23:34:14 UTC
cvs commit: ws-jaxme/src/test/jaxb types.xsd
jochen 2005/07/06 14:34:14
Modified: src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg
BeanGeneratingVisitor.java
src/jaxme/org/apache/ws/jaxme/generator/sg/impl
JAXBComplexTypeSG.java
. status.xml
src/jaxme/org/apache/ws/jaxme/junit NestedGroupTest.java
src/test/jaxb types.xsd
Log:
Use of xs:extension is now mapped to proper Java inheritance (at least for the bean classes.)
Revision Changes Path
1.3 +42 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanGeneratingVisitor.java
Index: BeanGeneratingVisitor.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanGeneratingVisitor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BeanGeneratingVisitor.java 7 May 2005 19:42:26 -0000 1.2
+++ BeanGeneratingVisitor.java 6 Jul 2005 21:34:13 -0000 1.3
@@ -42,11 +42,33 @@
return js;
}
+ private boolean isInheritedAttribute(AttributeSG pAttr, AttributeSG[] pInheritedAttributes) throws SAXException {
+ if (pInheritedAttributes != null) {
+ String p = pAttr.getPropertySG().getPropertyName();
+ for (int i = 0; i < pInheritedAttributes.length; i++) {
+ if (pInheritedAttributes[i].getPropertySG().getPropertyName().equals(p)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
private void generateAttributes(ComplexTypeSG pType) throws SAXException {
JavaSource js = getJavaSource();
AttributeSG[] myAttributes = pType.getAttributes();
+ AttributeSG[] inheritedAttributes = null;
+ if (pType.getTypeSG().isExtension()) {
+ TypeSG tSG = pType.getTypeSG().getExtendedType();
+ if (tSG.isComplex()) {
+ inheritedAttributes = tSG.getComplexTypeSG().getAttributes();
+ }
+ }
for (int i = 0; i < myAttributes.length; i++) {
- myAttributes[i].getPropertySG().generate(js);
+ AttributeSG attr = myAttributes[i];
+ if (!isInheritedAttribute(attr, inheritedAttributes)) {
+ attr.getPropertySG().generate(js);
+ }
}
}
@@ -82,7 +104,26 @@
}
}
+ private boolean isInheritedParticle(ParticleSG pParticle) throws SAXException {
+ String propertyName = pParticle.getPropertySG().getPropertyName();
+ if (ct.getTypeSG().isExtension()) {
+ TypeSG extType = ct.getTypeSG().getExtendedType();
+ if (extType.isComplex() && !extType.getComplexTypeSG().hasSimpleContent()) {
+ ParticleSG[] inheritedParticles = extType.getComplexTypeSG().getComplexContentSG().getElementParticles();
+ for (int i = 0; i < inheritedParticles.length; i++) {
+ if (inheritedParticles[i].getPropertySG().getPropertyName().equals(propertyName)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
private void elementParticle(GroupSG pGroupSG, ParticleSG pParticle) throws SAXException {
+ if (isInheritedParticle(pParticle)) {
+ return;
+ }
final JavaSource pJs = this.js;
final PropertySG elementSG = pParticle.getPropertySG();
if (isMixed) {
1.19 +14 -2 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexTypeSG.java
Index: JAXBComplexTypeSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexTypeSG.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JAXBComplexTypeSG.java 24 Apr 2005 20:16:48 -0000 1.18
+++ JAXBComplexTypeSG.java 6 Jul 2005 21:34:13 -0000 1.19
@@ -28,7 +28,6 @@
import org.apache.ws.jaxme.generator.sg.ComplexTypeSGChain;
import org.apache.ws.jaxme.generator.sg.Context;
import org.apache.ws.jaxme.generator.sg.GroupSG;
-import org.apache.ws.jaxme.generator.sg.ParticleSG;
import org.apache.ws.jaxme.generator.sg.SimpleContentSG;
import org.apache.ws.jaxme.generator.sg.SimpleContentSGChain;
import org.apache.ws.jaxme.generator.sg.TypeSG;
@@ -187,8 +186,21 @@
private void createXMLBean(ComplexTypeSG pController, JavaSource pJs)
throws SAXException {
- if (!pJs.isInterface()) {
+ if (pJs.isInterface()) {
+ if (pController.getTypeSG().isExtension()) {
+ TypeSG extType = pController.getTypeSG().getExtendedType();
+ if (extType.isComplex()) {
+ pJs.addExtends(extType.getComplexTypeSG().getClassContext().getXMLInterfaceName());
+ }
+ }
+ } else {
SerializableSG.makeSerializable(pController.getTypeSG().getSchema(), pJs);
+ if (pController.getTypeSG().isExtension()) {
+ TypeSG extType = pController.getTypeSG().getExtendedType();
+ if (extType.isComplex()) {
+ pJs.addExtends(extType.getComplexTypeSG().getClassContext().getXMLImplementationName());
+ }
+ }
}
BeanGeneratingVisitor visitor = new BeanGeneratingVisitor(pJs);
new ParticleWalker(visitor).walk(pController);
1.58 +1 -3 ws-jaxme/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/ws-jaxme/status.xml,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- status.xml 5 Jul 2005 08:04:31 -0000 1.57
+++ status.xml 6 Jul 2005 21:34:14 -0000 1.58
@@ -34,8 +34,6 @@
<action dev="JW" type="enhancement" context="generator">
Added support for mixed content.
</action>
- </release>
- <release version="0.4.1" date="Not yet released">
<action dev="JW" type="enhancement" context="generator">
Use of xs:extension is now mapped to proper Java
inheritance (at least for the bean classes).
@@ -44,7 +42,7 @@
Fixed that the handler and driver classes could not
be compiled, if enumerations had default values.
</action>
- </release>
+ </release>
<release version="0.4" date="2005-May-19">
<action dev="JW" type="fix" context="xs">
The methods XSSimpleContentImpl.isEmpty(),
1.7 +12 -0 ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/NestedGroupTest.java
Index: NestedGroupTest.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/NestedGroupTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NestedGroupTest.java 24 Apr 2005 20:16:49 -0000 1.6
+++ NestedGroupTest.java 6 Jul 2005 21:34:14 -0000 1.7
@@ -25,6 +25,10 @@
import org.apache.ws.jaxme.ValidationEvents;
import org.apache.ws.jaxme.impl.ValidationEventImpl;
import org.apache.ws.jaxme.test.misc.group.impl.PersonsImpl;
+import org.apache.ws.jaxme.test.misc.types.FsDirectory;
+import org.apache.ws.jaxme.test.misc.types.FsDirectoryType;
+import org.apache.ws.jaxme.test.misc.types.FsFile;
+import org.apache.ws.jaxme.test.misc.types.FsNode;
import org.apache.ws.jaxme.test.nestedgroups.MailTemplate;
import org.apache.ws.jaxme.test.nestedgroups.MailTemplateMixed;
import org.apache.ws.jaxme.test.nestedgroups.impl.MailTemplateImpl;
@@ -175,4 +179,12 @@
}
assertTrue(h.ok);
}
+
+ /** Tests proper inheritance of xs:extension.
+ */
+ public void testInheritance() throws Exception {
+ assertTrue(FsNode.class.isAssignableFrom(FsFile.class));
+ assertTrue(FsNode.class.isAssignableFrom(FsDirectory.class));
+ assertTrue(FsNode.class.isAssignableFrom(FsDirectoryType.class));
+ }
}
1.12 +41 -0 ws-jaxme/src/test/jaxb/types.xsd
Index: types.xsd
===================================================================
RCS file: /home/cvs/ws-jaxme/src/test/jaxb/types.xsd,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- types.xsd 28 Apr 2005 23:57:53 -0000 1.11
+++ types.xsd 6 Jul 2005 21:34:14 -0000 1.12
@@ -234,4 +234,45 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:complexType name="FsNode">
+ <xs:sequence>
+ <xs:element ref="ex:acl" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:long" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="parent" type="xs:long" use="required"/>
+ </xs:complexType>
+
+ <xs:element name="FsFile" type="ex:FsNode"/>
+
+ <xs:element name="FsDirectory">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="ex:FsNode">
+ <xs:attribute name="hidden" type="xs:boolean" use="optional" default="false"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="acl">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="rule" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="principal" type="xs:string" use="required"/>
+ <xs:attribute name="mode">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="allow"/>
+ <xs:enumeration value="deny"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org