poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881834 [7/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/XmlUnionImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlUnionImpl.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlUnionImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlUnionImpl.java Sat Sep
19 02:33:16 2020
@@ -15,57 +15,48 @@
 
 package org.apache.xmlbeans.impl.values;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Calendar;
-import java.math.BigInteger;
-import java.math.BigDecimal;
-
-import org.apache.xmlbeans.GDate;
-import org.apache.xmlbeans.GDuration;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlErrorCodes;
-import org.apache.xmlbeans.StringEnumAbstractBase;
-import org.apache.xmlbeans.GDateSpecification;
-import org.apache.xmlbeans.GDurationSpecification;
-import org.apache.xmlbeans.SimpleValue;
-
-import org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
-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 org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
 
 import javax.xml.namespace.QName;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
 
 
 /**
  * This class implements simple union types.
- *
  */
-public class XmlUnionImpl extends XmlObjectBase implements XmlAnySimpleType
-{
-    public XmlUnionImpl(SchemaType type, boolean complex)
-        { _schemaType = type; initComplexType(complex, false); }
+public class XmlUnionImpl extends XmlObjectBase implements XmlAnySimpleType {
+    public XmlUnionImpl(SchemaType type, boolean complex) {
+        _schemaType = type;
+        initComplexType(complex, false);
+    }
 
-    public SchemaType schemaType()
-        { return _schemaType; }
+    public SchemaType schemaType() {
+        return _schemaType;
+    }
 
-    public SchemaType instanceType()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).instanceType();
}
+    public SchemaType instanceType() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).instanceType();
+    }
 
-    private SchemaType _schemaType;
+    private final SchemaType _schemaType;
     private XmlAnySimpleType _value; // underlying value
     private String _textvalue = ""; // textual value
 
 
-
-
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
     // gets raw text value
 
-    protected String compute_text(NamespaceManager nsm)
-        { return _textvalue; }
+    protected String compute_text(NamespaceManager nsm) {
+        return _textvalue;
+    }
 
     protected boolean is_defaultable_ws(String v) {
         try {
@@ -76,18 +67,17 @@ public class XmlUnionImpl extends XmlObj
             _value = savedValue;
 
             return false;
-        }
-        catch (XmlValueOutOfRangeException e) {
+        } catch (XmlValueOutOfRangeException e) {
             return true;
         }
     }
 
-    protected void set_text(String s)
-    {
+    protected void set_text(String s) {
         // first check against any patterns...
-        if (!_schemaType.matchPatternFacet(s) && _validateOnSet())
+        if (!_schemaType.matchPatternFacet(s) && _validateOnSet()) {
             throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
-                new Object[] { "string", s, QNameHelper.readable(_schemaType) });
+                new Object[]{"string", s, QNameHelper.readable(_schemaType)});
+        }
 
 
         // save state for rollback
@@ -96,55 +86,46 @@ public class XmlUnionImpl extends XmlObj
 
         // iterate through the types, trying to create a type
         SchemaType[] members = _schemaType.getUnionConstituentTypes();
-        assert(members != null);
+        assert (members != null);
 
         boolean pushed = false;
         // boolean wasstrict = set_strict(true); // tell types to complain ferverently about
