xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r125217 - in xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/values xmlcomp/org/apache/xmlbeans/impl/tool
Date Fri, 14 Jan 2005 22:00:08 GMT
Author: radup
Date: Fri Jan 14 14:00:03 2005
New Revision: 125217

URL: http://svn.apache.org/viewcvs?view=rev&rev=125217
Log:
Failfast behavior for simple types, reviewed and made consistent.

Added:
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlValueNotSupportedException.java
Modified:
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java
   xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java?view=diff&rev=125217&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java&r1=125216&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java&r2=125217
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java	Fri Jan
14 14:00:03 2005
@@ -1090,7 +1090,7 @@
      */
     protected void update_from_complex_content()
     {
-        throw new XmlValueOutOfRangeException();
+        throw new XmlValueNotSupportedException("Complex content");
     }
 
     /**
@@ -1350,7 +1350,7 @@
     public double doubleValue()
         { BigDecimal bd = bigDecimalValue(); return bd == null ? 0.0 : bd.doubleValue();
}
     public BigDecimal bigDecimalValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
 
     // numerics: integral
     public BigInteger bigIntegerValue()
@@ -1453,7 +1453,7 @@
 
     // enums
     public StringEnumAbstractBase enumValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
 
     // various
     public String stringValue()
@@ -1553,23 +1553,23 @@
         { objectSet(obj); }
 
     public byte[] byteArrayValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public boolean booleanValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public GDate gDateValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public Date dateValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public Calendar calendarValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public GDuration gDurationValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public QName qNameValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public List listValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public List xlistValue()
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     public Object objectValue()
         { return java_value(this); }
 
@@ -1660,7 +1660,7 @@
         else
         {
             throw
-                new XmlValueOutOfRangeException(
+                new XmlValueNotSupportedException(
                     "Can't set union object of class : " +
                         o.getClass().getName() );
         }
@@ -1946,9 +1946,9 @@
     }
 
     protected void set_list(List list)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_boolean(boolean v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_byte(byte v)
         { set_int((int) v); }
     protected void set_short(short v)
@@ -1965,10 +1965,10 @@
         { set_BigDecimal(new BigDecimal(v)); }
 
     protected void set_enum(StringEnumAbstractBase e)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
 
     protected void set_ByteArray(byte[] b)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_b64(byte[] b)
         { set_ByteArray(b); }
     protected void set_hex(byte[] b)
@@ -1976,22 +1976,22 @@
     protected void set_BigInteger(BigInteger v)
         { set(new BigDecimal(v)); }
     protected void set_BigDecimal(BigDecimal v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_Date(Date v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_Calendar(Calendar v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_GDate(GDateSpecification v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_GDuration(GDurationSpecification v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_ComplexXml(XmlObject v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
     protected void set_QName(QName v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
 
     protected void set_notation(String v)
-        { throw new XmlValueOutOfRangeException(); }
+        { throw new XmlValueNotSupportedException(); }
 
     protected void set_xmlanysimple(XmlAnySimpleType v)
         { set_String(v.getStringValue()); }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java?view=diff&rev=125217&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java&r1=125216&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java&r2=125217
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlUnionImpl.java	Fri Jan
14 14:00:03 2005
@@ -85,8 +85,10 @@
     protected void set_text(String s)
     {
         // first check against any patterns...
-        if (!_schemaType.matchPatternFacet(s))
-            throw new XmlValueOutOfRangeException();
+        if (!_schemaType.matchPatternFacet(s) && _validateOnSet())
+            throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
+                new Object[] { "string", s, QNameHelper.readable(_schemaType) });
+
 
         // save state for rollback
         String original = _textvalue;
@@ -105,6 +107,8 @@
         }
         try
         {
+            for (boolean validate = true; !_validateOnSet(); validate = false)
+            {
             for (int i = 0; i < members.length; i++)
             {
                 // From the point of view of the following call, "this" is a generic
@@ -112,7 +116,7 @@
                 // (Note that "this" is not wrapped in the proxy object.)
                 try
                 {
-                    XmlAnySimpleType newval = ((SchemaTypeImpl)members[i]).newValidatingValue(s);
+                    XmlAnySimpleType newval = ((SchemaTypeImpl)members[i]).newValue(s, validate);
 
                     // now we need to check against (enuemration) restrictions
                     if (!check(newval, _schemaType))
@@ -133,6 +137,9 @@
                     // continue;
                 }
             }
+            if (!validate)
+                break;
+            }
         }
         finally
         {
@@ -144,7 +151,8 @@
 
         // doesn't match any of the members; rollback and throw
         _textvalue = original;
-        throw new XmlValueOutOfRangeException();
+        throw new XmlValueOutOfRangeException(XmlErrorCodes.DATATYPE_VALID$UNION,
+            new Object[] { s, QNameHelper.readable(_schemaType) });
     }
 
     protected void set_nil()
@@ -440,6 +448,8 @@
         }
         try
         {
+            for (boolean validate = true; !_validateOnSet(); validate = false)
+            {
             outer: for (int i = 0; i < members.length; i++)
             {
                 // candidates must be a logical match for the desired typecode
@@ -449,7 +459,7 @@
 
                     try
                     {
-                        newval = members[i].newValue(val);
+                        newval = ((SchemaTypeImpl) members[i]).newValue(val, validate);
                     }
                     catch (XmlValueOutOfRangeException e)
                     {
@@ -509,12 +519,19 @@
                     return;
                 }
             }
+            if (!validate)
+                break;
+            }
         }
         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) });
     }
 
     // here are the setters

Added: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlValueNotSupportedException.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlValueNotSupportedException.java?view=auto&rev=125217
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlValueNotSupportedException.java
Fri Jan 14 14:00:03 2005
@@ -0,0 +1,22 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.values;
+
+public class XmlValueNotSupportedException extends XmlValueOutOfRangeException
+{
+    public XmlValueNotSupportedException() {}
+    public XmlValueNotSupportedException(String message) { super(message); }
+}

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?view=diff&rev=125217&p1=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java&r1=125216&p2=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java&r2=125217
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java	(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java	Fri Jan 14
14:00:03 2005
@@ -936,7 +936,8 @@
     {
         StscState.addInfo(errorListener, "Loading schema file " + name);
         XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
-        opts.setValidateTreatLaxAsSkip();
+        if (noVDoc)
+            opts.setValidateTreatLaxAsSkip();
         if (schemadoc.validate(opts))
             scontentlist.add((schemadoc).getSchema());
     }
@@ -949,6 +950,7 @@
             StscState.addWarning(errorListener, "The WSDL " + name + " uses SOAP encoding.
SOAP encoding is not compatible with literal XML Schema.", XmlErrorCodes.GENERIC_ERROR, wsdldoc);
         StscState.addInfo(errorListener, "Loading wsdl file " + name);
         XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
+        if (noVDoc)
         opts.setValidateTreatLaxAsSkip();
         XmlObject[] types = wsdldoc.getDefinitions().getTypesArray();
         int count = 0;

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


Mime
View raw message