You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2020/08/28 20:49:50 UTC

svn commit: r1881284 [10/18] - in /xmlbeans/trunk/src: main/java/org/apache/xmlbeans/ main/java/org/apache/xmlbeans/impl/common/ main/java/org/apache/xmlbeans/impl/schema/ main/java/org/apache/xmlbeans/impl/store/ main/java/org/apache/xmlbeans/impl/too...

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/Locale.java Fri Aug 28 20:49:50 2020
@@ -44,8 +44,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 public final class Locale
-    implements DOMImplementation, SaajCallback, XmlLocale
-{
+    implements DOMImplementation, SaajCallback, XmlLocale {
     private static final XBLogger logger = XBLogFactory.getLogger(Locale.class);
 
     static final int ROOT = Cur.ROOT;
@@ -75,8 +74,7 @@ public final class Locale
         "frag");
     static final QName _xmlFragment = new QName("xml-fragment");
 
-    private Locale(SchemaTypeLoader stl, XmlOptions options)
-    {
+    private Locale(SchemaTypeLoader stl, XmlOptions options) {
         options = XmlOptions.maskNull(options);
 
         //
@@ -88,7 +86,7 @@ public final class Locale
         // Also - have a thread local setting for thread safety?  .. Perhaps something
         // in the type loader which defines whether ot not sync is on????
 
-        _noSync = options.hasOption(XmlOptions.UNSYNCHRONIZED);
+        _noSync = options.isUnsynchronized();
 
         _tempFrames = new Cur[_numTempFramesLeft = 8];
 
@@ -105,7 +103,7 @@ public final class Locale
 
         _schemaTypeLoader = stl;
 
-        _validateOnSet = options.hasOption(XmlOptions.VALIDATE_ON_SET);
+        _validateOnSet = options.isValidateOnSet();
 
         //
         // Check for Saaj implementation request
@@ -113,11 +111,11 @@ public final class Locale
 
         Object saajObj = options.get(Saaj.SAAJ_IMPL);
 
-        if (saajObj != null)
-        {
-            if (!(saajObj instanceof Saaj))
+        if (saajObj != null) {
+            if (!(saajObj instanceof Saaj)) {
                 throw new IllegalStateException(
                     "Saaj impl not correct type: " + saajObj);
+            }
 
             _saaj = (Saaj) saajObj;
 
@@ -133,49 +131,52 @@ public final class Locale
     /**
      * This option is checked in XmlObjectBase._copy(XmlOptions), the locale is used as the synchronization domain.
      * useNewLocale = true: copy will use a new locale, false: copy will use the same locale as the source
-     * @deprecated Replace usages with CopyUseNewSynchronizationDomain option
+     *
      * @see org.apache.xmlbeans.XmlOptions#setCopyUseNewSynchronizationDomain(boolean)
+     * @deprecated Replace usages with CopyUseNewSynchronizationDomain option
      */
-    public static final String COPY_USE_NEW_LOCALE             = "COPY_USE_NEW_LOCALE";
+    public static final String COPY_USE_NEW_LOCALE = "COPY_USE_NEW_LOCALE";
 
-    static Locale getLocale(SchemaTypeLoader stl, XmlOptions options)
-    {
-        if (stl == null)
+    static Locale getLocale(SchemaTypeLoader stl, XmlOptions options) {
+        if (stl == null) {
             stl = XmlBeans.getContextTypeLoader();
+        }
 
         options = XmlOptions.maskNull(options);
 
         Locale l = null;
 
-        if (options.hasOption(USE_SAME_LOCALE))
-        {
+        if (options.hasOption(USE_SAME_LOCALE)) {
             Object source = options.get(USE_SAME_LOCALE);
 
-            if (source instanceof Locale)
+            if (source instanceof Locale) {
                 l = (Locale) source;
-            else if (source instanceof XmlTokenSource)
+            } else if (source instanceof XmlTokenSource) {
                 l = (Locale) ((XmlTokenSource) source).monitor();
-            else
+            } else {
                 throw new IllegalArgumentException(
                     "Source locale not understood: " + source);
+            }
 
-            if (l._schemaTypeLoader != stl)
+            if (l._schemaTypeLoader != stl) {
                 throw new IllegalArgumentException(
                     "Source locale does not support same schema type loader");
+            }
 
-            if (l._saaj != null && l._saaj != options.get(Saaj.SAAJ_IMPL))
+            if (l._saaj != null && l._saaj != options.get(Saaj.SAAJ_IMPL)) {
                 throw new IllegalArgumentException(
                     "Source locale does not support same saaj");
+            }
 
-            if (l._validateOnSet &&
-                !options.hasOption(XmlOptions.VALIDATE_ON_SET))
+            if (l._validateOnSet && !options.isValidateOnSet()) {
                 throw new IllegalArgumentException(
                     "Source locale does not support same validate on set");
+            }
 
             // TODO - other things to check?
-        }
-        else
+        } else {
             l = new Locale(stl, options);
+        }
 
         return l;
     }
@@ -184,13 +185,12 @@ public final class Locale
     //
     //
 
-    static void associateSourceName(Cur c, XmlOptions options)
-    {
-        String sourceName = (String) XmlOptions.safeGet(options,
-            XmlOptions.DOCUMENT_SOURCE_NAME);
+    static void associateSourceName(Cur c, XmlOptions options) {
+        String sourceName = options == null ? null : options.getDocumentSourceName();
 
-        if (sourceName != null)
+        if (sourceName != null) {
             getDocProps(c, true).setSourceName(sourceName);
+        }
     }
 
     //
@@ -198,20 +198,17 @@ public final class Locale
     //
 
     static void autoTypeDocument(Cur c, SchemaType requestedType,
-        XmlOptions options)
-        throws XmlException
-    {
+                                 XmlOptions options)
+        throws XmlException {
         assert c.isRoot();
 
         // The type in the options overrides all sniffing
 
         options = XmlOptions.maskNull(options);
 
-        SchemaType optionType = (SchemaType) options.get(
-            XmlOptions.DOCUMENT_TYPE);
+        SchemaType optionType = options.getDocumentType();
 
-        if (optionType != null)
-        {
+        if (optionType != null) {
             c.setType(optionType);
             return;
         }
@@ -221,24 +218,23 @@ public final class Locale
         // An xsi:type can be used to pick a type out of the loader, or used to refine
         // a type with a name.
 
-        if (requestedType == null || requestedType.getName() != null)
-        {
+        if (requestedType == null || requestedType.getName() != null) {
             QName xsiTypeName = c.getXsiTypeName();
 
             SchemaType xsiSchemaType =
                 xsiTypeName == null ?
-                null : c._locale._schemaTypeLoader.findType(xsiTypeName);
+                    null : c._locale._schemaTypeLoader.findType(xsiTypeName);
 
             if (requestedType == null ||
-                requestedType.isAssignableFrom(xsiSchemaType))
+                requestedType.isAssignableFrom(xsiSchemaType)) {
                 type = xsiSchemaType;
+            }
         }
 
         // Look for a document element to establish type
 
         if (type == null &&
-            (requestedType == null || requestedType.isDocumentType()))
-        {
+            (requestedType == null || requestedType.isDocumentType())) {
             assert c.isRoot();
 
             c.push();
@@ -246,86 +242,85 @@ public final class Locale
             QName docElemName =
                 !c.hasAttrs() && Locale.toFirstChildElement(c) &&
                 !Locale.toNextSiblingElement(c)
-                ? c.getName() : null;
+                    ? c.getName() : null;
 
             c.pop();
 
-            if (docElemName != null)
-            {
+            if (docElemName != null) {
                 type =
                     c._locale._schemaTypeLoader.findDocumentType(docElemName);
 
-                if (type != null && requestedType != null)
-                {
+                if (type != null && requestedType != null) {
                     QName requesteddocElemNameName = requestedType.getDocumentElementName();
 
                     if (!requesteddocElemNameName.equals(docElemName) &&
-                        !requestedType.isValidSubstitution(docElemName))
-                    {
+                        !requestedType.isValidSubstitution(docElemName)) {
                         throw
                             new XmlException("Element " +
-                            QNameHelper.pretty(docElemName) +
-                            " is not a valid " +
-                            QNameHelper.pretty(requesteddocElemNameName) +
-                            " document or a valid substitution.");
+                                             QNameHelper.pretty(docElemName) +
+                                             " is not a valid " +
+                                             QNameHelper.pretty(requesteddocElemNameName) +
+                                             " document or a valid substitution.");
                     }
                 }
             }
         }
 
-        if (type == null && requestedType == null)
-        {
+        if (type == null && requestedType == null) {
             c.push();
 
             type =
                 Locale.toFirstNormalAttr(c) && !Locale.toNextNormalAttr(c)
-                ?
-                c._locale._schemaTypeLoader.findAttributeType(c.getName()) :
-                null;
+                    ?
+                    c._locale._schemaTypeLoader.findAttributeType(c.getName()) :
+                    null;
 
             c.pop();
         }
 
-        if (type == null)
+        if (type == null) {
             type = requestedType;
+        }
 
-        if (type == null)
+        if (type == null) {
             type = XmlBeans.NO_TYPE;
+        }
 
         c.setType(type);
 
-        if (requestedType != null)
-        {
-            if (type.isDocumentType())
+        if (requestedType != null) {
+            if (type.isDocumentType()) {
                 verifyDocumentType(c, type.getDocumentElementName());
-            else if (type.isAttributeType())
+            } else if (type.isAttributeType()) {
                 verifyAttributeType(c, type.getAttributeTypeAttributeName());
+            }
         }
     }
 
-    private static boolean namespacesSame(QName n1, QName n2)
-    {
-        if (n1 == n2)
+    private static boolean namespacesSame(QName n1, QName n2) {
+        if (n1 == n2) {
             return true;
+        }
 
-        if (n1 == null || n2 == null)
+        if (n1 == null || n2 == null) {
             return false;
+        }
 
-        if (n1.getNamespaceURI() == n2.getNamespaceURI())
+        if (n1.getNamespaceURI() == n2.getNamespaceURI()) {
             return true;
+        }
 
-        if (n1.getNamespaceURI() == null || n2.getNamespaceURI() == null)
+        if (n1.getNamespaceURI() == null || n2.getNamespaceURI() == null) {
             return false;
+        }
 
         return n1.getNamespaceURI().equals(n2.getNamespaceURI());
     }
 
-    private static void addNamespace(StringBuffer sb, QName name)
-    {
-        if (name.getNamespaceURI() == null)
+    private static void addNamespace(StringBuffer sb, QName name) {
+        if (name.getNamespaceURI() == null) {
             sb.append("<no namespace>");
-        else
-        {
+        } else {
             sb.append("\"");
             sb.append(name.getNamespaceURI());
             sb.append("\"");
@@ -333,54 +328,43 @@ public final class Locale
     }
 
     private static void verifyDocumentType(Cur c, QName docElemName)
-        throws XmlException
-    {
+        throws XmlException {
         assert c.isRoot();
 
         c.push();
 
-        try
-        {
+        try {
             StringBuffer sb = null;
 
             if (!Locale.toFirstChildElement(c) ||
-                Locale.toNextSiblingElement(c))
-            {
+                Locale.toNextSiblingElement(c)) {
                 sb = new StringBuffer();
 
                 sb.append("The document is not a ");
                 sb.append(QNameHelper.pretty(docElemName));
                 sb.append(
                     c.isRoot() ?
-                    ": no document element" : ": multiple document elements");
-            }
-            else
-            {
+                        ": no document element" : ": multiple document elements");
+            } else {
                 QName name = c.getName();
 
-                if (!name.equals(docElemName))
-                {
+                if (!name.equals(docElemName)) {
                     sb = new StringBuffer();
 
                     sb.append("The document is not a ");
                     sb.append(QNameHelper.pretty(docElemName));
 
-                    if (docElemName.getLocalPart().equals(name.getLocalPart()))
-                    {
+                    if (docElemName.getLocalPart().equals(name.getLocalPart())) {
                         sb.append(": document element namespace mismatch ");
                         sb.append("expected ");
                         addNamespace(sb, docElemName);
                         sb.append(" got ");
                         addNamespace(sb, name);
-                    }
-                    else if (namespacesSame(docElemName, name))
-                    {
+                    } else if (namespacesSame(docElemName, name)) {
                         sb.append(": document element local name mismatch ");
                         sb.append("expected " + docElemName.getLocalPart());
                         sb.append(" got " + name.getLocalPart());
-                    }
-                    else
-                    {
+                    } else {
                         sb.append(": document element mismatch ");
                         sb.append("got ");
                         sb.append(QNameHelper.pretty(name));
@@ -388,66 +372,52 @@ public final class Locale
                 }
             }
 
-            if (sb != null)
-            {
+            if (sb != null) {
                 XmlError err = XmlError.forCursor(sb.toString(),
                     new Cursor(c));
                 throw new XmlException(err.toString(), null, err);
             }
-        }
-        finally
-        {
+        } finally {
             c.pop();
         }
     }
 
     private static void verifyAttributeType(Cur c, QName attrName)
-        throws XmlException
-    {
+        throws XmlException {
         assert c.isRoot();
 
         c.push();
 
-        try
-        {
+        try {
             StringBuffer sb = null;
 
-            if (!Locale.toFirstNormalAttr(c) || Locale.toNextNormalAttr(c))
-            {
+            if (!Locale.toFirstNormalAttr(c) || Locale.toNextNormalAttr(c)) {
                 sb = new StringBuffer();
 
                 sb.append("The document is not a ");
                 sb.append(QNameHelper.pretty(attrName));
                 sb.append(
                     c.isRoot() ? ": no attributes" : ": multiple attributes");
-            }
-            else
-            {
+            } else {
                 QName name = c.getName();
 
-                if (!name.equals(attrName))
-                {
+                if (!name.equals(attrName)) {
                     sb = new StringBuffer();
 
                     sb.append("The document is not a ");
                     sb.append(QNameHelper.pretty(attrName));
 
-                    if (attrName.getLocalPart().equals(name.getLocalPart()))
-                    {
+                    if (attrName.getLocalPart().equals(name.getLocalPart())) {
                         sb.append(": attribute namespace mismatch ");
                         sb.append("expected ");
                         addNamespace(sb, attrName);
                         sb.append(" got ");
                         addNamespace(sb, name);
-                    }
-                    else if (namespacesSame(attrName, name))
-                    {
+                    } else if (namespacesSame(attrName, name)) {
                         sb.append(": attribute local name mismatch ");
                         sb.append("expected " + attrName.getLocalPart());
                         sb.append(" got " + name.getLocalPart());
-                    }
-                    else
-                    {
+                    } else {
                         sb.append(": attribute element mismatch ");
                         sb.append("got ");
                         sb.append(QNameHelper.pretty(name));
@@ -455,27 +425,22 @@ public final class Locale
                 }
             }
 
-            if (sb != null)
-            {
+            if (sb != null) {
                 XmlError err = XmlError.forCursor(sb.toString(),
                     new Cursor(c));
                 throw new XmlException(err.toString(), null, err);
             }
-        }
-        finally
-        {
+        } finally {
             c.pop();
         }
     }
 
-    static boolean isFragmentQName(QName name)
-    {
+    static boolean isFragmentQName(QName name) {
         return name.equals(Locale._openuriFragment) ||
-            name.equals(Locale._xmlFragment);
+               name.equals(Locale._xmlFragment);
     }
 
-    static boolean isFragment(Cur start, Cur end)
-    {
+    static boolean isFragment(Cur start, Cur end) {
         assert !end.isAttr();
 
         start.push();
@@ -484,21 +449,19 @@ public final class Locale
         int numDocElems = 0;
         boolean isFrag = false;
 
-        while (!start.isSamePos(end))
-        {
+        while (!start.isSamePos(end)) {
             int k = start.kind();
 
-            if (k == ATTR)
+            if (k == ATTR) {
                 break;
+            }
 
-            if (k == TEXT && !isWhiteSpace(start.getCharsAsString()))
-            {
+            if (k == TEXT && !isWhiteSpace(start.getCharsAsString())) {
                 isFrag = true;
                 break;
             }
 
-            if (k == ELEM && ++numDocElems > 1)
-            {
+            if (k == ELEM && ++numDocElems > 1) {
                 isFrag = true;
                 break;
             }
@@ -507,8 +470,9 @@ public final class Locale
 
             assert k != ATTR;
 
-            if (k != TEXT)
+            if (k != TEXT) {
                 start.toEnd();
+            }
 
             start.next();
         }
@@ -524,52 +488,44 @@ public final class Locale
     //
 
     public static XmlObject newInstance(SchemaTypeLoader stl, SchemaType type,
-        XmlOptions options)
-    {
+                                        XmlOptions options) {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.newInstance(type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.newInstance(type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
-    private XmlObject newInstance(SchemaType type, XmlOptions options)
-    {
+    private XmlObject newInstance(SchemaType type, XmlOptions options) {
         options = XmlOptions.maskNull(options);
 
         Cur c = tempCur();
 
 
-        SchemaType sType = (SchemaType) options.get(XmlOptions.DOCUMENT_TYPE);
+        SchemaType sType = options.getDocumentType();
 
-        if (sType == null)
+        if (sType == null) {
             sType = type == null ? XmlObject.type : type;
-        if (sType.isDocumentType())
+        }
+        if (sType.isDocumentType()) {
             c.createDomDocumentRoot();
-        else
-             c.createRoot();
+        } else {
+            c.createRoot();
+        }
         c.setType(sType);
 
         XmlObject x = (XmlObject) c.getUser();
@@ -584,8 +540,7 @@ public final class Locale
     //
 
     public static DOMImplementation newDomImplementation(SchemaTypeLoader stl,
-        XmlOptions options)
-    {
+                                                         XmlOptions options) {
         return (DOMImplementation) getLocale(stl, options);
     }
 
@@ -594,42 +549,32 @@ public final class Locale
     //
 
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
-        String xmlText, SchemaType type, XmlOptions options)
-        throws XmlException
-    {
+                                             String xmlText, SchemaType type, XmlOptions options)
+        throws XmlException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(xmlText, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(xmlText, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     private XmlObject parseToXmlObject(String xmlText, SchemaType type,
-        XmlOptions options)
-        throws XmlException
-    {
+                                       XmlOptions options)
+        throws XmlException {
         Cur c = parse(xmlText, type, options);
 
         XmlObject x = (XmlObject) c.getUser();
@@ -640,33 +585,24 @@ public final class Locale
     }
 
     Cur parse(String s, SchemaType type, XmlOptions options)
-        throws XmlException
-    {
+        throws XmlException {
         Reader r = new StringReader(s);
 
-        try
-        {
+        try {
             Cur c = getSaxLoader(options).load(this, new InputSource(r),
                 options);
 
             autoTypeDocument(c, type, options);
 
             return c;
-        }
-        catch (IOException e)
-        {
-            assert false: "StringReader should not throw IOException";
+        } catch (IOException e) {
+            assert false : "StringReader should not throw IOException";
 
             throw new XmlException(e.getMessage(), e);
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 r.close();
-            }
-            catch (IOException e)
-            {
+            } catch (IOException e) {
             }
         }
     }
@@ -679,53 +615,40 @@ public final class Locale
      * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
      */
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
-        XMLInputStream xis, SchemaType type, XmlOptions options)
-        throws XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException
-    {
+                                             XMLInputStream xis, SchemaType type, XmlOptions options)
+        throws XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(xis, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(xis, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     /**
      * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
      */
     public XmlObject parseToXmlObject(XMLInputStream xis, SchemaType type,
-        XmlOptions options)
-        throws XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException
-    {
+                                      XmlOptions options)
+        throws XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
         Cur c;
 
-        try
-        {
+        try {
             c = loadXMLInputStream(xis, options);
-        }
-        catch (org.apache.xmlbeans.xml.stream.XMLStreamException e)
-        {
+        } catch (org.apache.xmlbeans.xml.stream.XMLStreamException e) {
             throw new XmlException(e.getMessage(), e);
         }
 
@@ -743,50 +666,37 @@ public final class Locale
     //
 
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
-        XMLStreamReader xsr, SchemaType type, XmlOptions options)
-        throws XmlException
-    {
+                                             XMLStreamReader xsr, SchemaType type, XmlOptions options)
+        throws XmlException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(xsr, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(xsr, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     public XmlObject parseToXmlObject(XMLStreamReader xsr, SchemaType type,
-        XmlOptions options)
-        throws XmlException
-    {
+                                      XmlOptions options)
+        throws XmlException {
         Cur c;
 
-        try
-        {
+        try {
             c = loadXMLStreamReader(xsr, options);
-        }
-        catch (XMLStreamException e)
-        {
+        } catch (XMLStreamException e) {
             throw new XmlException(e.getMessage(), e);
         }
 
@@ -799,31 +709,27 @@ public final class Locale
         return x;
     }
 
-    private static void lineNumber(XMLEvent xe, LoadContext context)
-    {
+    private static void lineNumber(XMLEvent xe, LoadContext context) {
         org.apache.xmlbeans.xml.stream.Location loc = xe.getLocation();
 
-        if (loc != null)
+        if (loc != null) {
             context.lineNumber(loc.getLineNumber(), loc.getColumnNumber(), -1);
+        }
     }
 
-    private static void lineNumber(XMLStreamReader xsr, LoadContext context)
-    {
+    private static void lineNumber(XMLStreamReader xsr, LoadContext context) {
         javax.xml.stream.Location loc = xsr.getLocation();
 
-        if (loc != null)
-        {
+        if (loc != null) {
             context.lineNumber(loc.getLineNumber(), loc.getColumnNumber(),
                 loc.getCharacterOffset());
         }
     }
 
-    private void doAttributes(XMLStreamReader xsr, LoadContext context)
-    {
+    private void doAttributes(XMLStreamReader xsr, LoadContext context) {
         int n = xsr.getAttributeCount();
 
-        for (int a = 0; a < n; a++)
-        {
+        for (int a = 0; a < n; a++) {
             context.attr(xsr.getAttributeLocalName(a),
                 xsr.getAttributeNamespace(a),
                 xsr.getAttributePrefix(a),
@@ -831,20 +737,19 @@ public final class Locale
         }
     }
 
-    private void doNamespaces(XMLStreamReader xsr, LoadContext context)
-    {
+    private void doNamespaces(XMLStreamReader xsr, LoadContext context) {
         int n = xsr.getNamespaceCount();
 
-        for (int a = 0; a < n; a++)
-        {
+        for (int a = 0; a < n; a++) {
             String prefix = xsr.getNamespacePrefix(a);
 
-            if (prefix == null || prefix.length() == 0)
+            if (prefix == null || prefix.length() == 0) {
                 context.attr("xmlns", _xmlnsUri, null,
                     xsr.getNamespaceURI(a));
-            else
+            } else {
                 context.attr(prefix, _xmlnsUri, "xmlns",
                     xsr.getNamespaceURI(a));
+            }
         }
 
     }
@@ -853,27 +758,23 @@ public final class Locale
      * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
      */
     private Cur loadXMLInputStream(XMLInputStream xis, XmlOptions options)
-        throws org.apache.xmlbeans.xml.stream.XMLStreamException
-    {
+        throws org.apache.xmlbeans.xml.stream.XMLStreamException {
         options = XmlOptions.maskNull(options);
 
-        boolean lineNums = options.hasOption(XmlOptions.LOAD_LINE_NUMBERS);
+        boolean lineNums = options.isLoadLineNumbers();
 
         XMLEvent x = xis.peek();
 
-        if (x != null && x.getType() == XMLEvent.START_ELEMENT)
-        {
-            Map nsMap = ((StartElement) x).getNamespaceMap();
-
-            if (nsMap != null && nsMap.size() > 0)
-            {
-                Map namespaces = new HashMap();
+        if (x != null && x.getType() == XMLEvent.START_ELEMENT) {
+            Map<String, String> nsMap = ((StartElement) x).getNamespaceMap();
+
+            if (nsMap != null && nsMap.size() > 0) {
 
-                namespaces.putAll(nsMap);
+                Map<String, String> namespaces = new HashMap<>(nsMap);
 
                 options = new XmlOptions(options);
 
-                options.put(XmlOptions.LOAD_ADDITIONAL_NAMESPACES, namespaces);
+                options.setLoadAdditionalNamespaces(namespaces);
             }
         }
 
@@ -885,128 +786,132 @@ public final class Locale
         LoadContext context = new Cur.CurLoadContext(this, options);
 
         events:
-        for (XMLEvent xe = xis.next(); xe != null; xe = xis.next())
-        {
-            switch (xe.getType())
-            {
-            case XMLEvent.START_DOCUMENT:
-                StartDocument doc = (StartDocument) xe;
-
-                systemId = doc.getSystemId();
-                encoding = doc.getCharacterEncodingScheme();
-                version = doc.getVersion();
-                standAlone = doc.isStandalone();
-                standAlone = doc.isStandalone();
+        for (XMLEvent xe = xis.next(); xe != null; xe = xis.next()) {
+            switch (xe.getType()) {
+                case XMLEvent.START_DOCUMENT:
+                    StartDocument doc = (StartDocument) xe;
+
+                    systemId = doc.getSystemId();
+                    encoding = doc.getCharacterEncodingScheme();
+                    version = doc.getVersion();
+                    standAlone = doc.isStandalone();
+                    standAlone = doc.isStandalone();
 
-                if (lineNums)
-                    lineNumber(xe, context);
-
-                break;
+                    if (lineNums) {
+                        lineNumber(xe, context);
+                    }
 
-            case XMLEvent.END_DOCUMENT:
-                if (lineNums)
-                    lineNumber(xe, context);
+                    break;
 
-                break events;
+                case XMLEvent.END_DOCUMENT:
+                    if (lineNums) {
+                        lineNumber(xe, context);
+                    }
 
-            case XMLEvent.NULL_ELEMENT:
-                if (!xis.hasNext())
                     break events;
-                break;
 
-            case XMLEvent.START_ELEMENT:
-                context.startElement(XMLNameHelper.getQName(xe.getName()));
+                case XMLEvent.NULL_ELEMENT:
+                    if (!xis.hasNext()) {
+                        break events;
+                    }
+                    break;
 
-                if (lineNums)
-                    lineNumber(xe, context);
+                case XMLEvent.START_ELEMENT:
+                    context.startElement(XMLNameHelper.getQName(xe.getName()));
 
-                for (AttributeIterator ai = ((StartElement) xe).getAttributes();
-                     ai.hasNext();)
-                {
-                    Attribute attr = ai.next();
+                    if (lineNums) {
+                        lineNumber(xe, context);
+                    }
 
-                    context.attr(XMLNameHelper.getQName(attr.getName()),
-                        attr.getValue());
-                }
+                    for (AttributeIterator ai = ((StartElement) xe).getAttributes();
+                         ai.hasNext(); ) {
+                        Attribute attr = ai.next();
 
-                for (AttributeIterator ai = ((StartElement) xe).getNamespaces()
-                    ; ai.hasNext();)
-                {
-                    Attribute attr = ai.next();
+                        context.attr(XMLNameHelper.getQName(attr.getName()),
+                            attr.getValue());
+                    }
 
-                    XMLName name = attr.getName();
-                    String local = name.getLocalName();
+                    for (AttributeIterator ai = ((StartElement) xe).getNamespaces()
+                         ; ai.hasNext(); ) {
+                        Attribute attr = ai.next();
 
-                    if (name.getPrefix() == null && local.equals("xmlns"))
-                        local = "";
+                        XMLName name = attr.getName();
+                        String local = name.getLocalName();
 
-                    context.xmlns(local, attr.getValue());
-                }
+                        if (name.getPrefix() == null && local.equals("xmlns")) {
+                            local = "";
+                        }
 
-                break;
+                        context.xmlns(local, attr.getValue());
+                    }
 
-            case XMLEvent.END_ELEMENT:
-                context.endElement();
+                    break;
 
-                if (lineNums)
-                    lineNumber(xe, context);
+                case XMLEvent.END_ELEMENT:
+                    context.endElement();
 
-                break;
+                    if (lineNums) {
+                        lineNumber(xe, context);
+                    }
 
-            case XMLEvent.SPACE:
-                if (((Space) xe).ignorable())
                     break;
 
-                // Fall through
+                case XMLEvent.SPACE:
+                    if (((Space) xe).ignorable()) {
+                        break;
+                    }
+
+                    // Fall through
 
-            case XMLEvent.CHARACTER_DATA:
-                CharacterData cd = (CharacterData) xe;
+                case XMLEvent.CHARACTER_DATA:
+                    CharacterData cd = (CharacterData) xe;
 
-                if (cd.hasContent())
-                {
-                    context.text(cd.getContent());
+                    if (cd.hasContent()) {
+                        context.text(cd.getContent());
 
-                    if (lineNums)
-                        lineNumber(xe, context);
-                }
+                        if (lineNums) {
+                            lineNumber(xe, context);
+                        }
+                    }
 
-                break;
+                    break;
 
-            case XMLEvent.COMMENT:
-                org.apache.xmlbeans.xml.stream.Comment comment =
-                    (org.apache.xmlbeans.xml.stream.Comment) xe;
-
-                if (comment.hasContent())
-                {
-                    context.comment(comment.getContent());
+                case XMLEvent.COMMENT:
+                    org.apache.xmlbeans.xml.stream.Comment comment =
+                        (org.apache.xmlbeans.xml.stream.Comment) xe;
 
-                    if (lineNums)
-                        lineNumber(xe, context);
-                }
+                    if (comment.hasContent()) {
+                        context.comment(comment.getContent());
 
-                break;
+                        if (lineNums) {
+                            lineNumber(xe, context);
+                        }
+                    }
 
-            case XMLEvent.PROCESSING_INSTRUCTION:
-                ProcessingInstruction procInstr = (ProcessingInstruction) xe;
+                    break;
 
-                context.procInst(procInstr.getTarget(), procInstr.getData());
+                case XMLEvent.PROCESSING_INSTRUCTION:
+                    ProcessingInstruction procInstr = (ProcessingInstruction) xe;
 
-                if (lineNums)
-                    lineNumber(xe, context);
+                    context.procInst(procInstr.getTarget(), procInstr.getData());
 
-                break;
+                    if (lineNums) {
+                        lineNumber(xe, context);
+                    }
+
+                    break;
 
                 // These are ignored
-            case XMLEvent.ENTITY_REFERENCE:
-            case XMLEvent.START_PREFIX_MAPPING:
-            case XMLEvent.END_PREFIX_MAPPING:
-            case XMLEvent.CHANGE_PREFIX_MAPPING:
-            case XMLEvent.XML_EVENT:
-                break;
+                case XMLEvent.ENTITY_REFERENCE:
+                case XMLEvent.START_PREFIX_MAPPING:
+                case XMLEvent.END_PREFIX_MAPPING:
+                case XMLEvent.CHANGE_PREFIX_MAPPING:
+                case XMLEvent.XML_EVENT:
+                    break;
 
-            default :
-                throw new RuntimeException(
-                    "Unhandled xml event type: " + xe.getTypeAsString());
+                default:
+                    throw new RuntimeException(
+                        "Unhandled xml event type: " + xe.getTypeAsString());
             }
         }
 
@@ -1025,11 +930,10 @@ public final class Locale
     }
 
     private Cur loadXMLStreamReader(XMLStreamReader xsr, XmlOptions options)
-        throws XMLStreamException
-    {
+        throws XMLStreamException {
         options = XmlOptions.maskNull(options);
 
-        boolean lineNums = options.hasOption(XmlOptions.LOAD_LINE_NUMBERS);
+        boolean lineNums = options.isLoadLineNumbers();
 
         String encoding = null, version = null;
         boolean standAlone = false;
@@ -1038,41 +942,39 @@ public final class Locale
         int depth = 0;
 
         events:
-        for (int eventType = xsr.getEventType(); ; eventType = xsr.next())
-        {
-            switch (eventType)
-            {
-            case XMLStreamReader.START_DOCUMENT:
-                {
+        for (int eventType = xsr.getEventType(); ; eventType = xsr.next()) {
+            switch (eventType) {
+                case XMLStreamReader.START_DOCUMENT: {
                     depth++;
 
                     encoding = xsr.getCharacterEncodingScheme();
                     version = xsr.getVersion();
                     standAlone = xsr.isStandalone();
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break;
                 }
 
-            case XMLStreamReader.END_DOCUMENT:
-                {
+                case XMLStreamReader.END_DOCUMENT: {
                     depth--;
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break events;
                 }
 
-            case XMLStreamReader.START_ELEMENT:
-                {
+                case XMLStreamReader.START_ELEMENT: {
                     depth++;
                     context.startElement(xsr.getName());
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     doAttributes(xsr, context);
                     doNamespaces(xsr, context);
@@ -1080,80 +982,78 @@ public final class Locale
                     break;
                 }
 
-            case XMLStreamReader.END_ELEMENT:
-                {
+                case XMLStreamReader.END_ELEMENT: {
                     depth--;
                     context.endElement();
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break;
                 }
 
-            case XMLStreamReader.CHARACTERS:
-            case XMLStreamReader.CDATA:
-                {
+                case XMLStreamReader.CHARACTERS:
+                case XMLStreamReader.CDATA: {
                     context.text(xsr.getTextCharacters(), xsr.getTextStart(),
                         xsr.getTextLength());
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break;
                 }
 
-            case XMLStreamReader.COMMENT:
-                {
+                case XMLStreamReader.COMMENT: {
                     String comment = xsr.getText();
 
                     context.comment(comment);
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break;
                 }
 
-            case XMLStreamReader.PROCESSING_INSTRUCTION:
-                {
+                case XMLStreamReader.PROCESSING_INSTRUCTION: {
                     context.procInst(xsr.getPITarget(), xsr.getPIData());
 
-                    if (lineNums)
+                    if (lineNums) {
                         lineNumber(xsr, context);
+                    }
 
                     break;
                 }
 
-            case XMLStreamReader.ATTRIBUTE:
-                {
+                case XMLStreamReader.ATTRIBUTE: {
                     doAttributes(xsr, context);
                     break;
                 }
 
-            case XMLStreamReader.NAMESPACE:
-                {
+                case XMLStreamReader.NAMESPACE: {
                     doNamespaces(xsr, context);
                     break;
                 }
 
-            case XMLStreamReader.ENTITY_REFERENCE:
-                {
+                case XMLStreamReader.ENTITY_REFERENCE: {
                     context.text(xsr.getText());
                     break;
                 }
 
-            case XMLStreamReader.SPACE:
-            case XMLStreamReader.DTD:
-                break;
+                case XMLStreamReader.SPACE:
+                case XMLStreamReader.DTD:
+                    break;
 
-            default :
-                throw new RuntimeException(
-                    "Unhandled xml event type: " + eventType);
+                default:
+                    throw new RuntimeException(
+                        "Unhandled xml event type: " + eventType);
             }
 
-            if (!xsr.hasNext() || depth <= 0)
+            if (!xsr.hasNext() || depth <= 0) {
                 break;
+            }
         }
 
         Cur c = context.finish();
@@ -1174,42 +1074,32 @@ public final class Locale
     //
 
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
-        InputStream is, SchemaType type, XmlOptions options)
-        throws XmlException, IOException
-    {
+                                             InputStream is, SchemaType type, XmlOptions options)
+        throws XmlException, IOException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(is, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(is, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     private XmlObject parseToXmlObject(InputStream is, SchemaType type,
-        XmlOptions options)
-        throws XmlException, IOException
-    {
+                                       XmlOptions options)
+        throws XmlException, IOException {
         Cur c = getSaxLoader(options).load(this, new InputSource(is),
             options);
 
@@ -1227,42 +1117,32 @@ public final class Locale
     //
 
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
-        Reader reader, SchemaType type, XmlOptions options)
-        throws XmlException, IOException
-    {
+                                             Reader reader, SchemaType type, XmlOptions options)
+        throws XmlException, IOException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(reader, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(reader, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     private XmlObject parseToXmlObject(Reader reader, SchemaType type,
-        XmlOptions options)
-        throws XmlException, IOException
-    {
+                                       XmlOptions options)
+        throws XmlException, IOException {
         Cur c = getSaxLoader(options).load(this, new InputSource(reader),
             options);
 
@@ -1280,42 +1160,32 @@ public final class Locale
     //
 
     public static XmlObject parseToXmlObject(SchemaTypeLoader stl, Node node,
-        SchemaType type, XmlOptions options)
-        throws XmlException
-    {
+                                             SchemaType type, XmlOptions options)
+        throws XmlException {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.parseToXmlObject(node, type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.parseToXmlObject(node, type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
     public XmlObject parseToXmlObject(Node node, SchemaType type,
-        XmlOptions options)
-        throws XmlException
-    {
+                                      XmlOptions options)
+        throws XmlException {
         LoadContext context = new Cur.CurLoadContext(this, options);
 
         loadNode(node, context);
@@ -1333,49 +1203,44 @@ public final class Locale
         return x;
     }
 
-    private void loadNodeChildren(Node n, LoadContext context)
-    {
-        for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling())
+    private void loadNodeChildren(Node n, LoadContext context) {
+        for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling()) {
             loadNode(c, context);
+        }
     }
 
-    void loadNode(Node n, LoadContext context)
-    {
-        switch (n.getNodeType())
-        {
-        case Node.DOCUMENT_NODE:
-        case Node.DOCUMENT_FRAGMENT_NODE:
-        case Node.ENTITY_REFERENCE_NODE:
-            {
+    void loadNode(Node n, LoadContext context) {
+        switch (n.getNodeType()) {
+            case Node.DOCUMENT_NODE:
+            case Node.DOCUMENT_FRAGMENT_NODE:
+            case Node.ENTITY_REFERENCE_NODE: {
                 loadNodeChildren(n, context);
 
                 break;
             }
-        case Node.ELEMENT_NODE:
-            {
+            case Node.ELEMENT_NODE: {
                 context.startElement(
                     makeQualifiedQName(n.getNamespaceURI(), n.getNodeName()));
 
                 NamedNodeMap attrs = n.getAttributes();
 
-                for (int i = 0; i < attrs.getLength(); i++)
-                {
+                for (int i = 0; i < attrs.getLength(); i++) {
                     Node a = attrs.item(i);
 
                     String attrName = a.getNodeName();
                     String attrValue = a.getNodeValue();
 
-                    if (attrName.toLowerCase().startsWith("xmlns"))
-                    {
-                        if (attrName.length() == 5)
+                    if (attrName.toLowerCase().startsWith("xmlns")) {
+                        if (attrName.length() == 5) {
                             context.xmlns(null, attrValue);
-                        else
+                        } else {
                             context.xmlns(attrName.substring(6), attrValue);
-                    }
-                    else
+                        }
+                    } else {
                         context.attr(
                             makeQualifiedQName(a.getNamespaceURI(), attrName),
                             attrValue);
+                    }
                 }
 
                 loadNodeChildren(n, context);
@@ -1384,34 +1249,29 @@ public final class Locale
 
                 break;
             }
-        case Node.TEXT_NODE:
-        case Node.CDATA_SECTION_NODE:
-            {
+            case Node.TEXT_NODE:
+            case Node.CDATA_SECTION_NODE: {
                 context.text(n.getNodeValue());
                 break;
             }
-        case Node.COMMENT_NODE:
-            {
+            case Node.COMMENT_NODE: {
                 context.comment(n.getNodeValue());
                 break;
             }
-        case Node.PROCESSING_INSTRUCTION_NODE:
-            {
+            case Node.PROCESSING_INSTRUCTION_NODE: {
                 context.procInst(n.getNodeName(), n.getNodeValue());
                 break;
             }
-        case Node.DOCUMENT_TYPE_NODE:
-        case Node.ENTITY_NODE:
-        case Node.NOTATION_NODE:
-            {
+            case Node.DOCUMENT_TYPE_NODE:
+            case Node.ENTITY_NODE:
+            case Node.NOTATION_NODE: {
                 Node next = n.getNextSibling();
                 if (next != null) {
                     loadNode(next, context);
                 }
                 break;
             }
-        case Node.ATTRIBUTE_NODE:
-            {
+            case Node.ATTRIBUTE_NODE: {
                 throw new RuntimeException("Unexpected node");
             }
         }
@@ -1423,10 +1283,8 @@ public final class Locale
 
     private class XmlSaxHandlerImpl
         extends SaxHandler
-        implements XmlSaxHandler
-    {
-        XmlSaxHandlerImpl(Locale l, SchemaType type, XmlOptions options)
-        {
+        implements XmlSaxHandler {
+        XmlSaxHandlerImpl(Locale l, SchemaType type, XmlOptions options) {
             super(null);
 
             _options = options;
@@ -1442,36 +1300,31 @@ public final class Locale
             initSaxHandler(l, saxHandlerOptions);
         }
 
-        public ContentHandler getContentHandler()
-        {
+        public ContentHandler getContentHandler() {
             return _context == null ? null : this;
         }
 
-        public LexicalHandler getLexicalHandler()
-        {
+        public LexicalHandler getLexicalHandler() {
             return _context == null ? null : this;
         }
 
-        public void bookmarkLastEvent(XmlBookmark mark)
-        {
+        public void bookmarkLastEvent(XmlBookmark mark) {
             _context.bookmarkLastNonAttr(mark);
         }
 
-        public void bookmarkLastAttr(QName attrName, XmlBookmark mark)
-        {
+        public void bookmarkLastAttr(QName attrName, XmlBookmark mark) {
             _context.bookmarkLastAttr(attrName, mark);
         }
 
         public XmlObject getObject()
-            throws XmlException
-        {
-            if (_context == null)
+            throws XmlException {
+            if (_context == null) {
                 return null;
+            }
 
             _locale.enter();
 
-            try
-            {
+            try {
                 Cur c = _context.finish();
 
                 autoTypeDocument(c, _type, _options);
@@ -1483,9 +1336,7 @@ public final class Locale
                 _context = null;
 
                 return x;
-            }
-            finally
-            {
+            } finally {
                 _locale.exit();
             }
         }
@@ -1495,39 +1346,29 @@ public final class Locale
     }
 
     public static XmlSaxHandler newSaxHandler(SchemaTypeLoader stl,
-        SchemaType type, XmlOptions options)
-    {
+                                              SchemaType type, XmlOptions options) {
         Locale l = getLocale(stl, options);
 
-        if (l.noSync())
-        {
+        if (l.noSync()) {
             l.enter();
-            try
-            {
+            try {
                 return l.newSaxHandler(type, options);
-            }
-            finally
-            {
+            } finally {
                 l.exit();
             }
-        }
-        else
-            synchronized (l)
-            {
+        } else {
+            synchronized (l) {
                 l.enter();
-                try
-                {
+                try {
                     return l.newSaxHandler(type, options);
-                }
-                finally
-                {
+                } finally {
                     l.exit();
                 }
             }
+        }
     }
 
-    public XmlSaxHandler newSaxHandler(SchemaType type, XmlOptions options)
-    {
+    public XmlSaxHandler newSaxHandler(SchemaType type, XmlOptions options) {
         return new XmlSaxHandlerImpl(this, type, options);
     }
 
@@ -1535,28 +1376,25 @@ public final class Locale
     // used by the parser.  This factory would probably come from my
     // high speed parser.  Otherwise, use a thread local on
 
-    QName makeQName(String uri, String localPart)
-    {
+    QName makeQName(String uri, String localPart) {
         assert localPart != null && localPart.length() > 0;
         // TODO - make sure name is a well formed name?
 
         return _qnameFactory.getQName(uri, localPart);
     }
 
-    QName makeQNameNoCheck(String uri, String localPart)
-    {
+    QName makeQNameNoCheck(String uri, String localPart) {
         return _qnameFactory.getQName(uri, localPart);
     }
 
-    QName makeQName(String uri, String local, String prefix)
-    {
+    QName makeQName(String uri, String local, String prefix) {
         return _qnameFactory.getQName(uri, local, prefix == null ? "" : prefix);
     }
 
-    QName makeQualifiedQName(String uri, String qname)
-    {
-        if (qname == null)
+    QName makeQualifiedQName(String uri, String qname) {
+        if (qname == null) {
             qname = "";
+        }
 
         int i = qname.indexOf(':');
 
@@ -1569,45 +1407,41 @@ public final class Locale
     }
 
     static private class DocProps
-        extends XmlDocumentProperties
-    {
+        extends XmlDocumentProperties {
         private HashMap _map = new HashMap();
 
-        public Object put(Object key, Object value)
-        {
+        public Object put(Object key, Object value) {
             return _map.put(key, value);
         }
 
-        public Object get(Object key)
-        {
+        public Object get(Object key) {
             return _map.get(key);
         }
 
-        public Object remove(Object key)
-        {
+        public Object remove(Object key) {
             return _map.remove(key);
         }
     }
 
-    static XmlDocumentProperties getDocProps(Cur c, boolean ensure)
-    {
+    static XmlDocumentProperties getDocProps(Cur c, boolean ensure) {
         c.push();
 
-        while (c.toParent())
+        while (c.toParent()) {
             ;
+        }
 
         DocProps props = (DocProps) c.getBookmark(DocProps.class);
 
-        if (props == null && ensure)
+        if (props == null && ensure) {
             c.setBookmark(DocProps.class, props = new DocProps());
+        }
 
         c.pop();
 
         return props;
     }
 
-    interface ChangeListener
-    {
+    interface ChangeListener {
         void notifyChange();
 
         void setNextChangeListener(ChangeListener listener);
@@ -1615,29 +1449,27 @@ public final class Locale
         ChangeListener getNextChangeListener();
     }
 
-    void registerForChange(ChangeListener listener)
-    {
-        if (listener.getNextChangeListener() == null)
-        {
-            if (_changeListeners == null)
+    void registerForChange(ChangeListener listener) {
+        if (listener.getNextChangeListener() == null) {
+            if (_changeListeners == null) {
                 listener.setNextChangeListener(listener);
-            else
+            } else {
                 listener.setNextChangeListener(_changeListeners);
+            }
 
             _changeListeners = listener;
         }
     }
 
-    void notifyChange()
-    {
+    void notifyChange() {
         // First, notify the registered listeners ...
 
-        while (_changeListeners != null)
-        {
+        while (_changeListeners != null) {
             _changeListeners.notifyChange();
 
-            if (_changeListeners.getNextChangeListener() == _changeListeners)
+            if (_changeListeners.getNextChangeListener() == _changeListeners) {
                 _changeListeners.setNextChangeListener(null);
+            }
 
             ChangeListener next = _changeListeners.getNextChangeListener();
 
@@ -1656,32 +1488,32 @@ public final class Locale
     // Cursor helpers
     //
 
-    static String getTextValue(Cur c)
-    {
+    static String getTextValue(Cur c) {
         assert c.isNode();
 
-        if (!c.hasChildren())
+        if (!c.hasChildren()) {
             return c.getValueAsString();
+        }
 
         StringBuffer sb = new StringBuffer();
 
         c.push();
 
-        for (c.next(); !c.isAtEndOfLastPush(); c.next())
-            if (c.isText())
-            {
-                if ( (c._xobj.isComment() || c._xobj.isProcinst() ) && c._pos<c._xobj._cchValue )
+        for (c.next(); !c.isAtEndOfLastPush(); c.next()) {
+            if (c.isText()) {
+                if ((c._xobj.isComment() || c._xobj.isProcinst()) && c._pos < c._xobj._cchValue) {
                     continue;
+                }
                 CharUtil.getString(sb, c.getChars(-1), c._offSrc, c._cchSrc);
             }
+        }
 
         c.pop();
 
         return sb.toString();
     }
 
-    static int getTextValue(Cur c, int wsr, char[] chars, int off, int maxCch)
-    {
+    static int getTextValue(Cur c, int wsr, char[] chars, int off, int maxCch) {
         // TODO - hack impl for now ... improve
 
         assert c.isNode();
@@ -1690,46 +1522,48 @@ public final class Locale
 
         int n = s.length();
 
-        if (n > maxCch)
+        if (n > maxCch) {
             n = maxCch;
+        }
 
-        if (n <= 0)
+        if (n <= 0) {
             return 0;
+        }
 
         s.getChars(0, n, chars, off);
 
         return n;
     }
 
-    static String applyWhiteSpaceRule(String s, int wsr)
-    {
+    static String applyWhiteSpaceRule(String s, int wsr) {
         int l = s == null ? 0 : s.length();
 
-        if (l == 0 || wsr == WS_PRESERVE)
+        if (l == 0 || wsr == WS_PRESERVE) {
             return s;
+        }
 
         char ch;
 
-        if (wsr == WS_REPLACE)
-        {
-            for (int i = 0; i < l; i++)
-                if ((ch = s.charAt(i)) == '\n' || ch == '\r' || ch == '\t')
+        if (wsr == WS_REPLACE) {
+            for (int i = 0; i < l; i++) {
+                if ((ch = s.charAt(i)) == '\n' || ch == '\r' || ch == '\t') {
                     return processWhiteSpaceRule(s, wsr);
-        }
-        else if (wsr == Locale.WS_COLLAPSE)
-        {
+                }
+            }
+        } else if (wsr == Locale.WS_COLLAPSE) {
             if (CharUtil.isWhiteSpace(s.charAt(0)) ||
-                CharUtil.isWhiteSpace(s.charAt(l - 1)))
+                CharUtil.isWhiteSpace(s.charAt(l - 1))) {
                 return processWhiteSpaceRule(s, wsr);
+            }
 
             boolean lastWasWhite = false;
 
-            for (int i = 1; i < l; i++)
-            {
+            for (int i = 1; i < l; i++) {
                 boolean isWhite = CharUtil.isWhiteSpace(s.charAt(i));
 
-                if (isWhite && lastWasWhite)
+                if (isWhite && lastWasWhite) {
                     return processWhiteSpaceRule(s, wsr);
+                }
 
                 lastWasWhite = isWhite;
             }
@@ -1738,8 +1572,7 @@ public final class Locale
         return s;
     }
 
-    static String processWhiteSpaceRule(String s, int wsr)
-    {
+    static String processWhiteSpaceRule(String s, int wsr) {
         ScrubBuffer sb = getScrubBuffer(wsr);
 
         sb.scrub(s, 0, s.length());
@@ -1747,44 +1580,40 @@ public final class Locale
         return sb.getResultAsString();
     }
 
-    static final class ScrubBuffer
-    {
-        ScrubBuffer()
-        {
+    static final class ScrubBuffer {
+        ScrubBuffer() {
             _sb = new StringBuffer();
         }
 
-        void init(int wsr)
-        {
+        void init(int wsr) {
             _sb.delete(0, _sb.length());
 
             _wsr = wsr;
             _state = START_STATE;
         }
 
-        void scrub(Object src, int off, int cch)
-        {
-            if (cch == 0)
+        void scrub(Object src, int off, int cch) {
+            if (cch == 0) {
                 return;
+            }
 
-            if (_wsr == Locale.WS_PRESERVE)
-            {
+            if (_wsr == Locale.WS_PRESERVE) {
                 CharUtil.getString(_sb, src, off, cch);
                 return;
             }
 
             char[] chars;
 
-            if (src instanceof char[])
+            if (src instanceof char[]) {
                 chars = (char[]) src;
-            else
-            {
-                if (cch <= _srcBuf.length)
+            } else {
+                if (cch <= _srcBuf.length) {
                     chars = _srcBuf;
-                else if (cch <= 16384)
+                } else if (cch <= 16384) {
                     chars = _srcBuf = new char[16384];
-                else
+                } else {
                     chars = new char[cch];
+                }
 
                 CharUtil.getChars(chars, 0, src, off, cch);
                 off = 0;
@@ -1792,25 +1621,23 @@ public final class Locale
 
             int start = 0;
 
-            for (int i = 0; i < cch; i++)
-            {
+            for (int i = 0; i < cch; i++) {
                 char ch = chars[off + i];
 
-                if (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t')
-                {
+                if (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') {
                     _sb.append(chars, off + start, i - start);
 
                     start = i + 1;
 
-                    if (_wsr == Locale.WS_REPLACE)
+                    if (_wsr == Locale.WS_REPLACE) {
                         _sb.append(' ');
-                    else if (_state == NOSPACE_STATE)
+                    } else if (_state == NOSPACE_STATE) {
                         _state = SPACE_SEEN_STATE;
-                }
-                else
-                {
-                    if (_state == SPACE_SEEN_STATE)
+                    }
+                } else {
+                    if (_state == SPACE_SEEN_STATE) {
                         _sb.append(' ');
+                    }
 
                     _state = NOSPACE_STATE;
                 }
@@ -1819,8 +1646,7 @@ public final class Locale
             _sb.append(chars, off + start, cch - start);
         }
 
-        String getResultAsString()
-        {
+        String getResultAsString() {
             return _sb.toString();
         }
 
@@ -1837,10 +1663,8 @@ public final class Locale
     }
 
     private static ThreadLocal tl_scrubBuffer =
-        new ThreadLocal()
-        {
-            protected Object initialValue()
-            {
+        new ThreadLocal() {
+            protected Object initialValue() {
                 return new SoftReference(new ScrubBuffer());
             }
         };
@@ -1849,12 +1673,10 @@ public final class Locale
         tl_scrubBuffer.remove();
     }
 
-    static ScrubBuffer getScrubBuffer(int wsr)
-    {
+    static ScrubBuffer getScrubBuffer(int wsr) {
         SoftReference softRef = (SoftReference) tl_scrubBuffer.get();
         ScrubBuffer scrubBuffer = (ScrubBuffer) (softRef).get();
-        if (scrubBuffer == null)
-        {
+        if (scrubBuffer == null) {
             scrubBuffer = new ScrubBuffer();
             tl_scrubBuffer.set(new SoftReference(scrubBuffer));
         }
@@ -1863,42 +1685,35 @@ public final class Locale
         return scrubBuffer;
     }
 
-    static boolean pushToContainer(Cur c)
-    {
+    static boolean pushToContainer(Cur c) {
         c.push();
 
-        for (; ;)
-        {
-            switch (c.kind())
-            {
-            case ROOT:
-            case ELEM:
-                return true;
-            case -ROOT:
-            case -ELEM:
-                c.pop();
-                return false;
-            case COMMENT:
-            case PROCINST:
-                c.skip();
-                break;
-            default                      :
-                c.nextWithAttrs();
-                break;
+        for (; ; ) {
+            switch (c.kind()) {
+                case ROOT:
+                case ELEM:
+                    return true;
+                case -ROOT:
+                case -ELEM:
+                    c.pop();
+                    return false;
+                case COMMENT:
+                case PROCINST:
+                    c.skip();
+                    break;
+                default:
+                    c.nextWithAttrs();
+                    break;
             }
         }
     }
 
-    static boolean toFirstNormalAttr(Cur c)
-    {
+    static boolean toFirstNormalAttr(Cur c) {
         c.push();
 
-        if (c.toFirstAttr())
-        {
-            do
-            {
-                if (!c.isXmlns())
-                {
+        if (c.toFirstAttr()) {
+            do {
+                if (!c.isXmlns()) {
                     c.popButStay();
                     return true;
                 }
@@ -1911,21 +1726,19 @@ public final class Locale
         return false;
     }
 
-    static boolean toPrevNormalAttr(Cur c)
-    {
-        if (c.isAttr())
-        {
+    static boolean toPrevNormalAttr(Cur c) {
+        if (c.isAttr()) {
             c.push();
 
-            for (; ;)
-            {
+            for (; ; ) {
                 assert c.isAttr();
 
                 // See if I can move backward.  If I'm at the first attr, prev must return
                 // false and not move.
 
-                if (!c.prev())
+                if (!c.prev()) {
                     break;
+                }
 
                 // Skip past the text value or attr begin
 
@@ -1933,11 +1746,11 @@ public final class Locale
 
                 // I might have skipped over text above
 
-                if (!c.isAttr())
+                if (!c.isAttr()) {
                     c.prev();
+                }
 
-                if (c.isNormalAttr())
-                {
+                if (c.isNormalAttr()) {
                     c.popButStay();
                     return true;
                 }
@@ -1949,14 +1762,11 @@ public final class Locale
         return false;
     }
 
-    static boolean toNextNormalAttr(Cur c)
-    {
+    static boolean toNextNormalAttr(Cur c) {
         c.push();
 
-        while (c.toNextAttr())
-        {
-            if (!c.isXmlns())
-            {
+        while (c.toNextAttr()) {
+            if (!c.isXmlns()) {
                 c.popButStay();
                 return true;
             }
@@ -1967,26 +1777,25 @@ public final class Locale
         return false;
     }
 
-    Xobj findNthChildElem(Xobj parent, QName name, QNameSet set, int n)
-    {
+    Xobj findNthChildElem(Xobj parent, QName name, QNameSet set, int n) {
         // only one of (set or name) is not null
         // or both are null for a wildcard
         assert (name == null || set == null);
         assert n >= 0;
 
-        if (parent == null)
+        if (parent == null) {
             return null;
+        }
 
         int da = _nthCache_A.distance(parent, name, set, n);
         int db = _nthCache_B.distance(parent, name, set, n);
 
         Xobj x =
             da <= db
-            ? _nthCache_A.fetch(parent, name, set, n)
-            : _nthCache_B.fetch(parent, name, set, n);
+                ? _nthCache_A.fetch(parent, name, set, n)
+                : _nthCache_B.fetch(parent, name, set, n);
 
-        if (da == db)
-        {
+        if (da == db) {
             nthCache temp = _nthCache_A;
             _nthCache_A = _nthCache_B;
             _nthCache_B = temp;
@@ -1995,38 +1804,32 @@ public final class Locale
         return x;
     }
 
-    int count(Xobj parent, QName name, QNameSet set)
-    {
+    int count(Xobj parent, QName name, QNameSet set) {
         int n = 0;
 
         for (Xobj x = findNthChildElem(parent, name, set, 0);
-             x != null; x = x._nextSibling)
-        {
-            if (x.isElem())
-            {
-                if (set == null)
-                {
-                    if (x._name.equals(name))
+             x != null; x = x._nextSibling) {
+            if (x.isElem()) {
+                if (set == null) {
+                    if (x._name.equals(name)) {
                         n++;
-                }
-                else if (set.contains(x._name))
+                    }
+                } else if (set.contains(x._name)) {
                     n++;
+                }
             }
         }
 
         return n;
     }
 
-    static boolean toChild(Cur c, QName name, int n)
-    {
-        if (n >= 0 && pushToContainer(c))
-        {
+    static boolean toChild(Cur c, QName name, int n) {
+        if (n >= 0 && pushToContainer(c)) {
             Xobj x = c._locale.findNthChildElem(c._xobj, name, null, n);
 
             c.pop();
 
-            if (x != null)
-            {
+            if (x != null) {
                 c.moveTo(x);
                 return true;
             }
@@ -2035,8 +1838,7 @@ public final class Locale
         return false;
     }
 
-    static boolean toFirstChildElement(Cur c)
-    {
+    static boolean toFirstChildElement(Cur c) {
 //        if (!pushToContainer(c))
 //            return false;
 //
@@ -2051,32 +1853,29 @@ public final class Locale
 //        return true;
 
         Xobj originalXobj = c._xobj;
-        int  originalPos  = c._pos;
+        int originalPos = c._pos;
 
         loop:
-        for (; ;)
-        {
-            switch (c.kind())
-            {
-            case ROOT:
-            case ELEM:
-                break loop;
-            case -ROOT:
-            case -ELEM:
-                c.moveTo(originalXobj, originalPos);
-                return false;
-            case COMMENT:
-            case PROCINST:
-                c.skip();
-                break;
-            default:
-                c.nextWithAttrs();
-                break;
+        for (; ; ) {
+            switch (c.kind()) {
+                case ROOT:
+                case ELEM:
+                    break loop;
+                case -ROOT:
+                case -ELEM:
+                    c.moveTo(originalXobj, originalPos);
+                    return false;
+                case COMMENT:
+                case PROCINST:
+                    c.skip();
+                    break;
+                default:
+                    c.nextWithAttrs();
+                    break;
             }
         }
 
-        if (!c.toFirstChild() || (!c.isElem() && !toNextSiblingElement(c)))
-        {
+        if (!c.toFirstChild() || (!c.isElem() && !toNextSiblingElement(c))) {
             c.moveTo(originalXobj, originalPos);
             return false;
         }
@@ -2084,13 +1883,12 @@ public final class Locale
         return true;
     }
 
-    static boolean toLastChildElement(Cur c)
-    {
-        if (!pushToContainer(c))
+    static boolean toLastChildElement(Cur c) {
+        if (!pushToContainer(c)) {
             return false;
+        }
 
-        if (!c.toLastChild() || (!c.isElem() && !toPrevSiblingElement(c)))
-        {
+        if (!c.toLastChild() || (!c.isElem() && !toPrevSiblingElement(c))) {
             c.pop();
             return false;
         }
@@ -2100,10 +1898,10 @@ public final class Locale
         return true;
     }
 
-    static boolean toPrevSiblingElement(Cur cur)
-    {
-        if (!cur.hasParent())
+    static boolean toPrevSiblingElement(Cur cur) {
+        if (!cur.hasParent()) {
             return false;
+        }
 
         Cur c = cur.tempCur();
 
@@ -2111,20 +1909,19 @@ public final class Locale
 
         int k = c.kind();
 
-        if (k != ATTR)
-        {
-            for (; ;)
-            {
-                if (!c.prev())
+        if (k != ATTR) {
+            for (; ; ) {
+                if (!c.prev()) {
                     break;
+                }
 
                 k = c.kind();
 
-                if (k == ROOT || k == ELEM)
+                if (k == ROOT || k == ELEM) {
                     break;
+                }
 
-                if (c.kind() == -ELEM)
-                {
+                if (c.kind() == -ELEM) {
                     c.toParent();
 
                     cur.moveToCur(c);
@@ -2140,33 +1937,31 @@ public final class Locale
         return moved;
     }
 
-    static boolean toNextSiblingElement(Cur c)
-    {
-        if (!c.hasParent())
+    static boolean toNextSiblingElement(Cur c) {
+        if (!c.hasParent()) {
             return false;
+        }
 
         c.push();
 
         int k = c.kind();
 
-        if (k == ATTR)
-        {
+        if (k == ATTR) {
             c.toParent();
             c.next();
-        }
-        else if (k == ELEM)
+        } else if (k == ELEM) {
             c.skip();
+        }
 
-        while ((k = c.kind()) >= 0)
-        {
-            if (k == ELEM)
-            {
+        while ((k = c.kind()) >= 0) {
+            if (k == ELEM) {
                 c.popButStay();
                 return true;
             }
 
-            if (k > 0)
+            if (k > 0) {
                 c.toEnd();
+            }
 
             c.next();
         }
@@ -2176,30 +1971,27 @@ public final class Locale
         return false;
     }
 
-    static boolean toNextSiblingElement(Cur c, Xobj parent)
-    {
+    static boolean toNextSiblingElement(Cur c, Xobj parent) {
         Xobj originalXobj = c._xobj;
         int originalPos = c._pos;
 
         int k = c.kind();
 
-        if (k == ATTR)
-        {
+        if (k == ATTR) {
             c.moveTo(parent);
             c.next();
-        }
-        else if (k == ELEM)
+        } else if (k == ELEM) {
             c.skip();
+        }
 
-        while ((k = c.kind()) >= 0)
-        {
-            if (k == ELEM)
-            {
+        while ((k = c.kind()) >= 0) {
+            if (k == ELEM) {
                 return true;
             }
 
-            if (k > 0)
+            if (k > 0) {
                 c.toEnd();
+            }
 
             c.next();
         }
@@ -2209,21 +2001,17 @@ public final class Locale
         return false;
     }
 
-    static void applyNamespaces(Cur c, Map namespaces)
-    {
+    static void applyNamespaces(Cur c, Map namespaces) {
         assert c.isContainer();
 
         java.util.Iterator i = namespaces.keySet().iterator();
 
-        while (i.hasNext())
-        {
+        while (i.hasNext()) {
             String prefix = (String) i.next();
 
             // Usually, this is the predefined xml namespace
-            if (!prefix.toLowerCase().startsWith("xml"))
-            {
-                if (c.namespaceForPrefix(prefix, false) == null)
-                {
+            if (!prefix.toLowerCase().startsWith("xml")) {
+                if (c.namespaceForPrefix(prefix, false) == null) {
                     c.push();
 
                     c.next();
@@ -2238,38 +2026,38 @@ public final class Locale
         }
     }
 
-    static Map getAllNamespaces(Cur c, Map filleMe)
-    {
+    static Map<String,String> getAllNamespaces(Cur c, Map<String,String> filleMe) {
         assert c.isNode();
 
         c.push();
 
-        if (!c.isContainer())
+        if (!c.isContainer()) {
             c.toParent();
+        }
 
         assert c.isContainer();
 
-        do
-        {
+        do {
             QName cName = c.getName();
 
-            while (c.toNextAttr())
-            {
-                if (c.isXmlns())
-                {
+            while (c.toNextAttr()) {
+                if (c.isXmlns()) {
                     String prefix = c.getXmlnsPrefix();
                     String uri = c.getXmlnsUri();
 
-                    if (filleMe == null)
-                        filleMe = new HashMap();
+                    if (filleMe == null) {
+                        filleMe = new HashMap<>();
+                    }
 
-                    if (!filleMe.containsKey(prefix))
+                    if (!filleMe.containsKey(prefix)) {
                         filleMe.put(prefix, uri);
+                    }
                 }
             }
 
-            if (!c.isContainer())
+            if (!c.isContainer()) {
                 c.toParentRaw();
+            }
         }
         while (c.toParentRaw());
 
@@ -2278,15 +2066,12 @@ public final class Locale
         return filleMe;
     }
 
-    class nthCache
-    {
-        private boolean namesSame(QName pattern, QName name)
-        {
+    class nthCache {
+        private boolean namesSame(QName pattern, QName name) {
             return pattern == null || pattern.equals(name);
         }
 
-        private boolean setsSame(QNameSet patternSet, QNameSet set)
-        {
+        private boolean setsSame(QNameSet patternSet, QNameSet set) {
             // value equality is probably too expensive. Since the use case
             // involves QNameSets that are generated by the compiler, we
             // can use identity comparison.
@@ -2295,42 +2080,39 @@ public final class Locale
         }
 
         private boolean nameHit(QName namePattern, QNameSet setPattern,
-            QName name)
-        {
+                                QName name) {
             return
                 setPattern == null
-                ? namesSame(namePattern, name)
-                : setPattern.contains(name);
+                    ? namesSame(namePattern, name)
+                    : setPattern.contains(name);
         }
 
-        private boolean cacheSame(QName namePattern, QNameSet setPattern)
-        {
+        private boolean cacheSame(QName namePattern, QNameSet setPattern) {
             return
                 setPattern == null
-                ? namesSame(namePattern, _name)
-                : setsSame(setPattern, _set);
+                    ? namesSame(namePattern, _name)
+                    : setsSame(setPattern, _set);
         }
 
-        int distance(Xobj parent, QName name, QNameSet set, int n)
-        {
+        int distance(Xobj parent, QName name, QNameSet set, int n) {
             assert n >= 0;
 
-            if (_version != Locale.this.version())
+            if (_version != Locale.this.version()) {
                 return Integer.MAX_VALUE - 1;
+            }
 
-            if (parent != _parent || !cacheSame(name, set))
+            if (parent != _parent || !cacheSame(name, set)) {
                 return Integer.MAX_VALUE;
+            }
 
             return n > _n ? n - _n : _n - n;
         }
 
-        Xobj fetch(Xobj parent, QName name, QNameSet set, int n)
-        {
+        Xobj fetch(Xobj parent, QName name, QNameSet set, int n) {
             assert n >= 0;
 
             if (_version != Locale.this.version() || _parent != parent ||
-                !cacheSame(name, set) || n == 0)
-            {
+                !cacheSame(name, set) || n == 0) {
                 _version = Locale.this.version();
                 _parent = parent;
                 _name = name;
@@ -2339,10 +2121,8 @@ public final class Locale
 
                 loop:
                 for (Xobj x = parent._firstChild;
-                     x != null; x = x._nextSibling)
-                {
-                    if (x.isElem() && nameHit(name, set, x._name))
-                    {
+                     x != null; x = x._nextSibling) {
+                    if (x.isElem() && nameHit(name, set, x._name)) {
                         _child = x;
                         _n = 0;
 
@@ -2351,20 +2131,18 @@ public final class Locale
                 }
             }
 
-            if (_n < 0)
+            if (_n < 0) {
                 return null;
+            }
 
-            if (n > _n)
-            {
-                while (n > _n)
-                {
-                    for (Xobj x = _child._nextSibling; ; x = x._nextSibling)
-                    {
-                        if (x == null)
+            if (n > _n) {
+                while (n > _n) {
+                    for (Xobj x = _child._nextSibling; ; x = x._nextSibling) {
+                        if (x == null) {
                             return null;
+                        }
 
-                        if (x.isElem() && nameHit(name, set, x._name))
-                        {
+                        if (x.isElem() && nameHit(name, set, x._name)) {
                             _child = x;
                             _n++;
 
@@ -2372,18 +2150,14 @@ public final class Locale
                         }
                     }
                 }
-            }
-            else if (n < _n)
-            {
-                while (n < _n)
-                {
-                    for (Xobj x = _child._prevSibling; ; x = x._prevSibling)
-                    {
-                        if (x == null)
+            } else if (n < _n) {
+                while (n < _n) {
+                    for (Xobj x = _child._prevSibling; ; x = x._prevSibling) {
+                        if (x == null) {
                             return null;
+                        }
 
-                        if (x.isElem() && nameHit(name, set, x._name))
-                        {
+                        if (x.isElem() && nameHit(name, set, x._name)) {
                             _child = x;
                             _n--;
 
@@ -2408,12 +2182,12 @@ public final class Locale
     //
     //
 
-    Dom findDomNthChild ( Dom parent, int n )
-    {
+    Dom findDomNthChild(Dom parent, int n) {
         assert n >= 0;
 
-        if (parent == null)
+        if (parent == null) {
             return null;
+        }
 
         int da = _domNthCache_A.distance(parent, n);
         int db = _domNthCache_B.distance(parent, n);
@@ -2422,27 +2196,24 @@ public final class Locale
         // the "better" cache should never walk more than 1/2 len
         Dom x = null;
         boolean bInvalidate = (db - _domNthCache_B._len / 2 > 0) &&
-            (db - _domNthCache_B._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
+                              (db - _domNthCache_B._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
         boolean aInvalidate = (da - _domNthCache_A._len / 2 > 0) &&
-            (da - _domNthCache_A._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
-        if (da <= db)
-            if (!aInvalidate)
+                              (da - _domNthCache_A._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
+        if (da <= db) {
+            if (!aInvalidate) {
                 x = _domNthCache_A.fetch(parent, n);
-            else
-            {
+            } else {
                 _domNthCache_B._version = -1;//blitz the cache
                 x = _domNthCache_B.fetch(parent, n);
             }
-        else if (!bInvalidate)
+        } else if (!bInvalidate) {
             x = _domNthCache_B.fetch(parent, n);
-        else
-        {
+        } else {
             _domNthCache_A._version = -1;//blitz the cache
             x = _domNthCache_A.fetch(parent, n);
         }
 
-        if (da == db)
-        {
+        if (da == db) {
             domNthCache temp = _domNthCache_A;
             _domNthCache_A = _domNthCache_B;
             _domNthCache_B = temp;
@@ -2451,21 +2222,20 @@ public final class Locale
         return x;
     }
 
-    int domLength ( Dom parent )
-    {
-        if (parent == null)
+    int domLength(Dom parent) {
+        if (parent == null) {
             return 0;
+        }
 
-        int da = _domNthCache_A.distance( parent, 0 );
-        int db = _domNthCache_B.distance( parent, 0 );
+        int da = _domNthCache_A.distance(parent, 0);
+        int db = _domNthCache_B.distance(parent, 0);
 
         int len =
             da <= db
-            ? _domNthCache_A.length( parent )
-            : _domNthCache_B.length( parent );
+                ? _domNthCache_A.length(parent)
+                : _domNthCache_B.length(parent);
 
-        if (da == db)
-        {
+        if (da == db) {
             domNthCache temp = _domNthCache_A;
             _domNthCache_A = _domNthCache_B;
             _domNthCache_B = temp;
@@ -2474,39 +2244,37 @@ public final class Locale
         return len;
     }
 
-    void invalidateDomCaches ( Dom d )
-    {
-        if (_domNthCache_A._parent == d)
+    void invalidateDomCaches(Dom d) {
+        if (_domNthCache_A._parent == d) {
             _domNthCache_A._version = -1;
-        if (_domNthCache_B._parent == d)
+        }
+        if (_domNthCache_B._parent == d) {
             _domNthCache_B._version = -1;
+        }
     }
 
-    boolean isDomCached ( Dom d )
-    {
+    boolean isDomCached(Dom d) {
         return _domNthCache_A._parent == d || _domNthCache_B._parent == d;
     }
 
-    class domNthCache
-    {
+    class domNthCache {
 
-        int distance ( Dom parent, int n )
-        {
+        int distance(Dom parent, int n) {
             assert n >= 0;
 
-            if (_version != Locale.this.version())
+            if (_version != Locale.this.version()) {
                 return Integer.MAX_VALUE - 1;
+            }
 
-            if (parent != _parent)
+            if (parent != _parent) {
                 return Integer.MAX_VALUE;
+            }
 
             return n > _n ? n - _n : _n - n;
         }
 
-        int length ( Dom parent )
-        {
-            if (_version != Locale.this.version() || _parent != parent)
-            {
+        int length(Dom parent) {
+            if (_version != Locale.this.version() || _parent != parent) {
                 _parent = parent;
                 _version = Locale.this.version();
                 _child = null;
@@ -2514,17 +2282,13 @@ public final class Locale
                 _len = -1;
             }
 
-            if (_len == -1)
-            {
+            if (_len == -1) {
                 Dom x = null;
 
-                if (_child != null && _n != -1)
-                {
+                if (_child != null && _n != -1) {
                     x = _child;
                     _len = _n;
-                }
-                else
-                {
+                } else {
                     x = DomImpl.firstChild(_parent);
                     _len = 0;
 
@@ -2533,8 +2297,7 @@ public final class Locale
                     _n = 0;
                 }
 
-                for (; x != null; x = DomImpl.nextSibling(x) )
-                {
+                for (; x != null; x = DomImpl.nextSibling(x)) {
                     _len++;
                 }
             }
@@ -2543,23 +2306,19 @@ public final class Locale
             return _len;
         }
 
-        Dom fetch ( Dom parent, int n )
-        {
+        Dom fetch(Dom parent, int n) {
             assert n >= 0;
 

[... 1282 lines stripped ...]


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