xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r646955 - in /xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java
Date Thu, 10 Apr 2008 20:56:02 GMT
Author: radup
Date: Thu Apr 10 13:56:01 2008
New Revision: 646955

URL: http://svn.apache.org/viewvc?rev=646955&view=rev
Log:
Fix for XMLBEANS-279 and XMLBEANS-360.

Added:
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java
Modified:
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?rev=646955&r1=646954&r2=646955&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
Thu Apr 10 13:56:01 2008
@@ -372,6 +372,9 @@
         }
         else
         {
+            if (sType.getContentType() == SchemaType.SIMPLE_CONTENT && sType.hasStringEnumValues())
+                printStringEnumeration(sType);
+
             SchemaProperty[] props = getDerivedProperties(sType);
 
             for (int i = 0; i < props.length; i++)
@@ -838,8 +841,18 @@
     {
         SchemaType baseEnumType = sType.getBaseEnumType();
         String baseEnumClass = baseEnumType.getFullJavaName();
+        boolean hasBase;
+        if (baseEnumType.isAnonymousType() && baseEnumType.isSkippedAnonymousType())
+        {
+            if (sType.getContentBasedOnType() != null)
+                hasBase = sType.getContentBasedOnType().getBaseType() != baseEnumType;
+            else
+                hasBase = sType.getBaseType() != baseEnumType;
+        }
+        else
+            hasBase = baseEnumType != sType;
 
-        if (baseEnumType == sType)
+        if (!hasBase)
         {
             emit("");
             emit("org.apache.xmlbeans.StringEnumAbstractBase enumValue();");
@@ -861,7 +874,7 @@
             else
                 seenValues.add(enumValue);
             String constName = entries[i].getEnumName();
-            if (baseEnumType != sType)
+            if (hasBase)
                 emit("static final " + baseEnumClass + ".Enum " + constName + " = " + baseEnumClass
+ "." + constName + ";");
             else
                 emit("static final Enum " + constName + " = Enum.forString(\"" + javaStringEscape(enumValue)
+ "\");");
@@ -872,12 +885,12 @@
             if (repeatValues.contains(entries[i].getString()))
                 continue;
             String constName = "INT_" + entries[i].getEnumName();
-            if (baseEnumType != sType)
+            if (hasBase)
                 emit("static final int " + constName + " = " + baseEnumClass + "." + constName
+ ";");
             else
                 emit("static final int " + constName + " = Enum." + constName + ";");
         }
-        if (baseEnumType == sType)
+        if (!hasBase)
         {
             emit("");
             emit("/**");

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java?rev=646955&r1=646954&r2=646955&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java Thu Apr
10 13:56:01 2008
@@ -246,6 +246,8 @@
         SchemaTypeImpl baseType = (SchemaTypeImpl)sImpl.getBaseType();
         if (baseType != null)
             javaizeType(baseType);
+        if (sImpl.getContentBasedOnType() != null && sImpl.getContentBasedOnType()
!= baseType)
+            javaizeType((SchemaTypeImpl) sImpl.getContentBasedOnType());
 
         sImpl.startJavaizing();
 

Added: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java?rev=646955&view=auto
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java (added)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptionsBean.java Thu Apr 10 13:56:01
2008
@@ -0,0 +1,432 @@
+package org.apache.xmlbeans;
+
+import org.xml.sax.XMLReader;
+import org.xml.sax.EntityResolver;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Same as {@link XmlOptions} but adhering to JavaBean conventions
+ */
+public class XmlOptionsBean extends XmlOptions
+{
+    /**
+     * Construct a new blank XmlOptions.
+     */
+    public XmlOptionsBean ( ) { }
+
+    /**
+     * Construct a new XmlOptions, copying the options.
+     * @param other the source <code>XmlOptions</code> object
+     */
+    public XmlOptionsBean (XmlOptions other) {
+        super( other );
+    }
+
+
+    public void setSaveNamespacesFirst(boolean b)
+    {
+        if (b)
+            super.setSaveNamespacesFirst();
+        else
+            remove( SAVE_NAMESPACES_FIRST );
+    }
+
+    public boolean isSaveNamespacesFirst()
+    {
+        return hasOption( SAVE_NAMESPACES_FIRST );
+    }
+
+    public void setSavePrettyPrint(boolean b)
+    {
+        if (b)
+            super.setSavePrettyPrint();
+        else
+            remove( SAVE_PRETTY_PRINT );
+    }
+
+    public boolean isSavePrettyPrint()
+    {
+        return hasOption( SAVE_PRETTY_PRINT );
+    }
+
+    public Integer getSavePrettyPrintIndent()
+    {
+        return (Integer) get( SAVE_PRETTY_PRINT_INDENT );
+    }
+
+    public Integer getSavePrettyPrintOffset()
+    {
+        return (Integer) get( SAVE_PRETTY_PRINT_OFFSET );
+    }
+
+    public String getCharacterEncoding()
+    {
+        return (String) get( CHARACTER_ENCODING );
+    }
+
+    public SchemaType getDocumentType()
+    {
+        return (SchemaType) get ( DOCUMENT_TYPE );
+    }
+
+    public void setSaveAggressiveNamespaces(boolean b)
+    {
+        if (b)
+            super.setSaveAggressiveNamespaces();
+        else
+            remove( SAVE_AGGRESSIVE_NAMESPACES );
+    }
+
+    public boolean isSaveAggressiveNamespaces()
+    {
+        return hasOption( SAVE_AGGRESSIVE_NAMESPACES );
+    }
+
+    public QName getSaveSyntheticDocumentElement()
+    {
+        return (QName) get( SAVE_SYNTHETIC_DOCUMENT_ELEMENT );
+    }
+
+    public void setUseDefaultNamespace(boolean b)
+    {
+        if (b)
+            super.setUseDefaultNamespace();
+        else
+            remove( SAVE_USE_DEFAULT_NAMESPACE );
+    }
+
+    public boolean isUseDefaultNamespace()
+    {
+        return hasOption( SAVE_USE_DEFAULT_NAMESPACE );
+    }
+
+    public Map getSaveImplicitNamespaces()
+    {
+        return (Map) get( SAVE_IMPLICIT_NAMESPACES );
+    }
+
+    public Map getSaveSuggestedPrefixes()
+    {
+        return (Map) get( SAVE_SUGGESTED_PREFIXES );
+    }
+
+    public String getSaveFilterProcinst()
+    {
+        return (String) get( SAVE_FILTER_PROCINST );
+    }
+
+    public XmlOptionCharEscapeMap getSaveSubstituteCharacters()
+    {
+        return (XmlOptionCharEscapeMap) get( SAVE_SUBSTITUTE_CHARACTERS );
+    }
+
+    public void setSaveUseOpenFrag(boolean b)
+    {
+        if (b)
+            super.setSaveUseOpenFrag();
+        else
+            remove( SAVE_USE_OPEN_FRAGMENT );
+    }
+
+    public boolean isSaveUseOpenFrag()
+    {
+        return hasOption( SAVE_USE_OPEN_FRAGMENT );
+    }
+
+    public void setSaveOuter(boolean b)
+    {
+        if (b)
+            super.setSaveOuter();
+        else
+            remove( SAVE_OUTER );
+    }
+
+    public boolean isSaveOuter()
+    {
+        return hasOption( SAVE_OUTER );
+    }
+
+    public void setSaveInner(boolean b)
+    {
+        if (b)
+            super.setSaveInner();
+        else
+            remove( SAVE_INNER );
+    }
+
+    public boolean isSaveInner()
+    {
+        return hasOption( SAVE_INNER );
+    }
+
+    public void setSaveNoXmlDecl(boolean b)
+    {
+        if (b)
+            super.setSaveNoXmlDecl();
+        else
+            remove( SAVE_NO_XML_DECL );
+    }
+
+    public boolean isSaveNoXmlDecl()
+    {
+        return hasOption( SAVE_NO_XML_DECL );
+    }
+
+    public Integer getSaveCDataLengthThreshold()
+    {
+        return (Integer) get( SAVE_CDATA_LENGTH_THRESHOLD );
+    }
+
+    public Integer getSaveCDataEntityCountThreshold()
+    {
+        return (Integer) get( SAVE_CDATA_ENTITY_COUNT_THRESHOLD );
+    }
+
+    public void setSaveSaxNamespacePrefixes(boolean b)
+    {
+        if (b)
+            super.setSaveSaxNamespacePrefixes();
+        else
+            remove( SAVE_SAX_NAMESPACE_PREFIXES );
+    }
+
+    public boolean isSaveSaxNamespacePrefixes()
+    {
+        return hasOption( SAVE_SAX_NAMESPACE_PREFIXES );
+    }
+
+    public QName getLoadReplaceDocumentElement()
+    {
+        return (QName) get( LOAD_REPLACE_DOCUMENT_ELEMENT );
+    }
+
+    public void setLoadStripWhitespace(boolean b)
+    {
+        if (b)
+            super.setLoadStripWhitespace();
+        else
+            remove( LOAD_STRIP_WHITESPACE );
+    }
+
+    public boolean isSetLoadStripWhitespace()
+    {
+        return hasOption( LOAD_STRIP_WHITESPACE );
+    }
+
+    public void setLoadStripComments(boolean b)
+    {
+        if (b)
+            super.setLoadStripComments();
+        else
+            remove( LOAD_STRIP_COMMENTS );
+    }
+
+    public boolean isLoadStripComments()
+    {
+        return hasOption( LOAD_STRIP_COMMENTS );
+    }
+
+    public void setLoadStripProcinsts(boolean b)
+    {
+        if (b)
+            super.setLoadStripProcinsts();
+        else
+            remove( LOAD_STRIP_PROCINSTS );
+    }
+
+    public boolean isLoadStripProcinsts()
+    {
+        return hasOption( LOAD_STRIP_PROCINSTS );
+    }
+
+    public void setLoadLineNumbers(boolean b)
+    {
+        if (b)
+            super.setLoadLineNumbers();
+        else
+            remove( LOAD_LINE_NUMBERS );
+    }
+
+    public boolean isLoadLineNumbers()
+    {
+        return hasOption( LOAD_LINE_NUMBERS );
+    }
+
+    public Map getLoadSubstituteNamespaces()
+    {
+        return (Map) get( LOAD_SUBSTITUTE_NAMESPACES );
+    }
+
+    public void setLoadTrimTextBuffer(boolean b)
+    {
+        if (b)
+            super.setLoadTrimTextBuffer();
+        else
+            remove( LOAD_TRIM_TEXT_BUFFER );
+    }
+
+    public boolean isLoadTrimTextBuffer()
+    {
+        return hasOption( LOAD_TRIM_TEXT_BUFFER );
+    }
+
+    public Map getLoadAdditionalNamespaces()
+    {
+        return (Map) get( LOAD_ADDITIONAL_NAMESPACES );
+    }
+
+    public void setLoadMessageDigest(boolean b)
+    {
+        if (b)
+            super.setLoadMessageDigest();
+        else
+            remove( LOAD_MESSAGE_DIGEST );
+    }
+
+    public boolean isLoadMessageDigest()
+    {
+        return hasOption( LOAD_MESSAGE_DIGEST );
+    }
+
+    public void setLoadUseDefaultResolver(boolean b)
+    {
+        if (b)
+            super.setLoadUseDefaultResolver();
+        else
+            remove( LOAD_USE_DEFAULT_RESOLVER );
+    }
+
+    public boolean isLoadUseDefaultResolver()
+    {
+        return hasOption( LOAD_USE_DEFAULT_RESOLVER );
+    }
+
+    public String getXqueryCurrentNodeVar()
+    {
+        return (String) get( XQUERY_CURRENT_NODE_VAR );
+    }
+
+    public Map getXqueryVariables()
+    {
+        return (Map) get( XQUERY_VARIABLE_MAP );
+    }
+
+    public String getDocumentSourceName()
+    {
+        return (String) get( DOCUMENT_SOURCE_NAME );
+    }
+
+    public Map getCompileSubstituteNames()
+    {
+        return (Map) get( COMPILE_SUBSTITUTE_NAMES );
+    }
+
+    public void setCompileNoUpaRule(boolean b)
+    {
+        if (b)
+            super.setCompileNoUpaRule();
+        else
+            remove( COMPILE_NO_UPA_RULE );
+    }
+
+    public boolean isCompileNoUpaRule()
+    {
+        return hasOption( COMPILE_NO_UPA_RULE );
+    }
+
+    public void setCompileNoPvrRule(boolean b)
+    {
+        if (b)
+            super.setCompileNoPvrRule();
+        else
+            remove( COMPILE_NO_PVR_RULE );
+    }
+
+    public boolean isCompileNoPvrRule()
+    {
+        return hasOption( COMPILE_NO_PVR_RULE );
+    }
+
+    public void setCompileNoAnnotations(boolean b)
+    {
+        if (b)
+            super.setCompileNoAnnotations();
+        else
+            remove( COMPILE_NO_ANNOTATIONS );
+    }
+
+    public boolean isCompileNoAnnotations()
+    {
+        return hasOption( COMPILE_NO_ANNOTATIONS );
+    }
+
+    public void setCompileDownloadUrls(boolean b)
+    {
+        if (b)
+            super.setCompileDownloadUrls();
+        else
+            remove( COMPILE_DOWNLOAD_URLS );
+    }
+
+    public boolean isCompileDownloadUrls()
+    {
+        return hasOption( COMPILE_DOWNLOAD_URLS );
+    }
+
+    public Set getCompileMdefNamespaces()
+    {
+        return (Set) get( COMPILE_MDEF_NAMESPACES );
+    }
+
+    public void setValidateOnSet(boolean b)
+    {
+        if (b)
+            super.setValidateOnSet();
+        else
+            remove( VALIDATE_ON_SET );
+    }
+
+    public boolean isValidateOnSet()
+    {
+        return hasOption( VALIDATE_ON_SET );
+    }
+
+    public void setValidateTreatLaxAsSkip(boolean b)
+    {
+        if (b)
+            super.setValidateTreatLaxAsSkip();
+        else
+            remove( VALIDATE_TREAT_LAX_AS_SKIP );
+    }
+
+    public boolean isValidateTreatLaxAsSkip()
+    {
+        return hasOption( VALIDATE_TREAT_LAX_AS_SKIP );
+    }
+
+    public void setUnsynchronized(boolean b)
+    {
+        if (b)
+            super.setUnsynchronized();
+        else
+            remove( UNSYNCHRONIZED );
+    }
+
+    public boolean isUnsynchronized()
+    {
+        return hasOption( UNSYNCHRONIZED );
+    }
+
+    public EntityResolver getEntityResolver()
+    {
+        return (EntityResolver) get( ENTITY_RESOLVER );
+    }
+
+    public String getGenerateJavaVersion()
+    {
+        return (String) get( GENERATE_JAVA_VERSION );
+    }
+}



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


Mime
View raw message