xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r159092 - in xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java
Date Sat, 26 Mar 2005 04:26:11 GMT
Author: radup
Date: Fri Mar 25 20:26:09 2005
New Revision: 159092

URL: http://svn.apache.org/viewcvs?view=rev&rev=159092
Log:
Fix for http://issues.apache.org/jira/browse/XMLBEANS-8:
Correctly handle Java class generation for anonymous types defined in redefined types.

Modified:
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?view=diff&r1=159091&r2=159092
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
Fri Mar 25 20:26:09 2005
@@ -479,13 +479,24 @@
 
     void printNestedInnerTypes(SchemaType sType, SchemaTypeSystem system) throws IOException
     {
-        SchemaType[] anonTypes = sType.getAnonymousTypes();
-        for (int i = 0; i < anonTypes.length; i++)
+        boolean redefinition = sType.getName() != null &&
+            sType.getName().equals(sType.getBaseType().getName());
+        while (sType != null)
         {
-            if (anonTypes[i].isSkippedAnonymousType())
-                printNestedInnerTypes(anonTypes[i], system);
-            else
-                printInnerType(anonTypes[i], system);
+            SchemaType[] anonTypes = sType.getAnonymousTypes();
+            for (int i = 0; i < anonTypes.length; i++)
+            {
+                if (anonTypes[i].isSkippedAnonymousType())
+                    printNestedInnerTypes(anonTypes[i], system);
+                else
+                    printInnerType(anonTypes[i], system);
+            }
+            // For redefinition by extension, go ahead and print the anonymous
+            // types in the base
+            if (!redefinition ||
+                sType.getDerivationType() != SchemaType.DT_EXTENSION)
+                break;
+            sType = sType.getBaseType();
         }
     }
 
@@ -2494,13 +2505,24 @@
 
     void printNestedTypeImpls(SchemaType sType, SchemaTypeSystem system) throws IOException
     {
-        SchemaType[] anonTypes = sType.getAnonymousTypes();
-        for (int i = 0; i < anonTypes.length; i++)
+        boolean redefinition = sType.getName() != null &&
+            sType.getName().equals(sType.getBaseType().getName());
+        while (sType != null)
         {
-            if (anonTypes[i].isSkippedAnonymousType())
-                printNestedTypeImpls(anonTypes[i], system);
-            else
-                printInnerTypeImpl(anonTypes[i], system, true);
+            SchemaType[] anonTypes = sType.getAnonymousTypes();
+            for (int i = 0; i < anonTypes.length; i++)
+            {
+                if (anonTypes[i].isSkippedAnonymousType())
+                    printNestedTypeImpls(anonTypes[i], system);
+                else
+                    printInnerTypeImpl(anonTypes[i], system, true);
+            }
+            // For redefinition by extension, go ahead and print the anonymous
+            // types in the base
+            if (!redefinition ||
+                sType.getDerivationType() != SchemaType.DT_EXTENSION)
+                break;
+            sType = sType.getBaseType();
         }
     }
 }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java?view=diff&r1=159091&r2=159092
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java Fri Mar
25 20:26:09 2005
@@ -550,28 +550,6 @@
         _shortJavaName = _fullJavaName.substring(index);
     }
 
-    public void setInterfaceExtensions(InterfaceExtension[] interfaces)
-    {
-        assertResolved();
-        _interfaces = interfaces;
-    }
-
-    public InterfaceExtension[] getInterfaceExtensions()
-    {
-        return _interfaces;
-    }
-
-    public void setPrePostExtension(PrePostExtension prepost)
-    {
-        assertResolved();
-        _prepost = prepost;
-    }
-
-    public PrePostExtension getPrePostExtension()
-    {
-        return _prepost;
-    }
-
     public void setShortJavaImplName(String name)
     {
         assertResolved();
@@ -594,6 +572,28 @@
 
     public String getFullJavaImplName() { return _fullJavaImplName;}
     public String getShortJavaImplName() { return _shortJavaImplName;}
+
+    public void setInterfaceExtensions(InterfaceExtension[] interfaces)
+    {
+        assertResolved();
+        _interfaces = interfaces;
+    }
+
+    public InterfaceExtension[] getInterfaceExtensions()
+    {
+        return _interfaces;
+    }
+
+    public void setPrePostExtension(PrePostExtension prepost)
+    {
+        assertResolved();
+        _prepost = prepost;
+    }
+
+    public PrePostExtension getPrePostExtension()
+    {
+        return _prepost;
+    }
 
     public Object getUserData()
     {   return _userData; }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java?view=diff&r1=159091&r2=159092
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java Fri Mar
25 20:26:09 2005
@@ -68,6 +68,9 @@
             else
                 skipJavaizingType((SchemaTypeImpl)gType);
             allSeenTypes.addAll(Arrays.asList(gType.getAnonymousTypes()));
+            if (((SchemaTypeImpl) gType).isRedefinition() &&
+                gType.getDerivationType() == SchemaType.DT_EXTENSION)
+                addAnonymousTypesFromRedefinition(gType.getBaseType(), allSeenTypes);
         }
     }
 
