xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java
Date Sat, 17 Apr 2004 00:06:23 GMT
zieg        2004/04/16 17:06:23

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        MarshalStreamUtils.java RuntimeBindingType.java
                        UnmarshalResult.java
               v2/src/marshal/org/apache/xmlbeans/impl/richParser
                        XMLStreamReaderExtImpl.java
               v2/src/typeimpl/org/apache/xmlbeans/impl/util
                        XsTypeConverter.java
               v2/test/cases/marshal doc2.xml
               v2/test/src/drt/drtcases MarshalTests.java
  Log:
  improve error handling, in particular for boolean types
  
  Revision  Changes    Path
  1.21      +14 -13    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java
  
  Index: MarshalStreamUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalStreamUtils.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MarshalStreamUtils.java	9 Apr 2004 21:54:16 -0000	1.20
  +++ MarshalStreamUtils.java	17 Apr 2004 00:06:22 -0000	1.21
  @@ -78,7 +78,7 @@
                   //TODO: use real location (maybe just pass context to this method).
               catch (InvalidLexicalValueException ilve) {
                   addError(errors, ilve.getMessage(),
  -                         ilve.getLocation(), "<unknown>");
  +                         ilve.getLocation());
               }
           }
       }
  @@ -251,19 +251,20 @@
   
       static void addError(Collection errors,
                            String msg,
  -                         Location location,
  -                         String sourceName)
  +                         Location location)
       {
  -        final XmlError err;
  -        if (location != null) {
  -            err = XmlError.forLocation(msg,
  -                                       sourceName,
  -                                       location.getLineNumber(),
  -                                       location.getColumnNumber(),
  -                                       location.getCharacterOffset());
  -        } else {
  -            err = XmlError.forSource(msg, sourceName);
  -        }
  +        assert location != null;
  +
  +        String systemId = location.getSystemId();
  +        if (systemId == null) {
  +            systemId = "<unknown>"; // without this we get no line numbers
  +        }
  +        final XmlError err =
  +            XmlError.forLocation(msg,
  +                                 systemId,
  +                                 location.getLineNumber(),
  +                                 location.getColumnNumber(),
  +                                 location.getCharacterOffset());
           errors.add(err);
       }
   
  
  
  
  1.16      +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java
  
  Index: RuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- RuntimeBindingType.java	25 Mar 2004 03:19:28 -0000	1.15
  +++ RuntimeBindingType.java	17 Apr 2004 00:06:22 -0000	1.16
  @@ -230,7 +230,7 @@
               throws XmlException
           {
               assert parentObject != null;
  -            assert beanClass.isAssignableFrom(parentObject.getClass()) :
  +            assert beanClass.isInstance(parentObject) :
                   parentObject.getClass() + " is not a " + beanClass;
   
               return ReflectionUtils.invokeMethod(parentObject, getMethod);
  
  
  
  1.18      +2 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalResult.java
  
  Index: UnmarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalResult.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- UnmarshalResult.java	14 Apr 2004 23:03:51 -0000	1.17
  +++ UnmarshalResult.java	17 Apr 2004 00:06:22 -0000	1.18
  @@ -148,9 +148,8 @@
   
       void addError(String msg, Location location)
       {
  -        MarshalStreamUtils.addError(errors, msg,
  -                                    location,
  -                                    "<unknown>");
  +        assert location != null;
  +        MarshalStreamUtils.addError(errors, msg, location);
       }
   
       Collection getErrors()
  
  
  
  1.8       +3 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/richParser/XMLStreamReaderExtImpl.java
  
  Index: XMLStreamReaderExtImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/richParser/XMLStreamReaderExtImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLStreamReaderExtImpl.java	23 Feb 2004 17:18:13 -0000	1.7
  +++ XMLStreamReaderExtImpl.java	17 Apr 2004 00:06:23 -0000	1.8
  @@ -82,7 +82,7 @@
           {
               return XsTypeConverter.lexBoolean(_charSeq);
           }
  -        catch(IllegalArgumentException e)
  +        catch(InvalidLexicalValueException e)
           {
               throw new InvalidLexicalValueException(e, _charSeq.getLocation());
           }
  @@ -310,7 +310,7 @@
           {
               return XsTypeConverter.lexBoolean(_charSeq.reloadAtt(index, CharSeqTrimWS.XMLWHITESPACE_TRIM));
           }
  -        catch(IllegalArgumentException e)
  +        catch(InvalidLexicalValueException e)
           {
               throw new InvalidLexicalValueException(e, _charSeq.getLocation());
           }
  @@ -512,7 +512,7 @@
           {
               return XsTypeConverter.lexBoolean(cs);
           }
  -        catch(IllegalArgumentException e)
  +        catch(InvalidLexicalValueException e)
           {
               throw new InvalidLexicalValueException(e, _charSeq.getLocation());
           }
  
  
  
  1.8       +1 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java
  
  Index: XsTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XsTypeConverter.java	7 Apr 2004 23:30:56 -0000	1.7
  +++ XsTypeConverter.java	17 Apr 2004 00:06:23 -0000	1.8
  @@ -358,7 +358,7 @@
           {
               return lexBoolean(value);
           }
  -        catch(IllegalArgumentException e)
  +        catch(InvalidLexicalValueException e)
           {
               errors.add(XmlError.forMessage(e.getMessage()));
               return false;
  
  
  
  1.10      +4 -1      xml-xmlbeans/v2/test/cases/marshal/doc2.xml
  
  Index: doc2.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/doc2.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- doc2.xml	14 Apr 2004 23:03:51 -0000	1.9
  +++ doc2.xml	17 Apr 2004 00:06:23 -0000	1.10
  @@ -28,7 +28,10 @@
           <n1:SomeBool>false</n1:SomeBool>
           <n1:SomeBool>true</n1:SomeBool>
           <n1:SomeBool>0</n1:SomeBool>
  -        <n1:SomeBool>1</n1:SomeBool>
  +
  +        <n1:SomeBool
  +            xsi:nil="false"
  +            xmlns:xyz="pdq">1</n1:SomeBool>
   
           <n1:BooleanArray>
                true 
  
  
  
  1.55      +6 -2      xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java
  
  Index: MarshalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- MarshalTests.java	16 Apr 2004 17:35:57 -0000	1.54
  +++ MarshalTests.java	17 Apr 2004 00:06:23 -0000	1.55
  @@ -990,7 +990,9 @@
   
           final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
           XMLStreamReader xrdr =
  -            xmlInputFactory.createXMLStreamReader(new FileReader(doc));
  +            xmlInputFactory.createXMLStreamReader(doc.toURL().toString(),
  +                                                  new FileInputStream(doc));
  +
   
           final XmlOptions options = new XmlOptions();
           ObjectFactory of = new YourClass();
  @@ -1006,7 +1008,9 @@
   
           for (Iterator itr = errors.iterator(); itr.hasNext();) {
               XmlError xmlError = (XmlError)itr.next();
  -            inform("doc2-ERROR: " + xmlError);
  +
  +            inform("doc2-ERROR: source=" + xmlError.getSourceName() +
  +                   " " + xmlError);
           }
   
           Assert.assertTrue(errors.isEmpty());
  
  
  

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


Mime
View raw message