errors
-        if (has_store())
-        {
+        if (has_store()) {
             NamespaceContext.push(new NamespaceContext(get_store()));
             pushed = true;
         }
-        try
-        {
-            for (boolean validate = true; validate || !_validateOnSet(); validate = false)
-            {
-            for (int i = 0; i < members.length; i++)
-            {
-                // From the point of view of the following call, "this" is a generic
-                // XmlAnySimpleType implementation, for which only getText can be called.
-                // (Note that "this" is not wrapped in the proxy object.)
-                try
-                {
-                    XmlAnySimpleType newval = ((SchemaTypeImpl)members[i]).newValue(s, validate);
-
-                    // now we need to check against (enuemration) restrictions
-                    if (!check(newval, _schemaType))
-                        continue;
-
-                    // found one that works!
-                    _value = newval;
-                    return;
-                }
-                catch (XmlValueOutOfRangeException e)
-                {
-                    continue;
-                }
-                catch (Exception e)
-                {
-                    throw new RuntimeException("Troublesome union exception caused by unexpected
" + e, e);
-                    // assert(false) : "Unexpected " + e;
-                    // continue;
-                }
-            }
-            if (!validate)
-                break;
-            }
-        }
-        finally
-        {
-            if (pushed)
+        try {
+            for (boolean validate = true; validate || !_validateOnSet(); validate = false)
{
+                for (SchemaType member : members) {
+                    // From the point of view of the following call, "this" is a generic
+                    // XmlAnySimpleType implementation, for which only getText can be called.
+                    // (Note that "this" is not wrapped in the proxy object.)
+                    try {
+                        XmlAnySimpleType newval = ((SchemaTypeImpl) member).newValue(s, validate);
+
+                        // now we need to check against (enuemration) restrictions
+                        if (!check(newval, _schemaType)) {
+                            continue;
+                        }
+
+                        // found one that works!
+                        _value = newval;
+                        return;
+                    } catch (XmlValueOutOfRangeException ignored) {
+                    } catch (Exception e) {
+                        throw new RuntimeException("Troublesome union exception caused by
unexpected " + e, e);
+                        // assert(false) : "Unexpected " + e;
+                        // continue;
+                    }
+                }
+                if (!validate) {
+                    break;
+                }
+            }
+        } finally {
+            if (pushed) {
                 NamespaceContext.pop();
+            }
             // set_strict(wasstrict);
         }
 
@@ -152,184 +133,115 @@ public class XmlUnionImpl extends XmlObj
         // doesn't match any of the members; rollback and throw
         _textvalue = original;
         throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$UNION,
-            new Object[] { s, QNameHelper.readable(_schemaType) });
+            new Object[]{s, QNameHelper.readable(_schemaType)});
     }
 
-    protected void set_nil()
-    {
+    protected void set_nil() {
         _value = null;
         _textvalue = null;
     }
 
-    protected int get_wscanon_rule() { return SchemaType.WS_PRESERVE; }
+    protected int get_wscanon_rule() {
+        return SchemaType.WS_PRESERVE;
+    }
 
 
     // numerics
-    public float getFloatValue()
-        { check_dated(); return _value == null ? 0.0f : ((SimpleValue)_value).getFloatValue();
}
+    public float getFloatValue() {
+        check_dated();
+        return _value == null ? 0.0f : ((SimpleValue) _value).getFloatValue();
+    }
 
-    public double getDoubleValue()
-        { check_dated(); return _value == null ? 0.0 : ((SimpleValue)_value).getDoubleValue();
}
+    public double getDoubleValue() {
+        check_dated();
+        return _value == null ? 0.0 : ((SimpleValue) _value).getDoubleValue();
+    }
 
-    public BigDecimal getBigDecimalValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getBigDecimalValue();
}
+    public BigDecimal getBigDecimalValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getBigDecimalValue();
+    }
 
-    public BigInteger getBigIntegerValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getBigIntegerValue();
}
+    public BigInteger getBigIntegerValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getBigIntegerValue();
+    }
 
-    public byte getByteValue()
-        { check_dated(); return _value == null ? 0 : ((SimpleValue)_value).getByteValue();
}
+    public byte getByteValue() {
+        check_dated();
+        return _value == null ? 0 : ((SimpleValue) _value).getByteValue();
+    }
 
-    public short getShortValue()
-        { check_dated(); return _value == null ? 0 : ((SimpleValue)_value).getShortValue();
}
+    public short getShortValue() {
+        check_dated();
+        return _value == null ? 0 : ((SimpleValue) _value).getShortValue();
+    }
 
-    public int getIntValue()
-        { check_dated(); return _value == null ? 0 : ((SimpleValue)_value).getIntValue();
}
+    public int getIntValue() {
+        check_dated();
+        return _value == null ? 0 : ((SimpleValue) _value).getIntValue();
+    }
 
-    public long getLongValue()
-        { check_dated(); return _value == null ? 0 : ((SimpleValue)_value).getLongValue();
}
+    public long getLongValue() {
+        check_dated();
+        return _value == null ? 0 : ((SimpleValue) _value).getLongValue();
+    }
 
 
     // various
-    public byte[] getByteArrayValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getByteArrayValue();
}
-
-    public boolean getBooleanValue()
-        { check_dated(); return _value == null ? false : ((SimpleValue)_value).getBooleanValue();
}
-
-    public Calendar getCalendarValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getCalendarValue();
}
-
-    public Date getDateValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getDateValue();
}
+    public byte[] getByteArrayValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getByteArrayValue();
+    }
 
-    public GDate getGDateValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getGDateValue();
}
+    public boolean getBooleanValue() {
+        check_dated();
+        return _value != null && ((SimpleValue) _value).getBooleanValue();
+    }
 
