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/09/19 02:33:17 UTC

svn commit: r1881834 [4/7] - in /xmlbeans/trunk: ./ src/main/java/org/apache/xmlbeans/ src/main/java/org/apache/xmlbeans/impl/config/ src/main/java/org/apache/xmlbeans/impl/schema/ src/main/java/org/apache/xmlbeans/impl/tool/ src/main/java/org/apache/x...

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java Sat Sep 19 02:33:16 2020
@@ -15,116 +15,108 @@
 
 package org.apache.xmlbeans.impl.tool;
 
+import org.apache.xmlbeans.Filer;
 import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.SystemProperties;
-import org.apache.xmlbeans.impl.util.FilerImpl;
 import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.Filer;
 import org.apache.xmlbeans.impl.repackage.Repackager;
+import org.apache.xmlbeans.impl.util.FilerImpl;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
-public class SchemaCodeGenerator
-{
+public class SchemaCodeGenerator {
     /**
      * Saves a SchemaTypeSystem to the specified directory.
      *
-     * @param system the <code>SchemaTypeSystem</code> to save
+     * @param system     the <code>SchemaTypeSystem</code> to save
      * @param classesDir the destination directory for xsb's
      * @param sourceFile if present, the TypeSystemHolder source will be
      *                   generated in this file for subsequent compilation,
      *                   if null then the source will be generated in a temp
      *                   directory and then compiled to the destination dir
      * @param repackager the repackager to use when generating the holder class
-     * @param options options. Can be null
-     * @deprecated Use {@link SchemaTypeSystem.save()} instead.
+     * @param options    options. Can be null
+     * @deprecated Use {@link SchemaTypeSystem#save(Filer)} instead.
      */
     public static void saveTypeSystem(SchemaTypeSystem system, File classesDir,
-        File sourceFile, Repackager repackager, XmlOptions options)
-        throws IOException
-    {
+                                      File sourceFile, Repackager repackager, XmlOptions options)
+        throws IOException {
         Filer filer = new FilerImpl(classesDir, null, repackager, false, false);
         system.save(filer);
     }
 
-    static void deleteObsoleteFiles(File rootDir, File srcDir, Set seenFiles)
-    {
-        if (!(rootDir.isDirectory() && srcDir.isDirectory()))
+    static void deleteObsoleteFiles(File rootDir, File srcDir, Set seenFiles) {
+        if (!(rootDir.isDirectory() && srcDir.isDirectory())) {
             throw new IllegalArgumentException();
+        }
         String absolutePath = srcDir.getAbsolutePath();
         // Do a sanity check to make sure we don't delete by mistake some important dir
-        if (absolutePath.length() <= 5)
+        if (absolutePath.length() <= 5) {
             return;
+        }
         if (absolutePath.startsWith("/home/") &&
             (absolutePath.indexOf("/", 6) >= absolutePath.length() - 1 ||
-                absolutePath.indexOf("/", 6) < 0))
+             absolutePath.indexOf("/", 6) < 0)) {
             return;
+        }
 
         // Go recursively starting with srcDir and delete all files that are
         // not in the given Set
         File[] files = srcDir.listFiles();
-        for (int i = 0; i < files.length; i++)
-        {
-            if (files[i].isDirectory())
+        for (int i = 0; i < files.length; i++) {
+            if (files[i].isDirectory()) {
                 deleteObsoleteFiles(rootDir, files[i], seenFiles);
-            else if (seenFiles.contains(files[i]))
+            } else if (seenFiles.contains(files[i])) {
                 ;
-            else
-            {
+            } else {
                 deleteXmlBeansFile(files[i]);
                 deleteDirRecursively(rootDir, files[i].getParentFile());
             }
         }
     }
 
-    private static void deleteXmlBeansFile(File file)
-    {
-        if (file.getName().endsWith(".java"))
+    private static void deleteXmlBeansFile(File file) {
+        if (file.getName().endsWith(".java")) {
             file.delete();
+        }
     }
 
-    private static void deleteDirRecursively(File root, File dir)
-    {
+    private static void deleteDirRecursively(File root, File dir) {
         String[] list = dir.list();
-        while (list != null && list.length == 0 && !dir.equals(root))
-        {
+        while (list != null && list.length == 0 && !dir.equals(root)) {
             dir.delete();
             dir = dir.getParentFile();
             list = dir.list();
         }
     }
 
-    protected static File createTempDir() throws IOException
-    {
+    protected static File createTempDir() throws IOException {
 
 // Some beta builds of JDK1.5 are having troubles creating temp directories
 // if the java.io.tmpdir doesn't exist.  This seems to help.
-try {
-  File tmpDirFile = new File(SystemProperties.getProperty("java.io.tmpdir"));
-  tmpDirFile.mkdirs();
-} catch(Exception e) { e.printStackTrace(); }
+        try {
+            File tmpDirFile = new File(SystemProperties.getProperty("java.io.tmpdir"));
+            tmpDirFile.mkdirs();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
         File tmpFile = File.createTempFile("xbean", null);
         String path = tmpFile.getAbsolutePath();
-        if (!path.endsWith(".tmp"))
+        if (!path.endsWith(".tmp")) {
             throw new IOException("Error: createTempFile did not create a file ending with .tmp");
+        }
         path = path.substring(0, path.length() - 4);
         File tmpSrcDir = null;
 
-        for (int count = 0; count < 100; count++)
-        {
+        for (int count = 0; count < 100; count++) {
             String name = path + ".d" + (count == 0 ? "" : Integer.toString(count++));
 
             tmpSrcDir = new File(name);
 
-            if (!tmpSrcDir.exists())
-            {
+            if (!tmpSrcDir.exists()) {
                 boolean created = tmpSrcDir.mkdirs();
                 assert created : "Could not create " + tmpSrcDir.getAbsolutePath();
                 break;
@@ -135,106 +127,97 @@ try {
         return tmpSrcDir;
     }
 
-    protected static void tryHardToDelete(File dir)
-    {
+    protected static void tryHardToDelete(File dir) {
         tryToDelete(dir);
-        if (dir.exists())
+        if (dir.exists()) {
             tryToDeleteLater(dir);
+        }
     }
 
-    private static void tryToDelete(File dir)
-    {
-        if (dir.exists())
-        {
-            if (dir.isDirectory())
-            {
+    private static void tryToDelete(File dir) {
+        if (dir.exists()) {
+            if (dir.isDirectory()) {
                 String[] list = dir.list(); // can return null if I/O error
-                if (list != null)
-                    for (int i = 0; i < list.length; i++)
+                if (list != null) {
+                    for (int i = 0; i < list.length; i++) {
                         tryToDelete(new File(dir, list[i]));
+                    }
+                }
             }
-            if (!dir.delete())
+            if (!dir.delete()) {
                 return; // don't try very hard, because we're just deleting tmp
+            }
         }
     }
 
     private static Set deleteFileQueue = new HashSet();
     private static int triesRemaining = 0;
 
-    private static boolean tryNowThatItsLater()
-    {
+    private static boolean tryNowThatItsLater() {
         List files;
 
-        synchronized (deleteFileQueue)
-        {
+        synchronized (deleteFileQueue) {
             files = new ArrayList(deleteFileQueue);
             deleteFileQueue.clear();
         }
 
         List retry = new ArrayList();
 
-        for (Iterator i = files.iterator(); i.hasNext(); )
-        {
-            File file = (File)i.next();
+        for (Iterator i = files.iterator(); i.hasNext(); ) {
+            File file = (File) i.next();
             tryToDelete(file);
-            if (file.exists())
+            if (file.exists()) {
                 retry.add(file);
+            }
         }
 
-        synchronized (deleteFileQueue)
-        {
-            if (triesRemaining > 0)
+        synchronized (deleteFileQueue) {
+            if (triesRemaining > 0) {
                 triesRemaining -= 1;
+            }
 
             if (triesRemaining <= 0 || retry.size() == 0) // done?
+            {
                 triesRemaining = 0;
-            else
+            } else {
                 deleteFileQueue.addAll(retry); // try again?
+            }
 
             return (triesRemaining <= 0);
         }
     }
 
-    private static void giveUp()
-    {
-        synchronized (deleteFileQueue)
-        {
+    private static void giveUp() {
+        synchronized (deleteFileQueue) {
             deleteFileQueue.clear();
             triesRemaining = 0;
         }
     }
 
-    private static void tryToDeleteLater(File dir)
-    {
-        synchronized (deleteFileQueue)
-        {
+    private static void tryToDeleteLater(File dir) {
+        synchronized (deleteFileQueue) {
             deleteFileQueue.add(dir);
-            if (triesRemaining == 0)
-            {
-                new Thread()
-                {
-                    public void run()
-                    {
+            if (triesRemaining == 0) {
+                new Thread() {
+                    public void run() {
                         // repeats tryNow until triesRemaining == 0
-                        try
-                        {
-                            for (;;)
-                            {
-                                if (tryNowThatItsLater())
+                        try {
+                            for (; ; ) {
+                                if (tryNowThatItsLater()) {
                                     return; // succeeded
+                                }
                                 Thread.sleep(1000 * 3); // wait three seconds
                             }
-                        }
-                        catch (InterruptedException e)
-                        {
+                        } catch (InterruptedException e) {
                             giveUp();
                         }
                     }
                 };
             }
 
-            if (triesRemaining < 10)
+            if (triesRemaining < 10) {
                 triesRemaining = 10;
+            }
         }
     }
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBase64HolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBase64HolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBase64HolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBase64HolderEx.java Sat Sep 19 02:33:16 2020
@@ -16,110 +16,109 @@
 package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlErrorCodes;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
-public abstract class JavaBase64HolderEx extends JavaBase64Holder
-{
-    private SchemaType _schemaType;
+public abstract class JavaBase64HolderEx extends JavaBase64Holder {
+    private final SchemaType _schemaType;
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public JavaBase64HolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+    public JavaBase64HolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
-    protected int get_wscanon_rule()
-    {
+    protected int get_wscanon_rule() {
         return schemaType().getWhiteSpaceRule();
     }
 
-    protected void set_text(String s)
-    {
+    protected void set_text(String s) {
         final byte[] v;
 
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             v = validateLexical(s, schemaType(), _voorVc);
-        else
+        } else {
             v = lex(s, _voorVc);
+        }
 
-        if (v != null && _validateOnSet())
+        if (v != null && _validateOnSet()) {
             validateValue(v, schemaType(), XmlObjectBase._voorVc);
-        
-        super.set_ByteArray(v);
+        }
+
+        if (v != null) {
+            super.set_ByteArray(v);
+        }
     }
 
     // setters
-    protected void set_ByteArray(byte[] v)
-    {
-        if (_validateOnSet())
+    protected void set_ByteArray(byte[] v) {
+        if (_validateOnSet()) {
             validateValue(v, schemaType(), _voorVc);
-        
+        }
+
         super.set_ByteArray(v);
     }
 
-    public static void validateValue(byte[] v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateValue(byte[] v, SchemaType sType, ValidationContext context) {
         int i;
         XmlObject o;
 
-        if ((o = sType.getFacet(SchemaType.FACET_LENGTH)) != null)
-        {
-            if ((i = ((XmlObjectBase)o).bigIntegerValue().intValue()) != v.length)
-            {
+        if ((o = sType.getFacet(SchemaType.FACET_LENGTH)) != null) {
+            if ((i = ((XmlObjectBase) o).getBigIntegerValue().intValue()) != v.length) {
                 context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$BINARY,
-                    new Object[] { "base64Binary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"base64Binary", v.length, i, QNameHelper.readable(sType)});
             }
         }
 
-        if ((o = sType.getFacet( SchemaType.FACET_MIN_LENGTH )) != null)
-        {
-            if ((i = ((XmlObjectBase)o).bigIntegerValue().intValue()) > v.length)
-            {
+        if ((o = sType.getFacet(SchemaType.FACET_MIN_LENGTH)) != null) {
+            if ((i = ((XmlObjectBase) o).getBigIntegerValue().intValue()) > v.length) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$BINARY,
-                    new Object[] { "base64Binary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"base64Binary", v.length, i, QNameHelper.readable(sType)});
             }
         }
 
-        if ((o = sType.getFacet( SchemaType.FACET_MAX_LENGTH )) != null)
-        {
-            if ((i = ((XmlObjectBase)o).bigIntegerValue().intValue()) < v.length)
-            {
+        if ((o = sType.getFacet(SchemaType.FACET_MAX_LENGTH)) != null) {
+            if ((i = ((XmlObjectBase) o).getBigIntegerValue().intValue()) < v.length) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$BINARY,
-                    new Object[] { "base64Binary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"base64Binary", v.length, i, QNameHelper.readable(sType)});
             }
         }
-        
+
         XmlObject[] vals = sType.getEnumerationValues();
 
-        if (vals != null)
-        {
-            enumLoop: for ( i = 0 ; i < vals.length ; i++ )
-            {
-                byte[] enumBytes = ((XmlObjectBase)vals[i]).byteArrayValue();
+        if (vals != null) {
+            enumLoop:
+            for (i = 0; i < vals.length; i++) {
+                byte[] enumBytes = ((XmlObjectBase) vals[i]).getByteArrayValue();
 
-                if (enumBytes.length != v.length)
+                if (enumBytes.length != v.length) {
                     continue;
+                }
 
-                for ( int j = 0 ; j < enumBytes.length ; j++ )
-                    if (enumBytes[j] != v[j])
+                for (int j = 0; j < enumBytes.length; j++) {
+                    if (enumBytes[j] != v[j]) {
                         continue enumLoop;
-                
+                    }
+                }
+
                 break;
             }
-            
-            if (i >= vals.length)
+
+            if (i >= vals.length) {
                 context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID$NO_VALUE,
-                    new Object[] { "base64Binary", QNameHelper.readable(sType) });
+                    new Object[]{"base64Binary", QNameHelper.readable(sType)});
+            }
         }
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
-        validateValue(byteArrayValue(), schemaType(), ctx);
+        validateValue(getByteArrayValue(), schemaType(), ctx);
     }
 
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBooleanHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBooleanHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBooleanHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaBooleanHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,47 +15,46 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
 
+public abstract class JavaBooleanHolderEx extends JavaBooleanHolder {
+    private final SchemaType _schemaType;
 
-public abstract class JavaBooleanHolderEx extends JavaBooleanHolder
-{
-    private SchemaType _schemaType;
-
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public static boolean validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static boolean validateLexical(String v, SchemaType sType, ValidationContext context) {
         boolean b = JavaBooleanHolder.validateLexical(v, context);
         validatePattern(v, sType, context);
         return b;
     }
-    
-    public static void validatePattern(String v, SchemaType sType, ValidationContext context)
-    {
+
+    public static void validatePattern(String v, SchemaType sType, ValidationContext context) {
         // the only new facet that can apply to booleans is pattern!
-        if (!sType.matchPatternFacet(v))
+        if (!sType.matchPatternFacet(v)) {
             context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                new Object[] { "boolean", v, QNameHelper.readable(sType) });
+                new Object[]{"boolean", v, QNameHelper.readable(sType)});
+        }
     }
-    
-    public JavaBooleanHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-
-    protected void set_text(String s)
-    {
-        if (_validateOnSet())
+
+    public JavaBooleanHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
+
+    protected void set_text(String s) {
+        if (_validateOnSet()) {
             validatePattern(s, _schemaType, _voorVc);
+        }
         super.set_text(s);
     }
 
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolder.java Sat Sep 19 02:33:16 2020
@@ -15,9 +15,6 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.XmlObject;
@@ -25,32 +22,36 @@ import org.apache.xmlbeans.impl.common.V
 import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
-public class JavaDecimalHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_DECIMAL; }
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class JavaDecimalHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_DECIMAL;
+    }
 
     private BigDecimal _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // sets/gets raw text value
-    protected String compute_text(NamespaceManager nsm) { return XsTypeConverter.printDecimal(_value); }
-    protected void set_text(String s)
-    {
-        if (_validateOnSet())
+    protected String compute_text(NamespaceManager nsm) {
+        return XsTypeConverter.printDecimal(_value);
+    }
+
+    protected void set_text(String s) {
+        if (_validateOnSet()) {
             validateLexical(s, _voorVc);
+        }
 
         try {
             set_BigDecimal(new BigDecimal(s));
-        }
-        catch (NumberFormatException e)
-        {
-            _voorVc.invalid(XmlErrorCodes.DECIMAL, new Object[] { s });
+        } catch (NumberFormatException e) {
+            _voorVc.invalid(XmlErrorCodes.DECIMAL, new Object[]{s});
         }
     }
-    protected void set_nil()
-    {
+
+    protected void set_nil() {
         _value = null;
     }
 
@@ -58,101 +59,95 @@ public class JavaDecimalHolder extends X
      * Performs lexical validation only.
      */
 
-    public static void validateLexical(String v, ValidationContext context)
-    {
+    public static void validateLexical(String v, ValidationContext context) {
         // TODO - will want to validate Chars with built in white space handling
         //        However, this fcn sometimes takes a value with wsr applied
         //        already
         int l = v.length();
         int i = 0;
 
-        if (i < l)
-        {
+        if (i < l) {
             int ch = v.charAt(i);
 
-            if (ch == '+' || ch == '-')
+            if (ch == '+' || ch == '-') {
                 i++;
+            }
         }
 
         boolean sawDot = false;
         boolean sawDigit = false;
 
-        for ( ; i < l ; i++ )
-        {
+        for (; i < l; i++) {
             int ch = v.charAt(i);
 
-            if (ch == '.')
-            {
-                if (sawDot)
-                {
+            if (ch == '.') {
+                if (sawDot) {
                     context.invalid(XmlErrorCodes.DECIMAL,
-                        new Object[] { "saw '.' more than once: " + v });
+                        new Object[]{"saw '.' more than once: " + v});
                     return;
                 }
 
                 sawDot = true;
-            }
-            else if (ch >= '0' && ch <= '9')
-            {
+            } else if (ch >= '0' && ch <= '9') {
                 sawDigit = true;
-            }
-            else
-            {
+            } else {
                 // TODO - may need to escape error char
                 context.invalid(XmlErrorCodes.DECIMAL,
-                    new Object[] { "unexpected char '" + ch + "'" });
+                    new Object[]{"unexpected char '" + ch + "'"});
                 return;
             }
         }
 
-        if (!sawDigit)
-        {
+        if (!sawDigit) {
             context.invalid(XmlErrorCodes.DECIMAL,
-                new Object[] { "expected at least one digit" });
-            return;
+                new Object[]{"expected at least one digit"});
         }
     }
 
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return _value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return _value;
+    }
 
     // setters
-    protected void set_BigDecimal(BigDecimal v) { _value = v; }
+    protected void set_BigDecimal(BigDecimal v) {
+        _value = v;
+    }
 
     // comparators
-    protected int compare_to(XmlObject decimal)
-    {
-        return _value.compareTo(((XmlObjectBase)decimal).bigDecimalValue());
+    protected int compare_to(XmlObject decimal) {
+        return _value.compareTo(((XmlObjectBase) decimal).getBigDecimalValue());
     }
-    protected boolean equal_to(XmlObject decimal)
-    {
-        return (_value.compareTo(((XmlObjectBase)decimal).bigDecimalValue())) == 0;
+
+    protected boolean equal_to(XmlObject decimal) {
+        return (_value.compareTo(((XmlObjectBase) decimal).getBigDecimalValue())) == 0;
     }
 
-    static private BigInteger _maxlong = BigInteger.valueOf(Long.MAX_VALUE);
-    static private BigInteger _minlong = BigInteger.valueOf(Long.MIN_VALUE);
+    private static final BigInteger _maxlong = BigInteger.valueOf(Long.MAX_VALUE);
+    private static final BigInteger _minlong = BigInteger.valueOf(Long.MIN_VALUE);
 
     /**
      * Note, this is carefully aligned with hash codes for all xsd:decimal
      * primitives.
      */
-    protected int value_hash_code()
-    {
-        if (_value.scale() > 0)
-        {
-            if (_value.setScale(0, BigDecimal.ROUND_DOWN).compareTo(_value) != 0)
+    protected int value_hash_code() {
+        if (_value.scale() > 0) {
+            if (_value.setScale(0, BigDecimal.ROUND_DOWN).compareTo(_value) != 0) {
                 return decimalHashCode();
+            }
         }
 
         BigInteger intval = _value.toBigInteger();
 
         if (intval.compareTo(_maxlong) > 0 ||
-            intval.compareTo(_minlong) < 0)
+            intval.compareTo(_minlong) < 0) {
             return intval.hashCode();
+        }
 
         long longval = intval.longValue();
 
-        return (int)((longval >> 32) * 19 + longval);
+        return (int) ((longval >> 32) * 19 + longval);
     }
 
     /**
@@ -166,8 +161,11 @@ public class JavaDecimalHolder extends X
         // Get decimal value as string, and strip off zeroes on the right
         String strValue = _value.toString();
         int i;
-        for (i = strValue.length() - 1 ; i >= 0 ; i --)
-            if (strValue.charAt(i) != '0') break;
+        for (i = strValue.length() - 1; i >= 0; i--) {
+            if (strValue.charAt(i) != '0') {
+                break;
+            }
+        }
 
         assert strValue.indexOf('.') < i;
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java Sat Sep 19 02:33:16 2020
@@ -18,196 +18,175 @@ package org.apache.xmlbeans.impl.values;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.impl.common.ValidationContext;
 import org.apache.xmlbeans.impl.common.QNameHelper;
-
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
 import java.math.BigDecimal;
 
-public abstract class JavaDecimalHolderEx extends JavaDecimalHolder
-{
-    private SchemaType _schemaType;
-
-    public SchemaType schemaType()
-        { return _schemaType; }
-
-    public JavaDecimalHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-
-    protected void set_text(String s)
-    {
-        if (_validateOnSet())
+public abstract class JavaDecimalHolderEx extends JavaDecimalHolder {
+    private final SchemaType _schemaType;
+
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
+
+    public JavaDecimalHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
+
+    protected void set_text(String s) {
+        if (_validateOnSet()) {
             validateLexical(s, _schemaType, _voorVc);
+        }
 
         BigDecimal v = null;
         try {
             v = new BigDecimal(s);
-        }
-        catch (NumberFormatException e)
-        {
-            _voorVc.invalid(XmlErrorCodes.DECIMAL, new Object[] { s });
+        } catch (NumberFormatException e) {
+            _voorVc.invalid(XmlErrorCodes.DECIMAL, new Object[]{s});
         }
 
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
 
         super.set_BigDecimal(v);
     }
-    
-    protected void set_BigDecimal(BigDecimal v)
-    {
-        if (_validateOnSet())
+
+    protected void set_BigDecimal(BigDecimal v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
         super.set_BigDecimal(v);
     }
-    
-    public static void validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+
+    public static void validateLexical(String v, SchemaType sType, ValidationContext context) {
         JavaDecimalHolder.validateLexical(v, context);
-        
+
         // check pattern
-        if (sType.hasPatternFacet())
-        {
-            if (!sType.matchPatternFacet(v))
-            {
+        if (sType.hasPatternFacet()) {
+            if (!sType.matchPatternFacet(v)) {
                 // TODO - describe string and pattern here in error
                 context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                    new Object[] { "decimal", v, QNameHelper.readable(sType) });
+                    new Object[]{"decimal", v, QNameHelper.readable(sType)});
             }
         }
     }
-    
+
     /**
      * Performs facet validation only.
      */
 
-    public static void validateValue(BigDecimal v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateValue(BigDecimal v, SchemaType sType, ValidationContext context) {
         // fractional digits
         XmlObject fd = sType.getFacet(SchemaType.FACET_FRACTION_DIGITS);
-        if (fd != null)
-        {
-            int scale = ((XmlObjectBase)fd).getBigIntegerValue().intValue();
-            try
-            {
+        if (fd != null) {
+            int scale = ((XmlObjectBase) fd).getBigIntegerValue().intValue();
+            try {
                 // used only for side-effect - this does not change v despite
                 // the name of the method
                 v.setScale(scale);
-            }
-            catch(ArithmeticException e)
-            {
+            } catch (ArithmeticException e) {
                 // ArithmeticException will be thrown if cannot represent as an Integer
                 // with this scale - i.e. would need a fraction which would correspond
                 // to digits beyond the allowed number
                 context.invalid(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_VALID,
-                    new Object[] { new Integer(v.scale()), v.toString(), new Integer(scale), QNameHelper.readable(sType) });
+                    new Object[]{new Integer(v.scale()), v.toString(), new Integer(scale), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // total digits
         XmlObject td = sType.getFacet(SchemaType.FACET_TOTAL_DIGITS);
-        if (td != null)
-        {
+        if (td != null) {
             String temp = v.unscaledValue().toString();
-            int tdf = ((XmlObjectBase)td).getBigIntegerValue().intValue();
+            int tdf = ((XmlObjectBase) td).getBigIntegerValue().intValue();
             int origLen = temp.length();
             int len = origLen;
-            if (origLen > 0)
-            {
+            if (origLen > 0) {
                 // don't count leading minus
-                if (temp.charAt(0) == '-')
-                {
+                if (temp.charAt(0) == '-') {
                     len -= 1;
                 }
 
                 // don't count trailing zeros if we can absorb them into scale
                 int insignificantTrailingZeros = 0;
                 int vScale = v.scale();
-                for(int j = origLen-1;
-                    temp.charAt(j) == '0' && j > 0 && insignificantTrailingZeros < vScale;
-                    j--)
-                {
+                for (int j = origLen - 1;
+                     temp.charAt(j) == '0' && j > 0 && insignificantTrailingZeros < vScale;
+                     j--) {
                     insignificantTrailingZeros++;
                 }
 
                 len -= insignificantTrailingZeros;
             }
 
-            if (len > tdf)
-            {
+            if (len > tdf) {
                 context.invalid(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_VALID,
-                    new Object[] { new Integer(len), v.toString(), new Integer(tdf), QNameHelper.readable(sType) });
+                    new Object[]{new Integer(len), v.toString(), new Integer(tdf), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min ex
         XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
-        if (mine != null)
-        {
-            BigDecimal m = ((XmlObjectBase)mine).getBigDecimalValue();
-            if (v.compareTo(m) <= 0)
-            {
+        if (mine != null) {
+            BigDecimal m = ((XmlObjectBase) mine).getBigDecimalValue();
+            if (v.compareTo(m) <= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "decimal", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"decimal", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min in
         XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
-        if (mini != null)
-        {
-            BigDecimal m = ((XmlObjectBase)mini).getBigDecimalValue();
-            if (v.compareTo(m) < 0)
-            {
+        if (mini != null) {
+            BigDecimal m = ((XmlObjectBase) mini).getBigDecimalValue();
+            if (v.compareTo(m) < 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "decimal", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"decimal", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max in
         XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
-        if (maxi != null)
-        {
-            BigDecimal m = ((XmlObjectBase)maxi).getBigDecimalValue();
-            if (v.compareTo(m) > 0)
-            {
+        if (maxi != null) {
+            BigDecimal m = ((XmlObjectBase) maxi).getBigDecimalValue();
+            if (v.compareTo(m) > 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "decimal", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"decimal", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max ex
         XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
-        if (maxe != null)
-        {
-            BigDecimal m = ((XmlObjectBase)maxe).getBigDecimalValue();
-            if (v.compareTo(m) >= 0)
-            {
+        if (maxe != null) {
+            BigDecimal m = ((XmlObjectBase) maxe).getBigDecimalValue();
+            if (v.compareTo(m) >= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "decimal", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"decimal", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // enumeration
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-                if (v.equals(((XmlObjectBase)vals[i]).getBigDecimalValue()))
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (v.compareTo(((XmlObjectBase) val).getBigDecimalValue()) == 0) {
                     return;
+                }
+            }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "decimal", v, QNameHelper.readable(sType) });
+                new Object[]{"decimal", v, QNameHelper.readable(sType)});
         }
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
         validateValue(getBigDecimalValue(), schemaType(), ctx);
     }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolder.java Sat Sep 19 02:33:16 2020
@@ -15,97 +15,122 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
-public abstract class JavaDoubleHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_DOUBLE; }
+public abstract class JavaDoubleHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_DOUBLE;
+    }
 
     double _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // gets/sets raw text value
-    protected String compute_text(NamespaceManager nsm) { return serialize(_value); }
+    protected String compute_text(NamespaceManager nsm) {
+        return serialize(_value);
+    }
 
-    public static String serialize(double d)
-    {
-        if (d == Double.POSITIVE_INFINITY)
+    public static String serialize(double d) {
+        if (d == Double.POSITIVE_INFINITY) {
             return "INF";
-        else if (d == Double.NEGATIVE_INFINITY)
+        } else if (d == Double.NEGATIVE_INFINITY) {
             return "-INF";
-        else if (d == Double.NaN)
+        } else if (Double.isNaN(d)) {
             return "NaN";
-        else
+        } else {
             return Double.toString(d);
+        }
+    }
+
+    protected void set_text(String s) {
+        set_double(validateLexical(s, _voorVc));
     }
-    protected void set_text(String s)
-    {
-        set_double(validateLexical(s,_voorVc));
-    }
-    public static double validateLexical(String v, ValidationContext context)
-    {
-        try
-        {
+
+    public static double validateLexical(String v, ValidationContext context) {
+        try {
             return XsTypeConverter.lexDouble(v);
-        }
-        catch(NumberFormatException e)
-        {
+        } catch (NumberFormatException e) {
             context.invalid(XmlErrorCodes.DOUBLE, new Object[]{v});
 
             return Double.NaN;
         }
     }
-    protected void set_nil()
-    {
+
+    protected void set_nil() {
         _value = 0.0;
     }
 
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return new BigDecimal(_value); }
-    public double getDoubleValue() { check_dated(); return _value; }
-    public float getFloatValue() { check_dated(); return (float)_value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return new BigDecimal(_value);
+    }
+
+    public double getDoubleValue() {
+        check_dated();
+        return _value;
+    }
+
+    public float getFloatValue() {
+        check_dated();
+        return (float) _value;
+    }
 
     // setters
-    protected void set_double(double v) { _value = v; }
-    protected void set_float(float v) { set_double((double)v); }
-    protected void set_long(long v) { set_double((double)v); }
-    protected void set_BigDecimal(BigDecimal v) { set_double(v.doubleValue()); }
-    protected void set_BigInteger(BigInteger v) { set_double(v.doubleValue()); }
+    protected void set_double(double v) {
+        _value = v;
+    }
+
+    protected void set_float(float v) {
+        set_double(v);
+    }
+
+    protected void set_long(long v) {
+        set_double((double) v);
+    }
+
+    protected void set_BigDecimal(BigDecimal v) {
+        set_double(v.doubleValue());
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        set_double(v.doubleValue());
+    }
 
     // comparators
-    protected int compare_to(XmlObject d)
-    {
-        return compare(_value,((XmlObjectBase)d).doubleValue());
-    }
-    static int compare(double thisValue, double thatValue)
-    {
-        if (thisValue < thatValue) return -1;
-        if (thisValue > thatValue) return  1;
+    protected int compare_to(XmlObject d) {
+        return compare(_value, ((XmlObjectBase) d).getDoubleValue());
+    }
+
+    static int compare(double thisValue, double thatValue) {
+        if (thisValue < thatValue) {
+            return -1;
+        }
+        if (thisValue > thatValue) {
+            return 1;
+        }
 
         long thisBits = Double.doubleToLongBits(thisValue);
         long thatBits = Double.doubleToLongBits(thatValue);
 
-        return thisBits == thatBits ? 0 : thisBits < thatBits ? -1 : 1;
+        return Long.compare(thisBits, thatBits);
     }
 
-    protected boolean equal_to(XmlObject d)
-    {
-        return compare(_value, ((XmlObjectBase)d).doubleValue()) == 0;
+    protected boolean equal_to(XmlObject d) {
+        return compare(_value, ((XmlObjectBase) d).getDoubleValue()) == 0;
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         long v = Double.doubleToLongBits(_value);
-        return (int)((v >> 32) * 19 + v);
+        return (int) ((v >> 32) * 19 + v);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDoubleHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,97 +15,89 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
+
+
+public abstract class JavaDoubleHolderEx extends JavaDoubleHolder {
+    public JavaDoubleHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
+    private final SchemaType _schemaType;
 
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-public abstract class JavaDoubleHolderEx extends JavaDoubleHolder
-{
-    public JavaDoubleHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-    
-    private SchemaType _schemaType;
-
-    public SchemaType schemaType()
-        { return _schemaType; }
-
-    protected void set_double(double v)
-    {
-        if (_validateOnSet())
+    protected void set_double(double v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
         super.set_double(v);
     }
 
-    public static double validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static double validateLexical(String v, SchemaType sType, ValidationContext context) {
         double d = JavaDoubleHolder.validateLexical(v, context);
 
-        if (!sType.matchPatternFacet(v))
+        if (!sType.matchPatternFacet(v)) {
             context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                new Object[] { "double", v, QNameHelper.readable(sType) });
-        
+                new Object[]{"double", v, QNameHelper.readable(sType)});
+        }
+
         return d;
     }
-    
-    public static void validateValue(double v, SchemaType sType, ValidationContext context)
-    {
+
+    public static void validateValue(double v, SchemaType sType, ValidationContext context) {
         XmlObject x;
         double d;
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
-        {
-            if (compare(v, d = ((XmlObjectBase)x).doubleValue()) <= 0)
-            {
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) {
+            if (compare(v, d = ((XmlObjectBase) x).getDoubleValue()) <= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "double", new Double(v), new Double(d), QNameHelper.readable(sType) });
+                    new Object[]{"double", v, d, QNameHelper.readable(sType)});
             }
         }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null)
-        {
-            if (compare(v, d = ((XmlObjectBase)x).doubleValue()) < 0)
-            {
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) {
+            if (compare(v, d = ((XmlObjectBase) x).getDoubleValue()) < 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "double", new Double(v), new Double(d), QNameHelper.readable(sType) });
+                    new Object[]{"double", v, d, QNameHelper.readable(sType)});
             }
         }
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null)
-        {
-            if (compare(v, d = ((XmlObjectBase)x).doubleValue()) > 0)
-            {
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) {
+            if (compare(v, d = ((XmlObjectBase) x).getDoubleValue()) > 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "double", new Double(v), new Double(d), QNameHelper.readable(sType) });
+                    new Object[]{"double", v, d, QNameHelper.readable(sType)});
             }
         }
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null)
-        {
-            if (compare(v, d = ((XmlObjectBase)x).doubleValue()) >= 0)
-            {
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) {
+            if (compare(v, d = ((XmlObjectBase) x).getDoubleValue()) >= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "double", new Double(v), new Double(d), QNameHelper.readable(sType) });
+                    new Object[]{"double", v, d, QNameHelper.readable(sType)});
             }
         }
-        
+
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-                if (compare(v, ((XmlObjectBase)vals[i]).doubleValue()) == 0)
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (compare(v, ((XmlObjectBase) val).getDoubleValue()) == 0) {
                     return;
+                }
+            }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "double", new Double(v), QNameHelper.readable(sType) });
+                new Object[]{"double", v, QNameHelper.readable(sType)});
         }
     }
 
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
-        validateValue(doubleValue(), schemaType(), ctx);
+        validateValue(getDoubleValue(), schemaType(), ctx);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolder.java Sat Sep 19 02:33:16 2020
@@ -16,19 +16,19 @@
 package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlErrorCodes;
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
-public abstract class JavaFloatHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_FLOAT; }
+public abstract class JavaFloatHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_FLOAT;
+    }
 
     private float _value;
 
@@ -39,74 +39,97 @@ public abstract class JavaFloatHolder ex
         return serialize(_value);
     }
 
-    public static String serialize(float f)
-    {
-        if (f == Float.POSITIVE_INFINITY)
+    public static String serialize(float f) {
+        if (f == Float.POSITIVE_INFINITY) {
             return "INF";
-        else if (f == Float.NEGATIVE_INFINITY)
+        } else if (f == Float.NEGATIVE_INFINITY) {
             return "-INF";
-        else if (f == Float.NaN)
+        } else if (Float.isNaN(f)) {
             return "NaN";
-        else
+        } else {
             return Float.toString(f);
+        }
+    }
+
+    protected void set_text(String s) {
+        set_float(validateLexical(s, _voorVc));
     }
-    protected void set_text(String s)
-    {
-        set_float(validateLexical(s,_voorVc));
-    }
-    public static float validateLexical(String v, ValidationContext context)
-    {
-        try
-        {
+
+    public static float validateLexical(String v, ValidationContext context) {
+        try {
             return XsTypeConverter.lexFloat(v);
-        }
-        catch(NumberFormatException e)
-        {
+        } catch (NumberFormatException e) {
             context.invalid(XmlErrorCodes.FLOAT, new Object[]{v});
 
             return Float.NaN;
         }
     }
-    protected void set_nil()
-    {
+
+    protected void set_nil() {
         _value = 0.0f;
     }
+
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return new BigDecimal(_value); }
-    public double getDoubleValue() { check_dated(); return _value; }
-    public float getFloatValue() { check_dated(); return _value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return new BigDecimal(_value);
+    }
+
+    public double getDoubleValue() {
+        check_dated();
+        return _value;
+    }
+
+    public float getFloatValue() {
+        check_dated();
+        return _value;
+    }
 
     // setters
-    protected void set_double(double v) { set_float((float)v); }
-    protected void set_float(float v) { _value = v; }
-    protected void set_long(long v) { set_float((float)v); }
-    protected void set_BigDecimal(BigDecimal v) { set_float(v.floatValue()); }
-    protected void set_BigInteger(BigInteger v) { set_float(v.floatValue()); }
+    protected void set_double(double v) {
+        set_float((float) v);
+    }
+
+    protected void set_float(float v) {
+        _value = v;
+    }
+
+    protected void set_long(long v) {
+        set_float((float) v);
+    }
+
+    protected void set_BigDecimal(BigDecimal v) {
+        set_float(v.floatValue());
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        set_float(v.floatValue());
+    }
 
     // comparators
-    protected int compare_to(XmlObject f)
-    {
-        return compare(_value,((XmlObjectBase)f).floatValue());
+    protected int compare_to(XmlObject f) {
+        return compare(_value, ((XmlObjectBase) f).getFloatValue());
     }
 
-    static int compare(float thisValue, float thatValue)
-    {
-        if (thisValue < thatValue) return -1;
-        if (thisValue > thatValue) return  1;
+    static int compare(float thisValue, float thatValue) {
+        if (thisValue < thatValue) {
+            return -1;
+        }
+        if (thisValue > thatValue) {
+            return 1;
+        }
 
         int thisBits = Float.floatToIntBits(thisValue);
         int thatBits = Float.floatToIntBits(thatValue);
 
-        return thisBits == thatBits ? 0 : thisBits < thatBits ? -1 : 1;
+        return Integer.compare(thisBits, thatBits);
     }
 
-    protected boolean equal_to(XmlObject f)
-    {
-        return compare(_value, ((XmlObjectBase)f).floatValue()) == 0;
+    protected boolean equal_to(XmlObject f) {
+        return compare(_value, ((XmlObjectBase) f).getFloatValue()) == 0;
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return Float.floatToIntBits(_value);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaFloatHolderEx.java Sat Sep 19 02:33:16 2020
@@ -16,97 +16,89 @@
 package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlErrorCodes;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
 
+public abstract class JavaFloatHolderEx extends JavaFloatHolder {
+    public JavaFloatHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
-public abstract class JavaFloatHolderEx extends JavaFloatHolder
-{
-    public JavaFloatHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-    
-    private SchemaType _schemaType;
-
-    public SchemaType schemaType()
-        { return _schemaType; }
-
-    protected void set_float(float v)
-    {
-        if (_validateOnSet())
+    private final SchemaType _schemaType;
+
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
+
+    protected void set_float(float v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
         super.set_float(v);
     }
-    
-    public static float validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+
+    public static float validateLexical(String v, SchemaType sType, ValidationContext context) {
         float f = JavaFloatHolder.validateLexical(v, context);
 
-        if (!sType.matchPatternFacet(v))
+        if (!sType.matchPatternFacet(v)) {
             context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                new Object[] { "float", v, QNameHelper.readable(sType) });
-        
+                new Object[]{"float", v, QNameHelper.readable(sType)});
+        }
+
         return f;
     }
-    
-    public static void validateValue(float v, SchemaType sType, ValidationContext context)
-    {
+
+    public static void validateValue(float v, SchemaType sType, ValidationContext context) {
         XmlObject x;
         float f;
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
-        {
-            if (compare(v, f = ((XmlObjectBase)x).floatValue()) <= 0)
-            {
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) {
+            if (compare(v, f = ((XmlObjectBase) x).getFloatValue()) <= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "float", new Float(v), new Float(f), QNameHelper.readable(sType) });
+                    new Object[]{"float", v, f, QNameHelper.readable(sType)});
             }
         }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null)
-        {
-            if (compare(v, f = ((XmlObjectBase)x).floatValue()) < 0)
-            {
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) {
+            if (compare(v, f = ((XmlObjectBase) x).getFloatValue()) < 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "float", new Float(v), new Float(f), QNameHelper.readable(sType) });
+                    new Object[]{"float", v, f, QNameHelper.readable(sType)});
             }
         }
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null)
-        {
-            if (compare(v, f = ((XmlObjectBase)x).floatValue()) > 0)
-            {
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) {
+            if (compare(v, f = ((XmlObjectBase) x).getFloatValue()) > 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "float", new Float(v), new Float(f), QNameHelper.readable(sType) });
+                    new Object[]{"float", v, f, QNameHelper.readable(sType)});
             }
         }
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null)
-        {
-            if (compare(v, f = ((XmlObjectBase)x).floatValue()) >= 0)
-            {
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) {
+            if (compare(v, f = ((XmlObjectBase) x).getFloatValue()) >= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "float", new Float(v), new Float(f), QNameHelper.readable(sType) });
+                    new Object[]{"float", v, f, QNameHelper.readable(sType)});
             }
         }
-        
+
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-                if (compare(v, ((XmlObjectBase)vals[i]).floatValue()) == 0)
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (compare(v, ((XmlObjectBase) val).getFloatValue()) == 0) {
                     return;
+                }
+            }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "float", new Float(v), QNameHelper.readable(sType) });
+                new Object[]{"float", v, QNameHelper.readable(sType)});
         }
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
-        validateValue(floatValue(), schemaType(), ctx);
+        validateValue(getFloatValue(), schemaType(), ctx);
     }
 
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDateHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDateHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDateHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDateHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,75 +15,63 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
-import org.apache.xmlbeans.GDate;
-import org.apache.xmlbeans.GDateSpecification;
-import org.apache.xmlbeans.GDateBuilder;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
-import java.util.Date;
 import java.util.Calendar;
+import java.util.Date;
 
-public abstract class JavaGDateHolderEx extends XmlObjectBase
-{
-    public JavaGDateHolderEx(SchemaType type, boolean complex)
-    {
+public abstract class JavaGDateHolderEx extends XmlObjectBase {
+    public JavaGDateHolderEx(SchemaType type, boolean complex) {
         _schemaType = type;
         initComplexType(complex, false);
     }
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    private SchemaType _schemaType;
+    private final SchemaType _schemaType;
     private GDate _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // sets/gets raw text value
-    protected String compute_text(NamespaceManager nsm)
-        { return _value == null ? "" : _value.toString(); }
+    protected String compute_text(NamespaceManager nsm) {
+        return _value == null ? "" : _value.toString();
+    }
 
-    protected void set_text(String s)
-    {
+    protected void set_text(String s) {
         GDate newVal;
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             newVal = validateLexical(s, _schemaType, _voorVc);
-        else
+        } else {
             newVal = lex(s, _schemaType, _voorVc);
+        }
 
-        if (_validateOnSet() && newVal != null)
+        if (_validateOnSet() && newVal != null) {
             validateValue(newVal, _schemaType, _voorVc);
+        }
 
         _value = newVal;
     }
 
-    public static GDate lex(String v, SchemaType sType, ValidationContext context)
-    {
+    public static GDate lex(String v, SchemaType sType, ValidationContext context) {
         GDate date = null;
 
-        try
-        {
+        try {
             date = new GDate(v);
-        }
-        catch (Exception e)
-        {
-            context.invalid(XmlErrorCodes.DATE, new Object[] { v });
+        } catch (Exception e) {
+            context.invalid(XmlErrorCodes.DATE, new Object[]{v});
         }
 
-        if (date != null)
-        {
-            if (date.getBuiltinTypeCode() != sType.getPrimitiveType().getBuiltinTypeCode())
-            {
-                context.invalid(XmlErrorCodes.DATE, new Object[] { "wrong type: " + v });
+        if (date != null) {
+            if (date.getBuiltinTypeCode() != sType.getPrimitiveType().getBuiltinTypeCode()) {
+                context.invalid(XmlErrorCodes.DATE, new Object[]{"wrong type: " + v});
                 date = null;
-            }
-            else if (!date.isValid())
-            {
-                context.invalid(XmlErrorCodes.DATE, new Object[] { v });
+            } else if (!date.isValid()) {
+                context.invalid(XmlErrorCodes.DATE, new Object[]{v});
                 date = null;
             }
         }
@@ -91,80 +79,89 @@ public abstract class JavaGDateHolderEx
         return date;
     }
 
-    public static GDate validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static GDate validateLexical(String v, SchemaType sType, ValidationContext context) {
 
         GDate date = lex(v, sType, context);
 
-        if (date != null && sType.hasPatternFacet())
-            if (!sType.matchPatternFacet(v))
+        if (date != null && sType.hasPatternFacet()) {
+            if (!sType.matchPatternFacet(v)) {
                 context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                    new Object[] { "date", v, QNameHelper.readable(sType) });
+                    new Object[]{"date", v, QNameHelper.readable(sType)});
+            }
+        }
 
         return date;
     }
 
-    public static void validateValue(GDateSpecification v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateValue(GDateSpecification v, SchemaType sType, ValidationContext context) {
         XmlObject x;
         GDate g;
 
-        if (v.getBuiltinTypeCode() != sType.getPrimitiveType().getBuiltinTypeCode())
-            context.invalid(XmlErrorCodes.DATE, new Object[] { "Date (" + v + ") does not have the set of fields required for " + QNameHelper.readable(sType) });
+        if (v.getBuiltinTypeCode() != sType.getPrimitiveType().getBuiltinTypeCode()) {
+            context.invalid(XmlErrorCodes.DATE, new Object[]{"Date (" + v + ") does not have the set of fields required for " + QNameHelper.readable(sType)});
+        }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
-            if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) <= 0)
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) {
+            if (v.compareToGDate(g = ((XmlObjectBase) x).getGDateValue()) <= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "date", v, g, QNameHelper.readable(sType) });
+                    new Object[]{"date", v, g, QNameHelper.readable(sType)});
+            }
+        }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null)
-            if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) < 0)
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) {
+            if (v.compareToGDate(g = ((XmlObjectBase) x).getGDateValue()) < 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "date", v, g, QNameHelper.readable(sType) });
+                    new Object[]{"date", v, g, QNameHelper.readable(sType)});
+            }
+        }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null)
-            if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) >= 0)
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) {
+            if (v.compareToGDate(g = ((XmlObjectBase) x).getGDateValue()) >= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "date", v, g, QNameHelper.readable(sType) });
+                    new Object[]{"date", v, g, QNameHelper.readable(sType)});
+            }
+        }
 
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null)
-            if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) > 0)
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) {
+            if (v.compareToGDate(g = ((XmlObjectBase) x).getGDateValue()) > 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "date", v, g, QNameHelper.readable(sType) });
+                    new Object[]{"date", v, g, QNameHelper.readable(sType)});
+            }
+        }
 
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-                if (v.compareToGDate(((XmlObjectBase)vals[i]).gDateValue()) == 0)
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (v.compareToGDate(((XmlObjectBase) val).getGDateValue()) == 0) {
                     return;
+                }
+            }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "date", v, QNameHelper.readable(sType) });
+                new Object[]{"date", v, QNameHelper.readable(sType)});
         }
     }
 
-    protected void set_nil()
-    {
+    protected void set_nil() {
         _value = null;
     }
 
     // numerics: gYear, gMonth, gDay accept an integer
-    public int getIntValue()
-    {
+    public int getIntValue() {
         int code = schemaType().getPrimitiveType().getBuiltinTypeCode();
 
         if (code != SchemaType.BTC_G_DAY &&
-                code != SchemaType.BTC_G_MONTH &&
-                code != SchemaType.BTC_G_YEAR)
+            code != SchemaType.BTC_G_MONTH &&
+            code != SchemaType.BTC_G_YEAR) {
             throw new XmlValueOutOfRangeException();
+        }
 
         check_dated();
 
-        if (_value == null)
+        if (_value == null) {
             return 0;
+        }
 
-        switch (code)
-        {
+        switch (code) {
             case SchemaType.BTC_G_DAY:
                 return _value.getDay();
             case SchemaType.BTC_G_MONTH:
@@ -172,82 +169,82 @@ public abstract class JavaGDateHolderEx
             case SchemaType.BTC_G_YEAR:
                 return _value.getYear();
             default:
-                assert(false);
+                assert (false);
                 throw new IllegalStateException();
         }
     }
 
-    public GDate getGDateValue()
-    {
+    public GDate getGDateValue() {
         check_dated();
 
-        if (_value == null)
+        if (_value == null) {
             return null;
+        }
 
         return _value;
     }
-    
-    public Calendar getCalendarValue()
-    {
+
+    public Calendar getCalendarValue() {
         check_dated();
 
-        if (_value == null)
+        if (_value == null) {
             return null;
+        }
 
         return _value.getCalendar();
     }
 
-    public Date getDateValue()
-    {
+    public Date getDateValue() {
         check_dated();
 
-        if (_value == null)
+        if (_value == null) {
             return null;
+        }
 
         return _value.getDate();
     }
 
     // setters
-    protected void set_int(int v)
-    {
+    protected void set_int(int v) {
         int code = schemaType().getPrimitiveType().getBuiltinTypeCode();
 
         if (code != SchemaType.BTC_G_DAY &&
-                code != SchemaType.BTC_G_MONTH &&
-                code != SchemaType.BTC_G_YEAR)
+            code != SchemaType.BTC_G_MONTH &&
+            code != SchemaType.BTC_G_YEAR) {
             throw new XmlValueOutOfRangeException();
+        }
 
         GDateBuilder value = new GDateBuilder();
 
-        switch (code)
-        {
+        switch (code) {
             case SchemaType.BTC_G_DAY:
-                value.setDay(v); break;
+                value.setDay(v);
+                break;
             case SchemaType.BTC_G_MONTH:
-                value.setMonth(v); break;
+                value.setMonth(v);
+                break;
             case SchemaType.BTC_G_YEAR:
-                value.setYear(v); break;
+                value.setYear(v);
+                break;
         }
 
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             validateValue(value, _schemaType, _voorVc);
+        }
 
         _value = value.toGDate();
     }
 
-    protected void set_GDate(GDateSpecification v)
-    {
+    protected void set_GDate(GDateSpecification v) {
         int code = schemaType().getPrimitiveType().getBuiltinTypeCode();
 
         GDate candidate;
 
-        if (v.isImmutable() && (v instanceof GDate) && v.getBuiltinTypeCode() == code)
-            candidate = (GDate)v;
-        else
-        {
+        if (v.isImmutable() && (v instanceof GDate) && v.getBuiltinTypeCode() == code) {
+            candidate = (GDate) v;
+        } else {
             // truncate extra fields from the date if necessary.
-            if (v.getBuiltinTypeCode() != code)
-            {
+            if (v.getBuiltinTypeCode() != code) {
                 GDateBuilder gDateBuilder = new GDateBuilder(v);
                 gDateBuilder.setBuiltinTypeCode(code);
                 v = gDateBuilder;
@@ -255,65 +252,63 @@ public abstract class JavaGDateHolderEx
             candidate = new GDate(v);
         }
 
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             validateValue(candidate, _schemaType, _voorVc);
+        }
 
         _value = candidate;
     }
-    
-    protected void set_Calendar(Calendar c)
-    {
+
+    protected void set_Calendar(Calendar c) {
         int code = schemaType().getPrimitiveType().getBuiltinTypeCode();
 
         GDateBuilder gDateBuilder = new GDateBuilder(c);
         gDateBuilder.setBuiltinTypeCode(code);
         GDate value = gDateBuilder.toGDate();
- 
-        if (_validateOnSet())
+
+        if (_validateOnSet()) {
             validateValue(value, _schemaType, _voorVc);
+        }
 
         _value = value;
     }
 
-    protected void set_Date(Date v)
-    {
+    protected void set_Date(Date v) {
         int code = schemaType().getPrimitiveType().getBuiltinTypeCode();
 
         if (code != SchemaType.BTC_DATE && code != SchemaType.BTC_DATE_TIME ||
-            v == null)
+            v == null) {
             throw new XmlValueOutOfRangeException();
+        }
 
         GDateBuilder gDateBuilder = new GDateBuilder(v);
         gDateBuilder.setBuiltinTypeCode(code);
         GDate value = gDateBuilder.toGDate();
- 
-        if (_validateOnSet())
+
+        if (_validateOnSet()) {
             validateValue(value, _schemaType, _voorVc);
+        }
 
         _value = value;
     }
 
 
     // comparators
-    protected int compare_to(XmlObject obj)
-    {
-        return _value.compareToGDate(((XmlObjectBase)obj).gDateValue());
+    protected int compare_to(XmlObject obj) {
+        return _value.compareToGDate(((XmlObjectBase) obj).getGDateValue());
     }
 
-    protected boolean equal_to(XmlObject obj)
-    {
-        return _value.equals(((XmlObjectBase)obj).gDateValue());
+    protected boolean equal_to(XmlObject obj) {
+        return _value.equals(((XmlObjectBase) obj).getGDateValue());
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value.hashCode();
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
-        validateValue(gDateValue(), schemaType(), ctx);
+        validateValue(getGDateValue(), schemaType(), ctx);
     }
-    
+
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDurationHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDurationHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDurationHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaGDurationHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,146 +15,147 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.GDuration;
-import org.apache.xmlbeans.GDurationSpecification;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.impl.common.ValidationContext;
+import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.QNameHelper;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.impl.common.ValidationContext;
 
-public abstract class JavaGDurationHolderEx extends XmlObjectBase
-{
-    public JavaGDurationHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+public abstract class JavaGDurationHolderEx extends XmlObjectBase {
+    public JavaGDurationHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
     GDuration _value;
-    private SchemaType _schemaType;
+    private final SchemaType _schemaType;
 
-    public SchemaType schemaType() { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    protected void set_text(String s)
-    {
+    protected void set_text(String s) {
         GDuration newVal;
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             newVal = validateLexical(s, _schemaType, _voorVc);
-        else
+        } else {
             newVal = lex(s, _voorVc);
+        }
 
-        if (_validateOnSet() && newVal != null)
+        if (_validateOnSet() && newVal != null) {
             validateValue(newVal, _schemaType, _voorVc);
+        }
 
         _value = newVal;
     }
 
-    protected void set_GDuration(GDurationSpecification v)
-    {
-        if (_validateOnSet())
+    protected void set_GDuration(GDurationSpecification v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
-        
-        if (v.isImmutable() && (v instanceof GDuration))
-            _value = (GDuration)v;
-        else
+        }
+
+        if (v.isImmutable() && (v instanceof GDuration)) {
+            _value = (GDuration) v;
+        } else {
             _value = new GDuration(v);
+        }
     }
 
-    protected String compute_text(NamespaceManager nsm)
-        { return _value == null ? "" : _value.toString(); }
+    protected String compute_text(NamespaceManager nsm) {
+        return _value == null ? "" : _value.toString();
+    }
 
-    protected void set_nil()
-    {
+    protected void set_nil() {
         _value = null;
     }
 
-    public GDuration getGDurationValue()
-    {
+    public GDuration getGDurationValue() {
         check_dated();
 
         return _value == null ? null : _value;
     }
 
-    public static GDuration lex(String v, ValidationContext context)
-    {
+    public static GDuration lex(String v, ValidationContext context) {
         GDuration duration = null;
-        
-        try
-        {
+
+        try {
             duration = new GDuration(v);
-        }
-        catch (Exception e)
-        {
-            context.invalid(XmlErrorCodes.DURATION, new Object[] { v });
+        } catch (Exception e) {
+            context.invalid(XmlErrorCodes.DURATION, new Object[]{v});
         }
 
         return duration;
     }
 
-    public static GDuration validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static GDuration validateLexical(String v, SchemaType sType, ValidationContext context) {
         GDuration duration = lex(v, context);
 
-        if (duration != null && sType.hasPatternFacet())
-            if (!sType.matchPatternFacet(v))
+        if (duration != null && sType.hasPatternFacet()) {
+            if (!sType.matchPatternFacet(v)) {
                 context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                    new Object[] { "duration", v, QNameHelper.readable(sType) });
-        
+                    new Object[]{"duration", v, QNameHelper.readable(sType)});
+            }
+        }
+
         return duration;
     }
 
-    public static void validateValue(GDurationSpecification v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateValue(GDurationSpecification v, SchemaType sType, ValidationContext context) {
         XmlObject x;
         GDuration g;
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
-            if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) <= 0)
+
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) {
+            if (v.compareToGDuration(g = ((XmlObjectBase) x).getGDurationValue()) <= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "duration", v, g, QNameHelper.readable(sType) });
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null)
-            if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) < 0)
+                    new Object[]{"duration", v, g, QNameHelper.readable(sType)});
+            }
+        }
+
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) {
+            if (v.compareToGDuration(g = ((XmlObjectBase) x).getGDurationValue()) < 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "duration", v, g, QNameHelper.readable(sType) });
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null)
-            if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) >= 0)
+                    new Object[]{"duration", v, g, QNameHelper.readable(sType)});
+            }
+        }
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) {
+            if (v.compareToGDuration(g = ((XmlObjectBase) x).getGDurationValue()) >= 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "duration", v, g, QNameHelper.readable(sType) });
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null)
-            if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) > 0)
+                    new Object[]{"duration", v, g, QNameHelper.readable(sType)});
+            }
+        }
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) {
+            if (v.compareToGDuration(g = ((XmlObjectBase) x).getGDurationValue()) > 0) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "duration", v, g, QNameHelper.readable(sType) });
-        
+                    new Object[]{"duration", v, g, QNameHelper.readable(sType)});
+            }
+        }
+
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-                if (v.compareToGDuration(((XmlObjectBase)vals[i]).gDurationValue()) == 0)
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (v.compareToGDuration(((XmlObjectBase) val).getGDurationValue()) == 0) {
                     return;
+                }
+            }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "duration", v, QNameHelper.readable(sType) });
+                new Object[]{"duration", v, QNameHelper.readable(sType)});
         }
     }
-    
-    protected int compare_to(XmlObject d)
-    {
-        return _value.compareToGDuration(((XmlObjectBase) d).gDurationValue());
+
+    protected int compare_to(XmlObject d) {
+        return _value.compareToGDuration(((XmlObjectBase) d).getGDurationValue());
     }
 
-    protected boolean equal_to(XmlObject d)
-    {
-        return _value.equals(((XmlObjectBase) d).gDurationValue());
+    protected boolean equal_to(XmlObject d) {
+        return _value.equals(((XmlObjectBase) d).getGDurationValue());
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value.hashCode();
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
-        validateValue(gDurationValue(), schemaType(), ctx);
+        validateValue(getGDurationValue(), schemaType(), ctx);
     }
 }



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