poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881423 [1/4] - in /xmlbeans/trunk/src/main: java/org/apache/xmlbeans/ java/org/apache/xmlbeans/impl/common/ java/org/apache/xmlbeans/impl/schema/ java/org/apache/xmlbeans/impl/store/ java/org/apache/xmlbeans/impl/xpath/ java/org/apache/xm...
Date Thu, 03 Sep 2020 23:18:23 GMT
Author: kiwiwings
Date: Thu Sep  3 23:18:22 2020
New Revision: 1881423

URL: http://svn.apache.org/viewvc?rev=1881423&view=rev
Log:
remove xpath/xquery delegate constructs
rearrange xpath classes to one package
extract xpath factory methods to separate package
use generics instead of raw containers

Added:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Path.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPath.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Query.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
      - copied, changed from r1881422, xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java
Removed:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPath.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Path.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/PathDelegate.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Query.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/QueryDelegate.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/
Modified:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptions.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Cur.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Cursor.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Public2.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java
    xmlbeans/trunk/src/main/multimodule/java9/module-info.class
    xmlbeans/trunk/src/main/multimodule/java9/module-info.java

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptions.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptions.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptions.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptions.java Thu Sep  3 23:18:22 2020
@@ -150,8 +150,7 @@ public class XmlOptions implements java.
         LOAD_EXTERNAL_DTD,
         SAAJ_IMPL,
         LOAD_USE_LOCALE_CHAR_UTIL,
-        PATH_DELEGATE_INTERFACE,
-        XPATH_USE_DELEGATE,
+        XPATH_USE_SAXON,
         XPATH_USE_XMLBEANS,
         ATTTRIBUTE_VALIDATION_COMPAT_MODE
     }
@@ -1273,7 +1272,7 @@ public class XmlOptions implements java.
     }
 
     public boolean isCopyUseNewSynchronizationDomain() {
-        Boolean flag = (Boolean)get(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN);
+        Boolean flag = (Boolean) get(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN);
         return flag != null && flag;
     }
 
@@ -1365,7 +1364,7 @@ public class XmlOptions implements java.
     }
 
     public Saaj getSaaj() {
-        return (Saaj)get(XmlOptionsKeys.SAAJ_IMPL);
+        return (Saaj) get(XmlOptionsKeys.SAAJ_IMPL);
     }
 
     public XmlOptions setLoadUseLocaleCharUtil(boolean useCharUtil) {
@@ -1377,29 +1376,29 @@ public class XmlOptions implements java.
         return flag != null && flag;
     }
 