-    public GDuration getGDurationValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getGDurationValue();
}
+    public Calendar getCalendarValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getCalendarValue();
+    }
 
-    public QName getQNameValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getQNameValue();
}
+    public Date getDateValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getDateValue();
+    }
 
-    public List getListValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getListValue();
}
+    public GDate getGDateValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getGDateValue();
+    }
 
-    public List xgetListValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).xgetListValue();
}
+    public GDuration getGDurationValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getGDurationValue();
+    }
 
-    public StringEnumAbstractBase getEnumValue()
-        { check_dated(); return _value == null ? null : ((SimpleValue)_value).getEnumValue();
}
+    public QName getQNameValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getQNameValue();
+    }
 
-    public String getStringValue()
-        { check_dated(); return _value == null ? null : _value.getStringValue(); }
+    public List getListValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getListValue();
+    }
 
-    /**
-     * Returns true if the space of canonical lexical forms
-     * of the first (source) type overlaps with the full lexical space
-     * of the second (target) type. Both types must be primitives.
-     */
-    static boolean lexical_overlap(int source, int target)
-    {
-        // types are the same
-        if (source == target)
-            return true;
+    public List xgetListValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).xgetListValue();
+    }
 
-        // one of the types has the full lexical space
-        if (source == SchemaType.BTC_ANY_SIMPLE ||
-            target == SchemaType.BTC_ANY_SIMPLE ||
-            source == SchemaType.BTC_STRING ||
-            target == SchemaType.BTC_STRING ||
-            source == SchemaType.BTC_ANY_URI ||
-            target == SchemaType.BTC_ANY_URI)
-            return true;
+    public StringEnumAbstractBase getEnumValue() {
+        check_dated();
+        return _value == null ? null : ((SimpleValue) _value).getEnumValue();
+    }
 
