poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881834 [5/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...
Date Sat, 19 Sep 2020 02:33:17 GMT
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaHexBinaryHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaHexBinaryHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaHexBinaryHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaHexBinaryHolderEx.java Sat Sep 19 02:33:16 2020
@@ -16,113 +16,112 @@
 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.XmlObject;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.ValidationContext;
 
 
-public abstract class JavaHexBinaryHolderEx extends JavaHexBinaryHolder
-{
-    private SchemaType _schemaType;
+public abstract class JavaHexBinaryHolderEx extends JavaHexBinaryHolder {
+    private final SchemaType _schemaType;
 
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public JavaHexBinaryHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+    public JavaHexBinaryHolderEx(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) {
         byte[] v;
 
-        if (_validateOnSet())
+        if (_validateOnSet()) {
             v = validateLexical(s, schemaType(), _voorVc);
-        else
+        } else {
             v = lex(s, _voorVc);
+        }
 
-        if (_validateOnSet() && v != null)
+        if (_validateOnSet() && v != null) {
             validateValue(v, schemaType(), XmlObjectBase._voorVc);
-        
-        super.set_ByteArray(v);
+        }
+
+        if (v != null) {
+            super.set_ByteArray(v);
+        }
 
         _value = 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[] { "hexBinary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"hexBinary", 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[] { "hexBinary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"hexBinary", 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[] { "hexBinary", new Integer(v.length), new Integer(i), QNameHelper.readable(sType) } );
+                    new Object[]{"hexBinary", 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[] { "hexBinary", QNameHelper.readable(sType) });
+                    new Object[]{"hexBinary", 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/JavaIntHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolder.java Sat Sep 19 02:33:16 2020
@@ -16,88 +16,110 @@
 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.SimpleValue;
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
+import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
-import org.apache.xmlbeans.impl.util.XsTypeConverter;
-
-public abstract class JavaIntHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_INT; }
+public abstract class JavaIntHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_INT;
+    }
 
     private int _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // gets raw text value
-    public String compute_text(NamespaceManager nsm) { return Long.toString(_value); }
-    protected void set_text(String s)
-    {
-        try { set_int(XsTypeConverter.lexInt(s)); }
-        catch (Exception e) { throw new XmlValueOutOfRangeException(XmlErrorCodes.INT, new Object[] { s }); }
+    public String compute_text(NamespaceManager nsm) {
+        return Long.toString(_value);
     }
-    protected void set_nil()
-    {
+
+    protected void set_text(String s) {
+        try {
+            set_int(XsTypeConverter.lexInt(s));
+        } catch (Exception e) {
+            throw new XmlValueOutOfRangeException(XmlErrorCodes.INT, new Object[]{s});
+        }
+    }
+
+    protected void set_nil() {
         _value = 0;
     }
+
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return new BigDecimal((double) _value); }
-    public BigInteger getBigIntegerValue() { check_dated(); return BigInteger.valueOf(_value); }
-    public long getLongValue() { check_dated(); return _value; }
-    public int getIntValue() { check_dated(); return _value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return BigDecimal.valueOf((double) _value);
+    }
+
+    public BigInteger getBigIntegerValue() {
+        check_dated();
+        return BigInteger.valueOf(_value);
+    }
+
+    public long getLongValue() {
+        check_dated();
+        return _value;
+    }
+
+    public int getIntValue() {
+        check_dated();
+        return _value;
+    }
 
     static final BigInteger _max = BigInteger.valueOf(Integer.MAX_VALUE);
     static final BigInteger _min = BigInteger.valueOf(Integer.MIN_VALUE);
 
     // setters
-    protected void set_BigDecimal(BigDecimal v) { set_BigInteger(v.toBigInteger()); }
-    protected void set_BigInteger(BigInteger v)
-    {
-        if (v.compareTo(_max) > 0 || v.compareTo(_min) < 0)
+    protected void set_BigDecimal(BigDecimal v) {
+        set_BigInteger(v.toBigInteger());
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        if (v.compareTo(_max) > 0 || v.compareTo(_min) < 0) {
             throw new XmlValueOutOfRangeException();
+        }
         set_int(v.intValue());
     }
-    protected void set_long(long l)
-    {
-        if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE)
+
+    protected void set_long(long l) {
+        if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) {
             throw new XmlValueOutOfRangeException();
-        set_int((int)l);
+        }
+        set_int((int) l);
     }
-    protected void set_int(int i)
-    {
+
+    protected void set_int(int i) {
         _value = i;
     }
 
     // comparators
-    protected int compare_to(XmlObject i)
-    {
-        if (((SimpleValue)i).instanceType().getDecimalSize() > SchemaType.SIZE_INT)
+    protected int compare_to(XmlObject i) {
+        if (((SimpleValue) i).instanceType().getDecimalSize() > SchemaType.SIZE_INT) {
             return -i.compareTo(this);
+        }
 
-        return _value == ((XmlObjectBase)i).intValue() ? 0 :
-               _value < ((XmlObjectBase)i).intValue() ? -1 : 1;
+        return Integer.compare(_value, ((XmlObjectBase) i).getIntValue());
     }
 
-    protected boolean equal_to(XmlObject i)
-    {
-        if (((SimpleValue)i).instanceType().getDecimalSize() > SchemaType.SIZE_INT)
+    protected boolean equal_to(XmlObject i) {
+        if (((SimpleValue) i).instanceType().getDecimalSize() > SchemaType.SIZE_INT) {
             return i.valueEquals(this);
+        }
 
-        return _value == ((XmlObjectBase)i).intValue();
+        return _value == ((XmlObjectBase) i).getIntValue();
     }
 
     /**
      * Note, this is carefully aligned with hash codes for all xsd:decimal
      * primitives.
      */
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value;
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,169 +15,156 @@
 
 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;
 import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
-public abstract class JavaIntHolderEx extends JavaIntHolder
-{
-    public JavaIntHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-        
-    private SchemaType _schemaType;
+public abstract class JavaIntHolderEx extends JavaIntHolder {
+    public JavaIntHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
+
+    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) {
         int v;
 
-        try { v = XsTypeConverter.lexInt(s); }
-        catch (Exception e) { throw new XmlValueOutOfRangeException(); }
-        
-        if (_validateOnSet())
-        {
+        try {
+            v = XsTypeConverter.lexInt(s);
+        } catch (Exception e) {
+            throw new XmlValueOutOfRangeException();
+        }
+
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
             validateLexical(s, _schemaType, _voorVc);
         }
 
         super.set_int(v);
     }
-    
-    protected void set_int(int v)
-    {
-        if (_validateOnSet())
+
+    protected void set_int(int v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
 
         super.set_int(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)) {
                 context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                    new Object[] { "int", v, QNameHelper.readable(sType) });
+                    new Object[]{"int", v, QNameHelper.readable(sType)});
             }
         }
     }
-    
-    private static void validateValue(int v, SchemaType sType, ValidationContext context)
-    {
+
+    private static void validateValue(int v, SchemaType sType, ValidationContext context) {
         // total digits
         XmlObject td = sType.getFacet(SchemaType.FACET_TOTAL_DIGITS);
-        if (td != null)
-        {
+        if (td != null) {
             String temp = Integer.toString(v);
             int len = temp.length();
-            if (len > 0 && temp.charAt(0) == '-')
+            if (len > 0 && temp.charAt(0) == '-') {
                 len -= 1;
+            }
             int m = getIntValue(td);
-            if (len > m)
-            {
+            if (len > m) {
                 context.invalid(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_VALID,
-                    new Object[] { new Integer(len), temp, new Integer(getIntValue(td)), QNameHelper.readable(sType) });
+                    new Object[]{len, temp, getIntValue(td), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min ex
         XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
-        if (mine != null)
-        {
+        if (mine != null) {
             int m = getIntValue(mine);
-            if (!(v > m))
-            {
+            if (!(v > m)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "int", new Integer(v), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"int", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min in
         XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
-        if (mini != null)
-        {
+        if (mini != null) {
             int m = getIntValue(mini);
-            if (!(v >= m))
-            {
+            if (!(v >= m)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "int", new Integer(v), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"int", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max in
         XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
-        if (maxi != null)
-        {
+        if (maxi != null) {
             int m = getIntValue(maxi);
-            if (!(v <= m))
-            {
+            if (!(v <= m)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "int", new Integer(v), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"int", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max ex
         XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
-        if (maxe != null)
-        {
+        if (maxe != null) {
             int m = getIntValue(maxe);
-            if (!(v < m))
-            {
+            if (!(v < m)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "int", new Integer(v), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"int", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // enumeration
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-            {
-                if (v == getIntValue(vals[i]))
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (v == getIntValue(val)) {
                     return;
+                }
             }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "int", new Integer(v), QNameHelper.readable(sType) });
+                new Object[]{"int", v, QNameHelper.readable(sType)});
         }
     }
 
     private static int getIntValue(XmlObject o) {
         SchemaType s = o.schemaType();
-        switch (s.getDecimalSize()) 
-        {
+        switch (s.getDecimalSize()) {
             case SchemaType.SIZE_BIG_DECIMAL:
-                return ((XmlObjectBase)o).getBigDecimalValue().intValue();
+                return ((XmlObjectBase) o).getBigDecimalValue().intValue();
             case SchemaType.SIZE_BIG_INTEGER:
-                return ((XmlObjectBase)o).getBigIntegerValue().intValue();
+                return ((XmlObjectBase) o).getBigIntegerValue().intValue();
             case SchemaType.SIZE_LONG:
-                return (int)((XmlObjectBase)o).getLongValue();
+                return (int) ((XmlObjectBase) o).getLongValue();
             default:
-                return ((XmlObjectBase)o).getIntValue();
+                return ((XmlObjectBase) o).getIntValue();
         }
 
     }
 
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
         validateValue(getIntValue(), schemaType(), ctx);
     }
-    
+
 }
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolder.java Sat Sep 19 02:33:16 2020
@@ -16,83 +16,102 @@
 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.SimpleValue;
+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 java.math.BigDecimal;
 import java.math.BigInteger;
 
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
-
-public abstract class JavaIntegerHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_INTEGER; }
+public abstract class JavaIntegerHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_INTEGER;
+    }
 
     private BigInteger _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // gets/sets raw text value
-    protected String compute_text(NamespaceManager nsm) { return _value.toString(); }
-    protected void set_text(String s)
-    {
+    protected String compute_text(NamespaceManager nsm) {
+        return _value.toString();
+    }
+
+    protected void set_text(String s) {
         set_BigInteger(lex(s, _voorVc));
     }
-    public static BigInteger lex(String s, ValidationContext vc)
-    {
-        if (s.length() > 0 && s.charAt( 0 ) == '+' )
+
+    public static BigInteger lex(String s, ValidationContext vc) {
+        if (s.length() > 0 && s.charAt(0) == '+') {
             s = s.substring(1);
+        }
 
-        try { return new BigInteger(s); }
-        catch (Exception e) { vc.invalid(XmlErrorCodes.INTEGER, new Object[] { s }); return null; }
+        try {
+            return new BigInteger(s);
+        } catch (Exception e) {
+            vc.invalid(XmlErrorCodes.INTEGER, new Object[]{s});
+            return null;
+        }
     }
-    protected void set_nil()
-    {
+
+    protected void set_nil() {
         _value = null;
     }
+
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return _value == null ? null : new BigDecimal(_value); }
-    public BigInteger getBigIntegerValue() { check_dated(); return _value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return _value == null ? null : new BigDecimal(_value);
+    }
+
+    public BigInteger getBigIntegerValue() {
+        check_dated();
+        return _value;
+    }
 
     // setters
-    protected void set_BigDecimal(BigDecimal v) { _value = v.toBigInteger(); }
-    protected void set_BigInteger(BigInteger v) { _value = v; }
+    protected void set_BigDecimal(BigDecimal v) {
+        _value = v.toBigInteger();
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        _value = v;
+    }
 
     // comparators
-    protected int compare_to(XmlObject i)
-    {
-        if (((SimpleValue)i).instanceType().getDecimalSize() > SchemaType.SIZE_BIG_INTEGER)
+    protected int compare_to(XmlObject i) {
+        if (((SimpleValue) i).instanceType().getDecimalSize() > SchemaType.SIZE_BIG_INTEGER) {
             return -i.compareTo(this);
+        }
 
-        return _value.compareTo(((XmlObjectBase)i).bigIntegerValue());
+        return _value.compareTo(((XmlObjectBase) i).getBigIntegerValue());
     }
 
-    protected boolean equal_to(XmlObject i)
-    {
-        if (((SimpleValue)i).instanceType().getDecimalSize() > SchemaType.SIZE_BIG_INTEGER)
+    protected boolean equal_to(XmlObject i) {
+        if (((SimpleValue) i).instanceType().getDecimalSize() > SchemaType.SIZE_BIG_INTEGER) {
             return i.valueEquals(this);
+        }
 
-        return _value.equals(((XmlObjectBase)i).bigIntegerValue());
+        return _value.equals(((XmlObjectBase) i).getBigIntegerValue());
     }
 
-    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()
-    {
+    protected int value_hash_code() {
         if (_value.compareTo(_maxlong) > 0 ||
-            _value.compareTo(_minlong) < 0)
+            _value.compareTo(_minlong) < 0) {
             return _value.hashCode();
+        }
 
         long longval = _value.longValue();
 
-        return (int)((longval >> 32) * 19 + longval);
+        return (int) ((longval >> 32) * 19 + longval);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaIntegerHolderEx.java Sat Sep 19 02:33:16 2020
@@ -15,167 +15,154 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import java.math.BigInteger;
-
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
 import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlPositiveInteger;
-import org.apache.xmlbeans.impl.common.ValidationContext;
 import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.common.ValidationContext;
+
+import java.math.BigInteger;
 
-public class JavaIntegerHolderEx extends JavaIntegerHolder
-{
-    public JavaIntegerHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
-    
-    private SchemaType _schemaType;
+public class JavaIntegerHolderEx extends JavaIntegerHolder {
+    public JavaIntegerHolderEx(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
+    private final SchemaType _schemaType;
 
-    public SchemaType schemaType()
-        { return _schemaType; }
 
-    protected void set_text(String s)
-    {
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
+
+    protected void set_text(String s) {
         BigInteger v = lex(s, _voorVc);
-        
-        if (_validateOnSet())
+
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
-    
-        if (_validateOnSet())
+        }
+
+        if (_validateOnSet()) {
             validateLexical(s, _schemaType, _voorVc);
+        }
 
         super.set_BigInteger(v);
     }
-    
-    protected void set_BigInteger(BigInteger v)
-    {
-        if (_validateOnSet())
+
+    protected void set_BigInteger(BigInteger v) {
+        if (_validateOnSet()) {
             validateValue(v, _schemaType, _voorVc);
+        }
 
         super.set_BigInteger(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);
-        if ( v.lastIndexOf('.')>=0 )
+        if (v.lastIndexOf('.') >= 0) {
             context.invalid(XmlErrorCodes.INTEGER,
-                new Object[] { v });
+                new Object[]{v});
+        }
 
         // check pattern
-        if (sType.hasPatternFacet())
-        {
-            if (!sType.matchPatternFacet(v))
-            {
+        if (sType.hasPatternFacet()) {
+            if (!sType.matchPatternFacet(v)) {
                 context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                    new Object[] { "integer", v, QNameHelper.readable(sType) });
+                    new Object[]{"integer", v, QNameHelper.readable(sType)});
             }
         }
     }
 
-    private static void validateValue(BigInteger v, SchemaType sType, ValidationContext context)
-    {
+    private static void validateValue(BigInteger v, SchemaType sType, ValidationContext context) {
         // total digits
-        XmlPositiveInteger td = (XmlPositiveInteger)sType.getFacet(SchemaType.FACET_TOTAL_DIGITS);
-        if (td != null)
-        {
+        XmlPositiveInteger td = (XmlPositiveInteger) sType.getFacet(SchemaType.FACET_TOTAL_DIGITS);
+        if (td != null) {
             String temp = v.toString();
             int len = temp.length();
-            if (len > 0 && temp.charAt(0) == '-')
+            if (len > 0 && temp.charAt(0) == '-') {
                 len -= 1;
-            if (len > td.getBigIntegerValue().intValue())
-            {
+            }
+            if (len > td.getBigIntegerValue().intValue()) {
                 context.invalid(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_VALID,
-                    new Object[] { new Integer(len), temp, new Integer(td.getBigIntegerValue().intValue()), QNameHelper.readable(sType) });
+                    new Object[]{len, temp, td.getBigIntegerValue().intValue(), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min ex
         XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
-        if (mine != null)
-        {
+        if (mine != null) {
             BigInteger m = getBigIntegerValue(mine);
-            if (!(v.compareTo(m) > 0))
-            {
+            if (!(v.compareTo(m) > 0)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
-                    new Object[] { "integer", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"integer", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // min in
         XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
-        if (mini != null)
-        {
+        if (mini != null) {
             BigInteger m = getBigIntegerValue(mini);
-            if (!(v.compareTo(m) >= 0))
-            {
+            if (!(v.compareTo(m) >= 0)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID,
-                    new Object[] { "integer", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"integer", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max in
         XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
-        if (maxi != null)
-        {
+        if (maxi != null) {
             BigInteger m = getBigIntegerValue(maxi);
-            if (!(v.compareTo(m) <= 0))
-            {
+            if (!(v.compareTo(m) <= 0)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
-                    new Object[] { "integer", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"integer", v, m, QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // max ex
         XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
-        if (maxe != null)
-        {
+        if (maxe != null) {
             BigInteger m = getBigIntegerValue(maxe);
-            if (!(v.compareTo(m) < 0))
-            {
+            if (!(v.compareTo(m) < 0)) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID,
-                    new Object[] { "integer", v, m, QNameHelper.readable(sType) });
+                    new Object[]{"integer", 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(getBigIntegerValue(vals[i])))
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (v.equals(getBigIntegerValue(val))) {
                     return;
+                }
             }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "integer", v, QNameHelper.readable(sType) });
+                new Object[]{"integer", v, QNameHelper.readable(sType)});
         }
     }
 
-    private static BigInteger getBigIntegerValue(XmlObject o)
-    {
+    private static BigInteger getBigIntegerValue(XmlObject o) {
         SchemaType s = o.schemaType();
-        switch (s.getDecimalSize()) 
-        {
+        switch (s.getDecimalSize()) {
             case SchemaType.SIZE_BIG_DECIMAL:
-                return ((XmlObjectBase)o).bigDecimalValue().toBigInteger();
+                return ((XmlObjectBase) o).getBigDecimalValue().toBigInteger();
             case SchemaType.SIZE_BIG_INTEGER:
-                return ((XmlObjectBase)o).bigIntegerValue();
+                return ((XmlObjectBase) o).getBigIntegerValue();
             default:
                 throw new IllegalStateException("Bad facet type for Big Int: " + s);
         }
     }
 
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
         validateLexical(lexical, schemaType(), ctx);
         validateValue(getBigIntegerValue(), schemaType(), ctx);
     }
-    
+
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaLongHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaLongHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaLongHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaLongHolder.java Sat Sep 19 02:33:16 2020
@@ -16,80 +16,99 @@
 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.SimpleValue;
-
-import java.math.BigInteger;
-import java.math.BigDecimal;
-
+import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 import org.apache.xmlbeans.impl.util.XsTypeConverter;
 
-public abstract class JavaLongHolder extends XmlObjectBase
-{
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_LONG; }
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public abstract class JavaLongHolder extends XmlObjectBase {
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_LONG;
+    }
 
     private long _value;
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
 
     // gets raw text value
-    protected String compute_text(NamespaceManager nsm) { return Long.toString(_value); }
-    protected void set_text(String s)
-    {
-        try { set_long(XsTypeConverter.lexLong(s)); }
-        catch (Exception e) { throw new XmlValueOutOfRangeException(XmlErrorCodes.LONG, new Object[] { s }); }
+    protected String compute_text(NamespaceManager nsm) {
+        return Long.toString(_value);
     }
-    protected void set_nil()
-    {
+
+    protected void set_text(String s) {
+        try {
+            set_long(XsTypeConverter.lexLong(s));
+        } catch (Exception e) {
+            throw new XmlValueOutOfRangeException(XmlErrorCodes.LONG, new Object[]{s});
+        }
+    }
+
+    protected void set_nil() {
         _value = 0L;
     }
 
     // numerics: fractional
-    public BigDecimal getBigDecimalValue() { check_dated(); return BigDecimal.valueOf(_value); }
-    public BigInteger getBigIntegerValue() { check_dated(); return BigInteger.valueOf(_value); }
-    public long getLongValue() { check_dated(); return _value; }
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return BigDecimal.valueOf(_value);
+    }
+
+    public BigInteger getBigIntegerValue() {
+        check_dated();
+        return BigInteger.valueOf(_value);
+    }
+
+    public long getLongValue() {
+        check_dated();
+        return _value;
+    }
 
     private static final BigInteger _max = BigInteger.valueOf(Long.MAX_VALUE);
     private static final BigInteger _min = BigInteger.valueOf(Long.MIN_VALUE);
 
     // setters
-    protected void set_BigDecimal(BigDecimal v) { set_BigInteger(v.toBigInteger()); }
-    protected void set_BigInteger(BigInteger v)
-    {
-        if (v.compareTo(_max) > 0 || v.compareTo(_min) < 0)
+    protected void set_BigDecimal(BigDecimal v) {
+        set_BigInteger(v.toBigInteger());
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        if (v.compareTo(_max) > 0 || v.compareTo(_min) < 0) {
             throw new XmlValueOutOfRangeException();
+        }
         _value = v.longValue();
     }
-    protected void set_long(long l) { _value = l; }
+
+    protected void set_long(long l) {
+        _value = l;
+    }
 
     // comparators
-    protected int compare_to(XmlObject l)
-    {
-        if (((SimpleValue)l).instanceType().getDecimalSize() > SchemaType.SIZE_LONG)
+    protected int compare_to(XmlObject l) {
+        if (((SimpleValue) l).instanceType().getDecimalSize() > SchemaType.SIZE_LONG) {
             return -l.compareTo(this);
+        }
 
-        return _value == ((XmlObjectBase)l).longValue() ? 0 :
-               _value < ((XmlObjectBase)l).longValue() ? -1 : 1;
+        return Long.compare(_value, ((XmlObjectBase) l).getLongValue());
     }
 
-    protected boolean equal_to(XmlObject l)
-    {
-        if (((SimpleValue)l).instanceType().getDecimalSize() > SchemaType.SIZE_LONG)
+    protected boolean equal_to(XmlObject l) {
+        if (((SimpleValue) l).instanceType().getDecimalSize() > SchemaType.SIZE_LONG) {
             return l.valueEquals(this);
+        }
 
-        return _value == ((XmlObjectBase)l).longValue();
+        return _value == ((XmlObjectBase) l).getLongValue();
     }
 
     /**
      * Note, this is carefully aligned with hash codes for all xsd:decimal
      * primitives.
      */
-    protected int value_hash_code()
-    {
-        return (int)((_value >> 32) * 19 + _value);
+    protected int value_hash_code() {
+        return (int) ((_value >> 32) * 19 + _value);
     }
 
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaQNameHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaQNameHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaQNameHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaQNameHolder.java Sat Sep 19 02:33:16 2020
@@ -15,51 +15,48 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import org.apache.xmlbeans.impl.common.PrefixResolver;
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlErrorCodes;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.common.PrefixResolver;
+import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.ValidationContext;
 import org.apache.xmlbeans.impl.common.XMLChar;
-import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 
 import javax.xml.namespace.QName;
-import org.apache.xmlbeans.impl.values.NamespaceContext;
-   
-public class JavaQNameHolder extends XmlObjectBase
-{
-    public JavaQNameHolder() {}
 
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_QNAME; }
+public class JavaQNameHolder extends XmlObjectBase {
+    public JavaQNameHolder() {
+    }
+
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_QNAME;
+    }
 
     private QName _value;
 
-    protected int get_wscanon_rule()
-        { return SchemaType.WS_PRESERVE; }
-    
+    protected int get_wscanon_rule() {
+        return SchemaType.WS_PRESERVE;
+    }
+
     // an ergonomic prefixer so that you can say stringValue() on a free-floating QName.
     private static final NamespaceManager PRETTY_PREFIXER = new PrettyNamespaceManager();
-    
-    private static class PrettyNamespaceManager implements NamespaceManager
-    {
-        public String find_prefix_for_nsuri(String nsuri, String suggested_prefix)
-        {
+
+    private static class PrettyNamespaceManager implements NamespaceManager {
+        public String find_prefix_for_nsuri(String nsuri, String suggested_prefix) {
             return QNameHelper.suggestPrefix(nsuri);
         }
-        public String getNamespaceForPrefix(String prefix)
-        {
-            throw new RuntimeException( "Should not be called" );
+
+        public String getNamespaceForPrefix(String prefix) {
+            throw new RuntimeException("Should not be called");
         }
     }
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
-    public String compute_text(NamespaceManager nsm)
-    {
-        if (nsm == null)
-        {
+    public String compute_text(NamespaceManager nsm) {
+        if (nsm == null) {
             // we used to: throw new IllegalStateException("Cannot create QName prefix outside of a document");
             // but it's not nice to throw on stringValue()
             nsm = PRETTY_PREFIXER;
@@ -68,15 +65,16 @@ public class JavaQNameHolder extends Xml
 // TODO - what I really need to do here is that if there is no
 // namespace for this qname, then instead of finding the prefix for the
 // uri, I should make a call to set the default namespace for the
-// immediate context for this qname to be "".  
-   
+// immediate context for this qname to be "".
+
         String namespace = _value.getNamespaceURI();
         String localPart = _value.getLocalPart();
 
-        if (namespace == null || namespace.length() == 0)
+        if (namespace == null || namespace.length() == 0) {
             return localPart;
+        }
 
-        String prefix = nsm.find_prefix_for_nsuri( namespace, null );
+        String prefix = nsm.find_prefix_for_nsuri(namespace, null);
 
         assert prefix != null;
 
@@ -84,16 +82,12 @@ public class JavaQNameHolder extends Xml
     }
 
     public static QName validateLexical(
-        String v, ValidationContext context, PrefixResolver resolver)
-    {
+        String v, ValidationContext context, PrefixResolver resolver) {
         QName name;
 
-        try
-        {
+        try {
             name = parse(v, resolver);
-        }
-        catch ( XmlValueOutOfRangeException e )
-        {
+        } catch (XmlValueOutOfRangeException e) {
             context.invalid(e.getMessage());
             name = null;
         }
@@ -101,99 +95,100 @@ public class JavaQNameHolder extends Xml
         return name;
     }
 
-    private static QName parse(String v, PrefixResolver resolver)
-    {
+    private static QName parse(String v, PrefixResolver resolver) {
         String prefix, localname;
         int start;
         int end;
-        for (end = v.length(); end > 0; end -= 1)
-            if (!XMLChar.isSpace(v.charAt(end-1)))
+        for (end = v.length(); end > 0; end -= 1) {
+            if (!XMLChar.isSpace(v.charAt(end - 1))) {
                 break;
-        for (start = 0; start < end; start += 1)
-            if (!XMLChar.isSpace(v.charAt(start)))
+            }
+        }
+        for (start = 0; start < end; start += 1) {
+            if (!XMLChar.isSpace(v.charAt(start))) {
                 break;
+            }
+        }
 
         int firstcolon = v.indexOf(':', start);
-        if (firstcolon >= 0)
-        {
+        if (firstcolon >= 0) {
             prefix = v.substring(start, firstcolon);
             localname = v.substring(firstcolon + 1, end);
-        }
-        else
-        {
+        } else {
             prefix = "";
             localname = v.substring(start, end);
         }
 
-        if ( prefix.length()>0 && !XMLChar.isValidNCName(prefix) )
-            throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[] { "Prefix not a valid NCName in '" + v + "'" });
+        if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix)) {
+            throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[]{"Prefix not a valid NCName in '" + v + "'"});
+        }
 
-        if ( !XMLChar.isValidNCName(localname) )
-            throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[] { "Localname not a valid NCName in '" + v + "'" });
+        if (!XMLChar.isValidNCName(localname)) {
+            throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[]{"Localname not a valid NCName in '" + v + "'"});
+        }
 
         String uri =
             resolver == null ? null : resolver.getNamespaceForPrefix(prefix);
-        
-        if (uri == null)
-        {
-            if (prefix.length() > 0)
-                throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[] { "Can't resolve prefix '" + prefix + "'"});
-                        
+
+        if (uri == null) {
+            if (prefix.length() > 0) {
+                throw new XmlValueOutOfRangeException(XmlErrorCodes.QNAME, new Object[]{"Can't resolve prefix '" + prefix + "'"});
+            }
+
             uri = "";
         }
 
-        if ( prefix!=null && prefix.length()>0 )
-            return new QName(uri, localname, prefix );
-        else
-            return new QName( uri, localname );
-    }
-    
-    protected void set_text(String s)
-    {
+        if (prefix != null && prefix.length() > 0) {
+            return new QName(uri, localname, prefix);
+        } else {
+            return new QName(uri, localname);
+        }
+    }
+
+    protected void set_text(String s) {
         PrefixResolver resolver = NamespaceContext.getCurrent();
 
-        if (resolver == null && has_store())
+        if (resolver == null && has_store()) {
             resolver = get_store();
-        
+        }
+
         _value = parse(s, resolver);
     }
 
     // BUGBUG - having prefix here may not work
-    protected void set_QName(QName name)
-    {
+    protected void set_QName(QName name) {
         assert name != null;
-        
+
         // Sync force of creation of namesapce mapping ..
-        
-        if (has_store())
-            get_store().find_prefix_for_nsuri( name.getNamespaceURI(), null );
-        
+
+        if (has_store()) {
+            get_store().find_prefix_for_nsuri(name.getNamespaceURI(), null);
+        }
+
         _value = name;
     }
 
-    protected void set_xmlanysimple(XmlAnySimpleType value)
-    {
+    protected void set_xmlanysimple(XmlAnySimpleType value) {
         _value = parse(value.getStringValue(), NamespaceContext.getCurrent());
     }
 
-    protected void set_nil() { _value = null; }
+    protected void set_nil() {
+        _value = null;
+    }
 
     // setters, getters (setter already handled via set_text)
 
-    public QName getQNameValue()
-    {
+    public QName getQNameValue() {
         check_dated();
         return _value;
     }
 
     // comparators
-    protected boolean equal_to(XmlObject obj)
-    {
-        return _value.equals(((XmlObjectBase)obj).qNameValue());
+    protected boolean equal_to(XmlObject obj) {
+        return _value.equals(((XmlObjectBase) obj).getQNameValue());
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value.hashCode();
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolder.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolder.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolder.java Sat Sep 19 02:33:16 2020
@@ -17,40 +17,47 @@ package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlObject;
-
 import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 
-public class JavaStringHolder extends XmlObjectBase
-{
-    public JavaStringHolder() {}
+public class JavaStringHolder extends XmlObjectBase {
+    public JavaStringHolder() {
+    }
 
-    public SchemaType schemaType()
-        { return BuiltinSchemaTypeSystem.ST_STRING; }
+    public SchemaType schemaType() {
+        return BuiltinSchemaTypeSystem.ST_STRING;
+    }
 
     private String _value;
 
-    protected int get_wscanon_rule()
-        { return SchemaType.WS_PRESERVE; }
+    protected int get_wscanon_rule() {
+        return SchemaType.WS_PRESERVE;
+    }
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
-    public String compute_text(NamespaceManager nsm) { return _value; }
-    protected void set_text(String s) { _value = s; }
-    protected void set_nil() { _value = null; }
+    public String compute_text(NamespaceManager nsm) {
+        return _value;
+    }
+
+    protected void set_text(String s) {
+        _value = s;
+    }
+
+    protected void set_nil() {
+        _value = null;
+    }
 
     // string setter and getter already handled by XmlObjectBase
 
     // comparators
-    protected boolean equal_to(XmlObject obj)
-    {
-        return _value.equals(((XmlObjectBase)obj).stringValue());
+    protected boolean equal_to(XmlObject obj) {
+        return _value.equals(((XmlObjectBase) obj).getStringValue());
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value.hashCode();
     }
-    protected boolean is_defaultable_ws(String v)
-    {
+
+    protected boolean is_defaultable_ws(String v) {
         return false;
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java Sat Sep 19 02:33:16 2020
@@ -16,32 +16,33 @@
 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.XmlAnySimpleType;
-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 JavaStringHolderEx extends JavaStringHolder
-{
-    private SchemaType _schemaType;
+public abstract class JavaStringHolderEx extends JavaStringHolder {
+    private final SchemaType _schemaType;
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public JavaStringHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+    public JavaStringHolderEx(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)
-    {
-        if (_validateOnSet())
+    protected void set_text(String s) {
+        if (_validateOnSet()) {
             validateLexical(s, _schemaType, _voorVc);
-                 
+        }
+
         super.set_text(s);
     }
 
@@ -49,81 +50,70 @@ public abstract class JavaStringHolderEx
         try {
             validateLexical(v, _schemaType, _voorVc);
             return false;
-        }
-        catch (XmlValueOutOfRangeException e) {
+        } catch (XmlValueOutOfRangeException e) {
             return true;
         }
     }
 
-    public static void validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateLexical(String v, SchemaType sType, ValidationContext context) {
         // check against pattern
-        if (!sType.matchPatternFacet(v))
-        {
-            context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID, new Object[] { "string", v, QNameHelper.readable(sType) });
+        if (!sType.matchPatternFacet(v)) {
+            context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID, new Object[]{"string", v, QNameHelper.readable(sType)});
             return;
         }
 
         // check against length
         XmlObject len = sType.getFacet(SchemaType.FACET_LENGTH);
-        if (len != null)
-        {
-            int m = ((XmlObjectBase)len).bigIntegerValue().intValue();
-            if (v.length() != m)
-            {
+        if (len != null) {
+            int m = ((XmlObjectBase) len).getBigIntegerValue().intValue();
+            if (v.length() != m) {
                 context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$STRING,
-                    new Object[] { "string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // check against min length
         XmlObject min = sType.getFacet(SchemaType.FACET_MIN_LENGTH);
-        if (min != null)
-        {
-            int m = ((XmlObjectBase)min).bigIntegerValue().intValue();
-            if (v.length() < m)
-            {
+        if (min != null) {
+            int m = ((XmlObjectBase) min).getBigIntegerValue().intValue();
+            if (v.length() < m) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$STRING,
-                    new Object[] { "string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
                 return;
             }
         }
 
         // check against min length
         XmlObject max = sType.getFacet(SchemaType.FACET_MAX_LENGTH);
-        if (max != null)
-        {
-            int m = ((XmlObjectBase)max).bigIntegerValue().intValue();
-            if (v.length() > m)
-            {
+        if (max != null) {
+            int m = ((XmlObjectBase) max).getBigIntegerValue().intValue();
+            if (v.length() > m) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$STRING,
-                    new Object[] { "string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType) });
+                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
                 return;
             }
         }
-        
+
         // enumeration
         // NOTE: can't use .hasStringEnumValues() or .enumForString()
         // here since we may be validating against a string enum value
         // during StscSimpleTypeResolver.resolveFacets() and the string
         // enum table hasn't been constructed yet.
         XmlAnySimpleType[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-            {
-                if (v.equals(vals[i].getStringValue()))
+        if (vals != null) {
+            for (int i = 0; i < vals.length; i++) {
+                if (v.equals(vals[i].getStringValue())) {
                     return;
+                }
             }
             context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                new Object[] { "string", v, QNameHelper.readable(sType) });
+                new Object[]{"string", v, QNameHelper.readable(sType)});
         }
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
-        validateLexical(stringValue(), schemaType(), ctx);
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
+        validateLexical(getStringValue(), schemaType(), ctx);
     }
-    
+
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaUriHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaUriHolderEx.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaUriHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaUriHolderEx.java Sat Sep 19 02:33:16 2020
@@ -16,36 +16,37 @@
 package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.SimpleValue;
 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 class JavaUriHolderEx extends JavaUriHolder
-{
-    private SchemaType _schemaType;
+public class JavaUriHolderEx extends JavaUriHolder {
+    private final SchemaType _schemaType;
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public JavaUriHolderEx(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+    public JavaUriHolderEx(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)
-    {
-        if (_validateOnSet())
-        {
-            if (!check(s, _schemaType))
+    protected void set_text(String s) {
+        if (_validateOnSet()) {
+            if (!check(s, _schemaType)) {
                 throw new XmlValueOutOfRangeException();
+            }
 
-            if (!_schemaType.matchPatternFacet(s))
+            if (!_schemaType.matchPatternFacet(s)) {
                 throw new XmlValueOutOfRangeException();
+            }
         }
 
         super.set_text(s);
@@ -60,94 +61,95 @@ public class JavaUriHolderEx extends Jav
 //        super.set_uri(uri);
 //    }
 
-    public static void validateLexical(String v, SchemaType sType, ValidationContext context)
-    {
+    public static void validateLexical(String v, SchemaType sType, ValidationContext context) {
         XmlAnyUriImpl.validateLexical(v, context);
-        
+
         XmlObject[] vals = sType.getEnumerationValues();
 
-        if (vals != null)
-        {
+        if (vals != null) {
             int i;
-            
-            for ( i = 0 ; i < vals.length ; i++ )
-            {
-                String e = ((SimpleValue)vals[i]).getStringValue();
 
-                if (e.equals( v ))
+            for (i = 0; i < vals.length; i++) {
+                String e = ((SimpleValue) vals[i]).getStringValue();
+
+                if (e.equals(v)) {
                     break;
+                }
             }
-            
-            if (i >= vals.length)
+
+            if (i >= vals.length) {
                 context.invalid(XmlErrorCodes.DATATYPE_ENUM_VALID,
-                    new Object[] { "anyURI", v, QNameHelper.readable(sType) });
+                    new Object[]{"anyURI", v, QNameHelper.readable(sType)});
+            }
         }
-        
+
         // 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[] { "anyURI", v, QNameHelper.readable(sType) });
+                    new Object[]{"anyURI", v, QNameHelper.readable(sType)});
             }
         }
 
         XmlObject x;
         int i;
 
-        if ((x = sType.getFacet(SchemaType.FACET_LENGTH)) != null)
-            if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) != v.length())
+        if ((x = sType.getFacet(SchemaType.FACET_LENGTH)) != null) {
+            if ((i = ((SimpleValue) x).getBigIntegerValue().intValue()) != v.length()) {
                 context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$STRING,
-                    new Object[] { "anyURI", v, new Integer(i), QNameHelper.readable(sType) });
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MIN_LENGTH)) != null)
-            if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) > v.length())
+                    new Object[]{"anyURI", v, i, QNameHelper.readable(sType)});
+            }
+        }
+
+        if ((x = sType.getFacet(SchemaType.FACET_MIN_LENGTH)) != null) {
+            if ((i = ((SimpleValue) x).getBigIntegerValue().intValue()) > v.length()) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$STRING,
-                    new Object[] { "anyURI", v, new Integer(i), QNameHelper.readable(sType) });
-        
-        if ((x = sType.getFacet(SchemaType.FACET_MAX_LENGTH)) != null)
-            if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) < v.length())
+                    new Object[]{"anyURI", v, i, QNameHelper.readable(sType)});
+            }
+        }
+
+        if ((x = sType.getFacet(SchemaType.FACET_MAX_LENGTH)) != null) {
+            if ((i = ((SimpleValue) x).getBigIntegerValue().intValue()) < v.length()) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$STRING,
-                    new Object[] { "anyURI", v, new Integer(i), QNameHelper.readable(sType) });
+                    new Object[]{"anyURI", v, i, QNameHelper.readable(sType)});
+            }
+        }
     }
-    
-    private static boolean check(String v, SchemaType sType)
-    {
-        int length = v==null ? 0 : v.length();
+
+    private static boolean check(String v, SchemaType sType) {
+        int length = v == null ? 0 : v.length();
         // check against length
         XmlObject len = sType.getFacet(SchemaType.FACET_LENGTH);
-        if (len != null)
-        {
-            int m = ((SimpleValue)len).getBigIntegerValue().intValue();
-            if (!(length != m))
+        if (len != null) {
+            int m = ((SimpleValue) len).getBigIntegerValue().intValue();
+            if (length == m) {
                 return false;
+            }
         }
 
         // check against min length
         XmlObject min = sType.getFacet(SchemaType.FACET_MIN_LENGTH);
-        if (min != null)
-        {
-            int m = ((SimpleValue)min).getBigIntegerValue().intValue();
-            if (!(length >= m))
+        if (min != null) {
+            int m = ((SimpleValue) min).getBigIntegerValue().intValue();
+            if (length < m) {
                 return false;
+            }
         }
 
         // check against min length
         XmlObject max = sType.getFacet(SchemaType.FACET_MAX_LENGTH);
-        if (max != null)
-        {
-            int m = ((SimpleValue)max).getBigIntegerValue().intValue();
-            if (!(length <= m))
+        if (max != null) {
+            int m = ((SimpleValue) max).getBigIntegerValue().intValue();
+            if (length > m) {
                 return false;
+            }
         }
 
         return true;
     }
 
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
-        validateLexical(stringValue(), schemaType(), ctx);
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
+        validateLexical(getStringValue(), schemaType(), ctx);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlAnySimpleTypeImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlAnySimpleTypeImpl.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlAnySimpleTypeImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlAnySimpleTypeImpl.java Sat Sep 19 02:33:16 2020
@@ -16,57 +16,57 @@
 package org.apache.xmlbeans.impl.values;
 
 import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlAnySimpleType;
+import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
 
 /**
  * This class implements the anySimpleType for XML.
- *
  */
-public class XmlAnySimpleTypeImpl extends XmlObjectBase implements XmlAnySimpleType
-{
-    public XmlAnySimpleTypeImpl(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+public class XmlAnySimpleTypeImpl extends XmlObjectBase implements XmlAnySimpleType {
+    public XmlAnySimpleTypeImpl(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
-    public XmlAnySimpleTypeImpl()
-        { _schemaType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE; }
+    public XmlAnySimpleTypeImpl() {
+        _schemaType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
+    }
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    private SchemaType _schemaType;
+    private final SchemaType _schemaType;
 
     String _textvalue = "";
 
-    protected int get_wscanon_rule()
-    {
+    protected int get_wscanon_rule() {
         return SchemaType.WS_PRESERVE;
     }
 
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
     // gets raw text value
-    protected String compute_text(NamespaceManager nsm) { return _textvalue; }
-    protected void set_text(String s)
-    {
+    protected String compute_text(NamespaceManager nsm) {
+        return _textvalue;
+    }
+
+    protected void set_text(String s) {
         _textvalue = s;
     }
 
-    protected void set_nil()
-    {
+    protected void set_nil() {
         _textvalue = null;
     }
 
     // comparators
-    protected boolean equal_to(XmlObject obj)
-    {
+    protected boolean equal_to(XmlObject obj) {
         // compares against another anySimpleType
         // rule is: lexical values must match.
-        return _textvalue.equals(((XmlAnySimpleType)obj).getStringValue());
+        return _textvalue.equals(((XmlAnySimpleType) obj).getStringValue());
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         // matches JavaStringHolder's value_hash_code, so we can be hased against strings
         return (_textvalue == null ? 0 : _textvalue.hashCode());
     }



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


Mime
View raw message