-    public XmlOptions setXPathUseDelegate() {
-        return setXPathUseDelegate(true);
+    public XmlOptions setXPathUseSaxon() {
+        return setXPathUseSaxon(true);
     }
 
-    public XmlOptions setXPathUseDelegate(boolean xpathUseDelegate) {
-        return set(XmlOptionsKeys.XPATH_USE_DELEGATE, xpathUseDelegate);
+    public XmlOptions setXPathUseSaxon(boolean xpathUseSaxon) {
+        return set(XmlOptionsKeys.XPATH_USE_SAXON, xpathUseSaxon);
     }
 
-    public boolean isXPathUseDelegate() {
-        Boolean flag = (Boolean)get(XmlOptionsKeys.XPATH_USE_DELEGATE);
+    public boolean isXPathUseSaxon() {
+        Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_SAXON);
         return flag != null && flag;
     }
 
     public XmlOptions setXPathUseXmlBeans() {
-        return setXPathUseDelegate(true);
+        return setXPathUseSaxon(true);
     }
 
-    public XmlOptions setXPathUseXmlBeans(boolean xpathUseDelegate) {
-        return set(XmlOptionsKeys.XPATH_USE_XMLBEANS, xpathUseDelegate);
+    public XmlOptions setXPathUseXmlBeans(boolean xpathUseXmlBeans) {
+        return set(XmlOptionsKeys.XPATH_USE_XMLBEANS, xpathUseXmlBeans);
     }
 
     public boolean isXPathUseXmlBeans() {
-        Boolean flag = (Boolean)get(XmlOptionsKeys.XPATH_USE_XMLBEANS);
+        Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_XMLBEANS);
         return flag != null && flag;
     }
 
@@ -1408,7 +1407,7 @@ public class XmlOptions implements java.
     }
 
     public boolean isAttributeValidationCompatMode() {
-        Boolean flag = (Boolean)get(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE);
+        Boolean flag = (Boolean) get(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE);
         return flag != null && flag;
     }
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java Thu Sep  3 23:18:22 2020
@@ -17,6 +17,8 @@ package org.apache.xmlbeans.impl.common;
 
 import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.ValidatorListener.Event;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.Location;

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java Thu Sep  3 23:18:22 2020
@@ -15,18 +15,14 @@
 
 package org.apache.xmlbeans.impl.schema;
 
-import org.apache.xmlbeans.SchemaIdentityConstraint;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.SchemaAnnotation;
-import org.apache.xmlbeans.SchemaComponent;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.impl.common.XPath;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.xpath.XPath;
+
 import javax.xml.namespace.QName;
-import java.util.Map;
 import java.util.Collections;
+import java.util.Map;
 
-public class SchemaIdentityConstraintImpl implements SchemaIdentityConstraint
-{
+public class SchemaIdentityConstraintImpl implements SchemaIdentityConstraint {
     private SchemaContainer _container;
     private String _selector;
     private String[] _fields;
@@ -49,11 +45,13 @@ public class SchemaIdentityConstraintImp
         _container = c;
     }
 
-    public void setFilename(String filename)
-        { _filename = filename; }
+    public void setFilename(String filename) {
+        _filename = filename;
+    }
 
-    public String getSourceName()
-        { return _filename; }
+    public String getSourceName() {
+        return _filename;
+    }
 
 
     public String getSelector() {
@@ -66,22 +64,19 @@ public class SchemaIdentityConstraintImp
             try {
                 buildPaths();
                 p = _selectorPath;
-            }
-            catch (XPath.XPathCompileException e) {
-                assert false: "Failed to compile xpath. Should be caught by compiler " + e;
+            } catch (XPath.XPathCompileException e) {
+                assert false : "Failed to compile xpath. Should be caught by compiler " + e;
                 return null;
             }
         }
         return p;
     }
 
-    public void setAnnotation(SchemaAnnotation ann)
-    {
+    public void setAnnotation(SchemaAnnotation ann) {
         _annotation = ann;
     }
 
-    public SchemaAnnotation getAnnotation()
-    {
+    public SchemaAnnotation getAnnotation() {
         return _annotation;
     }
 
@@ -115,9 +110,8 @@ public class SchemaIdentityConstraintImp
             try {
                 buildPaths();
                 p = _fieldPaths;
-            }
-            catch (XPath.XPathCompileException e) {
-                assert false: "Failed to compile xpath. Should be caught by compiler " + e;
+            } catch (XPath.XPathCompileException e) {
+                assert false : "Failed to compile xpath. Should be caught by compiler " + e;
                 return null;
             }
         }
@@ -129,8 +123,9 @@ public class SchemaIdentityConstraintImp
         _selectorPath = XPath.compileXPath(_selector, _nsMap);
 
         _fieldPaths = new XPath[_fields.length];
-        for (int i = 0 ; i < _fieldPaths.length ; i++)
+        for (int i = 0; i < _fieldPaths.length; i++) {
             _fieldPaths[i] = XPath.compileXPath(_fields[i], _nsMap);
+        }
     }
 
     public void setReferencedKey(SchemaIdentityConstraint.Ref key) {
@@ -199,15 +194,19 @@ public class SchemaIdentityConstraintImp
 
     private SchemaIdentityConstraint.Ref _selfref = new SchemaIdentityConstraint.Ref(this);
 
-    public SchemaIdentityConstraint.Ref getRef()
-        { return _selfref; }
+    public SchemaIdentityConstraint.Ref getRef() {
+        return _selfref;
+    }
 
-    public SchemaComponent.Ref getComponentRef()
-        { return getRef(); }
+    public SchemaComponent.Ref getComponentRef() {
+        return getRef();
+    }
 
-    public Object getUserData()
-    {   return _userData; }
+    public Object getUserData() {
+        return _userData;
+    }
 
-    public void setUserData(Object data)
-    {   _userData = data; }
+    public void setUserData(Object data) {
+        _userData = data;
+    }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java Thu Sep  3 23:18:22 2020
@@ -19,6 +19,7 @@ import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.store.Locale;
 import org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
 import org.apache.xmlbeans.xml.stream.XMLInputStream;
 import org.apache.xmlbeans.xml.stream.XMLStreamException;
 import org.w3c.dom.DOMImplementation;
@@ -27,8 +28,6 @@ import org.w3c.dom.Node;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -41,39 +40,12 @@ import java.util.List;
 public abstract class SchemaTypeLoaderBase implements SchemaTypeLoader {
     private static final String USER_AGENT = "XMLBeans/" + XmlBeans.getVersion() + " (" + XmlBeans.getTitle() + ")";
 
-    private static final Method _pathCompiler = getMethod("org.apache.xmlbeans.impl.store.Path", "compilePath", new Class[]{String.class, XmlOptions.class});
-    private static final Method _queryCompiler = getMethod("org.apache.xmlbeans.impl.store.Query", "compileQuery", new Class[]{String.class, XmlOptions.class});
-
-    private static Method getMethod(String className, String methodName, Class[] args) {
-        try {
-            return
-                Class.forName(className).
-                    getDeclaredMethod(methodName, args);
-        } catch (Exception e) {
-            throw new IllegalStateException(
-                "Cannot find " + className + "." + methodName +
-                ".  verify that xmlstore " +
-                "(from xbean.jar) is on classpath");
-        }
-    }
-
-    private static Object invokeMethod(Method method, Object[] args) {
-        try {
-            return method.invoke(method, args);
-        } catch (InvocationTargetException e) {
-            Throwable t = e.getCause();
-            throw new IllegalStateException(t.getMessage(), t);
-        } catch (Exception e) {
-            throw new IllegalStateException(e.getMessage(), e);
-        }
-    }
-
     private static String doCompilePath(String pathExpr, XmlOptions options) {
-        return (String) invokeMethod(_pathCompiler, new Object[]{pathExpr, options});
+        return XPathFactory.compilePath(pathExpr, options);
     }
 
     private static String doCompileQuery(String queryExpr, XmlOptions options) {
-        return (String) invokeMethod(_queryCompiler, new Object[]{queryExpr, options});
+        return XPathFactory.compileQuery(queryExpr, options);
     }
 
     public SchemaType findType(QName name) {

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java Thu Sep  3 23:18:22 2020
@@ -15,30 +15,14 @@
 
 package org.apache.xmlbeans.impl.schema;
 
+import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.NameUtil;
-import org.apache.xmlbeans.QNameSetBuilder;
-import org.apache.xmlbeans.SchemaField;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaProperty;
-import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.UserType;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.SchemaStringEnumEntry;
-import org.apache.xmlbeans.XmlByte;
-import org.apache.xmlbeans.XmlShort;
-import org.apache.xmlbeans.InterfaceExtension;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.PrePostExtension;
-import org.apache.xmlbeans.BindingConfig;
-
-import java.util.*;
-import java.math.BigInteger;
 
 import javax.xml.namespace.QName;
+import java.math.BigInteger;
+import java.util.*;
 
-public class StscJavaizer
-{
+public class StscJavaizer {
 
     /**
      * XMLBEANS-307
@@ -46,35 +30,35 @@ public class StscJavaizer
      * xmlbeans scomp will fail with a code too large error
      */
     private static final int MAX_ENUM_COUNT = 3668;
+
     /**
      * Does a topo walk of all the types to resolve them.
      */
-    public static void javaizeAllTypes(boolean javaize)
-    {
+    public static void javaizeAllTypes(boolean javaize) {
         StscState state = StscState.get();
 
-        List allSeenTypes = new ArrayList();
+        List<SchemaType> allSeenTypes = new ArrayList<>();
         allSeenTypes.addAll(Arrays.asList(state.documentTypes()));
         allSeenTypes.addAll(Arrays.asList(state.attributeTypes()));
         allSeenTypes.addAll(Arrays.asList(state.globalTypes()));
 
         // First distribute the global names among the top entities.
-        if (javaize)
+        if (javaize) {
             assignGlobalJavaNames(allSeenTypes);
+        }
 
         // now fully javaize everything deeply.
-        for (int i = 0; i < allSeenTypes.size(); i++)
-        {
-            SchemaType gType = (SchemaType)allSeenTypes.get(i);
-            if (javaize)
-            {
-                javaizeType((SchemaTypeImpl)gType);
+        for (int i = 0; i < allSeenTypes.size(); i++) {
+            SchemaType gType = allSeenTypes.get(i);
+            if (javaize) {
+                javaizeType((SchemaTypeImpl) gType);
                 String className = gType.getFullJavaName();
-                if (className != null)
+                if (className != null) {
                     state.addClassname(className.replace('$', '.'), gType);
+                }
+            } else {
+                skipJavaizingType((SchemaTypeImpl) gType);
             }
-            else
-                skipJavaizingType((SchemaTypeImpl)gType);
             allSeenTypes.addAll(Arrays.asList(gType.getAnonymousTypes()));
             // We need to javaize the anonymous types defined inside redefined types
             // since redefined type do not get a Java class of their own.
@@ -84,19 +68,16 @@ public class StscJavaizer
         }
     }
 
-    static void assignGlobalJavaNames(Collection schemaTypes)
-    {
-        HashSet usedNames = new HashSet();
+    static void assignGlobalJavaNames(Collection<SchemaType> schemaTypes) {
+        HashSet<String> usedNames = new HashSet<>();
         StscState state = StscState.get();
 
-        for (Iterator i = schemaTypes.iterator(); i.hasNext(); )
-        {
-            SchemaTypeImpl sImpl = (SchemaTypeImpl)i.next();
+        for (SchemaType schemaType : schemaTypes) {
+            SchemaTypeImpl sImpl = (SchemaTypeImpl) schemaType;
             QName topName = findTopName(sImpl);
             String pickedName = state.getJavaname(topName, sImpl.isDocumentType() ?
                 BindingConfig.QNAME_DOCUMENT_TYPE : BindingConfig.QNAME_TYPE);
-            if (sImpl.isUnjavaized())
-            {
+            if (sImpl.isUnjavaized()) {
                 sImpl.setFullJavaName(pickFullJavaClassName(usedNames, findTopName(sImpl), pickedName, sImpl.isDocumentType(), sImpl.isAttributeType()));
                 sImpl.setFullJavaImplName(pickFullJavaImplName(usedNames, sImpl.getFullJavaName()));
 
@@ -109,84 +90,77 @@ public class StscJavaizer
         verifyInterfaceNameCollisions(usedNames, state);
     }
 
-    private static void verifyInterfaceNameCollisions(Set usedNames, StscState state)
-    {
+    private static void verifyInterfaceNameCollisions(Set<String> usedNames, StscState state) {
         BindingConfig config = state.getBindingConfig();
-        if (config == null)
+        if (config == null) {
             return;
+        }
 
         InterfaceExtension[] exts = config.getInterfaceExtensions();
-        for (int i = 0; i < exts.length; i++)
-        {
-            if (usedNames.contains(exts[i].getInterface().toLowerCase()))
-                state.error("InterfaceExtension interface '" + exts[i].getInterface() + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+        for (InterfaceExtension ext : exts) {
+            if (usedNames.contains(ext.getInterface().toLowerCase())) {
+                state.error("InterfaceExtension interface '" + ext.getInterface() + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+            }
 
-            String handler = exts[i].getStaticHandler();
-            if (handler != null && usedNames.contains(handler.toLowerCase()))
+            String handler = ext.getStaticHandler();
+            if (handler != null && usedNames.contains(handler.toLowerCase())) {
                 state.error("InterfaceExtension handler class '" + handler + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+            }
         }
 
         PrePostExtension[] prepost = config.getPrePostExtensions();
-        for (int i = 0; i < prepost.length; i++)
-        {
-            String handler = prepost[i].getStaticHandler();
-            if (handler != null && usedNames.contains(handler.toLowerCase()))
+        for (PrePostExtension prePostExtension : prepost) {
+            String handler = prePostExtension.getStaticHandler();
+            if (handler != null && usedNames.contains(handler.toLowerCase())) {
                 state.error("PrePostExtension handler class '" + handler + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+            }
         }
     }
 
-    private static void setUserTypes(SchemaTypeImpl sImpl, StscState state)
-    {
+    private static void setUserTypes(SchemaTypeImpl sImpl, StscState state) {
         BindingConfig config = state.getBindingConfig();
 
-        if (config != null)
-        {
+        if (config != null) {
             UserType utype = config.lookupUserTypeForQName(sImpl.getName());
-            if (utype != null)
-            {
+            if (utype != null) {
                 sImpl.setUserTypeName(utype.getJavaName());
                 sImpl.setUserTypeHandlerName(utype.getStaticHandler());
             }
         }
     }
 
-    private static void setExtensions(SchemaTypeImpl sImpl, StscState state)
-    {
+    private static void setExtensions(SchemaTypeImpl sImpl, StscState state) {
         String javaName = sImpl.getFullJavaName();
         BindingConfig config = state.getBindingConfig();
 
-        if (javaName != null && config != null)
-        {
+        if (javaName != null && config != null) {
             sImpl.setInterfaceExtensions(config.getInterfaceExtensions(javaName));
             sImpl.setPrePostExtension(config.getPrePostExtension(javaName));
         }
     }
 
-    private static boolean isStringType(SchemaType type)
-    {
-        if (type == null || type.getSimpleVariety() != SchemaType.ATOMIC)
+    private static boolean isStringType(SchemaType type) {
+        if (type == null || type.getSimpleVariety() != SchemaType.ATOMIC) {
             return false;
+        }
         return (type.getPrimitiveType().getBuiltinTypeCode() == SchemaType.BTC_STRING);
     }
 
-    static String pickConstantName(Set usedNames, String words)
-    {
+    static String pickConstantName(Set<String> usedNames, String words) {
         String base = NameUtil.upperCaseUnderbar(words);
 
-        if (base.length() == 0)
-        {
+        if (base.length() == 0) {
             base = "X";
         }
 
-        if (base.startsWith("INT_")) // reserved for int codes
-        {
+        if (base.startsWith("INT_")) {
+            // reserved for int codes
             base = "X_" + base;
         }
 
         String uniqName;
         int index = 1;
-        for (uniqName = base; usedNames.contains(uniqName); )
-        {
+        for (uniqName = base; usedNames.contains(uniqName); ) {
             index++;
             uniqName = base + "_" + index;
         }
@@ -196,77 +170,73 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static void skipJavaizingType(SchemaTypeImpl sImpl)
-    {
-        if (sImpl.isJavaized())
+    static void skipJavaizingType(SchemaTypeImpl sImpl) {
+        if (sImpl.isJavaized()) {
             return;
-        
-        SchemaTypeImpl baseType = (SchemaTypeImpl)sImpl.getBaseType();
-        if (baseType != null)
+        }
+
+        SchemaTypeImpl baseType = (SchemaTypeImpl) sImpl.getBaseType();
+        if (baseType != null) {
             skipJavaizingType(baseType);
-        
+        }
+
         sImpl.startJavaizing();
         secondPassProcessType(sImpl);
         sImpl.finishJavaizing();
     }
 
-    static void secondPassProcessType(SchemaTypeImpl sImpl)
-    {
-        if (isStringType(sImpl))
-        {
-            XmlAnySimpleType[] enumVals = sImpl.getEnumerationValues();
-
-            // if this is an enumerated string type, values are to be
-            // javaized as constants.
-            if (enumVals != null)
-            {
-                //ERROR is found at > 3668
-                if (enumVals.length > MAX_ENUM_COUNT)
-                {
-                    StscState.get().warning("SchemaType Enumeration found with too many enumeration values " +
-                        "to create a Java enumeration. The base SchemaType \"" +
-                        sImpl.getBaseEnumType() + "\" will be used instead", XmlError.SEVERITY_WARNING, null);
-
-                    sImpl = (SchemaTypeImpl) sImpl.getBaseEnumType();
-                }
-                else
-                {
-                    SchemaStringEnumEntry[] entryArray = new SchemaStringEnumEntry[enumVals.length];
-                    SchemaType basedOn = sImpl.getBaseEnumType();
-                    if (basedOn == sImpl)
-                    {
-                        Set usedNames = new HashSet();
-                        for (int i = 0; i < enumVals.length; i++)
-                        {
-                            String val = enumVals[i].getStringValue();
+    static void secondPassProcessType(SchemaTypeImpl sImpl) {
+        if (!isStringType(sImpl)) {
+            return;
+        }
 
-                            entryArray[i] = new SchemaStringEnumEntryImpl(val, i + 1, pickConstantName(usedNames, val));
-                        }
-                    }
-                    else
-                    {
-                        for (int i = 0; i < enumVals.length; i++)
-                        {
-                            String val = enumVals[i].getStringValue();
-                            entryArray[i] = basedOn.enumEntryForString(val);
-                        }
-                    }
-                    sImpl.setStringEnumEntries(entryArray);
-                }
+        XmlAnySimpleType[] enumVals = sImpl.getEnumerationValues();
+
+        // if this is an enumerated string type, values are to be
+        // javaized as constants.
+        if (enumVals == null) {
+            return;
+        }
+
+        // ERROR is found at > 3668
+        if (enumVals.length > MAX_ENUM_COUNT) {
+            StscState.get().warning("SchemaType Enumeration found with too many enumeration values to create a Java " +
+                                    "enumeration. The base SchemaType \"" + sImpl.getBaseEnumType() + "\" will be used instead", XmlError.SEVERITY_WARNING, null);
+            return;
+        }
+        SchemaType basedOn = sImpl.getBaseEnumType();
+        if (basedOn == null) {
+            return;
+        }
+
+        SchemaStringEnumEntry[] entryArray = new SchemaStringEnumEntry[enumVals.length];
+        if (basedOn == sImpl) {
+            Set<String> usedNames = new HashSet<>();
+            for (int i = 0; i < enumVals.length; i++) {
+                String val = enumVals[i].getStringValue();
+                entryArray[i] = new SchemaStringEnumEntryImpl(val, i + 1, pickConstantName(usedNames, val));
+            }
+        } else {
+            for (int i = 0; i < enumVals.length; i++) {
+                String val = enumVals[i].getStringValue();
+                entryArray[i] = basedOn.enumEntryForString(val);
             }
         }
+        sImpl.setStringEnumEntries(entryArray);
     }
 
-    static void javaizeType(SchemaTypeImpl sImpl)
-    {
-        if (sImpl.isJavaized())
+    static void javaizeType(SchemaTypeImpl sImpl) {
+        if (sImpl.isJavaized()) {
             return;
+        }
 
-        SchemaTypeImpl baseType = (SchemaTypeImpl)sImpl.getBaseType();
-        if (baseType != null)
+        SchemaTypeImpl baseType = (SchemaTypeImpl) sImpl.getBaseType();
+        if (baseType != null) {
             javaizeType(baseType);
-        if (sImpl.getContentBasedOnType() != null && sImpl.getContentBasedOnType() != baseType)
+        }
+        if (sImpl.getContentBasedOnType() != null && sImpl.getContentBasedOnType() != baseType) {
             javaizeType((SchemaTypeImpl) sImpl.getContentBasedOnType());
+        }
 
         sImpl.startJavaizing();
 
@@ -274,21 +244,19 @@ public class StscJavaizer
 
         secondPassProcessType(sImpl);
 
-        if (!sImpl.isSimpleType())
-        {
+        if (!sImpl.isSimpleType()) {
             SchemaProperty[] eltProps = sImpl.getElementProperties();
             SchemaProperty[] attrProps = sImpl.getAttributeProperties();
 
             // Handing out java names - this permits us to avoid collisions.
-            Set usedPropNames = new HashSet();
+            Set<String> usedPropNames = new HashSet<>();
 
             // First, copy all used property names from base, since these
             // cannnot be changed at this point and they may be arbitrary
             // because of derivation by restriction and the "nopvr" switch
             SchemaProperty[] baseProps = baseType.getProperties();
-            for (int i = 0; i < baseProps.length; i++)
-            {
-                String name = baseProps[i].getJavaPropertyName();
+            for (SchemaProperty baseProp : baseProps) {
+                String name = baseProp.getJavaPropertyName();
                 assert !usedPropNames.contains(name);
                 usedPropNames.add(name);
             }
@@ -297,15 +265,16 @@ public class StscJavaizer
             avoidExtensionMethods(usedPropNames, sImpl);
 
             // Assign names in two passes: first inherited names, then others.
-            for (boolean doInherited = true; ; doInherited = false)
-            {
-                if (eltProps.length > 0)
+            for (boolean doInherited = true; ; doInherited = false) {
+                if (eltProps.length > 0) {
                     assignJavaPropertyNames(usedPropNames, eltProps, baseType, doInherited);
+                }
 
                 assignJavaPropertyNames(usedPropNames, attrProps, baseType, doInherited);
 
-                if (doInherited == false)
+                if (!doInherited) {
                     break;
+                }
             }
 
             SchemaProperty[] allprops = sImpl.getProperties();
@@ -322,50 +291,45 @@ public class StscJavaizer
 
         // assign java type names to anonymous types
         // for redefined types, this step was performed when javaizing the redefinition
-        if (sImpl.getFullJavaName() != null || sImpl.getOuterType() != null)
+        if (sImpl.getFullJavaName() != null || sImpl.getOuterType() != null) {
             assignJavaAnonymousTypeNames(sImpl);
+        }
 
         sImpl.finishJavaizing();
     }
 
     private static final String[] PREFIXES = new String[]{"get", "xget", "isNil", "isSet", "sizeOf", "set",
-                "xset", "addNew", "setNil", "unset", "insert", "add", "insertNew", "addNew", "remove"};
+        "xset", "addNew", "setNil", "unset", "insert", "add", "insertNew", "addNew", "remove"};
 
-    private static void avoidExtensionMethods(Set usedPropNames, SchemaTypeImpl sImpl)
-    {
+    private static void avoidExtensionMethods(Set<String> usedPropNames, SchemaTypeImpl sImpl) {
         InterfaceExtension[] exts = sImpl.getInterfaceExtensions();
-        if (exts != null) for (int i = 0; i < exts.length; i++)
-        {
-            InterfaceExtension ext = exts[i];
-            InterfaceExtension.MethodSignature[] methods = ext.getMethods();
-            for (int j = 0; j < methods.length; j++)
-            {
-                String methodName = methods[j].getName();
-                for (int k = 0; k < PREFIXES.length; k++)
-                {
-                    String prefix = PREFIXES[k];
-                    if (methodName.startsWith(prefix))
-                        usedPropNames.add(methodName.substring(prefix.length()));
+        if (exts != null) {
+            for (InterfaceExtension ext : exts) {
+                InterfaceExtension.MethodSignature[] methods = ext.getMethods();
+                for (InterfaceExtension.MethodSignature method : methods) {
+                    String methodName = method.getName();
+                    for (String prefix : PREFIXES) {
+                        if (methodName.startsWith(prefix)) {
+                            usedPropNames.add(methodName.substring(prefix.length()));
+                        }
+                    }
                 }
             }
         }
     }
 
-    static void assignJavaAnonymousTypeNames(SchemaTypeImpl outerType)
-    {
-        Set usedTypeNames = new HashSet();
+    static void assignJavaAnonymousTypeNames(SchemaTypeImpl outerType) {
+        Set<String> usedTypeNames = new HashSet<>();
         SchemaType[] anonymousTypes = outerType.getAnonymousTypes();
         StscState state = StscState.get();
 
         int nrOfAnonTypes = anonymousTypes.length;
-        if (outerType.isRedefinition())
-        {
+        if (outerType.isRedefinition()) {
             // We have to add the anonymous types for redefinitions to the list
             // since they don't have another outer class
-            ArrayList list = new ArrayList();
+            ArrayList<SchemaType> list = new ArrayList<>();
             addAnonymousTypesFromRedefinition(outerType, list);
-            if (list.size() > 0)
-            {
+            if (list.size() > 0) {
                 SchemaType[] temp = new SchemaType[nrOfAnonTypes + list.size()];
                 list.toArray(temp);
                 System.arraycopy(anonymousTypes, 0, temp, list.size(), nrOfAnonTypes);
@@ -377,18 +341,16 @@ public class StscJavaizer
         // interface names must not be the same as an ancestor, use up
         // the ancestors
 
-        for ( SchemaType scanOuterType = outerType ;
-              scanOuterType != null ;
-              scanOuterType = scanOuterType.getOuterType() )
-        {
-            usedTypeNames.add( scanOuterType.getShortJavaName() );
+        for (SchemaType scanOuterType = outerType;
+             scanOuterType != null;
+             scanOuterType = scanOuterType.getOuterType()) {
+            usedTypeNames.add(scanOuterType.getShortJavaName());
         }
 
-        for ( SchemaType scanOuterType = outerType ;
-              scanOuterType != null ;
-              scanOuterType = scanOuterType.getOuterType() )
-        {
-            usedTypeNames.add( scanOuterType.getShortJavaImplName() );
+        for (SchemaType scanOuterType = outerType;
+             scanOuterType != null;
+             scanOuterType = scanOuterType.getOuterType()) {
+            usedTypeNames.add(scanOuterType.getShortJavaImplName());
         }
 
         // and because things are problematic if an inner type name
@@ -397,54 +359,52 @@ public class StscJavaizer
         usedTypeNames.add(getOutermostPackage(outerType.getFullJavaName()));
 
         // assign names
-        for (int i = 0; i < anonymousTypes.length; i++)
-        {
-            SchemaTypeImpl sImpl = (SchemaTypeImpl)anonymousTypes[i];
+        for (int i = 0; i < anonymousTypes.length; i++) {
+            SchemaTypeImpl sImpl = (SchemaTypeImpl) anonymousTypes[i];
             if (sImpl == null) // already handled in first pass
+            {
                 continue;
-            if (sImpl.isSkippedAnonymousType())
+            }
+            if (sImpl.isSkippedAnonymousType()) {
                 continue;
+            }
             String localname = null;
-            String javaname = null;
+            String javaname;
 
             SchemaField containerField = sImpl.getContainerField();
-            if (containerField != null)
-            {
+            if (containerField != null) {
                 QName qname = sImpl.getContainerField().getName();
                 localname = qname.getLocalPart();
                 javaname = state.getJavaname(sImpl.getContainerField().getName(), BindingConfig.QNAME_TYPE);
-            }
-            else
-            {
+            } else {
                 // not defined inside an Elt or Attr: must be a nested simple type
-                switch (sImpl.getOuterType().getSimpleVariety())
-                {
+                switch (sImpl.getOuterType().getSimpleVariety()) {
                     case SchemaType.UNION:
-                        javaname = "Member"; break;
+                        javaname = "Member";
+                        break;
                     case SchemaType.LIST:
-                        javaname = "Item"; break;
+                        javaname = "Item";
+                        break;
                     case SchemaType.ATOMIC:
                     default:
-                        assert(false) : "Weird type " + sImpl.toString();
-                        javaname = "Base"; break;
+                        assert (false) : "Weird type " + sImpl.toString();
+                        javaname = "Base";
+                        break;
                 }
             }
 
-            if (i < nrOfAnonTypes)
-            {
+            if (i < nrOfAnonTypes) {
                 sImpl.setShortJavaName(
                     pickInnerJavaClassName(usedTypeNames, localname, javaname));
                 sImpl.setShortJavaImplName(
                     pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
-            }
-            else
-            {
+            } else {
                 // This comes from redefined types, so we have to compute the
                 // full name here
                 sImpl.setFullJavaName(outerType.getFullJavaName() + "$" +
-                    pickInnerJavaClassName(usedTypeNames, localname, javaname));
+                                      pickInnerJavaClassName(usedTypeNames, localname, javaname));
                 sImpl.setFullJavaImplName(outerType.getFullJavaImplName() + "$" +
-                    pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
+                                          pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
             }
 
             // TODO(radup) why is this inside this loop here?
@@ -452,62 +412,58 @@ public class StscJavaizer
         }
     }
 
-    static void assignJavaPropertyNames(Set usedNames, SchemaProperty[] props, SchemaType baseType, boolean doInherited)
-    {
+    static void assignJavaPropertyNames(Set<String> usedNames, SchemaProperty[] props, SchemaType baseType, boolean doInherited) {
         StscState state = StscState.get();
 
         // two passes: first deal with inherited properties, then with new ones.
         // this ensures that we match up with base class definitions cleanly
         // BUGBUG(radup) We have to look for particles that have been removed
         // in the derivation tree for this type using derivation by restriction,
-        // because they have not been removed in Java and may collide with 
+        // because they have not been removed in Java and may collide with
         // this type's properties.
 
-        for (int i = 0; i < props.length; i++)
-        {
-            SchemaPropertyImpl sImpl = (SchemaPropertyImpl)props[i];
+        for (SchemaProperty prop : props) {
+            SchemaPropertyImpl sImpl = (SchemaPropertyImpl) prop;
 
             SchemaProperty baseProp =
-               (sImpl.isAttribute() ?
+                (sImpl.isAttribute() ?
                     baseType.getAttributeProperty(sImpl.getName()) :
                     baseType.getElementProperty(sImpl.getName()));
 
-            if ((baseProp != null) != doInherited)
+            if ((baseProp == null) == doInherited) {
                 continue;
+            }
 
             QName propQName = sImpl.getName();
 
             String theName;
 
-            if (baseProp == null)
+            if (baseProp == null) {
                 theName = pickJavaPropertyName(usedNames, propQName.getLocalPart(),
                     state.getJavaname(propQName, sImpl.isAttribute() ? BindingConfig.QNAME_ACCESSOR_ATTRIBUTE :
-                    BindingConfig.QNAME_ACCESSOR_ELEMENT));
-            else
+                        BindingConfig.QNAME_ACCESSOR_ELEMENT));
+            } else {
                 theName = baseProp.getJavaPropertyName();
+            }
 
             sImpl.setJavaPropertyName(theName);
 
             boolean isArray = (sImpl.getMaxOccurs() == null ||
-                sImpl.getMaxOccurs().compareTo(BigInteger.ONE) > 0);
+                               sImpl.getMaxOccurs().compareTo(BigInteger.ONE) > 0);
             boolean isSingleton = !isArray && (sImpl.getMaxOccurs().signum() > 0);
             boolean isOption = isSingleton && (sImpl.getMinOccurs().signum() == 0);
             SchemaType javaBasedOnType = sImpl.getType();
 
-            if (baseProp != null)
-            {
-                if (baseProp.extendsJavaArray())
-                {
+            if (baseProp != null) {
+                if (baseProp.extendsJavaArray()) {
                     isSingleton = false;
                     isOption = false;
                     isArray = true;
                 }
-                if (baseProp.extendsJavaSingleton())
-                {
+                if (baseProp.extendsJavaSingleton()) {
                     isSingleton = true;
                 }
-                if (baseProp.extendsJavaOption())
-                {
+                if (baseProp.extendsJavaOption()) {
                     isOption = true;
                 }
                 javaBasedOnType = baseProp.javaBasedOnType();
@@ -518,59 +474,60 @@ public class StscJavaizer
 
     }
 
-    static void assignJavaTypeCodes(SchemaProperty[] properties)
-    {
-        for (int i = 0; i < properties.length; i++)
-        {
-            SchemaPropertyImpl sImpl = (SchemaPropertyImpl)properties[i];
+    static void assignJavaTypeCodes(SchemaProperty[] properties) {
+        for (SchemaProperty property : properties) {
+            SchemaPropertyImpl sImpl = (SchemaPropertyImpl) property;
             SchemaType sType = sImpl.javaBasedOnType();
             sImpl.setJavaTypeCode(javaTypeCodeForType(sType));
         }
     }
 
-    static int javaTypeCodeInCommon(SchemaType[] types)
-    {
-        if (types == null || types.length == 0)
+    static int javaTypeCodeInCommon(SchemaType[] types) {
+        if (types == null || types.length == 0) {
             return SchemaProperty.XML_OBJECT;
+        }
 
         int code = javaTypeCodeForType(types[0]);
-        if (code == SchemaProperty.JAVA_OBJECT)
+        if (code == SchemaProperty.JAVA_OBJECT) {
             return code;
-        for (int i = 1; i < types.length; i++)
-        {
+        }
+        for (int i = 1; i < types.length; i++) {
             // if any two are different, the answer is java.lang.Object
-            if (code != javaTypeCodeForType(types[i]))
+            if (code != javaTypeCodeForType(types[i])) {
                 return SchemaProperty.JAVA_OBJECT;
+            }
         }
         return code;
     }
 
-    static int javaTypeCodeForType(SchemaType sType)
-    {
-        if (!sType.isSimpleType())
+    static int javaTypeCodeForType(SchemaType sType) {
+        if (!sType.isSimpleType()) {
             return SchemaProperty.XML_OBJECT;
+        }
 
-        if (((SchemaTypeImpl)sType).getUserTypeHandlerName() != null)
+        if (((SchemaTypeImpl) sType).getUserTypeHandlerName() != null) {
             return SchemaProperty.JAVA_USER;
+        }
 
-        if (sType.getSimpleVariety() == SchemaType.UNION)
-        {
+        if (sType.getSimpleVariety() == SchemaType.UNION) {
             // see if we can find an interesting common base type, e.g., for string enums
             SchemaType baseType = sType.getUnionCommonBaseType();
-            if (baseType != null && !baseType.isURType())
+            if (baseType != null && !baseType.isURType()) {
                 sType = baseType;
-            else
+            } else {
                 return javaTypeCodeInCommon(sType.getUnionConstituentTypes());
+            }
         }
 
-        if (sType.getSimpleVariety() == SchemaType.LIST)
+        if (sType.getSimpleVariety() == SchemaType.LIST) {
             return SchemaProperty.JAVA_LIST;
+        }
 
-        if (sType.isURType())
+        if (sType.isURType()) {
             return SchemaProperty.XML_OBJECT;
+        }
 
-        switch (sType.getPrimitiveType().getBuiltinTypeCode())
-        {
+        switch (sType.getPrimitiveType().getBuiltinTypeCode()) {
             case SchemaType.BTC_ANY_SIMPLE:
                 // return SchemaProperty.XML_OBJECT;
                 return SchemaProperty.JAVA_STRING;
@@ -600,8 +557,7 @@ public class StscJavaizer
                 return SchemaProperty.JAVA_DOUBLE;
 
             case SchemaType.BTC_DECIMAL:
-                switch (sType.getDecimalSize())
-                {
+                switch (sType.getDecimalSize()) {
                     case SchemaType.SIZE_BYTE:
                         return SchemaProperty.JAVA_BYTE;
                     case SchemaType.SIZE_SHORT:
@@ -618,20 +574,16 @@ public class StscJavaizer
                 }
 
             case SchemaType.BTC_STRING:
-                if (isStringType(sType.getBaseEnumType()))
-		{
+                if (isStringType(sType.getBaseEnumType())) {
                     // This is necessary for local types, etc.
                     // schema enums with > ~3668 cause a Java Src file to be created
                     // that cannot be compiled due to JVM restrictions
                     // FIXFIX: http://issues.apache.org/jira/browse/XMLBEANS-307
                     // FIXFIX: XMLBeans scomp throws error "code too large"
                     if (sType.getEnumerationValues() != null &&
-                            sType.getEnumerationValues().length > MAX_ENUM_COUNT) 
-                    {
+                        sType.getEnumerationValues().length > MAX_ENUM_COUNT) {
                         return SchemaProperty.JAVA_STRING;
-                    }
-                    else
-                    {
+                    } else {
                         return SchemaProperty.JAVA_ENUM;
                     }
                 }
@@ -654,40 +606,37 @@ public class StscJavaizer
                 return SchemaProperty.JAVA_CALENDAR;
 
             default:
-                assert(false) : "unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode();
+                assert (false) : "unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode();
                 throw new IllegalStateException("unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode() + " of " + sType.getPrimitiveType().getName());
         }
     }
 
-    static boolean isPropertyModelOrderInsensitive(SchemaProperty[] properties)
-    {
-        for (int i = 0; i < properties.length; i++)
-        {
-            SchemaProperty prop = properties[i];
-            if (prop.hasNillable() == SchemaProperty.VARIABLE)
+    static boolean isPropertyModelOrderInsensitive(SchemaProperty[] properties) {
+        for (SchemaProperty prop : properties) {
+            if (prop.hasNillable() == SchemaProperty.VARIABLE) {
                 return false;
-            if (prop.hasDefault() == SchemaProperty.VARIABLE)
+            }
+            if (prop.hasDefault() == SchemaProperty.VARIABLE) {
                 return false;
-            if (prop.hasFixed() == SchemaProperty.VARIABLE)
+            }
+            if (prop.hasFixed() == SchemaProperty.VARIABLE) {
                 return false;
+            }
             if (prop.hasDefault() != SchemaProperty.NEVER &&
-                prop.getDefaultText() == null)
+                prop.getDefaultText() == null) {
                 return false;
+            }
         }
         return true;
     }
 
-    static boolean protectReservedGlobalClassNames(String name)
-    {
+    static boolean protectReservedGlobalClassNames(String name) {
         int i = name.lastIndexOf('.');
         String lastSegment = name.substring(i + 1);
-        if (lastSegment.endsWith("Document") && !lastSegment.equals("Document"))
-            return true;
-        return false;
+        return lastSegment.endsWith("Document") && !lastSegment.equals("Document");
     }
 
-    static boolean protectReservedInnerClassNames(String name)
-    {
+    static boolean protectReservedInnerClassNames(String name) {
         return (name.equals("Enum") || name.equals("Factory"));
     }
 
@@ -713,27 +662,22 @@ public class StscJavaizer
         "ObjectValue",
         "Class",
     };
-    static Set PROTECTED_PROPERTIES_SET = new HashSet(Arrays.asList(PROTECTED_PROPERTIES));
+    static Set<String> PROTECTED_PROPERTIES_SET = new HashSet<>(Arrays.asList(PROTECTED_PROPERTIES));
 
-    static boolean protectReservedPropertyNames(String name)
-    {
+    static boolean protectReservedPropertyNames(String name) {
         return PROTECTED_PROPERTIES_SET.contains(name) ||
-            (name.endsWith("Array") && !name.equals("Array"));
+               (name.endsWith("Array") && !name.equals("Array"));
     }
 
-    static String pickFullJavaClassName(Set usedNames, QName qName, String configname, boolean isDocument, boolean isAttrType)
-    {
+    static String pickFullJavaClassName(Set<String> usedNames, QName qName, String configname, boolean isDocument, boolean isAttrType) {
         String base;
         boolean protect;
 
-        if (configname != null && configname.indexOf('.') >= 0)
-        {
+        if (configname != null && configname.indexOf('.') >= 0) {
             // a configname with dots defines the fully qualified java class name
             base = configname;
             protect = protectReservedGlobalClassNames(base);
-        }
-        else
-        {
+        } else {
             StscState state = StscState.get();
             String uri = qName.getNamespaceURI();
 
@@ -745,8 +689,7 @@ public class StscJavaizer
 
             String pkgPrefix = state.getPackageOverride(uri);
 
-            if (pkgPrefix != null)
-            {
+            if (pkgPrefix != null) {
                 // Form the new qualified class name from the new package name
                 // and the old class name
                 base = pkgPrefix + "." + base.substring(base.lastIndexOf('.') + 1);
@@ -754,28 +697,29 @@ public class StscJavaizer
 
             // See if there is a prefix...
             String javaPrefix = state.getJavaPrefix(uri);
-            if (javaPrefix != null)
+            if (javaPrefix != null) {
                 base = base.substring(0, base.lastIndexOf('.') + 1) + javaPrefix + base.substring(base.lastIndexOf('.') + 1);
+            }
 
             // a configname without dots may override the shortname part.
-            if (configname != null)
-            {
+            if (configname != null) {
                 base = base.substring(0, base.lastIndexOf('.') + 1) + configname;
             }
 
             protect = protectReservedGlobalClassNames(base);
-            if (configname == null)
-            {
+            if (configname == null) {
                 // add special suffix
-                if (isDocument)
+                if (isDocument) {
                     base = base + "Document";
-                else if (isAttrType)
+                } else if (isAttrType) {
                     base = base + "Attribute";
+                }
 
                 // add configured suffix
                 String javaSuffix = state.getJavaSuffix(uri);
-                if (javaSuffix != null)
+                if (javaSuffix != null) {
                     base = base + javaSuffix;
+                }
             }
         }
 
@@ -783,12 +727,12 @@ public class StscJavaizer
 
         int index = 1;
         String uniqName;
-        if (protect)
+        if (protect) {
             uniqName = base + index;
-        else
+        } else {
             uniqName = base;
-        while (usedNames.contains(uniqName.toLowerCase()) || uniqName.equals(outermostPkg))
-        {
+        }
+        while (usedNames.contains(uniqName.toLowerCase()) || uniqName.equals(outermostPkg)) {
             index++;
             uniqName = base + index;
         }
@@ -798,28 +742,27 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static String getOutermostPackage(String fqcn)
-    {
-        if (fqcn == null)
+    static String getOutermostPackage(String fqcn) {
+        if (fqcn == null) {
             return "";
+        }
 
         // remove class name
         int lastdot = fqcn.indexOf('.');
-        if (lastdot < 0)
+        if (lastdot < 0) {
             return "";
+        }
 
         // remove outer package names
         return fqcn.substring(0, lastdot);
     }
 
-    static String pickFullJavaImplName(Set usedNames, String intfName)
-    {
+    static String pickFullJavaImplName(Set<String> usedNames, String intfName) {
         // Strip off the package from the class name so we can replace it
         String className = intfName;
         String pkgName = null;
         int index = intfName.lastIndexOf('.');
-        if (index >= 0)
-        {
+        if (index >= 0) {
             className = intfName.substring(index + 1);
             pkgName = intfName.substring(0, index);
         }
@@ -830,8 +773,7 @@ public class StscJavaizer
 
         index = 1;
         String uniqName = base;
-        while (usedNames.contains(uniqName.toLowerCase()))
-        {
+        while (usedNames.contains(uniqName.toLowerCase())) {
             index++;
             uniqName = base + index;
         }
@@ -841,19 +783,19 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static String pickJavaPropertyName(Set usedNames, String localName, String javaName)
-    {
-        if (javaName == null)
+    static String pickJavaPropertyName(Set<String> usedNames, String localName, String javaName) {
+        if (javaName == null) {
             javaName = NameUtil.upperCamelCase(localName);
+        }
         boolean protect = protectReservedPropertyNames(javaName);
         String uniqName;
         int index = 1;
-        if (protect)
+        if (protect) {
             uniqName = javaName + index;
-        else
+        } else {
             uniqName = javaName;
-        while (usedNames.contains(uniqName))
-        {
+        }
+        while (usedNames.contains(uniqName)) {
             index++;
             uniqName = javaName + index;
         }
@@ -863,19 +805,19 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static String pickInnerJavaClassName(Set usedNames, String localName, String javaName)
-    {
-        if (javaName == null)
+    static String pickInnerJavaClassName(Set<String> usedNames, String localName, String javaName) {
+        if (javaName == null) {
             javaName = NameUtil.upperCamelCase(localName);
+        }
         boolean protect = protectReservedInnerClassNames(javaName);
         String uniqName;
         int index = 1;
-        if (protect)
+        if (protect) {
             uniqName = javaName + index;
-        else
+        } else {
             uniqName = javaName;
-        while (usedNames.contains(uniqName))
-        {
+        }
+        while (usedNames.contains(uniqName)) {
             index++;
             uniqName = javaName + index;
         }
@@ -885,14 +827,13 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static String pickInnerJavaImplName(Set usedNames, String localName, String javaName)
-    {
-        if (javaName == null)
+    static String pickInnerJavaImplName(Set<String> usedNames, String localName, String javaName) {
+        if (javaName == null) {
             javaName = NameUtil.upperCamelCase(localName) + "Impl";
+        }
         String uniqName = javaName;
         int index = 1;
-        while (usedNames.contains(uniqName))
-        {
+        while (usedNames.contains(uniqName)) {
             index++;
             uniqName = javaName + index;
         }
@@ -902,42 +843,41 @@ public class StscJavaizer
         return uniqName;
     }
 
-    static QName findTopName(SchemaType sType)
-    {
-        if (sType.getName() != null)
+    static QName findTopName(SchemaType sType) {
+        if (sType.getName() != null) {
             return sType.getName();
+        }
 
-        if (sType.isDocumentType())
-        {
+        if (sType.isDocumentType()) {
             // A document type must have a content model consisting of a single elt
-            if (sType.getContentModel() == null || sType.getContentModel().getParticleType() != SchemaParticle.ELEMENT)
+            if (sType.getContentModel() == null || sType.getContentModel().getParticleType() != SchemaParticle.ELEMENT) {
                 throw new IllegalStateException();
+            }
             return (sType.getDocumentElementName());
         }
 
-        if (sType.isAttributeType())
-        {
-            if (sType.getAttributeModel() == null || sType.getAttributeModel().getAttributes().length != 1)
+        if (sType.isAttributeType()) {
+            if (sType.getAttributeModel() == null || sType.getAttributeModel().getAttributes().length != 1) {
                 throw new IllegalStateException();
+            }
             return sType.getAttributeTypeAttributeName();
         }
 
         SchemaField sElt = sType.getContainerField();
-        assert(sElt != null);
-        assert(sType.getOuterType() == null);
+        assert (sElt != null);
+        assert (sType.getOuterType() == null);
         return sElt.getName();
     }
 
-    static void addAnonymousTypesFromRedefinition(SchemaType sType, List result)
-    {
-        while (((SchemaTypeImpl)sType).isRedefinition() &&
-                (sType.getDerivationType() == SchemaType.DT_EXTENSION ||
-                        sType.isSimpleType()))
-        {
+    static void addAnonymousTypesFromRedefinition(SchemaType sType, List<SchemaType> result) {
+        while (((SchemaTypeImpl) sType).isRedefinition() &&
+               (sType.getDerivationType() == SchemaType.DT_EXTENSION ||
+                sType.isSimpleType())) {
             sType = sType.getBaseType();
             SchemaType[] newAnonTypes = sType.getAnonymousTypes();
-            if (newAnonTypes.length > 0)
+            if (newAnonTypes.length > 0) {
                 result.addAll(Arrays.asList(newAnonTypes));
+            }
         }
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java Thu Sep  3 23:18:22 2020
@@ -18,7 +18,6 @@ package org.apache.xmlbeans.impl.schema;
 import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.XMLChar;
-import org.apache.xmlbeans.impl.common.XPath;
 import org.apache.xmlbeans.impl.schema.StscImporter.SchemaToProcess;
 import org.apache.xmlbeans.impl.values.NamespaceContext;
 import org.apache.xmlbeans.impl.values.XmlNonNegativeIntegerImpl;
@@ -27,6 +26,7 @@ import org.apache.xmlbeans.impl.values.X
 import org.apache.xmlbeans.impl.xb.xsdschema.*;
 import org.apache.xmlbeans.impl.xb.xsdschema.RedefineDocument.Redefine;
 import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument.Schema;
+import org.apache.xmlbeans.impl.xpath.XPath;
 import org.apache.xmlbeans.soap.SOAPArrayType;
 
 import javax.xml.namespace.QName;



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


Mime
View raw message