-        switch (source)
-        {
-            case SchemaType.BTC_BOOLEAN: switch(target)
-            {
-                case SchemaType.BTC_QNAME:       // "true" is valid NcName and therefore
QName
-                case SchemaType.BTC_NOTATION:    // "true" is valid NCName
-                    return true;
-                default:
-                    return false;
-            }
-            case SchemaType.BTC_BASE_64_BINARY: switch(target)
-            {
-                case SchemaType.BTC_BOOLEAN:     // "0" is valid boolean
-                case SchemaType.BTC_HEX_BINARY:  // "0" is valid hex
-                case SchemaType.BTC_QNAME:       // "a" is valid NcName and therefore QName
-                case SchemaType.BTC_NOTATION:    // "a" is valid NcName
-                case SchemaType.BTC_FLOAT:       // "0" is valid float
-                case SchemaType.BTC_DOUBLE:      // "0" is valid double
-                case SchemaType.BTC_DECIMAL:     // "0" is valid decimal
-                case SchemaType.BTC_DURATION:    // "P1Y2M3DT10H30M" is both b64 and duration
-                case SchemaType.BTC_G_YEAR:      // "1999" is valid year
-                    return true;
-                default:
-                    return false;           // "-" and ":" cannot come from b64
-            }
-            case SchemaType.BTC_HEX_BINARY: switch(target)
-            {
-                case SchemaType.BTC_BOOLEAN:     // "0" is valid boolean
-                case SchemaType.BTC_BASE_64_BINARY:  // "0" is valid b64
-                case SchemaType.BTC_QNAME:       // "A" is valid NcName and therefore QName
-                case SchemaType.BTC_NOTATION:    // "A" is valid NcName
-                case SchemaType.BTC_FLOAT:       // "0" is valid float
-                case SchemaType.BTC_DOUBLE:      // "0" is valid double
-                case SchemaType.BTC_DECIMAL:     // "0" is valid decimal
-                case SchemaType.BTC_G_YEAR:      // "1999" is valid year
-                    return true;
-                default:
-                    return false;           // "-" and ":" cannot come from b64
-            }
-            case SchemaType.BTC_QNAME:
-            case SchemaType.BTC_NOTATION: switch(target)
-            {
-                case SchemaType.BTC_BOOLEAN:     // "true" is valid boolean
-                case SchemaType.BTC_BASE_64_BINARY:  // "a" is valid b64
-                case SchemaType.BTC_HEX_BINARY:  // "a" is valid hex
-                case SchemaType.BTC_QNAME:       // "A" is valid NcName and therefore QName
-                case SchemaType.BTC_NOTATION:    // "A" is valid NcName and therefore QName
-                case SchemaType.BTC_DURATION:    // "P1Y2M3DT10H30M" is both NcName and duration
-                    return true;
-                default:
-                    return false;
-            }
-            case SchemaType.BTC_FLOAT:
-            case SchemaType.BTC_DOUBLE:
-            case SchemaType.BTC_DECIMAL:
-            case SchemaType.BTC_G_YEAR: switch(target)
-            {
-                case SchemaType.BTC_BASE_64_BINARY: // "0" is valid b64
-                case SchemaType.BTC_HEX_BINARY:  // "0" is valid hex
-                case SchemaType.BTC_FLOAT:       // "0" is valid float
-                case SchemaType.BTC_DOUBLE:      // "0" is valid double
-                case SchemaType.BTC_DECIMAL:     // "0" is valid decimal
-                case SchemaType.BTC_G_YEAR:      // "1999" is valid year
-                    return true;
-                default:
-                    return false;
-            }
-            case SchemaType.BTC_DURATION: switch(target)
-            {
-                case SchemaType.BTC_QNAME:
-                case SchemaType.BTC_NOTATION:
-                case SchemaType.BTC_BASE_64_BINARY:
-                    return true;
-                default:
-                    return false;
-            }
-            case SchemaType.BTC_DATE_TIME:
-            case SchemaType.BTC_TIME:
-            case SchemaType.BTC_DATE:
-            case SchemaType.BTC_G_YEAR_MONTH:
-            case SchemaType.BTC_G_MONTH_DAY:
-            case SchemaType.BTC_G_DAY:
-            case SchemaType.BTC_G_MONTH:
-            default:
-                return false;
-        }
+    public String getStringValue() {
+        check_dated();
+        return _value == null ? null : _value.getStringValue();
     }
 
     /**
@@ -343,28 +255,25 @@ public class XmlUnionImpl extends XmlObj
     private static final int JAVA_BYTEARRAY = SchemaType.BTC_LAST_BUILTIN + 4;
     private static final int JAVA_LIST = SchemaType.BTC_LAST_BUILTIN + 5;
 
-    private static boolean logical_overlap(SchemaType type, int javacode)
-    {
+    private static boolean logical_overlap(SchemaType type, int javacode) {
         // non-union types because it's being applied on irreducible union members!
-        assert(type.getSimpleVariety() != SchemaType.UNION);
+        assert (type.getSimpleVariety() != SchemaType.UNION);
 
-        if (javacode <= SchemaType.BTC_LAST_BUILTIN)
-        {
-            if (type.getSimpleVariety() != SchemaType.ATOMIC)
+        if (javacode <= SchemaType.BTC_LAST_BUILTIN) {
+            if (type.getSimpleVariety() != SchemaType.ATOMIC) {
                 return false;
+            }
 
             return (type.getPrimitiveType().getBuiltinTypeCode() == javacode);
         }
 
-        switch (javacode)
-        {
-        case JAVA_NUMBER:
-            {
-                if (type.getSimpleVariety() != SchemaType.ATOMIC)
+        switch (javacode) {
+            case JAVA_NUMBER: {
+                if (type.getSimpleVariety() != SchemaType.ATOMIC) {
                     return false;
+                }
 
-                switch (type.getPrimitiveType().getBuiltinTypeCode())
-                {
+                switch (type.getPrimitiveType().getBuiltinTypeCode()) {
                     case SchemaType.BTC_FLOAT:
                     case SchemaType.BTC_DOUBLE:
                     case SchemaType.BTC_DECIMAL:
@@ -375,26 +284,24 @@ public class XmlUnionImpl extends XmlObj
                 }
                 return false;
             }
-        case JAVA_DATE:
-            {
-                if (type.getSimpleVariety() != SchemaType.ATOMIC)
+            case JAVA_DATE: {
+                if (type.getSimpleVariety() != SchemaType.ATOMIC) {
                     return false;
+                }
 
-                switch (type.getPrimitiveType().getBuiltinTypeCode())
-                {
+                switch (type.getPrimitiveType().getBuiltinTypeCode()) {
                     case SchemaType.BTC_DATE_TIME:
                     case SchemaType.BTC_DATE:
                         return true;
                 }
                 return false;
             }
-        case JAVA_CALENDAR:
-            {
-                if (type.getSimpleVariety() != SchemaType.ATOMIC)
+            case JAVA_CALENDAR: {
+                if (type.getSimpleVariety() != SchemaType.ATOMIC) {
                     return false;
+                }
 
-                switch (type.getPrimitiveType().getBuiltinTypeCode())
-                {
+                switch (type.getPrimitiveType().getBuiltinTypeCode()) {
                     case SchemaType.BTC_DATE_TIME:
                     case SchemaType.BTC_DATE:
                     case SchemaType.BTC_TIME:
@@ -407,27 +314,25 @@ public class XmlUnionImpl extends XmlObj
                 }
                 return false;
             }
-                
-        case JAVA_BYTEARRAY:
-            {
-                if (type.getSimpleVariety() != SchemaType.ATOMIC)
+
+            case JAVA_BYTEARRAY: {
+                if (type.getSimpleVariety() != SchemaType.ATOMIC) {
                     return false;
+                }
 
-                switch (type.getPrimitiveType().getBuiltinTypeCode())
-                {
+                switch (type.getPrimitiveType().getBuiltinTypeCode()) {
                     case SchemaType.BTC_BASE_64_BINARY:
                     case SchemaType.BTC_HEX_BINARY:
                         return true;
                 }
                 return false;
             }
-        case JAVA_LIST:
-            {
+            case JAVA_LIST: {
                 return (type.getSimpleVariety() == SchemaType.LIST);
             }
         }
 
-        assert(false) : "missing case";
+        assert (false) : "missing case";
         return false;
     }
 
@@ -435,43 +340,32 @@ public class XmlUnionImpl extends XmlObj
      * Grabs a chained value of type st, creating and attaching
      * one if not present.
      */