@@ -275,7 +278,9 @@
         }
 
         // assign java type names to anonymous types
-        assignJavaAnonymousTypeNames(sImpl);
+        // for redefined types, this step was performed when javaizing the redefinition
+        if (sImpl.getFullJavaName() != null)
+            assignJavaAnonymousTypeNames(sImpl);
 
         sImpl.finishJavaizing();
     }
@@ -309,6 +314,23 @@
         SchemaType[] anonymousTypes = outerType.getAnonymousTypes();
         StscState state = StscState.get();
 
+        int nrOfAnonTypes = anonymousTypes.length;
+        if (outerType.isRedefinition() &&
+            outerType.getDerivationType() == SchemaType.DT_EXTENSION)
+        {
+            // We have to add the anonymous types for redefinitions to the list
+            // since they don't have another outer class
+            ArrayList list = new ArrayList();
+            addAnonymousTypesFromRedefinition(outerType.getBaseType(), list);
+            if (list.size() > 0)
+            {
+                SchemaType[] temp = new SchemaType[nrOfAnonTypes + list.size()];
+                list.toArray(temp);
+                System.arraycopy(anonymousTypes, 0, temp, list.size(), nrOfAnonTypes);
+                anonymousTypes = temp;
+            }
+        }
+
         // Because we generate nested java interfaces, and nested
         // interface names must not be the same as an ancestor, use up
         // the ancestors
@@ -365,10 +387,25 @@
                         javaname = "Base"; break;
                 }
             }
-            sImpl.setShortJavaName(
+
+            if (i < nrOfAnonTypes)
+            {
+                sImpl.setShortJavaName(
+                    pickInnerJavaClassName(usedTypeNames, localname, javaname));
+                sImpl.setShortJavaImplName(
+                    pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null
: javaname + "Impl"));
+            }
+            else
+            {
+                // This comes from redefined types, so we have to compute the
+                // full name here
+                sImpl.setFullJavaName(outerType.getFullJavaName() + "$" +
                     pickInnerJavaClassName(usedTypeNames, localname, javaname));
-            sImpl.setShortJavaImplName(
+                sImpl.setFullJavaImplName(outerType.getFullJavaImplName() + "$" +
                     pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null
: javaname + "Impl"));
+            }
+
+            // TODO(radup) why is this inside this loop here?
             setExtensions(sImpl, state);
         }
     }
@@ -829,4 +866,16 @@
         return sElt.getName();
     }
 
+    static void addAnonymousTypesFromRedefinition(SchemaType sType, List result)
+    {
+        while (sType != null)
+        {
+            SchemaType[] newAnonTypes = sType.getAnonymousTypes();
+            if (newAnonTypes.length > 0)
+                result.addAll(Arrays.asList(newAnonTypes));
+            if (sType.getDerivationType() != SchemaType.DT_EXTENSION)
+                break;
+            sType = sType.getBaseType();
+        }
+    }
 }

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java?view=diff&r1=159091&r2=159092
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java Fri Mar 25 20:26:09
2005
@@ -252,7 +252,16 @@
                 javac.setExecutable(forkedExecutable);
                 javac.setFailonerror(failonerror);
                 javac.setFork(fork);
-                if (source != null) javac.setSource(source);
+                if (source != null)
+                {
+                    javac.setSource(source);
+                    javac.setTarget(source);
+                }
+                else
+                {
+                    javac.setSource("1.4");
+                    javac.setTarget("1.4");
+                }
                 javac.setIncludeantruntime(includeAntRuntime);
                 javac.setIncludejavaruntime(includeJavaRuntime);
                 javac.setSrcdir(new Path(project, srcgendir.getAbsolutePath()));



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message