-    private void set_primitive(int typecode, Object val)
-    {
+    private void set_primitive(int typecode, Object val) {
         SchemaType[] members = _schemaType.getUnionConstituentTypes();
-        assert(members != null);
+        assert (members != null);
 
         boolean pushed = false;
-        if (has_store())
-        {
+        if (has_store()) {
             NamespaceContext.push(new NamespaceContext(get_store()));
             pushed = true;
         }
-        try
-        {
-            for (boolean validate = true; validate || !_validateOnSet(); validate = false)
-            {
-            outer: for (int i = 0; i < members.length; i++)
-            {
-                // candidates must be a logical match for the desired typecode
-                if (logical_overlap(members[i], typecode))
-                {
-                    XmlAnySimpleType newval;
-
-                    try
-                    {
-                        newval = ((SchemaTypeImpl) members[i]).newValue(val, validate);
-                    }
-                    catch (XmlValueOutOfRangeException e)
-                    {
-                        // doesn't match this type even though logical categories
-                        // line up (probably because of restriciton); try the next type.
-                        continue outer;
-                    }
-                    catch (Exception e)
-                    {
-                        assert(false) : "Unexpected " + e;
-                        continue outer;
-                    }
+        try {
+            for (boolean validate = true; validate || !_validateOnSet(); validate = false)
{
+                for (SchemaType member : members) {
+                    // candidates must be a logical match for the desired typecode
+                    if (logical_overlap(member, typecode)) {
+                        XmlAnySimpleType newval;
+
+                        try {
+                            newval = ((SchemaTypeImpl) member).newValue(val, validate);
+                        } catch (XmlValueOutOfRangeException ignored) {
+                            // doesn't match this type even though logical categories
+                            // line up (probably because of restriciton); try the next type.
+                            continue;
+                        } catch (Exception e) {
+                            assert (false) : "Unexpected " + e;
+                            continue;
+                        }
 
                     /* TODO: rethink this - disabling for now.
 
@@ -513,116 +407,166 @@ public class XmlUnionImpl extends XmlObj
 
                     */
 
-                    // No lexical masking: we're OK
-                    _value = newval;
-                    _textvalue = _value.stringValue();
-                    return;
+                        // No lexical masking: we're OK
+                        _value = newval;
+                        _textvalue = _value.getStringValue();
+                        return;
+                    }
+                }
+                if (!validate) {
+                    break;
                 }
             }
-            if (!validate)
-                break;
-            }
-        }
-        finally
-        {
-            if (pushed)
+        } finally {
+            if (pushed) {
                 NamespaceContext.pop();
+            }
         }
 
         // doesn't match any of the members; throw
         throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$UNION,
-            new Object[] { val.toString(), QNameHelper.readable(_schemaType) });
+            new Object[]{val.toString(), QNameHelper.readable(_schemaType)});
     }
 
     // here are the setters
 
-    protected void set_boolean(boolean v)
-        { set_primitive(SchemaType.BTC_BOOLEAN, new Boolean(v)); }
+    protected void set_boolean(boolean v) {
+        set_primitive(SchemaType.BTC_BOOLEAN, v);
+    }
+
+    protected void set_byte(byte v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_short(short v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_int(int v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_long(long v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_float(float v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_double(double v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_ByteArray(byte[] b) {
+        set_primitive(JAVA_BYTEARRAY, b);
+    }
+
+    protected void set_hex(byte[] b) {
+        set_primitive(JAVA_BYTEARRAY, b);
+    }
+
+    protected void set_b64(byte[] b) {
+        set_primitive(JAVA_BYTEARRAY, b);
+    }
+
+    protected void set_BigInteger(BigInteger v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_BigDecimal(BigDecimal v) {
+        set_primitive(JAVA_NUMBER, v);
+    }
+
+    protected void set_QName(QName v) {
+        set_primitive(SchemaType.BTC_QNAME, v);
+    }
+
+    protected void set_Calendar(Calendar c) {
+        set_primitive(JAVA_CALENDAR, c);
+    }
 
-    protected void set_byte(byte v)
-        { set_primitive(JAVA_NUMBER, new Byte(v)); }
-    protected void set_short(short v)
-        { set_primitive(JAVA_NUMBER, new Short(v)); }
-    protected void set_int(int v)
-        { set_primitive(JAVA_NUMBER, new Integer(v)); }
-    protected void set_long(long v)
-        { set_primitive(JAVA_NUMBER, new Long(v)); }
-    protected void set_float(float v)
-        { set_primitive(JAVA_NUMBER, new Float(v)); }
-    protected void set_double(double v)
-        { set_primitive(JAVA_NUMBER, new Double(v)); }
-
-    protected void set_ByteArray(byte[] b)
-        { set_primitive(JAVA_BYTEARRAY, b); }
-    protected void set_hex(byte[] b)
-        { set_primitive(JAVA_BYTEARRAY, b); }
-    protected void set_b64(byte[] b)
-        { set_primitive(JAVA_BYTEARRAY, b); }
-    protected void set_BigInteger(BigInteger v)
-        { set_primitive(JAVA_NUMBER, v); }
-    protected void set_BigDecimal(BigDecimal v)
-        { set_primitive(JAVA_NUMBER, v); }
-    protected void set_QName(QName v)
-        { set_primitive(SchemaType.BTC_QNAME, v); }
-
-    protected void set_Calendar(Calendar c)
-        { set_primitive(JAVA_CALENDAR, c); }
-    protected void set_Date(Date d)
-        { set_primitive(JAVA_DATE, d); }
-    protected void set_GDate(GDateSpecification d)
-    {
+    protected void set_Date(Date d) {
+        set_primitive(JAVA_DATE, d);
+    }
+
+    protected void set_GDate(GDateSpecification d) {
         int btc = d.getBuiltinTypeCode();
-        if (btc <= 0)
+        if (btc <= 0) {
             throw new XmlValueOutOfRangeException();
+        }
         set_primitive(btc, d);
     }
 
-    protected void set_GDuration(GDurationSpecification d)
-        { set_primitive(SchemaType.BTC_DURATION, d); }
+    protected void set_GDuration(GDurationSpecification d) {
+        set_primitive(SchemaType.BTC_DURATION, d);
+    }
+
+    protected void set_enum(StringEnumAbstractBase e) {
+        set_primitive(SchemaType.BTC_STRING, e);
+    }
+
+    protected void set_list(List<?> v) {
+        set_primitive(JAVA_LIST, v);
+    }
 
-    protected void set_enum(StringEnumAbstractBase e)
-        { set_primitive(SchemaType.BTC_STRING, e); }
 
-    protected void set_list(List v)
-        { set_primitive(JAVA_LIST, v); }
+    protected void set_xmlfloat(XmlObject v) {
+        set_primitive(SchemaType.BTC_FLOAT, v);
+    }
+
+    protected void set_xmldouble(XmlObject v) {
+        set_primitive(SchemaType.BTC_DOUBLE, v);
+    }
 
+    protected void set_xmldecimal(XmlObject v) {
+        set_primitive(SchemaType.BTC_DECIMAL, v);
+    }
 
-    protected void set_xmlfloat(XmlObject v)
-        { set_primitive(SchemaType.BTC_FLOAT, v); }
-    protected void set_xmldouble(XmlObject v)
-        { set_primitive(SchemaType.BTC_DOUBLE, v); }
-    protected void set_xmldecimal(XmlObject v)
-        { set_primitive(SchemaType.BTC_DECIMAL, v); }
-    protected void set_xmlduration(XmlObject v)
-        { set_primitive(SchemaType.BTC_DURATION, v); }
-    protected void set_xmldatetime(XmlObject v)
-        { set_primitive(SchemaType.BTC_DATE_TIME, v); }
-    protected void set_xmltime(XmlObject v)
-        { set_primitive(SchemaType.BTC_TIME, v); }
-    protected void set_xmldate(XmlObject v)
-        { set_primitive(SchemaType.BTC_DATE, v); }
-    protected void set_xmlgyearmonth(XmlObject v)
-        { set_primitive(SchemaType.BTC_G_YEAR_MONTH, v); }
-    protected void set_xmlgyear(XmlObject v)
-        { set_primitive(SchemaType.BTC_G_YEAR, v); }
-    protected void set_xmlgmonthday(XmlObject v)
-        { set_primitive(SchemaType.BTC_G_MONTH_DAY, v); }
-    protected void set_xmlgday(XmlObject v)
-        { set_primitive(SchemaType.BTC_G_DAY, v); }
-    protected void set_xmlgmonth(XmlObject v)
-        { set_primitive(SchemaType.BTC_G_MONTH, v); }
+    protected void set_xmlduration(XmlObject v) {
+        set_primitive(SchemaType.BTC_DURATION, v);
+    }
 
+    protected void set_xmldatetime(XmlObject v) {
+        set_primitive(SchemaType.BTC_DATE_TIME, v);
+    }
 
+    protected void set_xmltime(XmlObject v) {
+        set_primitive(SchemaType.BTC_TIME, v);
+    }
 
-    private static boolean check(XmlObject v, SchemaType sType)
-    {
+    protected void set_xmldate(XmlObject v) {
+        set_primitive(SchemaType.BTC_DATE, v);
+    }
+
+    protected void set_xmlgyearmonth(XmlObject v) {
+        set_primitive(SchemaType.BTC_G_YEAR_MONTH, v);
+    }
+
+    protected void set_xmlgyear(XmlObject v) {
+        set_primitive(SchemaType.BTC_G_YEAR, v);
+    }
+
+    protected void set_xmlgmonthday(XmlObject v) {
+        set_primitive(SchemaType.BTC_G_MONTH_DAY, v);
+    }
+
+    protected void set_xmlgday(XmlObject v) {
+        set_primitive(SchemaType.BTC_G_DAY, v);
+    }
+
+    protected void set_xmlgmonth(XmlObject v) {
+        set_primitive(SchemaType.BTC_G_MONTH, v);
+    }
+
+
+    private static boolean check(XmlObject v, SchemaType sType) {
         XmlObject[] vals = sType.getEnumerationValues();
-        if (vals != null)
-        {
-            for (int i = 0; i < vals.length; i++)
-            {
-                if (vals[i].valueEquals(v))
+        if (vals != null) {
+            for (XmlObject val : vals) {
+                if (val.valueEquals(v)) {
                     return true;
+                }
             }
             return false;
         }
@@ -630,36 +574,29 @@ public class XmlUnionImpl extends XmlObj
         return true;
     }
 
-    protected boolean equal_to(XmlObject xmlobj)
-    {
+    protected boolean equal_to(XmlObject xmlobj) {
         return _value.valueEquals(xmlobj);
     }
 
-    protected int value_hash_code()
-    {
+    protected int value_hash_code() {
         return _value.hashCode();
     }
-    
-    protected void validate_simpleval(String lexical, ValidationContext ctx)
-    {
-        try
-        {
+
+    protected void validate_simpleval(String lexical, ValidationContext ctx) {
+        try {
             check_dated();
-        }
-        catch (Exception e)
-        {
-            ctx.invalid(XmlErrorCodes.UNION, new Object[] { "'" + lexical + "' does not match
any of the member types for " + QNameHelper.readable(schemaType()) });
+        } catch (Exception e) {
+            ctx.invalid(XmlErrorCodes.UNION, new Object[]{"'" + lexical + "' does not match
any of the member types for " + QNameHelper.readable(schemaType())});
             return;
         }
-        if (_value == null)
-        {
-            ctx.invalid(XmlErrorCodes.UNION, new Object[] { "'" + lexical + "' does not match
any of the member types for " + QNameHelper.readable(schemaType()) });
+        if (_value == null) {
+            ctx.invalid(XmlErrorCodes.UNION, new Object[]{"'" + lexical + "' does not match
any of the member types for " + QNameHelper.readable(schemaType())});
             return;
         }
-        
-        ((XmlObjectBase)_value).validate_simpleval(lexical,  ctx);
+
+        ((XmlObjectBase) _value).validate_simpleval(lexical, ctx);
     }
-    
+
 
 }
 

Modified: xmlbeans/trunk/src/main/multimodule/java9/module-info.class
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/multimodule/java9/module-info.class?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlbeans/trunk/src/main/multimodule/java9/module-info.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/multimodule/java9/module-info.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/multimodule/java9/module-info.java (original)
+++ xmlbeans/trunk/src/main/multimodule/java9/module-info.java Sat Sep 19 02:33:16 2020
@@ -47,7 +47,7 @@ module org.apache.xmlbeans {
     // exports org.apache.xmlbeans.xml;
     exports org.apache.xmlbeans.xml.stream;
     exports org.apache.xmlbeans.xml.stream.events;
-    exports org.apache.xmlbeans.xml.stream.utils;
+    // exports org.apache.xmlbeans.xml.stream.utils;
 
     exports org.apache.xmlbeans.impl.xb.xmlconfig;
     exports org.apache.xmlbeans.impl.xb.xmlschema;

Modified: xmlbeans/trunk/src/test/java/xmlobject/schematypes/checkin/EnumTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlobject/schematypes/checkin/EnumTests.java?rev=1881834&r1=1881833&r2=1881834&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlobject/schematypes/checkin/EnumTests.java (original)
+++ xmlbeans/trunk/src/test/java/xmlobject/schematypes/checkin/EnumTests.java Sat Sep 19 02:33:16
2020
@@ -49,32 +49,32 @@ public class EnumTests {
         };
         Data[] data = doc.getStatusreport().getStatusArray();
         int t = 0;
-        for (int i = 0; i < data.length; i++) {
-            assertEquals(contents[t++], data[i].enumValue());
+        for (Data datum : data) {
+            assertEquals(contents[t++], datum.getEnumValue());
             // System.out.println("Target: " + data[i].getTarget() + ", value: " + data[i].enumValue());
-            assertEquals(contents[t++], data[i].getTarget());
+            assertEquals(contents[t++], datum.getTarget());
         }
     }
 
     @Test
-    public void testReport2() throws Exception {
+    public void testReport2() {
         StatusreportDocument doc = StatusreportDocument.Factory.newInstance();
         StatusreportDocument.Statusreport report = doc.addNewStatusreport();
 
         Data d = report.addNewStatus();
-        d.set(Quantity.ALL);
+        d.setEnumValue(Quantity.ALL);
         d.setTarget(Quantity.ALL);
 
         d = report.addNewStatus();
-        d.set(Quantity.FEW);
+        d.setEnumValue(Quantity.FEW);
         d.setTarget(Quantity.ALL);
 
         d = report.addNewStatus();
-        d.set(Quantity.MOST);
+        d.setEnumValue(Quantity.MOST);
         d.setTarget(Quantity.NONE);
 
         d = report.addNewStatus();
-        d.set(Quantity.NONE);
+        d.setEnumValue(Quantity.NONE);
         d.setTarget(Quantity.NONE);
 
         Quantity.Enum[] contents = {
@@ -89,15 +89,15 @@ public class EnumTests {
         };
         Data[] data = doc.getStatusreport().getStatusArray();
         int t = 0;
-        for (int i = 0; i < data.length; i++) {
-            assertEquals(contents[t++], data[i].enumValue());
+        for (Data datum : data) {
+            assertEquals(contents[t++], datum.getEnumValue());
             // System.out.println("Target: " + data[i].getTarget() + ", value: " + data[i].enumValue());
-            assertEquals(contents[t++], data[i].getTarget());
+            assertEquals(contents[t++], datum.getTarget());
         }
     }
 
     @Test
-    public void testReport3() throws Exception {
+    public void testReport3() {
         SalesreportDocument doc = SalesreportDocument.Factory.newInstance();
         SalesreportDocument.Salesreport report = doc.addNewSalesreport();
 
@@ -115,7 +115,7 @@ public class EnumTests {
 
         Unit[] xunits = report.xgetUnitArray();
         for (int i = 0; i < xunits.length; i++) {
-            assertEquals(contents[i], xunits[i].enumValue());
+            assertEquals(contents[i], xunits[i].getEnumValue());
         }
 
         Unit.Enum[] units = report.getUnitArray();



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


Mime
View raw message